diff --git a/src/photo/form/FieldsetPhotoChooser.tsx b/src/photo/form/FieldsetPhotoChooser.tsx index 2f2cb2c5..e3e003c6 100644 --- a/src/photo/form/FieldsetPhotoChooser.tsx +++ b/src/photo/form/FieldsetPhotoChooser.tsx @@ -8,6 +8,8 @@ import { GRID_SPACE_CLASSNAME } from '@/components'; import useDynamicPhoto from '../useDynamicPhoto'; import { IoSearch } from 'react-icons/io5'; import { useState } from 'react'; +import usePhotoQuery from '../usePhotoQuery'; +import Spinner from '@/components/Spinner'; export default function FieldsetPhotoChooser({ label, @@ -25,6 +27,10 @@ export default function FieldsetPhotoChooser({ photosHidden?: Photo[] }) { const [query, setQuery] = useState(''); + const { + photos: photosQuery, + isLoading, + } = usePhotoQuery(query); const { photo: photoAvatar, @@ -76,17 +82,19 @@ export default function FieldsetPhotoChooser({
Choose photo
- + {isLoading ? : } - setQuery(e.target.value)} + onChange={setQuery} + hideLabel />
- {photos.map(photo => ( + {(photosQuery.length > 0 ? photosQuery : photos).map(photo => ( onChange(photo.id)} />