import { useState } from 'react'; import { useNavigate } from 'react-router-dom'; import { useMutation } from '@tanstack/react-query'; import { useTranslation } from 'react-i18next'; import { useAuth } from '../contexts/AuthContext'; import { useToast } from '../contexts/ToastContext'; import { useTheme } from '../contexts/ThemeContext'; import { HelpCircle, X } from 'lucide-react'; export function LoginPage() { const navigate = useNavigate(); const { t } = useTranslation(); const { login } = useAuth(); const { showToast } = useToast(); const { mode } = useTheme(); const [username, setUsername] = useState(''); const [password, setPassword] = useState(''); const [showForgotPassword, setShowForgotPassword] = useState(false); const loginMutation = useMutation({ mutationFn: () => login(username, password), onSuccess: () => { showToast(t('login.loginSuccess')); navigate('/'); }, onError: (error: Error) => { showToast(error.message || t('login.loginFailed'), 'error'); }, }); const handleSubmit = (e: React.FormEvent) => { e.preventDefault(); if (!username || !password) { showToast(t('login.enterCredentials'), 'error'); return; } loginMutation.mutate(); }; return (
{t('login.subtitle')}
{t('login.forgotPasswordMessage')}
{t('login.howToReset')}