import { useState, useEffect } from "react"; import { useNavigate, Link } from "react-router-dom"; import { useAuth } from "@/contexts/AuthContext"; import { aethexToast } from "@/lib/aethex-toast"; import Layout from "@/components/Layout"; import { Button } from "@/components/ui/button"; import { Card, CardContent, CardDescription, CardHeader, CardTitle, } from "@/components/ui/card"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { Badge } from "@/components/ui/badge"; import LoadingScreen from "@/components/LoadingScreen"; import { LogIn, ArrowRight, Shield, Sparkles, Github, Mail, Lock, User, } from "lucide-react"; export default function Login() { const [isLoading, setIsLoading] = useState(false); const [isSignUp, setIsSignUp] = useState(false); const [email, setEmail] = useState(""); const [password, setPassword] = useState(""); const [fullName, setFullName] = useState(""); const navigate = useNavigate(); const { signIn, signUp, user, loading } = useAuth(); // Redirect if already logged in useEffect(() => { if (user && !loading) { navigate("/dashboard"); } }, [user, loading, navigate]); const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); setIsLoading(true); try { if (isSignUp) { await signUp(email, password, { id: "", // Will be set by Supabase full_name: fullName, user_type: "game_developer", // Default, can be changed in onboarding username: email.split("@")[0], // Generate username from email }); aethexToast.success({ title: "Account created!", description: "Please check your email to verify your account, then sign in." }); setIsSignUp(false); } else { await signIn(email, password); navigate("/dashboard"); } } catch (error: any) { console.error("Authentication error:", error); } finally { setIsLoading(false); } }; const handleSocialLogin = async (provider: string) => { setIsLoading(true); try { aethexToast.info({ title: "Social login", description: `${provider} login will be implemented in your Supabase setup` }); } finally { setIsLoading(false); } }; if (isLoading) { return ( ); } return ( {/* Floating particles effect */} {[...Array(20)].map((_, i) => ( ))} Welcome Back Sign in to your AeThex account to access the dashboard Secure Login {/* Social Login Buttons */} handleSocialLogin("github")} > Continue with GitHub handleSocialLogin("google")} > Continue with Google Or continue with email {/* Email/Password Form */} Email Address setEmail(e.target.value)} placeholder="Enter your email" className="pl-10 bg-background/50 border-border/50 focus:border-aethex-400" required /> Password setPassword(e.target.value)} placeholder="Enter your password" className="pl-10 bg-background/50 border-border/50 focus:border-aethex-400" required /> Remember me Forgot password? Sign In to Dashboard Don't have an account?{" "} navigate("/onboarding")} className="text-aethex-400 hover:underline font-medium" > Join AeThex {/* Security Notice */} 🔒 Your data is protected with enterprise-grade security ); }
Don't have an account?{" "} navigate("/onboarding")} className="text-aethex-400 hover:underline font-medium" > Join AeThex
🔒 Your data is protected with enterprise-grade security