import React, { useState } from 'react'; import { Formik, Form, Field } from 'formik'; import Router from 'next/router'; import { post } from 'lib/web'; import Button from 'components/interface/Button'; import FormLayout, { FormButtons, FormError, FormMessage, FormRow, } from 'components/layout/FormLayout'; const validate = ({ name, domain }) => { const errors = {}; if (!name) { errors.name = 'Required'; } if (!domain) { errors.domain = 'Required'; } return errors; }; export default function WebsiteForm({ initialValues, onSave, onClose }) { const [message, setMessage] = useState(); const handleSubmit = async values => { const response = await post(`/api/website`, values); if (response) { onSave(); } else { setMessage('Something went wrong.'); } }; return ( {() => (
{message}
)}
); }