diff --git a/src/pages/AdminLogin.tsx b/src/pages/AdminLogin.tsx index 92eeee2..ab678c4 100644 --- a/src/pages/AdminLogin.tsx +++ b/src/pages/AdminLogin.tsx @@ -8,9 +8,30 @@ export default function AdminLogin() { const [email, setEmail] = useState(''); const [password, setPassword] = useState(''); const [loading, setLoading] = useState(false); + const [googleLoading, setGoogleLoading] = useState(false); const [error, setError] = useState(null); const navigate = useNavigate(); + const handleGoogleSignIn = async (): Promise => { + setError(null); + setGoogleLoading(true); + try { + const { error: oauthError } = await supabase.auth.signInWithOAuth({ + provider: 'google', + options: { redirectTo: window.location.origin }, + }); + if (oauthError) { + setError(classifyAuthError(oauthError)); + setGoogleLoading(false); + } + // On success, the browser is redirected to Google; no further state work needed. + } catch (err) { + const message = err instanceof Error ? err.message : 'Google sign-in failed. Please try again.'; + setError(message); + setGoogleLoading(false); + } + }; + const handleLogin = async (e: React.FormEvent) => { e.preventDefault(); setLoading(true); @@ -85,6 +106,30 @@ export default function AdminLogin() { )} + + +
+
+ + or continue with + +
+
+
-