/** @jsxRuntime classic */ /** @jsx jsx */ import { jsx } from "@emotion/react"; import { useEffect } from "react"; import { useForm } from "react-hook-form"; import { useMutation } from "react-query"; import { Heading, Text, Box, FormControl, FormErrorMessage, Input, Button, } from "@chakra-ui/react"; import Modal from "./Modal"; import { AuthService } from "../core/services"; import { useToast, useUser } from "../core/hooks"; const Verify = ({ toggleModal }) => { const { handleSubmit, errors, register } = useForm(); const toast = useToast(); const [verify, { isLoading, error, data }] = useMutation(async (data) => { const verificationResponse = await AuthService.verify(data); return verificationResponse.data; }); const { getUser } = useUser(); useEffect(() => { if (!data) { return; } getUser(); toggleModal(null); }, [data, getUser, toggleModal]); useEffect(() => { if (error?.response?.data?.detail) { toast(error.response.data.detail, "error"); } }, [error, toast]); return ( toggleModal(null)}> Verify account
{errors.code && errors.code.message}
We just sent you a verification code by email. Please enter the code here so we can verify that you are who you say you are.
); }; export default Verify;