'use client'; import { useState, type FormEvent } from 'react'; import { useRouter } from 'next/navigation'; import { Shield } from 'lucide-react'; import { useConfig } from '@/hooks/use-config'; import { useThemeStore } from '@/stores/theme-store'; import { apiFetch } from '@/lib/browser-navigation'; export default function AdminLoginPage() { const router = useRouter(); const [password, setPassword] = useState(''); const [error, setError] = useState(''); const [loading, setLoading] = useState(false); const { loginLogoLightUrl, loginLogoDarkUrl } = useConfig(); const resolvedTheme = useThemeStore((s) => s.resolvedTheme); const logoUrl = resolvedTheme === 'dark' ? loginLogoDarkUrl : loginLogoLightUrl; async function handleSubmit(e: FormEvent) { e.preventDefault(); setError(''); setLoading(true); try { const res = await apiFetch('/api/admin/auth', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ password }), }); const data = await res.json(); if (!res.ok) { setError(data.error || 'Login failed'); return; } router.push('/admin'); } catch { setError('Network error. Please try again.'); } finally { setLoading(false); } } return (
{logoUrl ? ( ) : ( )}

Admin Dashboard

Enter your admin password to continue

setPassword(e.target.value)} className="flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm text-foreground transition-all duration-200 placeholder:text-muted-foreground hover:border-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:border-ring" placeholder="Enter admin password" required autoFocus autoComplete="current-password" />
{error && (
{error}
)}
); }