'use client'; import { useState } from 'react'; import { useRouter } from 'next/navigation'; import Link from 'next/link'; import { Logo } from '@/components/logo'; import { Button } from '@/components/ui/button'; import { Input, Label } from '@/components/input'; import { apiFetch } from '@/lib/api'; export default function AdminLogin() { const router = useRouter(); const [email, setEmail] = useState(''); const [password, setPassword] = useState(''); const [state, setState] = useState<'idle' | 'submitting' | 'error'>('idle'); const [error, setError] = useState(null); async function submit(e: React.FormEvent) { e.preventDefault(); setState('submitting'); setError(null); try { await apiFetch('/v1/auth/admin/login', { method: 'POST', body: JSON.stringify({ email, password }), }); router.replace('/admin'); } catch (err) { const detail = (err as { detail?: { error?: string } }).detail; const code = detail?.error; setError( code === 'not_admin' ? 'That account exists but is not an admin.' : code === 'invalid_credentials' ? 'Wrong email or password.' : (err as Error).message, ); setState('error'); } } return (

Admin sign in

restricted

Email + password. Non-admin accounts use the magic link at{' '} /login .

setEmail(e.target.value)} placeholder="admin@yourcompany.com" />
setPassword(e.target.value)} placeholder="••••••••" />
{error &&

{error}

}
← Back to home
); }