fix: complete InvesteMoz validation and error corrections
This commit is contained in:
@@ -9,7 +9,9 @@ export type PortalNavItem = {
|
||||
};
|
||||
export type PortalNavAccess = {
|
||||
contentManagementHref?: string | null;
|
||||
contentManagementAccess?: {opportunities?:{index:string;create?:string|null}};
|
||||
contentManagementAccess?: {
|
||||
opportunities?: { index: string; create?: string | null };
|
||||
};
|
||||
scopedAdministration?: { label: string; href: string }[];
|
||||
procurement?: boolean;
|
||||
authenticated: boolean;
|
||||
@@ -35,8 +37,15 @@ const link = (id: string, label: string, href: string): PortalNavItem => ({
|
||||
href,
|
||||
});
|
||||
/** Display the existing server decision; a generic manager flag cannot override a scoped denial. */
|
||||
export function canShowLegacyManagement(auth?:{user?:unknown;canManagePortal?:boolean;legacyManagementAccess?:boolean}):boolean {
|
||||
return !!auth?.user && (auth.legacyManagementAccess??auth.canManagePortal??false);
|
||||
export function canShowLegacyManagement(auth?: {
|
||||
user?: unknown;
|
||||
canManagePortal?: boolean;
|
||||
legacyManagementAccess?: boolean;
|
||||
}): boolean {
|
||||
return (
|
||||
!!auth?.user &&
|
||||
(auth.legacyManagementAccess ?? auth.canManagePortal ?? false)
|
||||
);
|
||||
}
|
||||
|
||||
/** One route catalogue for the public shell and authenticated pages. */
|
||||
@@ -378,7 +387,11 @@ export function legacyPortalNavigation(
|
||||
'Gestão de perfis',
|
||||
profile.administration,
|
||||
),
|
||||
link('profile-installation','Instalação dos perfis 040000','/management/profile-install'),
|
||||
link(
|
||||
'profile-installation',
|
||||
'Instalação dos perfis 040000',
|
||||
'/management/profile-install',
|
||||
),
|
||||
]
|
||||
: []),
|
||||
],
|
||||
@@ -447,10 +460,22 @@ export function currentNavigationItem(
|
||||
|
||||
/** Investor organization; existing capability filters still determine private destinations. */
|
||||
export function portalNavigation(access: PortalNavAccess): PortalNavItem[] {
|
||||
const previous = legacyPortalNavigation({...access,manager:access.authenticated&&access.manager,profileAccess:access.authenticated?access.profileAccess:null});
|
||||
const workHub=access.authenticated?access.contentManagementHref:null;
|
||||
const workOpportunities=access.authenticated?access.contentManagementAccess?.opportunities:undefined;
|
||||
const workCreate=access.authenticated?(access.profileAccess?.create||workOpportunities?.create||(access.manager&&access.opportunityManagement?.installed?access.opportunityManagement.create.href:null)):null;
|
||||
const previous = legacyPortalNavigation({
|
||||
...access,
|
||||
manager: access.authenticated && access.manager,
|
||||
profileAccess: access.authenticated ? access.profileAccess : null,
|
||||
});
|
||||
const workHub = access.authenticated ? access.contentManagementHref : null;
|
||||
const workOpportunities = access.authenticated
|
||||
? access.contentManagementAccess?.opportunities
|
||||
: undefined;
|
||||
const workCreate = access.authenticated
|
||||
? access.profileAccess?.create ||
|
||||
workOpportunities?.create ||
|
||||
(access.manager && access.opportunityManagement?.installed
|
||||
? access.opportunityManagement.create.href
|
||||
: null)
|
||||
: null;
|
||||
return uniqueNavigationDestinations([
|
||||
{
|
||||
id: 'discovery',
|
||||
@@ -478,7 +503,15 @@ export function portalNavigation(access: PortalNavAccess): PortalNavItem[] {
|
||||
),
|
||||
link('sectors', 'Sectores de investimento', '/sectores'),
|
||||
link('locations', 'Localizações', '/oportunidades?view=map'),
|
||||
...(access.procurement ? [link('procurement','Concursos e anúncios','/concursos')] : []),
|
||||
...(access.procurement
|
||||
? [
|
||||
link(
|
||||
'procurement',
|
||||
'Concursos e anúncios',
|
||||
'/concursos',
|
||||
),
|
||||
]
|
||||
: []),
|
||||
{
|
||||
id: 'related-catalogues',
|
||||
label: 'Catálogos relacionados',
|
||||
@@ -555,19 +588,61 @@ export function portalNavigation(access: PortalNavAccess): PortalNavItem[] {
|
||||
),
|
||||
],
|
||||
},
|
||||
...[{
|
||||
|
||||
{
|
||||
id: 'work',
|
||||
label: 'Área de trabalho',
|
||||
children: [
|
||||
link('work-entry', workHub ? 'Gestão de conteúdos e oportunidades':'Acesso à gestão', workHub || '/acesso-gestao'),
|
||||
...(workCreate ? [
|
||||
link('prepare-analysis', 'Preparar análise e ideia', workCreate+'?analysis=proactive'),
|
||||
] : []),
|
||||
...(workOpportunities ? [link('work-opportunities','Oportunidades em preparação',workOpportunities.index)] : []),
|
||||
...previous.filter(group=>['management','profile-opportunities'].includes(group.id)).flatMap(group=>group.children??[]),
|
||||
...(access.authenticated&&access.scopedAdministration?.length ? [{id:'work-administration',label:'Administração',children:access.scopedAdministration.map((item,index)=>link('scoped-'+index,item.label,item.href))}] : []),
|
||||
link(
|
||||
'work-entry',
|
||||
workHub
|
||||
? 'Gestão de conteúdos e oportunidades'
|
||||
: 'Acesso à gestão',
|
||||
workHub || '/acesso-gestao',
|
||||
),
|
||||
...(workCreate
|
||||
? [
|
||||
link(
|
||||
'prepare-analysis',
|
||||
'Preparar análise e ideia',
|
||||
workCreate + '?analysis=proactive',
|
||||
),
|
||||
]
|
||||
: []),
|
||||
...(workOpportunities
|
||||
? [
|
||||
link(
|
||||
'work-opportunities',
|
||||
'Oportunidades em preparação',
|
||||
workOpportunities.index,
|
||||
),
|
||||
]
|
||||
: []),
|
||||
...previous
|
||||
.filter((group) =>
|
||||
['management', 'profile-opportunities'].includes(
|
||||
group.id,
|
||||
),
|
||||
)
|
||||
.flatMap((group) => group.children ?? []),
|
||||
...(access.authenticated && access.scopedAdministration?.length
|
||||
? [
|
||||
{
|
||||
id: 'work-administration',
|
||||
label: 'Administração',
|
||||
children: access.scopedAdministration.map(
|
||||
(item, index) =>
|
||||
link(
|
||||
'scoped-' + index,
|
||||
item.label,
|
||||
item.href,
|
||||
),
|
||||
),
|
||||
},
|
||||
]
|
||||
: []),
|
||||
],
|
||||
}],
|
||||
},
|
||||
...previous.filter((group) => group.id === 'account'),
|
||||
...(access.authenticated &&
|
||||
access.businesses &&
|
||||
|
||||
Reference in New Issue
Block a user