mirror of
https://github.com/Tria-plc/emaui.git
synced 2026-08-27 22:30:56 +00:00
fixes
This commit is contained in:
@@ -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<string, string[] | '*'> = {
|
||||
individual: '*',
|
||||
const NAV_ACCESS: Record<string, string[] | "*"> = {
|
||||
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<string, { i18nKey: string }> = {
|
||||
"/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);
|
||||
|
||||
@@ -42,6 +42,7 @@ const authSlice = createSlice({
|
||||
state.isAuthenticated = false;
|
||||
state.currentProfile = null;
|
||||
authStorage.clear();
|
||||
clearCurrentProfile();
|
||||
},
|
||||
setToken(state, action: PayloadAction<string>) {
|
||||
state.token = action.payload;
|
||||
|
||||
Reference in New Issue
Block a user