import FormWithConfirm from '@/components/FormWithConfirm'; import SubmitButtonWithStatus from '@/components/SubmitButtonWithStatus'; import IconGrSync from '@/site/IconGrSync'; import { clsx } from 'clsx/lite'; import { ComponentProps } from 'react'; export default function PhotoSyncButton({ action, label, onFormSubmit, formData: { photoId, photoUrl } = {}, photoTitle, hasAiTextGeneration, shouldConfirm, shouldToast, }: { action: (formData: FormData) => void label?: string formData?: { photoId?: string photoUrl?: string } photoTitle?: string hasAiTextGeneration?: boolean shouldConfirm?: boolean shouldToast?: boolean } & ComponentProps) { const confirmText = ['Overwrite']; if (photoTitle) { confirmText.push(`"${photoTitle}"`); } confirmText.push('data from original file?'); if (hasAiTextGeneration) { confirmText.push( 'AI text will be generated for undefined fields.'); } confirmText.push('This action cannot be undone.'); return ( {photoId && } {photoUrl && } } onFormSubmitToastMessage={shouldToast ? photoTitle ? `"${photoTitle}" data synced` : 'Data synced' : undefined} onFormSubmit={onFormSubmit} > {label} ); }