import type { MenuRole } from "../model/menu-interface"; export const getCurrentMenu = ( menus: MenuRole[], pathname: string, ): MenuRole | null => { for (const menu of menus) { if ( menu.urlPath !== "" && (menu.urlPath === pathname || pathname.startsWith(menu.urlPath)) ) return menu; if (menu.children) { const children = getCurrentMenu(menu.children, pathname); if (children) return children; } } return null; };