diff --git a/apps/web/src/lib/components/Sidebar.svelte b/apps/web/src/lib/components/Sidebar.svelte index a6a505f..702a47c 100644 --- a/apps/web/src/lib/components/Sidebar.svelte +++ b/apps/web/src/lib/components/Sidebar.svelte @@ -58,6 +58,8 @@ label: string; link: string; permission?: MenuItemPermission; + excludePaths?: string[]; + exact?: boolean; } interface MenuItem { @@ -66,6 +68,8 @@ link: string; permission?: MenuItemPermission; submenus?: SubMenuItem[]; + excludePaths?: string[]; + exact?: boolean; } // Estrutura do menu definida no frontend @@ -107,7 +111,8 @@ { label: 'Meus Pedidos', link: '/pedidos', - permission: { recurso: 'pedidos', acao: 'listar' } + permission: { recurso: 'pedidos', acao: 'listar' }, + excludePaths: ['/pedidos/aceite', '/pedidos/minhas-analises'] }, { label: 'Pedidos para Aceite', @@ -261,7 +266,15 @@ return iconMap[name] || Home; } - function isRouteActive(path: string, exact = false) { + function isRouteActive(path: string, options: { exact?: boolean; excludePaths?: string[] } = {}) { + const { exact = false, excludePaths = [] } = options; + + if (excludePaths.length > 0) { + if (excludePaths.some((excludePath) => currentPath.startsWith(excludePath))) { + return false; + } + } + if (exact) return currentPath === path; return currentPath === path || currentPath.startsWith(path + '/'); } @@ -630,7 +643,10 @@ {#snippet menuItem(item: MenuItem)} {@const Icon = getIconComponent(item.icon)} - {@const isActive = isRouteActive(item.link, item.link === '/')} + {@const isActive = isRouteActive(item.link, { + exact: item.link === '/', + excludePaths: item.excludePaths + })} {@const hasSubmenus = item.submenus && item.submenus.length > 0}