diff --git a/src/admin/AdminComponentPageClient.tsx b/src/admin/AdminComponentPageClient.tsx index 9ba7f18d..507008d0 100644 --- a/src/admin/AdminComponentPageClient.tsx +++ b/src/admin/AdminComponentPageClient.tsx @@ -10,7 +10,6 @@ import StatusIcon from '@/components/StatusIcon'; import clsx from 'clsx/lite'; import { useState } from 'react'; import { Photo } from '@/photo'; -import FieldsetPhotoQuery from '@/photo/form/FieldsetPhotoQuery'; import FieldsetPhotoChooser from '@/photo/form/FieldsetPhotoChooser'; export default function AdminComponentPageClient({ @@ -23,7 +22,6 @@ export default function AdminComponentPageClient({ photosCount: number }) { const [valuePhoto, setValuePhoto] = useState(photo?.id ?? ''); - const [valuePhotoChooser, setValuePhotoChooser] = useState(photo?.id ?? ''); const [value, setValue] = useState('visible'); @@ -45,14 +43,6 @@ export default function AdminComponentPageClient({ photo={photo} photos={photos} photosCount={photosCount} - value={valuePhotoChooser} - onChange={setValuePhotoChooser} - /> - -
- diff --git a/src/photo/form/FieldsetPhotoQuery.tsx b/src/photo/form/FieldsetPhotoQuery.tsx deleted file mode 100644 index f3b6b64f..00000000 --- a/src/photo/form/FieldsetPhotoQuery.tsx +++ /dev/null @@ -1,69 +0,0 @@ -'use client'; - -import FieldsetWithStatus from '@/components/FieldsetWithStatus'; -import { Photo } from '..'; -import { useEffect, useState } from 'react'; -import { AnnotatedTag } from '../form'; -import { useDebounce } from 'use-debounce'; -import PhotoSmall from '../PhotoSmall'; -import { getPhotosAction } from '../actions'; - -const convertPhotoToAnnotatedTag = (photo: Photo): AnnotatedTag => ({ - value: photo.id, - label: photo.title, - icon:
- -
, -}); - -export default function FieldsetPhotoQuery({ - label, - photos = [], - value, - onChange, -}: { - label: string - photos?: Photo[] - value: string - onChange: (value: string) => void -}) { - const [query, setQuery] = useState(''); - const [queryDebounced] = useDebounce(query, 500); - const [isQuerying, setIsQuerying] = useState(false); - - const [photoOptions, setPhotoOptions] = useState(photos - .map(convertPhotoToAnnotatedTag), - ); - - useEffect(() => { - if (queryDebounced) { - // eslint-disable-next-line react-hooks/set-state-in-effect - setIsQuerying(true); - getPhotosAction({ query: queryDebounced }) - .then(photos => { - setPhotoOptions(photos.map(convertPhotoToAnnotatedTag)); - }) - .finally(() => { - setIsQuerying(false); - }); - } else { - setPhotoOptions([]); - } - }, [queryDebounced]); - - return ( - - photoOptions.find(option => option.value === value)?.label} - tagOptionsAllowNewValues={false} - tagOptionsShouldParameterize={false} - tagOptionsLimit={1} - loading={isQuerying} - /> - ); -}