diff --git a/apps/portal/src/app/layouts/PortalLayout.tsx b/apps/portal/src/app/layouts/PortalLayout.tsx index 075adda96..7564afeec 100644 --- a/apps/portal/src/app/layouts/PortalLayout.tsx +++ b/apps/portal/src/app/layouts/PortalLayout.tsx @@ -157,6 +157,46 @@ const NAV_ITEMS: (NavItem & { i18nKey: string })[] = [ }, ]; +// ── Sidebar visibility rules ────────────────────────────────────────────── +// Edit these lists to change what each user type sees. Values are the `to` +// paths from NAV_ITEMS above. '*' means every item. + +const ALWAYS_VISIBLE = ['/notifications', '/profile', '/support']; + +const NAV_ACCESS: Record = { + individual: '*', + cadet: [ + '/dashboard', + '/seafarer-registry', + '/seaman-book', + '/certificates', + '/endorsements', + '/documents', + ], + registration: [ + '/vessel-registration-dashboard', + '/vessel-registration', + '/vessel-registration/transfer', + ], + transfer: [ + '/vessel-registration-dashboard', + '/vessel-registration', + '/vessel-registration/transfer', + ], + logistics: [ + '/logistics-dashboard', + '/freight-forwarder-license', + '/shipping-agent-license', + '/combined-license', + '/joint-investment-license', + '/mto-license', + '/waiver', + ], +}; + +// Used when userType is missing or unrecognized. Set to '*' to show everything. +const FALLBACK_ACCESS: string[] | '*' = ['/dashboard']; + const PAGE_META: Record = { "/dashboard": { i18nKey: "nav.dashboard" }, "/vessel-registration-dashboard": { @@ -189,6 +229,14 @@ export function PortalLayout() { const location = useLocation(); const dispatch = useDispatch(); const user = useAppSelector((state) => state.auth.user); + const allowed = NAV_ACCESS[user?.userType ?? ''] ?? FALLBACK_ACCESS; + const visibleNavItems = + allowed === '*' + ? NAV_ITEMS + : NAV_ITEMS.filter( + (item) => + ALWAYS_VISIBLE.includes(item.to ?? '') || allowed.includes(item.to ?? ''), + ); const [navOpened, { toggle: toggleNav, close: closeNav }] = useDisclosure(); const [sidebarCollapsed, { toggle: toggleSidebar }] = useDisclosure(false); diff --git a/libs/auth/src/lib/types/auth.types.ts b/libs/auth/src/lib/types/auth.types.ts index b6babe272..a11cb4faa 100644 --- a/libs/auth/src/lib/types/auth.types.ts +++ b/libs/auth/src/lib/types/auth.types.ts @@ -8,6 +8,7 @@ export interface AuthUser { en: string; }; status: string; + userType?: string; sharepointId: string | null; hasSetPassword: boolean; hasFinishedRegistration: boolean;