import { useState } from "react"; import { ThemeToggle } from "../components/ThemeToggle"; import { authClient } from "../lib/auth-client"; interface LoginPageProps { navigate: ( route: | "/" | "/login" | "/signup" | "/pricing" | "/dashboard" | "/forgot-password" | "/reset-password", ) => void; } export default function LoginPage({ navigate }: LoginPageProps) { const [email, setEmail] = useState(""); const [password, setPassword] = useState(""); const [error, setError] = useState(null); const [isLoading, setIsLoading] = useState(false); const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); setError(null); setIsLoading(true); try { const result = await authClient.signIn.email({ email, password, }); if (result.error) { setError(result.error.message || "Failed to sign in. Please check your credentials."); setIsLoading(false); return; } navigate("/dashboard"); } catch (err) { setError("An unexpected error occurred. Please try again."); setIsLoading(false); } }; return (
{/* Navigation */} {/* Login Form */}

Welcome back

Sign in to your account to continue

{error && (

{error}

)}
setEmail(e.target.value)} placeholder="you@example.com" required disabled={isLoading} className="w-full px-3 py-2 border border-input rounded-md bg-background text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent disabled:opacity-50 disabled:cursor-not-allowed" />
setPassword(e.target.value)} placeholder="Enter your password" required disabled={isLoading} className="w-full px-3 py-2 border border-input rounded-md bg-background text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent disabled:opacity-50 disabled:cursor-not-allowed" />

Don't have an account?{" "}

); }