diff options
Diffstat (limited to 'src/client/pages/LoginPage.tsx')
| -rw-r--r-- | src/client/pages/LoginPage.tsx | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/client/pages/LoginPage.tsx b/src/client/pages/LoginPage.tsx index 835c73e..0af45c6 100644 --- a/src/client/pages/LoginPage.tsx +++ b/src/client/pages/LoginPage.tsx @@ -1,12 +1,15 @@ import { faSpinner } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; +import { useAtomValue, useSetAtom } from "jotai"; import { type FormEvent, useEffect, useState } from "react"; import { useLocation } from "wouter"; -import { ApiClientError, useAuth } from "../stores"; +import { ApiClientError } from "../api/client"; +import { isAuthenticatedAtom, loginAtom } from "../atoms"; export function LoginPage() { const [, navigate] = useLocation(); - const { login, isAuthenticated } = useAuth(); + const isAuthenticated = useAtomValue(isAuthenticatedAtom); + const login = useSetAtom(loginAtom); const [username, setUsername] = useState(""); const [password, setPassword] = useState(""); const [error, setError] = useState<string | null>(null); @@ -26,7 +29,7 @@ export function LoginPage() { setIsSubmitting(true); try { - await login(username, password); + await login({ username, password }); navigate("/", { replace: true }); } catch (err) { if (err instanceof ApiClientError) { |
