"use client"; import { useState } from "react"; import { signInWithEmailAndPassword, GoogleAuthProvider, signInWithPopup } from "firebase/auth"; import { auth } from "@/lib/firebase"; import { useRouter } from "next/navigation"; export default function LoginPage() { const [email, setEmail] = useState(""); const [password, setPassword] = useState(""); const [error, setError] = useState(null); const [loading, setLoading] = useState(false); const router = useRouter(); async function handleSubmit(e: React.FormEvent) { e.preventDefault(); setLoading(true); setError(null); try { await signInWithEmailAndPassword(auth, email, password); router.push("/dashboard"); } catch { setError("Invalid email or password."); } finally { setLoading(false); } } async function handleGoogle() { setLoading(true); setError(null); try { await signInWithPopup(auth, new GoogleAuthProvider()); router.push("/dashboard"); } catch { setError("Google sign-in failed. Try again."); } finally { setLoading(false); } } return (

DRB Portal

setEmail(e.target.value)} required autoComplete="email" className="w-full bg-gray-800 border border-gray-700 rounded-lg px-3 py-2 text-white text-sm focus:outline-none focus:border-indigo-500" />
setPassword(e.target.value)} required autoComplete="current-password" className="w-full bg-gray-800 border border-gray-700 rounded-lg px-3 py-2 text-white text-sm focus:outline-none focus:border-indigo-500" />
{error &&

{error}

}
or
); }