import React, { useState } from 'react'; const API_URL = import.meta.env.VITE_EFC_API_URL; export default function ForgotPassword() { const [email, setEmail] = useState(''); const [username, setUsername] = useState(''); const [loading, setLoading] = useState(false); const [success, setSuccess] = useState(false); const [error, setError] = useState(''); const handleSubmit = async (e) => { e.preventDefault(); setLoading(true); setError(''); setSuccess(false); try { const res = await fetch(`${API_URL}/user/password-reset/`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ username, email }), }); if (!res.ok) { const data = await res.json().catch(() => ({})); setError(data.detail || 'No se pudo enviar el correo.'); } else { setSuccess(true); } } catch (err) { setError('Error de red. Intenta de nuevo.'); } setLoading(false); }; return (
{/* Background pattern */}
{/* Main Card */}
{/* Header with navy background */}

EFC

Recuperar contraseña

Ingresa tu usuario y correo para recibir el enlace de recuperación

{/* Form */}
{success ? (
Si el correo está registrado, recibirás un enlace para restablecer tu contraseña.
) : (
setUsername(e.target.value)} onFocus={e => { e.target.style.borderColor = 'transparent'; e.target.style.boxShadow = '0 0 0 2px #4DA6FF'; }} onBlur={e => { e.target.style.borderColor = '#d1d5db'; e.target.style.boxShadow = 'none'; }} onMouseEnter={e => { if (document.activeElement !== e.target) { e.target.style.borderColor = '#4DA6FF'; } }} onMouseLeave={e => { if (document.activeElement !== e.target) { e.target.style.borderColor = '#d1d5db'; } }} />
setEmail(e.target.value)} onFocus={e => { e.target.style.borderColor = 'transparent'; e.target.style.boxShadow = '0 0 0 2px #4DA6FF'; }} onBlur={e => { e.target.style.borderColor = '#d1d5db'; e.target.style.boxShadow = 'none'; }} onMouseEnter={e => { if (document.activeElement !== e.target) { e.target.style.borderColor = '#4DA6FF'; } }} onMouseLeave={e => { if (document.activeElement !== e.target) { e.target.style.borderColor = '#d1d5db'; } }} />
{error &&
{error}
}
)}
Volver al inicio de sesión
{/* Floating elements */}
); }