"use client"; import { useState } from "react"; import { Card, Button, Input } from "@/shared/components"; import { useRouter } from "next/navigation"; export default function LoginPage() { const [password, setPassword] = useState(""); const [error, setError] = useState(""); const [loading, setLoading] = useState(false); const router = useRouter(); const handleLogin = async (e) => { e.preventDefault(); setLoading(true); setError(""); try { const res = await fetch("/api/auth/login", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ password }), }); if (res.ok) { router.push("/dashboard"); router.refresh(); } else { const data = await res.json(); setError(data.error || "Invalid password"); } } catch (err) { setError("An error occurred. Please try again."); } finally { setLoading(false); } }; return (
Enter your password to access the dashboard