import { useForm } from '@inertiajs/react'; import classNames from 'classnames'; import React, { useRef, useState } from 'react'; import useRoute from '@/Hooks/useRoute'; import ActionSection from '@/Components/ActionSection'; import DangerButton from '@/Components/DangerButton'; import DialogModal from '@/Components/DialogModal'; import TextInput from '@/Components/TextInput'; import InputError from '@/Components/InputError'; import SecondaryButton from '@/Components/SecondaryButton'; export default function DeleteUserForm() { const route = useRoute(); const [confirmingUserDeletion, setConfirmingUserDeletion] = useState(false); const form = useForm({ password: '', }); const passwordRef = useRef(null); function confirmUserDeletion() { setConfirmingUserDeletion(true); setTimeout(() => passwordRef.current?.focus(), 250); } function deleteUser() { form.delete(route('current-user.destroy'), { preserveScroll: true, onSuccess: () => closeModal(), onError: () => passwordRef.current?.focus(), onFinish: () => form.reset(), }); } function closeModal() { setConfirmingUserDeletion(false); form.reset(); } return (
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.
form.setData('password', e.currentTarget.value)} />
Cancel Delete Account
); }