@@ -35,6 +35,7 @@ export function procurementNavigation(
|
||||
orderCancellation = false,
|
||||
operationalOrders = false,
|
||||
privateAudit = false,
|
||||
capitalRegister = false,
|
||||
): ProcurementGroup[] {
|
||||
const groups: ProcurementGroup[] = [
|
||||
{
|
||||
@@ -42,6 +43,11 @@ export function procurementNavigation(
|
||||
label: 'Requisições',
|
||||
icon: ClipboardList,
|
||||
entries: [
|
||||
{
|
||||
id: 'my_workflow_tasks',
|
||||
label: 'As minhas tarefas',
|
||||
path: '/requisicoes/tarefas',
|
||||
},
|
||||
{
|
||||
id: 'process_search',
|
||||
label: 'Pesquisar processos',
|
||||
@@ -57,11 +63,6 @@ export function procurementNavigation(
|
||||
label: 'Minhas requisições',
|
||||
path: '/requisicoes?view=mine',
|
||||
},
|
||||
{
|
||||
id: 'my_workflow_tasks',
|
||||
label: 'As minhas tarefas',
|
||||
path: '/requisicoes/tarefas',
|
||||
},
|
||||
{
|
||||
id: 'my_drafts',
|
||||
label: 'Os meus rascunhos',
|
||||
@@ -69,7 +70,7 @@ export function procurementNavigation(
|
||||
},
|
||||
{
|
||||
id: 'all_requests',
|
||||
label: 'Todas as autorizadas',
|
||||
label: 'Requisições autorizadas',
|
||||
path: '/requisicoes?view=all',
|
||||
},
|
||||
{ id: 'planning', label: 'Planeamento', path: '/planeamento' },
|
||||
@@ -424,6 +425,12 @@ export function procurementNavigation(
|
||||
path: '/equipamentos',
|
||||
roles: inventory,
|
||||
},
|
||||
{
|
||||
id: 'capital_register',
|
||||
label: 'Projectos e imobilizado',
|
||||
path: '/projectos-imobilizado',
|
||||
roles: inventory,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
@@ -557,9 +564,25 @@ export function procurementNavigation(
|
||||
label: 'Compras',
|
||||
icon: ClipboardList,
|
||||
entries: purchasing.flatMap((group) =>
|
||||
group.entries.map((entry) => ({
|
||||
(group.id === 'sourcing'
|
||||
? [
|
||||
...group.entries.filter(
|
||||
(entry) => entry.id !== 'supply_imports',
|
||||
),
|
||||
...group.entries.filter(
|
||||
(entry) => entry.id === 'supply_imports',
|
||||
),
|
||||
]
|
||||
: group.entries
|
||||
).map((entry) => ({
|
||||
...entry,
|
||||
section: group.label,
|
||||
section:
|
||||
entry.id === 'supply_imports'
|
||||
? 'Importação'
|
||||
: group.id === 'sourcing' &&
|
||||
entry.id.startsWith('supply_')
|
||||
? 'Fornecimento e reposição'
|
||||
: group.label,
|
||||
})),
|
||||
),
|
||||
},
|
||||
@@ -596,6 +619,7 @@ export function procurementNavigation(
|
||||
(entry.id !== 'audit_private' || privateAudit) &&
|
||||
(entry.id !== 'operational_orders' ||
|
||||
operationalOrders) &&
|
||||
(entry.id !== 'capital_register' || capitalRegister) &&
|
||||
(entry.id !== 'new_request' ||
|
||||
!Array.isArray(role) ||
|
||||
role.includes('requester')) &&
|
||||
@@ -615,6 +639,29 @@ export function activeProcurementEntry(
|
||||
url: string,
|
||||
): string | undefined {
|
||||
const current = new URL(url, 'http://local');
|
||||
if (
|
||||
(current.pathname === '/compras/acordos/vigencia' ||
|
||||
(current.pathname === '/compras/fornecimento' &&
|
||||
['agreements', 'contracts'].includes(
|
||||
current.searchParams.get('view') ?? 'agreements',
|
||||
))) &&
|
||||
groups.some((group) =>
|
||||
group.entries.some((entry) => entry.id === 'supply_agreements'),
|
||||
)
|
||||
)
|
||||
return 'supply_agreements';
|
||||
if (
|
||||
(/^\/requisicoes\/\d+\/(classificacao-pautal|base-legal|estimativa-importacao)(?:\/|$)/.test(
|
||||
current.pathname,
|
||||
) ||
|
||||
/^\/compras\/importacoes\/\d+\/(custos|documentos|suporte-bancario|acompanhamento)(?:\/|$)/.test(
|
||||
current.pathname,
|
||||
)) &&
|
||||
groups.some((group) =>
|
||||
group.entries.some((entry) => entry.id === 'supply_imports'),
|
||||
)
|
||||
)
|
||||
return 'supply_imports';
|
||||
if (/^\/ordens\/\d+\/recepcoes/.test(current.pathname)) return 'receipts';
|
||||
if (/^\/requisicoes\/\d+\/adjudicacao(?:\/|$)/.test(current.pathname))
|
||||
return 'orders';
|
||||
@@ -644,5 +691,17 @@ export function activeProcurementEntry(
|
||||
return target.pathname.length * 100 + target.searchParams.size;
|
||||
};
|
||||
matches.sort((a, b) => specificity(b.path) - specificity(a.path));
|
||||
if (
|
||||
matches.length === 0 &&
|
||||
/^\/administracao\/(prazos-aprovacao|revisao-urgencias)(?:\/|$)/.test(
|
||||
current.pathname,
|
||||
) &&
|
||||
groups.some((group) =>
|
||||
group.entries.some(
|
||||
(entry) => entry.id === 'organization_parameters',
|
||||
),
|
||||
)
|
||||
)
|
||||
return 'organization_parameters';
|
||||
return matches[0]?.id;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user