import { useState } from "react"; import { useLocation } from "wouter"; import { useAuth } from "../contexts/AuthContext"; export function Login() { const [username, setUsername] = useState(""); const [password, setPassword] = useState(""); const [error, setError] = useState(""); const [isLoading, setIsLoading] = useState(false); const { login } = useAuth(); const [, setLocation] = useLocation(); const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); setError(""); setIsLoading(true); try { const success = await login(username, password); if (success) { setLocation("/"); } else { setError("Invalid username or password"); } } catch (_err) { setError("An error occurred during login"); } finally { setIsLoading(false); } }; return (

Feedaka Login

setUsername(e.target.value)} required style={{ width: "100%", padding: "0.5rem", border: "1px solid #ccc", borderRadius: "4px", }} disabled={isLoading} />
setPassword(e.target.value)} required style={{ width: "100%", padding: "0.5rem", border: "1px solid #ccc", borderRadius: "4px", }} disabled={isLoading} />
{error && (
{error}
)}
); }