- API client with axios interceptors: JWT attach + 401 auto-refresh - Auth store (Zustand): login/logout/loadFromStorage with localStorage - Login page: gradient background, Ant Design form, error handling - Home page: dashboard with statistics cards - App.tsx: PrivateRoute guard, /login route, auth state restoration - MainLayout: dynamic user display, logout dropdown, menu navigation - Users API service: CRUD with pagination support
16 lines
416 B
TypeScript
16 lines
416 B
TypeScript
import { create } from 'zustand';
|
|
|
|
interface AppState {
|
|
theme: 'light' | 'dark';
|
|
sidebarCollapsed: boolean;
|
|
toggleSidebar: () => void;
|
|
setTheme: (theme: 'light' | 'dark') => void;
|
|
}
|
|
|
|
export const useAppStore = create<AppState>((set) => ({
|
|
theme: 'light',
|
|
sidebarCollapsed: false,
|
|
toggleSidebar: () => set((s) => ({ sidebarCollapsed: !s.sidebarCollapsed })),
|
|
setTheme: (theme) => set({ theme }),
|
|
}));
|