diff --git a/src/app/login/page.tsx b/src/app/login/page.tsx index 572c81b..7ae6f3b 100644 --- a/src/app/login/page.tsx +++ b/src/app/login/page.tsx @@ -1,6 +1,7 @@ 'use client' import { Logo } from '@/components/logo' +import { Button } from '@/components/ui/button' import { signUp } from '@/features/auth/actions' import { supabase } from '@/lib/supabase/client' import { ArrowRight, Loader2 } from 'lucide-react' @@ -34,8 +35,9 @@ function LoginForm() { const [busy, setBusy] = useState(false) const [error, setError] = useState(null) const [notice, setNotice] = useState(null) + const [loadingOAuth, setLoadingOAuth] = useState(false) - async function submit(e: React.FormEvent) { + async function submit(e: React.SubmitEvent) { e.preventDefault() if (busy) return setBusy(true) @@ -62,6 +64,24 @@ function LoginForm() { } } + async function signInWithGithub() { + setLoadingOAuth(true) + try { + const { error } = await supabase.auth.signInWithOAuth({ + provider: 'github', + }) + if (error) throw error + router.replace(explicitNext || '/onboarding') + } catch (err) { + setError( + err instanceof Error + ? err.message + : 'Falha na autenticação GitHub OAuth', + ) + setLoadingOAuth(false) + } + } + return (
@@ -84,43 +104,77 @@ function LoginForm() { : 'Leva 30 segundos. Sem cartão.'}

-
- setEmail(e.target.value)} - placeholder='seu@email.com' - className='rounded-xl border border-[#DFE5E9] bg-white px-4 py-3 text-[#1b1916] outline-none focus:border-primary/50 focus:ring-2 focus:ring-primary/20' - /> - setPassword(e.target.value)} - placeholder='senha (mín. 6 caracteres)' - className='rounded-xl border border-[#DFE5E9] bg-white px-4 py-3 text-[#1b1916] outline-none focus:border-primary/50 focus:ring-2 focus:ring-primary/20' - /> - - {error &&

{error}

} - {notice &&

{notice}

} +
+
+ + {error &&

{error}

} +
+
+
+ ou +
+
- - +
+ setEmail(e.target.value)} + placeholder='seu@email.com' + className='rounded-xl border border-[#DFE5E9] bg-white px-4 py-3 text-[#1b1916] outline-none focus:border-primary/50 focus:ring-2 focus:ring-primary/20' + /> + setPassword(e.target.value)} + placeholder='senha (mín. 6 caracteres)' + className='rounded-xl border border-[#DFE5E9] bg-white px-4 py-3 text-[#1b1916] outline-none focus:border-primary/50 focus:ring-2 focus:ring-primary/20' + /> + {error &&

{error}

} + {notice &&

{notice}

} + +
+