- install ky, zustand, @mui/material, @fontsource/roboto, dayjs, clsx - install @tanstack/react-table, react-hook-form, zod, @hookform/resolvers - create kyClient.ts with auth interceptors - create Zustand store for session (useSessionStore.ts) - add MUI theming (theme.ts, ThemeProvider in AppProviders) - add dayjs utils with ru locale (formatDate, formatRelative) - add clsx cn() utility - add base Table component using @tanstack/react-table - create ADR-015 documenting architectural decisions - create SDD artifacts: spec.md, plan.md, tasks.md - build, lint, and 111 tests passing
39 lines
910 B
TypeScript
39 lines
910 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 });
|
|
},
|
|
}));
|