import React, { useState, useEffect } from 'react'; import { Link, useNavigate, useLocation } from 'react-router-dom'; import { useAuthActions, useAuthError, useAuthLoading, useIsAuthenticated } from '../../stores'; import { Button, Input, Card } from '../../components/ui'; import { PublicLayout } from '../../components/layout'; const LoginPage: React.FC = () => { const [email, setEmail] = useState(''); const [password, setPassword] = useState(''); const [rememberMe, setRememberMe] = useState(false); const navigate = useNavigate(); const location = useLocation(); const { login } = useAuthActions(); const error = useAuthError(); const loading = useAuthLoading(); const isAuthenticated = useIsAuthenticated(); const from = (location.state as any)?.from?.pathname || '/app'; useEffect(() => { if (isAuthenticated && !loading) { // Add a small delay to ensure the auth state has fully settled setTimeout(() => { navigate(from, { replace: true }); }, 100); } }, [isAuthenticated, loading, navigate, from]); const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); if (!email || !password) return; try { await login(email, password); } catch (err) { // Error is handled by the store } }; return (
PI

Inicia sesión en tu cuenta

O{' '} regístrate para comenzar tu prueba gratuita

{error && (

Error de autenticación

{error}
)}
setEmail(e.target.value)} />
setPassword(e.target.value)} />
setRememberMe(e.target.checked)} />
Demo
Al iniciar sesión, aceptas nuestros{' '} Términos de Servicio {' '}y{' '} Política de Privacidad
); }; export default LoginPage;