diff --git a/src/photo/form/FieldsetPhotoChooser.tsx b/src/photo/form/FieldsetPhotoChooser.tsx index b96b699d..02fc4cca 100644 --- a/src/photo/form/FieldsetPhotoChooser.tsx +++ b/src/photo/form/FieldsetPhotoChooser.tsx @@ -18,6 +18,9 @@ import SegmentMenu from '@/components/SegmentMenu'; import IconFavs from '@/components/icons/IconFavs'; import InfinitePhotoScroll from '../InfinitePhotoScroll'; +// TODO: +// Create empty state for all modes, including no search results + type Mode = 'all' | 'favs' | 'search'; const CLASSNAME_GRID = 'grid grid-cols-3 gap-0.5'; @@ -98,6 +101,16 @@ export default function FieldsetPhotoChooser({ {renderPhoto(photo)} ; + const photosToShow = showQuery && query + ? photosQuery + : mode === 'favs' + ? photosFavs : photos; + + const shouldPaginate = + !(showQuery && query) && + photosCount > photos.length && + mode !== 'favs'; + return ( <> @@ -176,28 +189,21 @@ export default function FieldsetPhotoChooser({ 'space-y-0.5', )}>
- {(showQuery && query - ? photosQuery - : mode === 'favs' - ? photosFavs : photos) - .map(photo => renderPhotoButton(photo))} + {photosToShow.map(photo => renderPhotoButton(photo))}
- { - !(showQuery && query) && - photosCount > photos.length && - mode !== 'favs' && - - {({ key, photos }) => ( -
- {photos.map(photo => renderPhotoButton(photo))} -
- )} -
} + {shouldPaginate && + + {({ key, photos }) => ( +
+ {photos.map(photo => renderPhotoButton(photo))} +
+ )} +
}