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 SignInFormProps { onToggleForm: () => void; } export function SignInForm({ onToggleForm }: SignInFormProps) { const [email, setEmail] = useState(''); const [password, setPassword] = useState(''); const [isProcessing, setIsProcessing] = useState(false); const handleSignIn = async (e: React.FormEvent) => { e.preventDefault(); setIsProcessing(true); try { const { error } = await getSupabase().auth.signInWithPassword({ email, password }); if (error) { throw error; } toast.success('Successfully signed in!'); } catch (error) { const authError = error as AuthError; toast.error(authError.message || 'Failed to sign in'); } 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 ( <>
Don't have an account?{' '}
> ); }