"use client"; import { useState } from "react"; import { useRouter } from "next/navigation"; import Link from "next/link"; import { Loader2 } from "lucide-react"; import { APP_NAME } from "@/lib/constants"; export default function LoginPage() { const router = useRouter(); const [email, setEmail] = useState(""); const [password, setPassword] = useState(""); const [error, setError] = useState(""); const [isLoading, setIsLoading] = useState(false); const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); setError(""); setIsLoading(true); try { const res = await fetch("/api/auth/login", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ email, password }), }); const data = await res.json(); if (!res.ok) { setError(data.error || "Login failed"); return; } router.push("/"); router.refresh(); } catch { setError("An error occurred"); } finally { setIsLoading(false); } }; return (

{APP_NAME}

Sign in to your account

{error && (
{error}
)}
setEmail(e.target.value)} required className="w-full px-4 py-3 bg-surface border border-border rounded-lg focus:outline-none focus:border-muted" placeholder="you@example.com" />
setPassword(e.target.value)} required className="w-full px-4 py-3 bg-surface border border-border rounded-lg focus:outline-none focus:border-muted" placeholder="Enter your password" />

Don't have an account?{" "} Create one

); }