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); const result = await login(username, password); if (result.success) { setLocation("/"); } else { setError(result.error); } setIsLoading(false); }; return (