import { useState } from 'react'; import { useNavigate } from 'react-router-dom'; import { useMutation } from '@tanstack/react-query'; import { useAuth } from '../contexts/AuthContext'; import { useToast } from '../contexts/ToastContext'; import { useTheme } from '../contexts/ThemeContext'; export function LoginPage() { const navigate = useNavigate(); const { login } = useAuth(); const { showToast } = useToast(); const { mode } = useTheme(); const [username, setUsername] = useState(''); const [password, setPassword] = useState(''); const loginMutation = useMutation({ mutationFn: () => login(username, password), onSuccess: () => { showToast('Logged in successfully'); navigate('/'); }, onError: (error: Error) => { showToast(error.message || 'Login failed', 'error'); }, }); const handleSubmit = (e: React.FormEvent) => { e.preventDefault(); if (!username || !password) { showToast('Please enter username and password', 'error'); return; } loginMutation.mutate(); }; return (
Bambuddy

Bambuddy Login

Sign in to your account

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="Enter your username" 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="Enter your password" autoComplete="current-password" />
); }