import { useRef, useState, FormEventHandler } from 'react' import DangerButton from '@/Components/DangerButton' import InputError from '@/Components/InputError' import InputLabel from '@/Components/InputLabel' import Modal from '@/Components/Modal' import SecondaryButton from '@/Components/SecondaryButton' import TextInput from '@/Components/TextInput' import { useForm } from '@inertiajs/react' import { profile_destroy_path } from '@/routes' export default function DeleteUserForm({ className = '' }: { className?: string }) { const [confirmingUserDeletion, setConfirmingUserDeletion] = useState(false) const passwordInput = useRef(null) const { data, setData, delete: destroy, processing, reset, errors, } = useForm({ password: '', }) const confirmUserDeletion = () => { setConfirmingUserDeletion(true) } const deleteUser: FormEventHandler = (e) => { e.preventDefault() destroy(profile_destroy_path(), { preserveScroll: true, onSuccess: () => closeModal(), onError: () => passwordInput.current?.focus(), onFinish: () => reset(), }) } const closeModal = () => { setConfirmingUserDeletion(false) reset() } return (

Delete Account

Once your account is deleted, all of its resources and data will be permanently deleted. Before deleting your account, please download any data or information that you wish to retain.

Delete Account

Are you sure you want to delete your account?

Once your account is deleted, all of its resources and data will be permanently deleted. Please enter your password to confirm you would like to permanently delete your account.

setData('password', e.target.value)} className="mt-1 block w-3/4" isFocused placeholder="Password" />
Cancel Delete Account
) }