import type { ReactNode } from 'react'; export interface Module { id: string; name: string; icon: string; path: string; component: ReactNode; enabled: boolean; requiresAuth: boolean; requiresAdmin?: boolean; } export interface ModuleCategory { id: string; name: string; modules: Module[]; } // Define available modules export const appModules: ModuleCategory[] = [ { id: 'main', name: 'Main Features', modules: [ { id: 'dashboard', name: 'sidebar.dashboard', icon: 'dashboard', path: '/dashboard', component: null, // Will be lazy loaded enabled: true, requiresAuth: true, }, { id: 'search', name: 'sidebar.search', icon: 'search', path: '/search', component: null, enabled: true, requiresAuth: true, }, { id: 'notifications', name: 'sidebar.notifications', icon: 'notifications', path: '/notifications', component: null, enabled: true, requiresAuth: true, }, { id: 'feature1', name: 'sidebar.feature1', icon: 'playlist_play', path: '/feature1', component: null, enabled: true, requiresAuth: true, }, { id: 'feature2', name: 'sidebar.feature2', icon: 'download', path: '/feature2', component: null, enabled: true, requiresAuth: true, }, { id: 'feature3', name: 'sidebar.feature3', icon: 'cast', path: '/feature3', component: null, enabled: true, requiresAuth: true, }, ], }, { id: 'admin', name: 'Administration', modules: [ { id: 'users', name: 'sidebar.users', icon: 'group', path: '/admin/users', component: null, enabled: true, requiresAuth: true, requiresAdmin: true, }, { id: 'settings', name: 'sidebar.settings', icon: 'settings', path: '/settings', component: null, enabled: true, requiresAuth: true, }, ], }, ]; // Helper to get enabled modules export function getEnabledModules(isAdmin: boolean = false): Module[] { const allModules = appModules.flatMap((category) => category.modules); return allModules.filter((module) => { if (!module.enabled) return false; if (module.requiresAdmin && !isAdmin) return false; return true; }); } // Helper to get modules by category export function getModulesByCategory(categoryId: string, isAdmin: boolean = false): Module[] { const category = appModules.find((cat) => cat.id === categoryId); if (!category) return []; return category.modules.filter((module) => { if (!module.enabled) return false; if (module.requiresAdmin && !isAdmin) return false; return true; }); }