import { useState, type FormEvent } from 'react'; import { useAuth } from '../context/AuthContext'; import { useToast } from '../context/ToastContext'; export function Login() { const { signIn } = useAuth(); const { push } = useToast(); const [email, setEmail] = useState(''); const [token, setToken] = useState(''); const [busy, setBusy] = useState(false); const [error, setError] = useState(null); async function onSubmit(e: FormEvent) { e.preventDefault(); if (!email.trim() || !token.trim()) return; setBusy(true); setError(null); try { await signIn(email.trim(), token.trim().toUpperCase()); push('success', 'Welcome back'); } catch (err) { const msg = err instanceof Error ? err.message : 'Sign in failed'; setError(msg); push('error', msg); } finally { setBusy(false); } } return (
APPE

APPE Admin

Sign in with your admin QR token and email.

setEmail(e.target.value)} autoComplete="username" required />
setToken(e.target.value)} autoComplete="current-password" required />
{error &&
{error}
}
); }