diff --git a/src/admin/AdminBatchEditPanelClient.tsx b/src/admin/AdminBatchEditPanelClient.tsx index 0bd5ac8b..f543e8e9 100644 --- a/src/admin/AdminBatchEditPanelClient.tsx +++ b/src/admin/AdminBatchEditPanelClient.tsx @@ -13,6 +13,7 @@ import { usePathname } from 'next/navigation'; import { PATH_GRID_INFERRED } from '@/site/paths'; import PhotoTagFieldset from './PhotoTagFieldset'; import { tagMultiplePhotosAction } from '@/photo/actions'; +import { toastSuccess } from '@/toast'; export default function AdminBatchEditPanelClient({ uniqueTags, @@ -33,6 +34,12 @@ export default function AdminBatchEditPanelClient({ const [tagErrorMessage, setTagErrorMessage] = useState(''); const isTagging = tags !== undefined; + const resetForm = () => { + setSelectedPhotoIds?.(undefined); + setTags(undefined); + setTagErrorMessage(''); + }; + const photosPlural = selectedPhotoIds?.length === 1 ? 'photo' : 'photos'; const renderPhotoText = () => selectedPhotoIds?.length === 0 @@ -61,9 +68,20 @@ export default function AdminBatchEditPanelClient({ tags, selectedPhotoIds ?? [], ) + .then(() => { + toastSuccess( + `Tags applied to ${selectedPhotoIds?.length} ${photosPlural}` + ); + resetForm(); + }) .finally(() => setIsLoading(false)); }} - disabled={!tags || Boolean(tagErrorMessage) || isLoading} + disabled={ + !tags || + Boolean(tagErrorMessage) || + (selectedPhotoIds?.length ?? 0) === 0 || + isLoading + } primary > Apply Tags