import React, { useState } from 'react'; import { FormattedMessage } from 'react-intl'; import { Formik, Form, Field } from 'formik'; import Button from 'components/common/Button'; import FormLayout, { FormButtons, FormError, FormMessage, FormRow, } from 'components/layout/FormLayout'; import usePost from 'hooks/usePost'; const CONFIRMATION_WORD = 'RESET'; const validate = ({ confirmation }) => { const errors = {}; if (confirmation !== CONFIRMATION_WORD) { errors.confirmation = !confirmation ? ( ) : ( ); } return errors; }; export default function ResetForm({ values, onSave, onClose }) { const post = usePost(); const [message, setMessage] = useState(); const handleSubmit = async ({ type, id }) => { const { ok, data } = await post(`/api/${type}/${id}/reset`); if (ok) { onSave(); } else { setMessage( data || , ); } }; return ( {props => (
{values.name} }} />

{CONFIRMATION_WORD} }} />

{message}
)}
); }