import { IoLogoGoogle } from 'react-icons/io'; import router from 'next/router'; import { toast } from 'react-toastify'; import { useState } from 'react'; type LoginProps = { resetPassword: (email: string) => Promise<{ error: { message: string } }>; signIn: ({}) => Promise<{ data: Record; error: { message: string }; }>; }; const Login = ({ resetPassword, signIn }: LoginProps): JSX.Element => { const [email, setEmail] = useState(''); const [password, setPassword] = useState(''); const [forgot, setForgot] = useState(false); const resetPasswordLogin = () => { resetPassword(email).then((result: { error: { message: string } }) => { if (result.error) { toast.error(result.error.message); } else toast.success('Check your email to reset your password!'); }); }; const login = (e: React.SyntheticEvent) => { e.preventDefault(); // Handle the login. Go to the homepage if success or display an error. signIn({ email, password, }).then( (result: { data: Record; error: { message: string }; }) => { if (result.data) { router.push('/'); } if (result.error) { toast.error(result.error.message); } } ); }; return (
{!forgot && ( <>

Account Login

{ setEmail(event.target.value); }} />
{ setPassword(event.target.value); }} />
or login with
)} {forgot && ( <>

Password recovery

{ setEmail(event.target.value); }} />

)}
); }; export default Login;