// components/LoginPage.tsx import React, { useState } from 'react'; import { motion } from 'framer-motion'; import { Lock, User } from 'lucide-react'; import toast from 'react-hot-toast'; import { useTranslation } from 'react-i18next'; import { useAuth } from '../utils/AuthContext'; const LoginPage: React.FC = () => { const { t } = useTranslation(); const { login } = useAuth(); const [username, setUsername] = useState(''); const [password, setPassword] = useState(''); const [isSubmitting, setIsSubmitting] = useState(false); const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); if (!username || !password) { toast.error(t('auth.credentialsRequired')); return; } setIsSubmitting(true); try { await login(username, password); toast.success(t('auth.sessionStarted')); } catch (err) { console.error('Error en login', err); const msg = err instanceof Error ? err.message : 'Error al iniciar sesión'; toast.error(msg); } finally { setIsSubmitting(false); } }; return (
{t('auth.loginTitle')}