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 AdminAlbumBadge from '@/admin/AdminAlbumBadge';
|
||||
import AdminAlbumForm from '@/admin/AdminAlbumForm';
|
||||
import { HAS_LOCATION_SERVICES } from '@/app/config';
|
||||
|
||||
const MAX_PHOTO_TO_SHOW = 6;
|
||||
|
||||
@ -40,7 +41,10 @@ export default async function AlbumPageEdit({
|
||||
backLabel="Albums"
|
||||
breadcrumb={<AdminAlbumBadge {...{ album, count, hideBadge: true }} />}
|
||||
>
|
||||
<AdminAlbumForm {...{ album }}>
|
||||
<AdminAlbumForm {...{
|
||||
album,
|
||||
hasLocationServices: HAS_LOCATION_SERVICES,
|
||||
}}>
|
||||
{photos.length > 0 &&
|
||||
<PhotoLightbox
|
||||
{...{ count, photos, album }}
|
||||
|
||||
@ -17,9 +17,11 @@ import deepEqual from 'fast-deep-equal/es6/react';
|
||||
|
||||
export default function AdminAlbumForm({
|
||||
album,
|
||||
hasLocationServices,
|
||||
children,
|
||||
}: {
|
||||
album: Album
|
||||
hasLocationServices?: boolean
|
||||
children?: ReactNode
|
||||
}) {
|
||||
const { invalidateSwr } = useAppState();
|
||||
@ -65,12 +67,13 @@ export default function AdminAlbumForm({
|
||||
readOnly={readOnly}
|
||||
className={clsx(key === 'description' && '[&_textarea]:h-36')}
|
||||
/>))}
|
||||
<PlaceInput {...{
|
||||
initialPlace,
|
||||
setPlace,
|
||||
setIsLoadingPlace,
|
||||
className: 'relative z-1',
|
||||
}} />
|
||||
{hasLocationServices &&
|
||||
<PlaceInput {...{
|
||||
initialPlace,
|
||||
setPlace,
|
||||
setIsLoadingPlace,
|
||||
className: 'relative z-1',
|
||||
}} />}
|
||||
{(albumForm.location || isLoadingPlace) &&
|
||||
<div className="space-y-4 w-full">
|
||||
<FieldsetWithStatus
|
||||
@ -96,7 +99,9 @@ export default function AdminAlbumForm({
|
||||
type="textarea"
|
||||
value={JSON.stringify(albumForm.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>}
|
||||
{children}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user