import { useState } from 'react'; import { TextInput, PasswordInput, Button, Paper, Title, Container, Group, Alert } from '@mantine/core'; import { User, Lock } from 'phosphor-react'; // ← Importa los iconos Phosphor export function LoginPage() { const [email, setEmail] = useState(''); const [password, setPassword] = useState(''); const [error, setError] = useState(''); const [loading, setLoading] = useState(false); const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); setLoading(true); setError(''); // Aquí deberías llamar a tu endpoint de login (ajusta la URL y payload) try { const res = await fetch('/api/v1/usuarios/login', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ email, password }) }); if (!res.ok) throw new Error('Credenciales incorrectas'); // Aquí puedes guardar el usuario/token en el estado global o localStorage window.location.href = '/'; } catch (err: any) { setError(err.message); } finally { setLoading(false); } }; return ( Iniciar sesión
} // ← Usa el icono Phosphor aquí value={email} onChange={e => setEmail(e.target.value)} required mb={10} /> } // ← Usa el icono Phosphor aquí value={password} onChange={e => setPassword(e.target.value)} required mb={20} /> {error && {error}}
); }