import { useForm } from '@inertiajs/react'; import { FormEventHandler, useRef } from 'react'; // Components... import InputError from '@/components/input-error'; import { Button } from '@/components/ui/button'; import { Input } from '@/components/ui/input'; import { Label } from '@/components/ui/label'; import HeadingSmall from '@/components/heading-small'; import { useTranslation } from '@/hooks/use-translation'; import { Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogTitle, DialogTrigger } from '@/components/ui/dialog'; export default function DeleteUser({ graceDays }: { graceDays: number }) { const { t } = useTranslation(); const passwordInput = useRef(null); const { data, setData, delete: destroy, processing, reset, errors, clearErrors } = useForm({ password: '' }); const deleteUser: FormEventHandler = (e) => { e.preventDefault(); destroy(route('profile.destroy'), { preserveScroll: true, onSuccess: () => closeModal(), onError: () => passwordInput.current?.focus(), onFinish: () => reset(), }); }; const closeModal = () => { clearErrors(); reset(); }; return (

{t('Warning')}

{t( 'Your account is deactivated immediately. After :days days it is permanently erased, including your identifying details in the activity log — this cannot be undone.', { days: graceDays }, )}

{t('Are you sure you want to delete your account?')} {t('Your account will be deactivated now and permanently erased after :days days. Enter your password to confirm.', { days: graceDays, })}
setData('password', e.target.value)} placeholder={t('Password')} autoComplete="current-password" />
); }