import { useState, FormEvent } from 'react'; import { useNavigate, Link } from 'react-router-dom'; import { useAuthStore } from '../../stores/authStore'; import { useUIStore } from '../../stores/uiStore'; export function Login() { const [username, setUsername] = useState(''); const [password, setPassword] = useState(''); const { login, isLoading, error, clearError } = useAuthStore(); const { darkMode, toggleDarkMode } = useUIStore(); const navigate = useNavigate(); const handleSubmit = async (e: FormEvent) => { e.preventDefault(); clearError(); try { await login(username, password); navigate('/'); } catch (err) { // Error is handled by the store } }; return (
Sign in to your account