import { ApiError, Session, UserCredentials } from '@supabase/gotrue-js'; import { IoLogoGoogle } from 'react-icons/io'; import router from 'next/router'; import { toast } from 'react-toastify'; import { useState } from 'react'; type SignUpPanelProperties = { signUp: (data: UserCredentials) => Promise<{ user: Session['user'] | null; session: Session | null; error: ApiError | null; }>; signIn: (data: UserCredentials) => Promise<{ user: Session['user'] | null; session: Session | null; error: ApiError | null; }>; }; const SignUpPanel = ({ signIn, signUp, }: SignUpPanelProperties): JSX.Element => { const [email, setEmail] = useState(''); const [password, setPassword] = useState(''); const signup = async ( event: React.SyntheticEvent ): Promise => { event.preventDefault(); // Handle the login. Go to the homepage if success or display an error. const result = await signUp({ email, password, }); if (result.error) { toast.error(result.error.message); } else if (result.user?.confirmation_sent_at) { toast.success( 'A confirmation email has been sent to you, watch your mailbox!' ); } else if (result.user) { void router.push('/'); } }; return (

Account Sign Up

{ setEmail(event.target.value); }} />
{ setPassword(event.target.value); }} />
or sign up with
); }; export default SignUpPanel;