import * as Yup from "yup"; import { useState } from "react"; import PropTypes from "prop-types"; import { Formik, Form } from "formik"; import { Button } from "../Button"; import { TextField } from "../Form/TextField"; import accountsService from "../../services/accountsService"; const accountRemovalSchema = Yup.object().shape({ confirm: Yup.string().oneOf(["delete"], `Type "delete" to confirm`), }); export const AccountRemovalForm = ({ abort, onSuccess }) => { const [error, setError] = useState(false); return ( { try { setError(false); await accountsService.delete("user"); onSuccess(); } catch { setError(true); } }} > {({ errors, touched, isValid, dirty }) => (

Delete account

This will completely delete your account. This process can't be undone.


Type "delete" in the field below to remove your account.

{error && (
There was an error processing your request. Please try again later.
)} )}
); }; AccountRemovalForm.propTypes = { abort: PropTypes.func.isRequired, onSuccess: PropTypes.func.isRequired, };