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 (
Bambuddy

{t('login.title')}

{t('login.subtitle')}

setUsername(e.target.value)} className="block w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors" placeholder={t('login.usernamePlaceholder')} autoComplete="username" />
setPassword(e.target.value)} className="block w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors" placeholder={t('login.passwordPlaceholder')} autoComplete="current-password" />
{/* Forgot Password Modal */} {showForgotPassword && (
setShowForgotPassword(false)} >
e.stopPropagation()} >

{t('login.forgotPasswordTitle')}

{t('login.forgotPasswordMessage')}

{t('login.howToReset')}

  1. {t('login.resetStep1')}
  2. {t('login.resetStep2')}
  3. {t('login.resetStep3')}
  4. {t('login.resetStep4')}
)}
); }