"use client"; import { useState } from "react"; import { useRouter } from "next/navigation"; import Link from "next/link"; export default function AdminLoginPage() { const router = useRouter(); const [email, setEmail] = useState(""); const [password, setPassword] = useState(""); const [error, setError] = useState(null); const [busy, setBusy] = useState(false); async function onSubmit(e: React.FormEvent) { e.preventDefault(); setError(null); setBusy(true); try { const res = await fetch("/api/auth/admin/login", { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ email, password }), }); const data = await res.json().catch(() => ({})); if (!res.ok) { setError(data.error ?? "Sign-in failed"); return; } router.push(data.redirect ?? "/admin"); router.refresh(); } catch { setError("Network error"); } finally { setBusy(false); } } return (

Admin sign-in

Use your email and password.

{error && (

{error}

)}
← Back
); }