I have a sidebar menu. I would like to hide some paths, based on user's role. Here I have ROUTES like this:
export const ROUTES: RouteInfo[] = [
{
path: '/overview',
title: 'Overview',
type: 'link',
icontype: 'search'
},
{
path: '/loyalty',
title: 'Loyalty',
type: 'sub',
icontype: 'loyalty',
collapse: 'loyalty',
children: [
{ path: 'programs', title: 'Programs', ab: 'P', icontype: 'accessibility' },
{ path: 'members', title: 'Members', ab: 'M', icontype: 'group_add' },
{ path: 'segments', title: 'Segments', ab: 'S', icontype: 'data_usage' },
{ path: 'emailautomation', title: 'Email automation', ab: 'EA', icontype: 'mail' }
]
},
... etc
My sidebar appears like as fallows:
this.menuItems = ROUTES.filter(menuItem => menuItem);
I'd like to filter children array, taking into consideration user's role.
How can I filter these ROUTES to hide, for example, path 'programs' ?