diff --git a/apps/backoffice/src/app/features/user-management-host/UserManagementHostPage.tsx b/apps/backoffice/src/app/features/user-management-host/UserManagementHostPage.tsx index 542c37097..e6d8038d2 100644 --- a/apps/backoffice/src/app/features/user-management-host/UserManagementHostPage.tsx +++ b/apps/backoffice/src/app/features/user-management-host/UserManagementHostPage.tsx @@ -19,7 +19,7 @@ import { useNavigate, useLocation } from 'react-router-dom'; function readToken(): string | null { return ( - localStorage.getItem('fhc-backoffice-auth-token') ?? + localStorage.getItem('ema-backoffice-auth-token') ?? (() => { const escaped = 'auth-token'.replace(/([.$?*|{}()[\]\\/+^])/g, '\\$1'); const match = document.cookie.match(new RegExp('(?:^|; )' + escaped + '=([^;]*)')); @@ -29,7 +29,7 @@ function readToken(): string | null { } function readRefreshToken(): string | null { - return localStorage.getItem('fhc-backoffice-auth-refresh-token') ?? null; + return localStorage.getItem('ema-backoffice-refresh-token') ?? null; } export default function UserManagementHostPage() { @@ -68,6 +68,14 @@ export default function UserManagementHostPage() { } if (data.type === 'UM_ROUTE_CHANGED' && typeof data.path === 'string') { + // Allow the module to navigate the host away by using /return/. + // Add a nav item with href: "/return/dashboard" in project.theme.ts + // navItems to send the user back to the host app. + const returnMatch = data.path.match(/^\/return\/(.+)/); + if (returnMatch) { + navigate('/' + returnMatch[1], { replace: true }); + return; + } const target = '/um' + data.path; if (window.location.pathname + window.location.search !== target) { navigate(target, { replace: true }); diff --git a/user-management-config/main.tsx b/user-management-config/main.tsx index b1d689859..b1c25067e 100644 --- a/user-management-config/main.tsx +++ b/user-management-config/main.tsx @@ -15,6 +15,9 @@ i18n.addResourceBundle("en", "translation", { paperlessOffice: "Ethiopian Maritime Authority", welcomeSubtext: "Sign in to access your maritime services efficiently.", }, + organization: { + "Back to Dashboard": "Back to Dashboard", + }, }, true, true); createRoot(document.getElementById("root")!).render( diff --git a/user-management-config/project.theme.ts b/user-management-config/project.theme.ts index 32fd4a78e..b4bf4b9a2 100644 --- a/user-management-config/project.theme.ts +++ b/user-management-config/project.theme.ts @@ -169,6 +169,12 @@ export const projectTheme: DesignConfig = { { label: "activityLog", href: "/user-management/activity_log", icon: "activity", roles: ["super_admin"], isPrimary: false, enabled: true }, { label: "setting", href: "/user-management/settings", icon: "settings", roles: ["super_admin"], isPrimary: false, enabled: true }, { label: "Letter Template", href: "/user-management/templates", icon: "file", roles: ["super_admin"], isPrimary: false, enabled: true }, + + // ── Return to host app ───────────────────────────────────────────────── + // Clicking navigates the HOST (parent window) to the destination. The + // /return/ prefix is intercepted by UserManagementHostPage.tsx to tell the + // host to navigate itself, not the iframe. + { label: "Back to Dashboard", href: "/return/dashboard", icon: "dashboard", roles: ["admin", "unit_admin", "super_admin"], isPrimary: false, enabled: true }, ], // ── Top tab bar skin (legacy view) ─────────────────────────────────────