"use client" import { Button } from "@/components/ui/button" import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card" import { ArrowLeft, Eye, EyeOff } from "lucide-react" import Link from "next/link" import { useState } from "react" import { useRouter } from "next/navigation" import { Logo } from "@/components/Logo" export default function LoginPage() { const [showPassword, setShowPassword] = useState(false) const [email, setEmail] = useState("") const [password, setPassword] = useState("") const [error, setError] = useState("") const router = useRouter() const handleLogin = async (e: React.FormEvent) => { e.preventDefault() setError("") 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 (data.success) { if (data.role === "admin") { router.push("/admin") } else { router.push("/dashboard") } } else { setError(data.error || "Invalid email or password.") } } catch (err) { setError("An error occurred. Please try again.") } } return (
Back to Home
Welcome back Enter your credentials to access your dashboard.
setEmail(e.target.value)} placeholder="student@example.com" suppressHydrationWarning className="w-full bg-background border border-border rounded-xl px-4 py-3 text-sm focus:outline-none focus:ring-2 focus:ring-[#00F0FF] focus:border-transparent transition-all" />
Forgot password?
setPassword(e.target.value)} placeholder="••••••••" suppressHydrationWarning className="w-full bg-background border border-border rounded-xl px-4 py-3 text-sm focus:outline-none focus:ring-2 focus:ring-[#00F0FF] focus:border-transparent transition-all pr-10" />
{error && (
{error}
)}

Don't have an account? Sign up

) }