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 (