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 (
Sign in to your account