import React, { useState } from 'react'; import { Formik, Form, Field } from 'formik'; import { del } from 'lib/web'; import Button from 'components/common/Button'; import FormLayout, { FormButtons, FormError, FormMessage, FormRow, } from 'components/layout/FormLayout'; import { FormattedMessage } from 'react-intl'; const CONFIRMATION_WORD = 'DELETE'; const validate = ({ confirmation }) => { const errors = {}; if (confirmation !== CONFIRMATION_WORD) { errors.confirmation = !confirmation ? ( ) : ( ); } return errors; }; export default function DeleteForm({ values, onSave, onClose }) { const [message, setMessage] = useState(); const handleSubmit = async ({ type, id }) => { const response = await del(`/api/${type}/${id}`); if (typeof response !== 'string') { onSave(); } else { setMessage(); } }; return ( {props => (
{values.name} }} />

{CONFIRMATION_WORD} }} />

{message}
)}
); }