diff --git a/src/admin/select/AdminBatchEditPanelClient.tsx b/src/admin/select/AdminBatchEditPanelClient.tsx index 86e49c8a..eafcd9eb 100644 --- a/src/admin/select/AdminBatchEditPanelClient.tsx +++ b/src/admin/select/AdminBatchEditPanelClient.tsx @@ -4,7 +4,7 @@ import LoaderButton from '@/components/primitives/LoaderButton'; import AppGrid from '@/components/AppGrid'; import { clsx } from 'clsx/lite'; import { IoCloseSharp } from 'react-icons/io5'; -import { useEffect, useRef, useState } from 'react'; +import { useEffect, useRef } from 'react'; import { Tags } from '@/tag'; import FieldsetTag from '@/tag/FieldsetTag'; import { batchPhotoAction } from '@/photo/actions'; @@ -44,15 +44,17 @@ export default function AdminBatchEditPanelClient({ selectAllCount, isPerformingSelectEdit, setIsPerformingSelectEdit, + albumTitles, + setAlbumTitles, + tags, + setTags, + tagErrorMessage, + setTagErrorMessage, } = useSelectPhotosState(); const appText = useAppText(); - const [albumTitles, setAlbumsTitles] = useState(); const isInAlbumMode = albumTitles !== undefined; - - const [tags, setTags] = useState(); - const [tagErrorMessage, setTagErrorMessage] = useState(''); const isInTagMode = tags !== undefined; const batchPhotoActionArguments = ( @@ -103,9 +105,9 @@ export default function AdminBatchEditPanelClient({ className="translate-y-[0.5px]" />} onClick={() => { - setAlbumsTitles(undefined); - setTags(undefined); - setTagErrorMessage(''); + setAlbumTitles?.(undefined); + setTags?.(undefined); + setTagErrorMessage?.(''); }} disabled={isPerformingSelectEdit} /> @@ -182,14 +184,14 @@ export default function AdminBatchEditPanelClient({ }} /> setAlbumsTitles('')} + onClick={() => setAlbumTitles?.('')} disabled={isFormDisabled} icon={} > Album setTags('')} + onClick={() => setTags?.('')} disabled={isFormDisabled} icon={} > @@ -234,7 +236,7 @@ export default function AdminBatchEditPanelClient({ ? setTags?.(tags)} onError={setTagErrorMessage} readOnly={isPerformingSelectEdit} openOnLoad diff --git a/src/admin/select/SelectPhotosProvider.tsx b/src/admin/select/SelectPhotosProvider.tsx index 4fd78523..24e346e1 100644 --- a/src/admin/select/SelectPhotosProvider.tsx +++ b/src/admin/select/SelectPhotosProvider.tsx @@ -51,6 +51,10 @@ export default function SelectPhotosProvider({ const [isPerformingSelectEdit, setIsPerformingSelectEdit] = useState(false); + const [albumTitles, setAlbumTitles] = useState(); + const [tags, setTags] = useState(); + const [tagErrorMessage, setTagErrorMessage] = useState(''); + const getPhotoGridElements = useCallback(() => document.querySelectorAll(`[${DATA_KEY_PHOTO_GRID}=true]`) , []); @@ -118,6 +122,9 @@ export default function SelectPhotosProvider({ setIsSelectingAllPhotos(false); setSelectAllPhotoOptions(undefined); setSelectAllCount(undefined); + setAlbumTitles(undefined); + setTags(undefined); + setTagErrorMessage(''); } }, [isSelectingPhotos, getPhotoGridElements]); @@ -136,6 +143,12 @@ export default function SelectPhotosProvider({ togglePhotoSelection, isPerformingSelectEdit, setIsPerformingSelectEdit, + albumTitles, + setAlbumTitles, + tags, + setTags, + tagErrorMessage, + setTagErrorMessage, }}> {children} diff --git a/src/admin/select/SelectPhotosState.ts b/src/admin/select/SelectPhotosState.ts index d7b435cf..f5c2c614 100644 --- a/src/admin/select/SelectPhotosState.ts +++ b/src/admin/select/SelectPhotosState.ts @@ -5,16 +5,22 @@ export type SelectPhotosState = { canCurrentPageSelectPhotos?: boolean isSelectingPhotos?: boolean isSelectingAllPhotos?: boolean - shouldShowSelectAll?: boolean - toggleIsSelectingAllPhotos?: () => void startSelectingPhotos?: () => void stopSelectingPhotos?: () => void + shouldShowSelectAll?: boolean + toggleIsSelectingAllPhotos?: () => void selectedPhotoIds?: string[] selectAllPhotoOptions?: PhotoQueryOptions selectAllCount?: number togglePhotoSelection?: (photoId: string) => void isPerformingSelectEdit?: boolean setIsPerformingSelectEdit?: Dispatch> + albumTitles?: string + setAlbumTitles?: Dispatch> + tags?: string + setTags?: Dispatch> + tagErrorMessage?: string + setTagErrorMessage?: Dispatch> }; export const SelectPhotosContext = createContext({});