'use client' import { useState } from 'react' import { createClient } from '@/lib/supabase/client' import { useRouter } from 'next/navigation' export default function LoginPage() { const [email, setEmail] = useState('') const [password, setPassword] = useState('') const [isSignUp, setIsSignUp] = useState(false) const [loading, setLoading] = useState(false) const [error, setError] = useState('') const [message, setMessage] = useState('') const router = useRouter() const supabase = createClient() const handleSubmit = async (e: React.FormEvent) => { e.preventDefault() setLoading(true) setError('') setMessage('') try { if (isSignUp) { const { error } = await supabase.auth.signUp({ email, password, options: { emailRedirectTo: `${window.location.origin}/onboarding`, }, }) if (error) throw error setMessage('Check your email to verify your account!') } else { const { error } = await supabase.auth.signInWithPassword({ email, password, }) if (error) throw error router.push('/') } } catch (err: any) { setError(err.message) } finally { setLoading(false) } } const handleGitHubLogin = async () => { const { error } = await supabase.auth.signInWithOAuth({ provider: 'github', options: { redirectTo: `${window.location.origin}/onboarding`, }, }) if (error) setError(error.message) } return (

{isSignUp ? 'Create Account' : 'Sign In'}

{isSignUp ? 'Join AeThex Live' : 'Welcome back to AeThex Live'}

{error && (
{error}
)} {message && (
{message}
)}
setEmail(e.target.value)} className="w-full bg-gray-900 border border-gray-700 rounded px-4 py-2 text-white placeholder-gray-500 focus:outline-none focus:border-purple-500" placeholder="you@example.com" />
setPassword(e.target.value)} className="w-full bg-gray-900 border border-gray-700 rounded px-4 py-2 text-white placeholder-gray-500 focus:outline-none focus:border-purple-500" placeholder="••••••••" />
or

{isSignUp ? 'Already have an account?' : "Don't have an account?"}{' '}

) }