import { lazy, Suspense } from 'react'; import { Routes, Route, Navigate } from 'react-router-dom'; import { useAuth } from '@/hooks/useAuth'; import LockScreen from '@/components/auth/LockScreen'; import AppLayout from '@/components/layout/AppLayout'; // AS-2: Lazy-load all route components to reduce initial bundle parse time const DashboardPage = lazy(() => import('@/components/dashboard/DashboardPage')); const TodosPage = lazy(() => import('@/components/todos/TodosPage')); const CalendarPage = lazy(() => import('@/components/calendar/CalendarPage')); const RemindersPage = lazy(() => import('@/components/reminders/RemindersPage')); const ProjectsPage = lazy(() => import('@/components/projects/ProjectsPage')); const ProjectDetail = lazy(() => import('@/components/projects/ProjectDetail')); const PeoplePage = lazy(() => import('@/components/people/PeoplePage')); const LocationsPage = lazy(() => import('@/components/locations/LocationsPage')); const SettingsPage = lazy(() => import('@/components/settings/SettingsPage')); const NotificationsPage = lazy(() => import('@/components/notifications/NotificationsPage')); const AdminPortal = lazy(() => import('@/components/admin/AdminPortal')); const RouteFallback = () => (
Loading...
); function ProtectedRoute({ children }: { children: React.ReactNode }) { const { authStatus, isLoading } = useAuth(); if (isLoading) { return
; } if (!authStatus?.authenticated) { return ; } return <>{children}; } function AdminRoute({ children }: { children: React.ReactNode }) { const { authStatus, isLoading } = useAuth(); if (isLoading) { return
; } if (!authStatus?.authenticated || authStatus?.role !== 'admin') { return ; } return <>{children}; } function App() { return ( } /> } > } /> }>} /> }>} /> }>} /> }>} /> }>} /> }>} /> }>} /> }>} /> }>} /> }>} /> }> } /> ); } export default App;