diff --git a/src/app/(auth-state)/admin/photos/page.tsx b/src/app/(auth-state)/admin/photos/page.tsx index ba81c851..b94e7fed 100644 --- a/src/app/(auth-state)/admin/photos/page.tsx +++ b/src/app/(auth-state)/admin/photos/page.tsx @@ -125,6 +125,9 @@ export default async function AdminTagsPage({ } + onFormSubmitToastMessage={` + "${titleForPhoto(photo)}" EXIF data synced + `} /> { icon?: JSX.Element styleAsLink?: boolean spinnerColor?: SpinnerColor + onFormSubmitToastMessage?: string } -export default function SubmitButtonWithStatus(props: Props) { - const { - icon, - styleAsLink, - spinnerColor, - children, - disabled, - className, - type: _type, - ...buttonProps - } = props; +export default function SubmitButtonWithStatus({ + icon, + styleAsLink, + spinnerColor, + onFormSubmitToastMessage, + children, + disabled, + className, + type: _type, + ...buttonProps +}: Props) { const { pending } = useFormStatus(); + const pendingPrevious = useRef(pending); + + useEffect(() => { + if ( + pendingPrevious.current && + !pending && + onFormSubmitToastMessage + ) { + toastSuccess(onFormSubmitToastMessage); + } + pendingPrevious.current = pending; + }, [pending, onFormSubmitToastMessage]); return (