import { destroy } from '@/actions/App/Http/Controllers/Settings/AutomationRuleController'; import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, } from '@/components/ui/alert-dialog'; import type { AutomationRule } from '@/types/automation-rule'; import { router } from '@inertiajs/react'; import { useState } from 'react'; interface DeleteAutomationRuleDialogProps { rule: AutomationRule; open: boolean; onOpenChange: (open: boolean) => void; onSuccess?: () => void; } export function DeleteAutomationRuleDialog({ rule, open, onOpenChange, onSuccess, }: DeleteAutomationRuleDialogProps) { const [isDeleting, setIsDeleting] = useState(false); const handleDelete = () => { setIsDeleting(true); router.delete(destroy(rule.id).url, { preserveState: true, preserveScroll: true, onSuccess: () => { onOpenChange(false); onSuccess?.(); }, onFinish: () => { setIsDeleting(false); }, }); }; return ( Delete Automation Rule Are you sure you want to delete "{rule.title}"? This action cannot be undone. Cancel {isDeleting ? 'Deleting...' : 'Delete'} ); }