Files
emaui/apps/portal/src/app/router.tsx
2026-06-13 11:21:32 +03:00

97 lines
3.7 KiB
TypeScript

import { createBrowserRouter, Navigate } from 'react-router-dom';
import type { ReactNode } from 'react';
import { I18nextProvider } from 'react-i18next';
import { i18n } from './i18n/config';
import { PortalLayout } from './layouts/PortalLayout';
// Auth (standalone pages, no portal chrome)
import { LoginPage, SignupPage, OTPVerificationPage, ForgotPasswordPage } from '@ema-platform/auth';
// Portal feature pages
import { DashboardPage } from './features/dashboard/pages/DashboardPage';
import { ServicesPage } from './features/licenses/pages/ServicesPage';
// Redesigned portal pages (new look & feel) — kept alongside the originals.
import { PortalLayoutV2 } from './v2/PortalLayoutV2';
import { DashboardV2 } from './v2/pages/DashboardV2';
import { ApplicationsV2 } from './v2/pages/ApplicationsV2';
import { ApplyV2 } from './v2/pages/ApplyV2';
import { ApplyPage } from './features/licenses/pages/ApplyPage';
import { ApplicationsListPage } from './features/licenses/pages/ApplicationsListPage';
import { ApplicationDetailPage } from './features/licenses/pages/ApplicationDetailPage';
import { MyLicensesPage } from './features/licenses/pages/MyLicensesPage';
import { LicenseDetailPage } from './features/licenses/pages/LicenseDetailPage';
import { ProfilePage } from './features/profile/pages/ProfilePage';
import { SupportPage } from './features/support/pages/SupportPage';
// IAM (admin user management) — kept reachable but isolated under its own
// provider so it does not depend on the portal's provider tree.
import {
AppProviders as IamProviders,
UserManagementLayout,
UserManagementPage,
} from '@tria-plc/iamui-common';
function IsolatedIam({ children }: { children: ReactNode }) {
return <IamProviders>{children}</IamProviders>;
}
export const router = createBrowserRouter([
// Standalone auth pages
{ path: '/login', element: <LoginPage /> },
{ path: '/signup', element: <SignupPage /> },
{ path: '/otp-verify', element: <OTPVerificationPage /> },
{ path: '/forgot-password', element: <ForgotPasswordPage /> },
// Portal (open access for this UI template).
// Wrapped in the portal's own i18n instance so it is isolated from the
// global i18next singleton that `@tria-plc/iamui-common` initializes.
{
element: (
<I18nextProvider i18n={i18n}>
<PortalLayout />
</I18nextProvider>
),
children: [
{ path: '/', element: <Navigate to="/dashboard" replace /> },
{ path: '/dashboard', element: <DashboardPage /> },
{ path: '/services', element: <ServicesPage /> },
{ path: '/apply', element: <ApplyPage /> },
{ path: '/applications', element: <ApplicationsListPage /> },
{ path: '/applications/:id', element: <ApplicationDetailPage /> },
{ path: '/licenses', element: <MyLicensesPage /> },
{ path: '/licenses/:id', element: <LicenseDetailPage /> },
{ path: '/profile', element: <ProfilePage /> },
{ path: '/support', element: <SupportPage /> },
],
},
// Redesigned portal (new look & feel) under /v2 — isolated in the portal i18n
// instance, same as the original portal routes.
{
element: (
<I18nextProvider i18n={i18n}>
<PortalLayoutV2 />
</I18nextProvider>
),
children: [
{ path: '/v2', element: <Navigate to="/v2/dashboard" replace /> },
{ path: '/v2/dashboard', element: <DashboardV2 /> },
{ path: '/v2/applications', element: <ApplicationsV2 /> },
{ path: '/v2/apply', element: <ApplyV2 /> },
],
},
// IAM admin user management (isolated providers)
{
element: (
<IsolatedIam>
<UserManagementLayout />
</IsolatedIam>
),
children: [{ path: '/users', element: <UserManagementPage /> }],
},
{ path: '*', element: <Navigate to="/" replace /> },
]);