import { Link, usePage } from '@inertiajs/react'; import { Building2, ClipboardList, LayoutGrid, Users, Scale, ShieldAlert, FileCheck2, PackageCheck, Warehouse, } from 'lucide-react'; import AppLogo from '@/components/app-logo'; import { NavMain } from '@/components/nav-main'; import { NavUser } from '@/components/nav-user'; import { Sidebar, SidebarContent, SidebarFooter, SidebarHeader, SidebarMenu, SidebarMenuButton, SidebarMenuItem, } from '@/components/ui/sidebar'; import { dashboard } from '@/routes'; import type { NavItem } from '@/types'; const generalNavItems: NavItem[] = [ { title: 'Visão geral', href: dashboard(), icon: LayoutGrid, }, { title: 'Conflitos de interesses', href: '/conflitos', icon: ShieldAlert }, ]; export function AppSidebar() { const { auth, payablesAvailable } = usePage().props; const canReadPurchases = [ 'admin', 'procurement', 'finance', 'department_head', ].includes(auth.user.purchasing_role ?? ''); const purchasingItems: NavItem[] = [ { title: 'Requisições', href: '/requisicoes', icon: ClipboardList }, ...(auth.user.purchasing_role === 'procurement' ? [ { title: 'Regras de investimento', href: '/regras-investimento', icon: FileCheck2, }, ] : []), ...(canReadPurchases ? [ { title: 'Fornecedores', href: '/fornecedores', icon: Users }, { title: 'Avaliação de fornecedores', href: '/fornecedores/avaliacoes', icon: Users, }, { title: 'Cotações', href: '/cotacoes', icon: Scale }, { title: 'Ordens de compra', href: '/ordens', icon: FileCheck2, }, ] : []), ]; const inventoryItems = [ ...([ 'admin', 'procurement', 'finance', 'warehouse', 'department_head', ].includes(auth.user.purchasing_role ?? '') ? [{ title: 'Recepção', href: '/recepcoes', icon: PackageCheck }] : []), ...([ 'admin', 'procurement', 'finance', 'warehouse', 'department_head', ].includes(auth.user.purchasing_role ?? '') ? [ { title: 'Equipamentos e peças', href: '/equipamentos', icon: Warehouse, }, ] : []), ...(['admin', 'procurement', 'finance', 'warehouse'].includes( auth.user.purchasing_role ?? '', ) ? [ { title: 'Stock e movimentos', href: '/stock', icon: Warehouse, }, { title: 'Saídas e inventários', href: '/stock/operacoes', icon: ClipboardList, }, ] : []), ]; const administrationItems = auth.user.purchasing_role === 'admin' ? [ { title: 'Empresa e equipa', href: '/empresa', icon: Building2, }, ] : []; return ( {['admin', 'finance'].includes( auth.user.purchasing_role ?? '', ) && ( )} {inventoryItems.length > 0 && ( )} {administrationItems.length > 0 && ( )} Página inicial ); }