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'; import DashboardPage from '@/components/dashboard/DashboardPage'; import TodosPage from '@/components/todos/TodosPage'; import CalendarPage from '@/components/calendar/CalendarPage'; import RemindersPage from '@/components/reminders/RemindersPage'; import ProjectsPage from '@/components/projects/ProjectsPage'; import ProjectDetail from '@/components/projects/ProjectDetail'; import PeoplePage from '@/components/people/PeoplePage'; import LocationsPage from '@/components/locations/LocationsPage'; import SettingsPage from '@/components/settings/SettingsPage'; import NotificationsPage from '@/components/notifications/NotificationsPage'; const AdminPortal = lazy(() => import('@/components/admin/AdminPortal')); function ProtectedRoute({ children }: { children: React.ReactNode }) { const { authStatus, isLoading } = useAuth(); if (isLoading) { return (
Loading...
); } if (!authStatus?.authenticated) { return ; } return <>{children}; } function AdminRoute({ children }: { children: React.ReactNode }) { const { authStatus, isLoading } = useAuth(); if (isLoading) { return (
Loading...
); } if (!authStatus?.authenticated || authStatus?.role !== 'admin') { return ; } return <>{children}; } function App() { return ( } /> } > } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> Loading...}> } /> ); } export default App;