Initial Commit
This commit is contained in:
23
client/src/App.jsx
Normal file
23
client/src/App.jsx
Normal file
@@ -0,0 +1,23 @@
|
||||
import { BrowserRouter, Navigate, Route, Routes } from 'react-router-dom';
|
||||
import { isAuthenticated } from './api';
|
||||
import Login from './pages/Login';
|
||||
import Apps from './pages/Apps';
|
||||
import Catalog from './pages/Catalog';
|
||||
import Viewer from './pages/Viewer';
|
||||
|
||||
function ProtectedRoute({ children }) {
|
||||
return isAuthenticated() ? children : <Navigate to="/login" replace />;
|
||||
}
|
||||
|
||||
export default function App() {
|
||||
return (
|
||||
<BrowserRouter>
|
||||
<Routes>
|
||||
<Route path="/login" element={<Login />} />
|
||||
<Route path="/" element={<ProtectedRoute><Catalog /></ProtectedRoute>} />
|
||||
<Route path="/apps" element={<ProtectedRoute><Apps /></ProtectedRoute>} />
|
||||
<Route path="/viewer/:id" element={<ProtectedRoute><Viewer /></ProtectedRoute>} />
|
||||
</Routes>
|
||||
</BrowserRouter>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user