- Create code-first route tree in src/app/routing/routeTree.tsx - Replace ProtectedRoute with beforeLoad auth guards - Add useSearchParamsCompat for URLSearchParams access - Update App.tsx, layouts, and all page/widget imports - Add frontend tooling: biome, prettier, env config - Update all tests for TanStack Router compatibility - Remove react-router-dom dependency, @tanstack/router-plugin - Consolidate biome config at root level
39 lines
897 B
TypeScript
39 lines
897 B
TypeScript
import { create } from 'zustand'
|
|
import type { UserResponse } from '@/shared/api/responses'
|
|
|
|
interface SessionState {
|
|
user: UserResponse | null
|
|
accessToken: string | null
|
|
isLoading: boolean
|
|
isAuthenticated: boolean
|
|
setSession: (authData: { user: UserResponse; accessToken: string }) => void
|
|
clearSession: () => void
|
|
setLoading: (isLoading: boolean) => void
|
|
}
|
|
|
|
export const useSessionStore = create<SessionState>((set) => ({
|
|
user: null,
|
|
accessToken: null,
|
|
isLoading: true,
|
|
isAuthenticated: false,
|
|
setSession: (authData) => {
|
|
set({
|
|
user: authData.user,
|
|
accessToken: authData.accessToken,
|
|
isAuthenticated: true,
|
|
isLoading: false,
|
|
})
|
|
},
|
|
clearSession: () => {
|
|
set({
|
|
user: null,
|
|
accessToken: null,
|
|
isAuthenticated: false,
|
|
isLoading: false,
|
|
})
|
|
},
|
|
setLoading: (isLoading) => {
|
|
set({ isLoading })
|
|
},
|
|
}))
|