import React, { useState } from 'react'; import { useNavigate, Link, useLocation } from 'react-router-dom'; import { Hexagon, ArrowRight, Loader2, AlertCircle, CheckCircle2 } from 'lucide-react'; import { verifyCode } from '../services/dataService'; export const VerifyCode: React.FC = () => { const navigate = useNavigate(); const location = useLocation(); const email = location.state?.email || ''; const [code, setCode] = useState(''); const [isLoading, setIsLoading] = useState(false); const [error, setError] = useState(''); const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); if (!email) { setError('E-mail não encontrado. Tente registrar novamente.'); return; } setIsLoading(true); setError(''); try { const success = await verifyCode({ email, code }); if (success) { navigate('/login', { state: { message: 'E-mail verificado com sucesso! Agora você pode entrar.' } }); } } catch (err: any) { setError(err.message || 'Código inválido ou expirado.'); } finally { setIsLoading(false); } }; return (
Insira o código de 6 dígitos enviado para {email}