new features
This commit is contained in:
@@ -126,12 +126,7 @@ const baseNavigationItems: NavigationItem[] = [
|
||||
text: 'Shop',
|
||||
icon: <Store />,
|
||||
path: '/shop',
|
||||
subItems: [
|
||||
{ text: 'Katalog', path: '/shop?tab=0' },
|
||||
{ text: 'Meine Anfragen', path: '/shop?tab=1' },
|
||||
{ text: 'Alle Anfragen', path: '/shop?tab=2' },
|
||||
{ text: 'Übersicht', path: '/shop?tab=3' },
|
||||
],
|
||||
// subItems computed dynamically in navigationItems useMemo
|
||||
permission: 'shop:view',
|
||||
},
|
||||
{
|
||||
@@ -194,8 +189,21 @@ function Sidebar({ mobileOpen, onMobileClose }: SidebarProps) {
|
||||
subItems: vehicleSubItems.length > 0 ? vehicleSubItems : undefined,
|
||||
permission: 'fahrzeuge:view',
|
||||
};
|
||||
|
||||
// Build Shop sub-items dynamically based on permissions (tab order must match Shop.tsx)
|
||||
const shopSubItems: SubItem[] = [];
|
||||
let shopTabIdx = 0;
|
||||
if (hasPermission('shop:create_request')) { shopSubItems.push({ text: 'Meine Anfragen', path: `/shop?tab=${shopTabIdx}` }); shopTabIdx++; }
|
||||
if (hasPermission('shop:approve_requests')) { shopSubItems.push({ text: 'Alle Anfragen', path: `/shop?tab=${shopTabIdx}` }); shopTabIdx++; }
|
||||
if (hasPermission('shop:view_overview')) { shopSubItems.push({ text: 'Übersicht', path: `/shop?tab=${shopTabIdx}` }); shopTabIdx++; }
|
||||
shopSubItems.push({ text: 'Katalog', path: `/shop?tab=${shopTabIdx}` });
|
||||
|
||||
const items = baseNavigationItems
|
||||
.map((item) => item.path === '/fahrzeuge' ? fahrzeugeItem : item)
|
||||
.map((item) => {
|
||||
if (item.path === '/fahrzeuge') return fahrzeugeItem;
|
||||
if (item.path === '/shop') return { ...item, subItems: shopSubItems };
|
||||
return item;
|
||||
})
|
||||
.filter((item) => !item.permission || hasPermission(item.permission));
|
||||
return hasPermission('admin:view') ? [...items, adminItem, adminSettingsItem] : items;
|
||||
}, [vehicleSubItems, hasPermission]);
|
||||
|
||||
Reference in New Issue
Block a user