feat(FIX-158): completed feature
This commit is contained in:
@@ -28,7 +28,6 @@ export type Permission =
|
||||
|
||||
export function can(role: Role, permission: Permission): boolean {
|
||||
if (role === 'admin') return true;
|
||||
// Future: granular permission checks when backend supports them
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -38,14 +37,15 @@ export interface NavItem {
|
||||
icon: string;
|
||||
permission: Permission;
|
||||
badge?: number;
|
||||
parentHref?: string;
|
||||
}
|
||||
|
||||
export const NAV_ITEMS: NavItem[] = [
|
||||
{ href: '/', label: 'Dashboard', icon: '📊', permission: 'dashboard' },
|
||||
{ href: '/reporting', label: 'Reporting', icon: '📈', permission: 'reporting.read' },
|
||||
{ href: '/reporting/dashboard', label: ' Dashboard', icon: '📊', permission: 'reporting.read' },
|
||||
{ href: '/reporting/sales', label: ' Ventas', icon: '🧾', permission: 'reporting.read' },
|
||||
{ href: '/reporting/products', label: ' Productos', icon: '📦', permission: 'reporting.read' },
|
||||
{ href: '/reporting/dashboard', label: 'Dashboard', icon: '📊', permission: 'reporting.read', parentHref: '/reporting' },
|
||||
{ href: '/reporting/sales', label: 'Ventas', icon: '🧾', permission: 'reporting.read', parentHref: '/reporting' },
|
||||
{ href: '/reporting/products', label: 'Productos', icon: '📦', permission: 'reporting.read', parentHref: '/reporting' },
|
||||
{ href: '/products', label: 'Productos', icon: '📦', permission: 'products.read' },
|
||||
{ href: '/orders', label: 'Pedidos', icon: '🧾', permission: 'orders.read' },
|
||||
{ href: '/payments', label: 'Pagos', icon: '💳', permission: 'orders.read' },
|
||||
@@ -64,6 +64,10 @@ export const NAV_ITEMS: NavItem[] = [
|
||||
{ href: '/settings', label: 'Ajustes', icon: '⚙️', permission: 'dashboard' },
|
||||
];
|
||||
|
||||
export function visibleNavItems(role: Role): NavItem[] {
|
||||
return NAV_ITEMS.filter((item) => can(role, item.permission));
|
||||
export function topNavItems(role: Role): NavItem[] {
|
||||
return NAV_ITEMS.filter((item) => !item.parentHref && can(role, item.permission));
|
||||
}
|
||||
|
||||
export function subNavItems(parentHref: string, role: Role): NavItem[] {
|
||||
return NAV_ITEMS.filter((item) => item.parentHref === parentHref && can(role, item.permission));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user