import { useState } from 'react'; import { Link, useNavigate } from 'react-router-dom'; export default function AdminLogin() { const navigate = useNavigate(); const [email, setEmail] = useState(''); const [password, setPassword] = useState(''); const [loading, setLoading] = useState(false); const [error, setError] = useState(null); async function submit(e: React.FormEvent) { e.preventDefault(); setLoading(true); setError(null); try { const r = await fetch('/api/admin/login', { method: 'POST', credentials: 'include', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ email: email.trim(), password }), }); if (r.status === 401) { setError('Email ou senha incorretos.'); return; } if (!r.ok) { setError('Erro inesperado. Tenta de novo.'); return; } navigate('/admin', { replace: true }); } catch { setError('Falha de rede.'); } finally { setLoading(false); } } return (

Painel dos noivos

Acesso restrito a Stefanie & Leandro.

{error && (

{error}

)} ← Voltar pra página pública
); }