import { useMutation } from '@tanstack/react-query'; import { getClientAuthToken } from 'lib/client'; import useApi from 'hooks/useApi'; import { Button, Form, FormButtons, FormInput, SubmitButton, TextField } from 'react-basics'; import styles from './Form.module.css'; const CONFIRM_VALUE = 'DELETE'; export default function UserDeleteForm({ userId, onSave, onClose }) { const { del } = useApi(getClientAuthToken()); const { mutate, error, isLoading } = useMutation(data => del(`/users/${userId}`, data)); const handleSubmit = async data => { mutate(data, { onSuccess: async () => { onSave(); }, }); }; return (
To delete this user, type {CONFIRM_VALUE} in the box below to confirm.
value === CONFIRM_VALUE }} > Save
); }