From f8e4be9b36a16969ac53bd9ce12ce8064be10196 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sun, 4 Jan 2026 17:43:59 +0900 Subject: refactor(client): migrate state management from React Context to Jotai MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace AuthProvider and SyncProvider with Jotai atoms for more granular state management and better performance. This migration: - Creates atoms for auth, sync, decks, cards, noteTypes, and study state - Uses atomFamily for parameterized state (e.g., cards by deckId) - Introduces StoreInitializer component for subscription initialization - Updates all components and pages to use useAtomValue/useSetAtom - Updates all tests to use Jotai Provider with createStore pattern 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- src/client/pages/LoginPage.tsx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/client/pages/LoginPage.tsx') 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(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) { -- cgit v1.2.3-70-g09d2