import { useState } from 'react'; import { useRouter } from 'next/router'; export default function Signup() { const [username, setUsername] = useState(''); const [password, setPassword] = useState(''); const [error, setError] = useState(null); const router = useRouter(); const handleSubmit = async e => { e.preventDefault(); setError(null); try { const res = await fetch('/api/signup', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ username, password }) }); const data = await res.json(); if (!res.ok) throw new Error(data.message || 'Signup failed'); alert('Conta criada! Redirecionando para login...'); router.push('/login'); } catch (err) { setError(err.message); } }; return (

Cadastro - Expedição Gold

{error &&

{error}

}
setUsername(e.target.value)} required style={{ width: '100%', padding: '0.5rem', marginTop: 0.5 }} />
setPassword(e.target.value)} required style={{ width: '100%', padding: '0.5rem', marginTop: 0.5 }} />

Já tem conta? Faça login

); }