From 0c3d817ee11327570488ed4e0fba17b08d0f155d Mon Sep 17 00:00:00 2001 From: Estifo77 <139631617+Estifo77@users.noreply.github.com> Date: Wed, 29 Jul 2026 12:08:36 +0300 Subject: [PATCH] fixes --- apps/portal/src/app/layouts/PortalLayout.tsx | 59 +++++++++++--------- libs/auth/src/lib/store/auth.slice.ts | 1 + 2 files changed, 33 insertions(+), 27 deletions(-) diff --git a/apps/portal/src/app/layouts/PortalLayout.tsx b/apps/portal/src/app/layouts/PortalLayout.tsx index ca8e4aa49..21e6e7316 100644 --- a/apps/portal/src/app/layouts/PortalLayout.tsx +++ b/apps/portal/src/app/layouts/PortalLayout.tsx @@ -164,41 +164,42 @@ const NAV_ITEMS: (NavItem & { i18nKey: string })[] = [ // matches a profession named "Deck Cadet". Values are the `to` paths from // NAV_ITEMS above. '*' means every item. -const ALWAYS_VISIBLE = ['/notifications', '/profile', '/support']; +const ALWAYS_VISIBLE = ["/notifications", "/profile", "/support"]; -const NAV_ACCESS: Record = { - individual: '*', +const NAV_ACCESS: Record = { + null: "*", + individual: "*", cadet: [ - '/dashboard', - '/seafarer-registry', - '/seaman-book', - '/certificates', - '/endorsements', - '/documents', + "/dashboard", + "/seafarer-registry", + "/seaman-book", + "/certificates", + "/endorsements", + "/documents", ], registration: [ - '/vessel-registration-dashboard', - '/vessel-registration', - '/vessel-registration/transfer', + "/vessel-registration-dashboard", + "/vessel-registration", + "/vessel-registration/transfer", ], transfer: [ - '/vessel-registration-dashboard', - '/vessel-registration', - '/vessel-registration/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', + "/logistics-dashboard", + "/freight-forwarder-license", + "/shipping-agent-license", + "/combined-license", + "/joint-investment-license", + "/mto-license", + "/waiver", ], }; // Used when profession is missing or matches no key above. Set to '*' to show everything. -const FALLBACK_ACCESS: string[] | '*' = ['/dashboard']; +const FALLBACK_ACCESS: string[] | "*" = ["/dashboard"]; const PAGE_META: Record = { "/dashboard": { i18nKey: "nav.dashboard" }, @@ -233,17 +234,21 @@ export function PortalLayout() { const dispatch = useDispatch(); const user = useAppSelector((state) => state.auth.user); const currentProfile = useAppSelector((state) => state.auth.currentProfile); - const professionName = (currentProfile?.profession?.name?.en ?? "").toLowerCase(); + const professionName = ( + currentProfile?.profession?.name?.en ?? "" + ).toLowerCase(); const matchedKey = Object.keys(NAV_ACCESS).find((key) => professionName.includes(key), ); - const allowed = (matchedKey ? NAV_ACCESS[matchedKey] : undefined) ?? FALLBACK_ACCESS; + const allowed = + (matchedKey ? NAV_ACCESS[matchedKey] : undefined) ?? FALLBACK_ACCESS; const visibleNavItems = - allowed === '*' + allowed === "*" ? NAV_ITEMS : NAV_ITEMS.filter( (item) => - ALWAYS_VISIBLE.includes(item.to ?? '') || allowed.includes(item.to ?? ''), + 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/store/auth.slice.ts b/libs/auth/src/lib/store/auth.slice.ts index 1fb70a533..4b154a2aa 100644 --- a/libs/auth/src/lib/store/auth.slice.ts +++ b/libs/auth/src/lib/store/auth.slice.ts @@ -42,6 +42,7 @@ const authSlice = createSlice({ state.isAuthenticated = false; state.currentProfile = null; authStorage.clear(); + clearCurrentProfile(); }, setToken(state, action: PayloadAction) { state.token = action.payload;