fix: system admin bypasses workspace filter in sidebar
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { useState, useEffect, useCallback } from 'react';
|
||||
import { useMyWorkspaces, useWorkspaceContext, type WorkspaceContext } from '@/api/hooks/workspaces';
|
||||
import { useAuthStore } from '@/store/authStore';
|
||||
|
||||
const STORAGE_KEY = 'leocrm-active-workspace';
|
||||
|
||||
@@ -47,6 +48,9 @@ export function useWorkspace() {
|
||||
|
||||
// Check if a module is visible in the current workspace
|
||||
const isModuleVisible = useCallback((moduleKey: string): boolean => {
|
||||
// System admins see all modules regardless of workspace
|
||||
const user = useAuthStore.getState().user;
|
||||
if (user?.is_system_admin) return true;
|
||||
// If no workspace context, show all (backward compatible)
|
||||
if (!context?.workspace_id || !context?.modules?.length) return true;
|
||||
return visibleModuleKeys.has(moduleKey);
|
||||
|
||||
Reference in New Issue
Block a user