aboutsummaryrefslogtreecommitdiffhomepage
path: root/frontend/src/pages/Login.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'frontend/src/pages/Login.tsx')
-rw-r--r--frontend/src/pages/Login.tsx16
1 files changed, 9 insertions, 7 deletions
diff --git a/frontend/src/pages/Login.tsx b/frontend/src/pages/Login.tsx
index 76a775a..7dc71e7 100644
--- a/frontend/src/pages/Login.tsx
+++ b/frontend/src/pages/Login.tsx
@@ -1,13 +1,14 @@
+import { useSetAtom } from "jotai";
import { useState } from "react";
import { useLocation } from "wouter";
-import { useAuth } from "../contexts/AuthContext";
+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 } = useAuth();
+ const login = useSetAtom(loginAtom);
const [, setLocation] = useLocation();
const handleSubmit = async (e: React.FormEvent) => {
@@ -15,13 +16,14 @@ export function Login() {
setError("");
setIsLoading(true);
- const result = await login(username, password);
- if (result.success) {
+ try {
+ await login({ username, password });
setLocation("/");
- } else {
- setError(result.error);
+ } catch (err) {
+ setError(err instanceof Error ? err.message : "Login failed");
+ } finally {
+ setIsLoading(false);
}
- setIsLoading(false);
};
return (