import { destroy } from '@/actions/App/Http/Controllers/Settings/AccountController'; import { Button } from '@/components/ui/button'; import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, } from '@/components/ui/dialog'; import { Input } from '@/components/ui/input'; import { Label } from '@/components/ui/label'; import { type Account } from '@/types/account'; import { Form, router } from '@inertiajs/react'; import { useState } from 'react'; interface DeleteAccountDialogProps { account: Account; open: boolean; onOpenChange: (open: boolean) => void; onSuccess?: () => void; redirectTo?: string; } export function DeleteAccountDialog({ account, open, onOpenChange, onSuccess, redirectTo, }: DeleteAccountDialogProps) { const [confirmText, setConfirmText] = useState(''); function handleOpenChange(newOpen: boolean) { if (!newOpen) { setConfirmText(''); } onOpenChange(newOpen); } const isDeleteEnabled = confirmText === 'DELETE'; return ( Delete Account

This action is irreversible. All transactions in this account will also be permanently deleted.

Type DELETE to confirm.

setConfirmText(e.target.value)} placeholder="Type DELETE" autoComplete="off" />
{ handleOpenChange(false); if (redirectTo) { router.visit(redirectTo); } else { onSuccess?.(); } }} > {({ processing }) => ( )}
); }