import { useState } from "react" import { fetchAPI } from "utils/api" import * as yup from "yup" import { Formik, Form, Field } from "formik" import Button from "../elements/button" const LeadForm = ({ data }) => { const [loading, setLoading] = useState(false) const LeadSchema = yup.object().shape({ email: yup.string().email().required(), }) return (

{data.title}

{ setLoading(true) try { setErrors({ api: null }) await fetchAPI( "/lead-form-submissions", {}, { method: "POST", body: JSON.stringify({ email: values.email, location: data.location, }), } ) } catch (err) { setErrors({ api: err.message }) } setLoading(false) setSubmitting(false) }} > {({ errors, touched, isSubmitting }) => (
)}
) } export default LeadForm