import { useState } from 'react' import { Loader2, AlertTriangle } from 'lucide-react' import { accountsApi } from '@/api/accounts' import { useAuthStore } from '@/store/authStore' import { cn } from '@/lib/utils' import { useNavigate } from 'react-router-dom' interface Props { onClose: () => void } export function DeleteAccountModal({ onClose }: Props) { const logout = useAuthStore((s) => s.logout) const navigate = useNavigate() const [password, setPassword] = useState('') const [isSubmitting, setIsSubmitting] = useState(false) const [error, setError] = useState(null) const handleDelete = async (e: React.FormEvent) => { e.preventDefault() if (!password) return setIsSubmitting(true) setError(null) try { await accountsApi.deleteAccount(password) await logout() navigate('/login') } catch (err) { const axiosErr = err as { response?: { data?: { detail?: string } } } setError(axiosErr.response?.data?.detail ?? 'Failed to delete account') } finally { setIsSubmitting(false) } } return (

Delete Account

This action is permanent. Your account, data, and all associated flows will be permanently deleted.

setPassword(e.target.value)} required className={cn( 'mt-1 block w-full rounded-lg border border-border bg-card px-3 py-2', 'text-foreground focus:border-primary focus:outline-hidden' )} />
{error &&

{error}

}
) }