Consolida recepcoes, stock, equipamentos e identidade SGC

This commit is contained in:
2026-10-28 13:54:53 +02:00
parent eb1c8b8074
commit 75ffdb395c
76 changed files with 6933 additions and 152 deletions
+80 -15
View File
@@ -7,6 +7,8 @@ import {
Scale,
ShieldAlert,
FileCheck2,
PackageCheck,
Warehouse,
} from 'lucide-react';
import AppLogo from '@/components/app-logo';
import { NavMain } from '@/components/nav-main';
@@ -23,42 +25,89 @@ import {
import { dashboard } from '@/routes';
import type { NavItem } from '@/types';
const mainNavItems: NavItem[] = [
const generalNavItems: NavItem[] = [
{
title: 'Visão geral',
href: dashboard(),
icon: LayoutGrid,
},
{ title: 'Requisições', href: '/requisicoes', icon: ClipboardList },
{ title: 'Conflitos de interesses', href: '/conflitos', icon: ShieldAlert },
];
export function AppSidebar() {
const { auth } = usePage().props;
const purchasingItems = [
const canReadPurchases = [
'admin',
'procurement',
'finance',
'department_head',
].includes(auth.user.purchasing_role ?? '')
? [
...mainNavItems,
{ title: 'Fornecedores', href: '/fornecedores', icon: Users },
{ title: 'Cotações', href: '/cotacoes', icon: Scale },
{ title: 'Ordens de compra', href: '/ordens', icon: FileCheck2 },
]
: mainNavItems;
const items =
].includes(auth.user.purchasing_role ?? '');
const purchasingItems: NavItem[] = [
{ title: 'Requisições', href: '/requisicoes', icon: ClipboardList },
...(canReadPurchases
? [
{ title: 'Fornecedores', href: '/fornecedores', 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'
? [
...purchasingItems,
{
title: 'Empresa e equipa',
href: '/empresa',
icon: Building2,
},
]
: purchasingItems;
: [];
return (
<Sidebar collapsible="icon" variant="inset">
<SidebarHeader>
@@ -74,10 +123,26 @@ export function AppSidebar() {
</SidebarHeader>
<SidebarContent>
<NavMain items={items} />
<NavMain title="Geral" items={generalNavItems} />
<NavMain title="Compras" items={purchasingItems} />
{inventoryItems.length > 0 && (
<NavMain title="Armazém" items={inventoryItems} />
)}
{administrationItems.length > 0 && (
<NavMain
title="Administração"
items={administrationItems}
/>
)}
</SidebarContent>
<SidebarFooter>
<Link
href="/"
className="px-3 py-2 text-xs text-muted-foreground hover:text-foreground"
>
Página inicial
</Link>
<NavUser />
</SidebarFooter>
</Sidebar>