import { FC, useEffect, useState, useCallback } from 'react' import { validate } from 'email-validator' import { Info } from '@components/icons' import { useUI } from '@components/ui/context' import { Logo, Button, Input } from '@components/ui' import useSignup from '@lib/bigcommerce/use-signup' interface Props {} const ForgotPassword: FC = () => { // Form State const [email, setEmail] = useState('') const [loading, setLoading] = useState(false) const [message, setMessage] = useState('') const [dirty, setDirty] = useState(false) const [disabled, setDisabled] = useState(false) const signup = useSignup() const { setModalView, closeModal } = useUI() const handleSignup = async () => { if (!dirty && !disabled) { setDirty(true) handleValidation() } // try { // setLoading(true) // setMessage('') // await signup({ // email, // }) // setLoading(false) // closeModal() // } catch ({ errors }) { // setMessage(errors[0].message) // setLoading(false) // } } const handleValidation = useCallback(() => { // Unable to send form unless fields are valid. if (dirty) { setDisabled(!validate(email)) } }, [email, dirty]) useEffect(() => { handleValidation() }, [handleValidation]) return (
{message && (
{message}
)}
Do you have an account? {` `} setModalView('LOGIN_VIEW')} > Log In
) } export default ForgotPassword