<script setup lang="ts">
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';
import { Link, usePage } from '@inertiajs/vue3';
import { BookOpen, Folder, LayoutGrid, User, Briefcase, Workflow, ChartBar, Waypoints } from 'lucide-vue-next';
import AppLogo from './AppLogo.vue';

const allNavItems: NavItem[] = [
    // {
    //     title: 'Dashboard',
    //     href: dashboard(),
    //     icon: LayoutGrid,
    // },
    {
        title: 'User Management',
        href: '/user-management', // 👈 matches your Laravel route
        icon: User,
        roles: ['admin'],
    },
    {
        title: 'Project Management',
        href: '/project-management',
        icon: Briefcase, // new icon
    },
    {
        title: 'Product Backlogs',
        href: '/product-backlogs',
        icon: Workflow, // new icon
    },
    {
        title: 'Fuzzy Operations',
        href: '/fuzzy-operations',
        icon: ChartBar, // new icon
    },
    {
        title: 'I-USPA Decisions',
        href: '/i-uspa-decisions',
        icon: Waypoints, // new icon
    },
];

const page = usePage()
const role = page.props.auth?.user?.role ?? 'user'

const mainNavItems = allNavItems.filter(item => {
  return !item.roles || item.roles.includes(role)
})

const footerNavItems: NavItem[] = [
    {
        title: 'Github Repo',
        href: 'https://github.com/laravel/vue-starter-kit',
        icon: Folder,
    },
    {
        title: 'Documentation',
        href: 'https://laravel.com/docs/starter-kits#vue',
        icon: BookOpen,
    },
];
</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 :items="footerNavItems" />
            <NavUser />
        </SidebarFooter>
    </Sidebar>
    <slot />
</template>
