import { Form } from '@inertiajs/react'; import { Save, X } from 'lucide-react'; import type { ReactNode } from 'react'; import { Button } from '@/components/ui/button'; import { Dialog, DialogContent, DialogFooter, DialogHeader, DialogTitle, } from '@/components/ui/dialog'; import { cn } from '@/lib/utils'; type FormDialogProps = { open: boolean; onOpenChange: (open: boolean) => void; title: string; action: React.ComponentProps['action']; resetOnSuccess?: boolean; onSuccess?: () => void; submitDisabled?: boolean; submitLabel?: ReactNode; submittingLabel?: ReactNode; contentClassName?: string; children: | ReactNode | ((ctx: { errors: Record; processing: boolean; }) => ReactNode); }; export function FormDialog({ open, onOpenChange, title, action, resetOnSuccess, onSuccess, submitDisabled = false, submitLabel = 'Simpan', submittingLabel = 'Menyimpan...', contentClassName, children, }: FormDialogProps) { return (
{({ errors, processing }) => ( <> {title}
{typeof children === 'function' ? children({ errors, processing }) : children}
)}
); }