fix permissions
This commit is contained in:
@@ -190,7 +190,7 @@ function Sidebar({ mobileOpen, onMobileClose }: SidebarProps) {
|
|||||||
let ausruestungTabIdx = 0;
|
let ausruestungTabIdx = 0;
|
||||||
if (hasPermission('ausruestungsanfrage:create_request')) { ausruestungSubItems.push({ text: 'Meine Anfragen', path: `/ausruestungsanfrage?tab=${ausruestungTabIdx}` }); ausruestungTabIdx++; }
|
if (hasPermission('ausruestungsanfrage:create_request')) { ausruestungSubItems.push({ text: 'Meine Anfragen', path: `/ausruestungsanfrage?tab=${ausruestungTabIdx}` }); ausruestungTabIdx++; }
|
||||||
if (hasPermission('ausruestungsanfrage:approve')) { ausruestungSubItems.push({ text: 'Alle Anfragen', path: `/ausruestungsanfrage?tab=${ausruestungTabIdx}` }); ausruestungTabIdx++; }
|
if (hasPermission('ausruestungsanfrage:approve')) { ausruestungSubItems.push({ text: 'Alle Anfragen', path: `/ausruestungsanfrage?tab=${ausruestungTabIdx}` }); ausruestungTabIdx++; }
|
||||||
ausruestungSubItems.push({ text: 'Katalog', path: `/ausruestungsanfrage?tab=${ausruestungTabIdx}` });
|
if (hasPermission('ausruestungsanfrage:view')) { ausruestungSubItems.push({ text: 'Katalog', path: `/ausruestungsanfrage?tab=${ausruestungTabIdx}` }); ausruestungTabIdx++; }
|
||||||
|
|
||||||
// Build Issues sub-items dynamically (tab order must match Issues.tsx)
|
// Build Issues sub-items dynamically (tab order must match Issues.tsx)
|
||||||
const issuesSubItems: SubItem[] = [
|
const issuesSubItems: SubItem[] = [
|
||||||
|
|||||||
@@ -1450,7 +1450,7 @@ export default function Ausruestungsanfrage() {
|
|||||||
const canCreate = hasPermission('ausruestungsanfrage:create_request');
|
const canCreate = hasPermission('ausruestungsanfrage:create_request');
|
||||||
const canApprove = hasPermission('ausruestungsanfrage:approve');
|
const canApprove = hasPermission('ausruestungsanfrage:approve');
|
||||||
|
|
||||||
const tabCount = 1 + (canCreate ? 1 : 0) + (canApprove ? 1 : 0);
|
const tabCount = (canCreate ? 1 : 0) + (canApprove ? 1 : 0) + (canView ? 1 : 0);
|
||||||
|
|
||||||
const [activeTab, setActiveTab] = useState(() => {
|
const [activeTab, setActiveTab] = useState(() => {
|
||||||
const t = Number(searchParams.get('tab'));
|
const t = Number(searchParams.get('tab'));
|
||||||
@@ -1473,11 +1473,11 @@ export default function Ausruestungsanfrage() {
|
|||||||
let next = 0;
|
let next = 0;
|
||||||
if (canCreate) { map.meine = next; next++; }
|
if (canCreate) { map.meine = next; next++; }
|
||||||
if (canApprove) { map.alle = next; next++; }
|
if (canApprove) { map.alle = next; next++; }
|
||||||
map.katalog = next;
|
if (canView) { map.katalog = next; next++; }
|
||||||
return map;
|
return map;
|
||||||
}, [canCreate, canApprove]);
|
}, [canCreate, canApprove, canView]);
|
||||||
|
|
||||||
if (!canView) {
|
if (!canView && !canCreate && !canApprove) {
|
||||||
return (
|
return (
|
||||||
<DashboardLayout>
|
<DashboardLayout>
|
||||||
<Typography>Keine Berechtigung.</Typography>
|
<Typography>Keine Berechtigung.</Typography>
|
||||||
@@ -1493,13 +1493,13 @@ export default function Ausruestungsanfrage() {
|
|||||||
<Tabs value={activeTab} onChange={handleTabChange} variant="scrollable" scrollButtons="auto">
|
<Tabs value={activeTab} onChange={handleTabChange} variant="scrollable" scrollButtons="auto">
|
||||||
{canCreate && <Tab label="Meine Anfragen" />}
|
{canCreate && <Tab label="Meine Anfragen" />}
|
||||||
{canApprove && <Tab label="Alle Anfragen" />}
|
{canApprove && <Tab label="Alle Anfragen" />}
|
||||||
<Tab label="Katalog" />
|
{canView && <Tab label="Katalog" />}
|
||||||
</Tabs>
|
</Tabs>
|
||||||
</Box>
|
</Box>
|
||||||
|
|
||||||
{canCreate && activeTab === tabIndex.meine && <MeineAnfragenTab />}
|
{canCreate && activeTab === tabIndex.meine && <MeineAnfragenTab />}
|
||||||
{canApprove && activeTab === tabIndex.alle && <AlleAnfragenTab />}
|
{canApprove && activeTab === tabIndex.alle && <AlleAnfragenTab />}
|
||||||
{activeTab === tabIndex.katalog && <KatalogTab />}
|
{canView && activeTab === tabIndex.katalog && <KatalogTab />}
|
||||||
</DashboardLayout>
|
</DashboardLayout>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user