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 (

Feedaka Login

setUsername(e.target.value)} required className="w-full p-2 border border-gray-300 rounded disabled:opacity-70 disabled:cursor-not-allowed" disabled={isLoading} />
setPassword(e.target.value)} required className="w-full p-2 border border-gray-300 rounded disabled:opacity-70 disabled:cursor-not-allowed" disabled={isLoading} />
{error && (
{error}
)}
); }