import { createBrowserRouter, Navigate } from 'react-router'; import { ProtectedRoute } from './auth/ProtectedRoute'; import { RequireAdmin } from './auth/RequireAdmin'; import { LoginPage } from './auth/LoginPage'; import { OidcCallback } from './auth/OidcCallback'; import { LayoutShell } from './components/LayoutShell'; import { config } from './config'; import { lazy, Suspense } from 'react'; import { Spinner } from '@cameleer/design-system'; const ExchangesPage = lazy(() => import('./pages/Exchanges/ExchangesPage')); const DashboardPage = lazy(() => import('./pages/DashboardTab/DashboardPage')); const RuntimePage = lazy(() => import('./pages/RuntimeTab/RuntimePage')); const AdminLayout = lazy(() => import('./pages/Admin/AdminLayout')); const RbacPage = lazy(() => import('./pages/Admin/RbacPage')); const AuditLogPage = lazy(() => import('./pages/Admin/AuditLogPage')); const OidcConfigPage = lazy(() => import('./pages/Admin/OidcConfigPage')); const DatabaseAdminPage = lazy(() => import('./pages/Admin/DatabaseAdminPage')); const ClickHouseAdminPage = lazy(() => import('./pages/Admin/ClickHouseAdminPage')); const AppConfigPage = lazy(() => import('./pages/Admin/AppConfigPage')); const LogsPage = lazy(() => import('./pages/LogsTab/LogsPage')); const SwaggerPage = lazy(() => import('./pages/Swagger/SwaggerPage')); function SuspenseWrapper({ children }: { children: React.ReactNode }) { return ( }> {children} ); } const basename = config.basePath.replace(/\/$/, '') || undefined; export const router = createBrowserRouter([ { path: '/login', element: }, { path: '/oidc/callback', element: }, { element: , children: [ { element: , children: [ // Default redirect { index: true, element: }, // Exchanges tab { path: 'exchanges', element: }, { path: 'exchanges/:appId', element: }, { path: 'exchanges/:appId/:routeId', element: }, { path: 'exchanges/:appId/:routeId/:exchangeId', element: }, // Dashboard tab { path: 'dashboard', element: }, { path: 'dashboard/:appId', element: }, { path: 'dashboard/:appId/:routeId', element: }, // Runtime tab { path: 'runtime', element: }, { path: 'runtime/:appId', element: }, { path: 'runtime/:appId/:instanceId', element: }, // Logs tab { path: 'logs', element: }, { path: 'logs/:appId', element: }, { path: 'logs/:appId/:routeId', element: }, // Config tab (accessible to VIEWER+, shows all apps or single app) { path: 'config', element: }, { path: 'config/:appId', element: }, // Admin (ADMIN role required) { element: , children: [{ path: 'admin', element: , children: [ { index: true, element: }, { path: 'rbac', element: }, { path: 'audit', element: }, { path: 'oidc', element: }, { path: 'database', element: }, { path: 'clickhouse', element: }, ], }], }, { path: 'api-docs', element: }, ], }, ], }, ], { basename });