Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 | import { BrowserRouter as Router, Routes, Route, Navigate } from 'react-router-dom'; import { lazy, Suspense } from 'react'; import { useAuthStore } from './store'; import DattaLayout from './components/layout/DattaLayout'; // Lazy load all pages for code splitting const Dashboard = lazy(() => import('./pages/Dashboard')); const Analytics = lazy(() => import('./pages/Analytics')); const Settings = lazy(() => import('./pages/Settings')); const Projects = lazy(() => import('./pages/Projects')); const Profile = lazy(() => import('./pages/Profile')); const Localization = lazy(() => import('./pages/Localization')); const Login = lazy(() => import('./pages/Login')); const RecordingSession = lazy(() => import('./pages/RecordingSession')); const SessionHistory = lazy(() => import('./pages/SessionHistory')); const WebSDRManagement = lazy(() => import('./pages/WebSDRManagement')); const SystemStatus = lazy(() => import('./pages/SystemStatus')); const DataIngestion = lazy(() => import('./pages/DataIngestion')); // Loading fallback component const LoadingFallback = () => ( <div className="flex items-center justify-center min-h-screen"> <div className="text-center"> <div className="inline-block animate-spin rounded-full h-12 w-12 border-b-2 border-gray-900 dark:border-gray-100"></div> <p className="mt-4 text-gray-600 dark:text-gray-400">Loading...</p> </div> </div> ); interface ProtectedRouteProps { children: React.ReactNode; } const ProtectedRoute: React.FC<ProtectedRouteProps> = ({ children }) => { const { isAuthenticated } = useAuthStore(); if (!isAuthenticated) { return <Navigate to="/login" replace />; } return <DattaLayout>{children}</DattaLayout>; }; function App() { return ( <Router> <Suspense fallback={<LoadingFallback />}> <Routes> {/* Public Routes */} <Route path="/login" element={<Login />} /> {/* Protected Routes */} <Route path="/dashboard" element={ <ProtectedRoute> <Dashboard /> </ProtectedRoute> } /> <Route path="/localization" element={ <ProtectedRoute> <Localization /> </ProtectedRoute> } /> <Route path="/analytics" element={ <ProtectedRoute> <Analytics /> </ProtectedRoute> } /> <Route path="/data-ingestion" element={ <ProtectedRoute> <DataIngestion /> </ProtectedRoute> } /> <Route path="/projects" element={ <ProtectedRoute> <Projects /> </ProtectedRoute> } /> <Route path="/settings" element={ <ProtectedRoute> <Settings /> </ProtectedRoute> } /> <Route path="/profile" element={ <ProtectedRoute> <Profile /> </ProtectedRoute> } /> <Route path="/recording" element={ <ProtectedRoute> <RecordingSession /> </ProtectedRoute> } /> <Route path="/history" element={ <ProtectedRoute> <SessionHistory /> </ProtectedRoute> } /> <Route path="/websdrs" element={ <ProtectedRoute> <WebSDRManagement /> </ProtectedRoute> } /> <Route path="/system-status" element={ <ProtectedRoute> <SystemStatus /> </ProtectedRoute> } /> {/* Redirect */} <Route path="/" element={<Navigate to="/dashboard" replace />} /> <Route path="*" element={<Navigate to="/dashboard" replace />} /> </Routes> </Suspense> </Router> ); } export default App; |