import { useState } from 'react'; import { toast } from 'react-toastify'; import { getSupabase } from '~/lib/supabase/client'; import type { AuthError } from '@supabase/supabase-js'; import { GoogleIcon } from '~/components/icons/google-icon'; interface SignUpFormProps { onToggleForm: () => void; } export function SignUpForm({ onToggleForm }: SignUpFormProps) { const [email, setEmail] = useState(''); const [password, setPassword] = useState(''); const [confirmPassword, setConfirmPassword] = useState(''); const [isProcessing, setIsProcessing] = useState(false); const handleSignUp = async (e: React.FormEvent) => { e.preventDefault(); if (password !== confirmPassword) { toast.error('Passwords do not match'); return; } setIsProcessing(true); try { const { error } = await getSupabase().auth.signUp({ email, password }); if (error) { throw error; } toast.success('Check your email for the confirmation link!'); } catch (error) { const authError = error as AuthError; toast.error(authError.message || 'Failed to sign up'); } finally { setIsProcessing(false); } }; const handleGoogleSignIn = async () => { const { error } = await getSupabase().auth.signInWithOAuth({ provider: 'google', }); if (error) { toast.error(error.message || 'Failed to sign in with Google'); } }; return ( <>
Already have an account?{' '}
> ); }