mirror of
https://github.com/Tria-plc/emaui.git
synced 2026-08-26 13:02:50 +00:00
163 lines
8.8 KiB
TypeScript
163 lines
8.8 KiB
TypeScript
import { createBrowserRouter, Navigate } from 'react-router-dom';
|
|
import { I18nextProvider } from 'react-i18next';
|
|
import { i18n } from './i18n/config';
|
|
import { PortalLayout } from './layouts/PortalLayout';
|
|
import { ProtectedRoute } from './components/ProtectedRoute';
|
|
|
|
// 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 { ProfilePage } from './features/profile/pages/ProfilePage';
|
|
import { SupportPage } from './features/support/pages/SupportPage';
|
|
import { SeafarerRegistrationPage } from './features/seafarer/pages/SeafarerRegistrationPage';
|
|
import { SeafarerRegistryPage } from './features/seafarer/pages/SeafarerRegistryPage';
|
|
import { SeafarerProfilePage } from './features/seafarer/pages/SeafarerProfilePage';
|
|
|
|
// Phase 1 pages
|
|
import { DocumentVaultPage } from './features/documents/pages/DocumentVaultPage';
|
|
import { SeamanBookPage } from './features/seaman-book/pages/SeamanBookPage';
|
|
import { SeamanBookApplicationPage } from './features/seaman-book/pages/SeamanBookApplicationPage';
|
|
import { NotificationsPage } from './features/notifications/pages/NotificationsPage';
|
|
|
|
// Phase 2 — CoC / CoP
|
|
import { CertificatesPage } from './features/certificates/pages/CertificatesPage';
|
|
import { CoCApplicationPage } from './features/certificates/pages/CoCApplicationPage';
|
|
|
|
// Phase 3 — Endorsement
|
|
import { EndorsementPage } from './features/endorsement/pages/EndorsementPage';
|
|
import { VesselRegistrationPage } from './features/vessel-registration/pages/VesselRegistrationPage';
|
|
import { VesselRegistrationApplicationPage } from './features/vessel-registration/pages/VesselRegistrationApplicationPage';
|
|
import { OwnershipTransferPage } from './features/vessel-registration/pages/OwnershipTransferPage';
|
|
import { VesselRegistrationDashboardPage } from './features/vessel-registration-dashboard/pages/VesselRegistrationDashboardPage';
|
|
import { VesselOwnerLayout } from './layouts/VesselOwnerLayout';
|
|
import { VesselOwnerLoginPage } from './features/vessel-owner/pages/VesselOwnerLoginPage';
|
|
import { VesselOwnerRegisterPage } from './features/vessel-owner/pages/VesselOwnerRegisterPage';
|
|
import { VesselOwnerDashboardPage } from './features/vessel-owner/pages/VesselOwnerDashboardPage';
|
|
import { MyApplicationsPage } from './features/licensing/pages/MyApplicationsPage';
|
|
import { PaymentCheckPage } from './features/payments/pages/PaymentCheckPage';
|
|
import { PaymentSuccessPage } from './features/payments/pages/PaymentSuccessPage';
|
|
import { PaymentFailurePage } from './features/payments/pages/PaymentFailurePage';
|
|
import { LicenseApplicationPage } from './features/licensing/pages/LicenseApplicationPage';
|
|
import { WaiverPage } from './features/waiver/pages/WaiverPage';
|
|
|
|
export const router = createBrowserRouter([
|
|
// Public auth pages
|
|
{ path: '/login', element: <LoginPage /> },
|
|
{ path: '/signup', element: <SignupPage /> },
|
|
|
|
// Protected auth pages
|
|
{
|
|
element: <ProtectedRoute><OTPVerificationPage /></ProtectedRoute>,
|
|
path: '/otp-verify',
|
|
},
|
|
{
|
|
element: <ProtectedRoute><ForgotPasswordPage /></ProtectedRoute>,
|
|
path: '/forgot-password',
|
|
},
|
|
// The two-step setup wizard is gone. Signing up lands on the dashboard, and
|
|
// profile details are collected where they are actually needed: on /profile,
|
|
// via the dashboard nudge, or inline in an application flow. The path stays
|
|
// as a redirect so existing bookmarks and emailed links do not 404.
|
|
{ path: '/profile-setup', element: <Navigate to="/profile" replace /> },
|
|
|
|
// Portal — protected.
|
|
{
|
|
element: (
|
|
<ProtectedRoute>
|
|
<I18nextProvider i18n={i18n}>
|
|
<PortalLayout />
|
|
</I18nextProvider>
|
|
</ProtectedRoute>
|
|
),
|
|
children: [
|
|
{ path: '/', element: <Navigate to="/dashboard" replace /> },
|
|
{ path: '/dashboard', element: <DashboardPage /> },
|
|
|
|
// Config-driven licensing: one set of pages serves every licence type.
|
|
{ path: '/licensing/applications', element: <MyApplicationsPage /> },
|
|
|
|
// Telebirr returns the applicant to these.
|
|
{ path: '/payments/check', element: <PaymentCheckPage /> },
|
|
{ path: '/payments/success', element: <PaymentSuccessPage /> },
|
|
{ path: '/payments/failure', element: <PaymentFailurePage /> },
|
|
{ path: '/licensing/:typeCode/apply', element: <LicenseApplicationPage /> },
|
|
{
|
|
path: '/licensing/:typeCode/applications/:applicationId',
|
|
element: <LicenseApplicationPage />,
|
|
},
|
|
|
|
// Seafarer
|
|
{ path: '/seafarer-registration', element: <SeafarerRegistrationPage /> },
|
|
{ path: '/seafarer-registry', element: <SeafarerRegistryPage /> },
|
|
{ path: '/seafarer-registry/:id', element: <SeafarerProfilePage /> },
|
|
|
|
// Phase 1
|
|
{ path: '/documents', element: <DocumentVaultPage /> },
|
|
{ path: '/seaman-book', element: <SeamanBookPage /> },
|
|
{ path: '/seaman-book/apply', element: <SeamanBookApplicationPage /> },
|
|
{ path: '/notifications', element: <NotificationsPage /> },
|
|
|
|
// Phase 2 — CoC / CoP
|
|
{ path: '/certificates', element: <CertificatesPage /> },
|
|
{ path: '/certificates/apply', element: <CoCApplicationPage /> },
|
|
|
|
// Phase 3 — Endorsement
|
|
{ path: '/endorsements', element: <EndorsementPage /> },
|
|
{ path: '/vessel-registration-dashboard', element: <VesselRegistrationDashboardPage /> },
|
|
{ path: '/vessel-registration', element: <VesselRegistrationPage /> },
|
|
{ path: '/vessel-registration/apply', element: <VesselRegistrationApplicationPage /> },
|
|
{ path: '/vessel-registration/transfer', element: <OwnershipTransferPage /> },
|
|
// Legacy per-licence-type URLs. Each once had its own hand-written page
|
|
// that posted to a `/logistics-licenses/*` endpoint the API never had,
|
|
// and dropped every uploaded document on the floor. They are kept as
|
|
// redirects so old bookmarks land somewhere real; the config-driven
|
|
// wizard below serves every licence type from one place.
|
|
{ path: '/logistics-dashboard', element: <Navigate to="/dashboard" replace /> },
|
|
{ path: '/freight-forwarder-license', element: <Navigate to="/licensing/applications" replace /> },
|
|
{ path: '/freight-forwarder-license/apply', element: <Navigate to="/licensing/FREIGHT_FORWARDER/apply" replace /> },
|
|
{ path: '/freight-forwarder-license/:id/renew', element: <Navigate to="/licensing/applications" replace /> },
|
|
{ path: '/shipping-agent-license', element: <Navigate to="/licensing/applications" replace /> },
|
|
{ path: '/shipping-agent-license/apply', element: <Navigate to="/licensing/SHIPPING_AGENT/apply" replace /> },
|
|
{ path: '/shipping-agent-license/:id/renew', element: <Navigate to="/licensing/applications" replace /> },
|
|
{ path: '/combined-license', element: <Navigate to="/licensing/applications" replace /> },
|
|
{ path: '/combined-license/apply', element: <Navigate to="/licensing/COMBINED_SA_FF/apply" replace /> },
|
|
{ path: '/combined-license/:id/renew', element: <Navigate to="/licensing/applications" replace /> },
|
|
{ path: '/joint-investment-license', element: <Navigate to="/licensing/applications" replace /> },
|
|
{ path: '/joint-investment-license/apply', element: <Navigate to="/licensing/JOINT_INVESTOR/apply" replace /> },
|
|
{ path: '/joint-investment-license/:id/renew', element: <Navigate to="/licensing/applications" replace /> },
|
|
{ path: '/mto-license', element: <Navigate to="/licensing/applications" replace /> },
|
|
{ path: '/mto-license/apply', element: <Navigate to="/licensing/MULTIMODAL_TRANSPORT_OPERATOR/apply" replace /> },
|
|
{ path: '/mto-license/:id/renew', element: <Navigate to="/licensing/applications" replace /> },
|
|
// Waiver has no backend yet, so it says so rather than pretending.
|
|
{ path: '/waiver', element: <WaiverPage /> },
|
|
{ path: '/waiver/apply', element: <Navigate to="/waiver" replace /> },
|
|
|
|
// General
|
|
{ path: '/profile', element: <ProfilePage /> },
|
|
{ path: '/support', element: <SupportPage /> },
|
|
],
|
|
},
|
|
|
|
{ path: '/vessel-owner/login', element: <VesselOwnerLoginPage /> },
|
|
{ path: '/vessel-owner/register', element: <VesselOwnerRegisterPage /> },
|
|
{
|
|
element: (
|
|
<ProtectedRoute>
|
|
<I18nextProvider i18n={i18n}>
|
|
<VesselOwnerLayout />
|
|
</I18nextProvider>
|
|
</ProtectedRoute>
|
|
),
|
|
children: [
|
|
{ path: '/vessel-owner/dashboard', element: <VesselOwnerDashboardPage /> },
|
|
{ path: '/vessel-owner/registration', element: <VesselRegistrationPage /> },
|
|
{ path: '/vessel-owner/registration/apply', element: <VesselRegistrationApplicationPage /> },
|
|
{ path: '/vessel-owner/registration/transfer', element: <OwnershipTransferPage /> },
|
|
],
|
|
},
|
|
|
|
{ path: '*', element: <Navigate to="/" replace /> },
|
|
]);
|