Only show <PlaceInput /> when location services are enabled
This commit is contained in:
parent
362c739b75
commit
0218c07870
@ -6,6 +6,7 @@ import PhotoLightbox from '@/photo/PhotoLightbox';
|
|||||||
import { getAlbumFromSlug } from '@/album/query';
|
import { getAlbumFromSlug } from '@/album/query';
|
||||||
import AdminAlbumBadge from '@/admin/AdminAlbumBadge';
|
import AdminAlbumBadge from '@/admin/AdminAlbumBadge';
|
||||||
import AdminAlbumForm from '@/admin/AdminAlbumForm';
|
import AdminAlbumForm from '@/admin/AdminAlbumForm';
|
||||||
|
import { HAS_LOCATION_SERVICES } from '@/app/config';
|
||||||
|
|
||||||
const MAX_PHOTO_TO_SHOW = 6;
|
const MAX_PHOTO_TO_SHOW = 6;
|
||||||
|
|
||||||
@ -40,7 +41,10 @@ export default async function AlbumPageEdit({
|
|||||||
backLabel="Albums"
|
backLabel="Albums"
|
||||||
breadcrumb={<AdminAlbumBadge {...{ album, count, hideBadge: true }} />}
|
breadcrumb={<AdminAlbumBadge {...{ album, count, hideBadge: true }} />}
|
||||||
>
|
>
|
||||||
<AdminAlbumForm {...{ album }}>
|
<AdminAlbumForm {...{
|
||||||
|
album,
|
||||||
|
hasLocationServices: HAS_LOCATION_SERVICES,
|
||||||
|
}}>
|
||||||
{photos.length > 0 &&
|
{photos.length > 0 &&
|
||||||
<PhotoLightbox
|
<PhotoLightbox
|
||||||
{...{ count, photos, album }}
|
{...{ count, photos, album }}
|
||||||
|
|||||||
@ -17,9 +17,11 @@ import deepEqual from 'fast-deep-equal/es6/react';
|
|||||||
|
|
||||||
export default function AdminAlbumForm({
|
export default function AdminAlbumForm({
|
||||||
album,
|
album,
|
||||||
|
hasLocationServices,
|
||||||
children,
|
children,
|
||||||
}: {
|
}: {
|
||||||
album: Album
|
album: Album
|
||||||
|
hasLocationServices?: boolean
|
||||||
children?: ReactNode
|
children?: ReactNode
|
||||||
}) {
|
}) {
|
||||||
const { invalidateSwr } = useAppState();
|
const { invalidateSwr } = useAppState();
|
||||||
@ -65,12 +67,13 @@ export default function AdminAlbumForm({
|
|||||||
readOnly={readOnly}
|
readOnly={readOnly}
|
||||||
className={clsx(key === 'description' && '[&_textarea]:h-36')}
|
className={clsx(key === 'description' && '[&_textarea]:h-36')}
|
||||||
/>))}
|
/>))}
|
||||||
<PlaceInput {...{
|
{hasLocationServices &&
|
||||||
initialPlace,
|
<PlaceInput {...{
|
||||||
setPlace,
|
initialPlace,
|
||||||
setIsLoadingPlace,
|
setPlace,
|
||||||
className: 'relative z-1',
|
setIsLoadingPlace,
|
||||||
}} />
|
className: 'relative z-1',
|
||||||
|
}} />}
|
||||||
{(albumForm.location || isLoadingPlace) &&
|
{(albumForm.location || isLoadingPlace) &&
|
||||||
<div className="space-y-4 w-full">
|
<div className="space-y-4 w-full">
|
||||||
<FieldsetWithStatus
|
<FieldsetWithStatus
|
||||||
@ -96,7 +99,9 @@ export default function AdminAlbumForm({
|
|||||||
type="textarea"
|
type="textarea"
|
||||||
value={JSON.stringify(albumForm.location)}
|
value={JSON.stringify(albumForm.location)}
|
||||||
isModified={!deepEqual(albumForm.location, album.location)}
|
isModified={!deepEqual(albumForm.location, album.location)}
|
||||||
readOnly
|
// Make field editable if location services are disabled
|
||||||
|
// to allow for data to be manually erased
|
||||||
|
readOnly={isLoadingPlace || hasLocationServices}
|
||||||
/>
|
/>
|
||||||
</div>}
|
</div>}
|
||||||
{children}
|
{children}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user