refactor: remove static routes and stop multiple token api call in sse
This commit is contained in:
@@ -7,6 +7,7 @@ interface AppState {
|
||||
user: UserProfile | null;
|
||||
tenant: TenantInfo | null;
|
||||
permissions: string[];
|
||||
defaultRoute: string | null;
|
||||
loadStatus: AppLoadStatus;
|
||||
isInitialized: boolean;
|
||||
setLoading: () => void;
|
||||
@@ -16,6 +17,7 @@ interface AppState {
|
||||
user: UserProfile;
|
||||
tenant?: TenantInfo | null;
|
||||
permissions?: string[];
|
||||
defaultRoute?: string | null;
|
||||
}) => void;
|
||||
clear: () => void;
|
||||
}
|
||||
@@ -24,16 +26,23 @@ export const useAppStore = create<AppState>()((set) => ({
|
||||
user: null,
|
||||
tenant: null,
|
||||
permissions: [],
|
||||
defaultRoute: null,
|
||||
loadStatus: 'idle',
|
||||
isInitialized: false,
|
||||
setLoading: () => set({ loadStatus: 'loading', isInitialized: false }),
|
||||
setLoaded: () => set({ loadStatus: 'loaded', isInitialized: true }),
|
||||
setLoadError: () => set({ loadStatus: 'error', isInitialized: true }),
|
||||
setUserContext: ({ user, tenant = null, permissions = [] }) =>
|
||||
setUserContext: ({
|
||||
user,
|
||||
tenant = null,
|
||||
permissions = [],
|
||||
defaultRoute = null,
|
||||
}) =>
|
||||
set({
|
||||
user,
|
||||
tenant,
|
||||
permissions,
|
||||
defaultRoute,
|
||||
loadStatus: 'loaded',
|
||||
isInitialized: true,
|
||||
}),
|
||||
@@ -42,6 +51,7 @@ export const useAppStore = create<AppState>()((set) => ({
|
||||
user: null,
|
||||
tenant: null,
|
||||
permissions: [],
|
||||
defaultRoute: null,
|
||||
loadStatus: 'idle',
|
||||
isInitialized: false,
|
||||
}),
|
||||
|
||||
Reference in New Issue
Block a user