import { FC, useEffect, useState, useCallback } from 'react'; import { validate } from 'email-validator'; import { useUI } from '@components/ui/context'; import { Logo, Button, Input } from '@components/ui'; 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 { setModalView, closeModal } = useUI(); const handleResetPassword = async (e: React.SyntheticEvent) => { e.preventDefault(); if (!dirty && !disabled) { setDirty(true); handleValidation(); } }; 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;