import { useSetAtom } from "jotai"; import { useState } from "react"; import { useLocation } from "wouter"; import { loginAtom } from "../atoms"; export function Login() { const [username, setUsername] = useState(""); const [password, setPassword] = useState(""); const [error, setError] = useState(""); const [isLoading, setIsLoading] = useState(false); const login = useSetAtom(loginAtom); const [, setLocation] = useLocation(); const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); setError(""); setIsLoading(true); try { await login({ username, password }); setLocation("/"); } catch (err) { setError(err instanceof Error ? err.message : "Login failed"); } finally { setIsLoading(false); } }; return (

feedaka

Sign in to your account

setUsername(e.target.value)} required className="w-full rounded-lg border border-stone-200 bg-white px-4 py-2.5 text-sm text-stone-900 transition-all duration-200 placeholder:text-stone-400 focus:border-sky-500 focus:outline-none focus:ring-2 focus:ring-sky-500/20 disabled:cursor-not-allowed disabled:opacity-70" disabled={isLoading} />
setPassword(e.target.value)} required className="w-full rounded-lg border border-stone-200 bg-white px-4 py-2.5 text-sm text-stone-900 transition-all duration-200 placeholder:text-stone-400 focus:border-sky-500 focus:outline-none focus:ring-2 focus:ring-sky-500/20 disabled:cursor-not-allowed disabled:opacity-70" disabled={isLoading} />
{error && (
{error}
)}
); }