104 lines
2.5 KiB
Vue
104 lines
2.5 KiB
Vue
<script setup lang="ts">
|
|
import { Link, usePage } from '@inertiajs/vue3';
|
|
import { BookOpen, FolderGit2, LayoutGrid, Gift, Settings, ShieldCheck, Users } from 'lucide-vue-next';
|
|
import { computed } from 'vue';
|
|
import AppLogo from '@/components/AppLogo.vue';
|
|
import NavFooter from '@/components/NavFooter.vue';
|
|
import NavMain from '@/components/NavMain.vue';
|
|
import NavUser from '@/components/NavUser.vue';
|
|
import {
|
|
Sidebar,
|
|
SidebarContent,
|
|
SidebarFooter,
|
|
SidebarHeader,
|
|
SidebarMenu,
|
|
SidebarMenuButton,
|
|
SidebarMenuItem,
|
|
} from '@/components/ui/sidebar';
|
|
import { dashboard } from '@/routes';
|
|
import type { NavItem } from '@/types';
|
|
|
|
const page = usePage();
|
|
|
|
const userRole = computed(() => {
|
|
return (page.props.auth.user as any)?.role || 'user';
|
|
});
|
|
|
|
const isModOrAdmin = computed(() => {
|
|
return ['admin', 'mod'].includes(userRole.value);
|
|
});
|
|
|
|
const isAdmin = computed(() => {
|
|
return userRole.value === 'admin';
|
|
});
|
|
|
|
const mainNavItems = computed<NavItem[]>(() => {
|
|
const items: NavItem[] = [
|
|
{
|
|
title: 'Dashboard',
|
|
href: dashboard(),
|
|
icon: LayoutGrid,
|
|
}
|
|
];
|
|
|
|
if (isModOrAdmin.value) {
|
|
items.push({
|
|
title: 'Bonuses',
|
|
href: '/admin/bonuses',
|
|
icon: Gift,
|
|
});
|
|
}
|
|
|
|
if (isAdmin.value) {
|
|
items.push({
|
|
title: 'Benutzer',
|
|
href: '/admin/users',
|
|
icon: Users,
|
|
});
|
|
}
|
|
|
|
return items;
|
|
});
|
|
|
|
const footerNavItems = computed<NavItem[]>(() => {
|
|
const items: NavItem[] = [];
|
|
|
|
if (isAdmin.value) {
|
|
items.push({
|
|
title: 'System Settings',
|
|
href: '/admin/settings',
|
|
icon: ShieldCheck,
|
|
});
|
|
}
|
|
|
|
return items;
|
|
});
|
|
|
|
</script>
|
|
|
|
<template>
|
|
<Sidebar collapsible="icon" variant="inset">
|
|
<SidebarHeader>
|
|
<SidebarMenu>
|
|
<SidebarMenuItem>
|
|
<SidebarMenuButton size="lg" as-child>
|
|
<Link :href="dashboard()">
|
|
<AppLogo />
|
|
</Link>
|
|
</SidebarMenuButton>
|
|
</SidebarMenuItem>
|
|
</SidebarMenu>
|
|
</SidebarHeader>
|
|
|
|
<SidebarContent>
|
|
<NavMain :items="mainNavItems" />
|
|
</SidebarContent>
|
|
|
|
<SidebarFooter>
|
|
<NavFooter v-if="footerNavItems.length > 0" :items="footerNavItems" />
|
|
<NavUser />
|
|
</SidebarFooter>
|
|
</Sidebar>
|
|
<slot />
|
|
</template>
|