fix(menu): подсветка родительского пункта на detail-страницах

Refs EventHub/EventHubFrontAdmin#7

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-07-13 17:06:59 +03:00
parent 7a2467370a
commit 9deaa34a6e
2 changed files with 17 additions and 2 deletions
+15
View File
@@ -52,3 +52,18 @@ export function filterMenuByRole<T extends { roles?: AdminRole[] }>(
): T[] {
return items.filter((item) => !item.roles || (role && item.roles.includes(role as AdminRole)));
}
/** Ключ пункта меню для detail-маршрутов (/users/:id → /users). */
export function getMenuSelectedKey(pathname: string): string {
if (MENU_ITEMS.some((item) => item.key === pathname)) {
return pathname;
}
const segment = pathname.split('/').filter(Boolean)[0];
if (segment) {
const parent = `/${segment}`;
if (MENU_ITEMS.some((item) => item.key === parent)) {
return parent;
}
}
return pathname;
}