"use client"; import { useState } from "react"; import { useRouter } from "next/navigation"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"; import { Separator } from "@/components/ui/separator"; import { signUpWithEmail, signInWithEmail, signInWithGoogle, signInWithGitHub } from "@/lib/firebase/auth"; import { Github, Loader2 } from "lucide-react"; import { toast } from "sonner"; export default function AuthPage() { const router = useRouter(); const [isSignUp, setIsSignUp] = useState(false); const [isLoading, setIsLoading] = useState(false); const [email, setEmail] = useState(""); const [password, setPassword] = useState(""); const [displayName, setDisplayName] = useState(""); const handleEmailAuth = async (e: React.FormEvent) => { e.preventDefault(); setIsLoading(true); try { if (isSignUp) { if (!displayName.trim()) { toast.error("Please enter your name"); setIsLoading(false); return; } const { workspace } = await signUpWithEmail(email, password, displayName); toast.success("Account created successfully!"); router.push(`/${workspace}/projects`); } else { await signInWithEmail(email, password); toast.success("Signed in successfully!"); // Get user's workspace from Firestore router.push(`/marks-account/projects`); // TODO: Get actual workspace } } catch (error: any) { toast.error(error.message); } finally { setIsLoading(false); } }; const handleGoogleSignIn = async () => { setIsLoading(true); try { await signInWithGoogle(); toast.success("Signed in with Google!"); router.push(`/marks-account/projects`); // TODO: Get actual workspace } catch (error: any) { toast.error(error.message); } finally { setIsLoading(false); } }; const handleGitHubSignIn = async () => { setIsLoading(true); try { await signInWithGitHub(); toast.success("Signed in with GitHub!"); router.push(`/marks-account/projects`); // TODO: Get actual workspace } catch (error: any) { toast.error(error.message); } finally { setIsLoading(false); } }; return (
{/* Logo */}
Vib'n
{/* Auth Card */} {isSignUp ? "Create your account" : "Welcome back"} {isSignUp ? "Sign up to start building with Vib'n" : "Sign in to continue to Vib'n"} {/* Social Sign In */}
Or continue with email
{/* Email Sign In Form */}
{isSignUp && (
setDisplayName(e.target.value)} disabled={isLoading} required />
)}
setEmail(e.target.value)} disabled={isLoading} required />
setPassword(e.target.value)} disabled={isLoading} required minLength={6} /> {isSignUp && (

Must be at least 6 characters

)}
{/* Toggle Sign Up/Sign In */}
{isSignUp ? "Already have an account?" : "Don't have an account?"} {" "}
{/* Footer */}

By continuing, you agree to our Terms of Service and Privacy Policy.

); }