import { createBrowserRouter } from 'react-router-dom'; import { lazy, Suspense } from 'react'; import Layout from './components/Layout'; import ProtectedRoute from './components/ProtectedRoute'; import LoginPage from './pages/LoginPage'; import { RouterErrorPage, NotFoundPage } from './pages/ErrorPages'; // Core pages - loaded immediately import DashboardPage from './pages/DashboardPage'; // Lazy load all other pages to reduce initial bundle const DailyWalkthroughPage = lazy(() => import('./pages/DailyWalkthroughPage')); const RoomsPage = lazy(() => import('./pages/RoomsPage')); const RoomDetailPage = lazy(() => import('./pages/RoomDetailPage')); const BatchesPage = lazy(() => import('./pages/BatchesPage')); const BatchDetailPage = lazy(() => import('./pages/BatchDetailPage')); const TimeclockPage = lazy(() => import('./pages/TimeclockPage')); const SuppliesPage = lazy(() => import('./pages/SuppliesPage')); const TasksPage = lazy(() => import('./pages/TasksPage')); const TaskTemplatesPage = lazy(() => import('./pages/TaskTemplatesPage')); const WalkthroughSettingsPage = lazy(() => import('./pages/WalkthroughSettingsPage')); const RolesPage = lazy(() => import('./pages/RolesPage')); const TouchPointPage = lazy(() => import('./pages/TouchPointPage')); const IPMDashboardPage = lazy(() => import('./pages/IPMDashboardPage')); const SettingsPage = lazy(() => import('./pages/SettingsPage')); const ReportsPage = lazy(() => import('./pages/ReportsPage')); // Heavy components const LayoutDesignerPage = lazy(() => import('./features/layout-designer/LayoutDesignerPage')); const VisitorKioskPage = lazy(() => import('./pages/VisitorKioskPage')); const VisitorManagementPage = lazy(() => import('./pages/VisitorManagementPage')); const BadgePage = lazy(() => import('./pages/BadgePage')); // Phase 10: Compliance & Audit const AuditLogPage = lazy(() => import('./pages/AuditLogPage')); const DocumentsPage = lazy(() => import('./pages/DocumentsPage')); // Phase 13: Advanced Features const EnvironmentDashboard = lazy(() => import('./pages/EnvironmentDashboard')); const FinancialDashboard = lazy(() => import('./pages/FinancialDashboard')); const InsightsDashboard = lazy(() => import('./pages/InsightsDashboard')); // Loading spinner component for Suspense fallbacks const PageLoader = () => (
); export const router = createBrowserRouter([ { path: '/login', element: , }, // Visitor Kiosk - Public, no auth required { path: '/kiosk', element: (
}>
), errorElement: , }, { path: '/badges/:id', element: (
}>
), errorElement: , }, { path: '/', element: ( ), errorElement: , children: [ { index: true, element: , }, { path: 'walkthrough', element: }>, }, { path: 'touch-points', element: }>, }, { path: 'ipm', element: }>, }, { path: 'rooms', element: }>, }, { path: 'rooms/:id', element: }>, }, { path: 'batches', element: }>, }, { path: 'batches/:id', element: }>, }, { path: 'timeclock', element: }>, }, { path: 'supplies', element: }>, }, { path: 'tasks', element: }>, }, { path: 'tasks/templates', element: }>, }, { path: 'reports', element: }>, }, { path: 'roles', element: }>, }, { path: 'visitors', element: }>, }, { path: 'settings', element: }>, }, { path: 'settings/walkthrough', element: }>, }, // Phase 10: Compliance & Audit { path: 'compliance/audit', element: }>, }, { path: 'compliance/documents', element: }>, }, // Phase 13: Advanced Features { path: 'environment', element: }>, }, { path: 'financial', element: }>, }, { path: 'insights', element: }>, }, // 404 catch-all { path: '*', element: , }, ], }, // Layout Designer - Full screen, outside main layout { path: '/layout-designer', element: (
}>
), errorElement: , }, ]);