Spaces:
Running
Running
Create frontend/src/App.jsx
Browse files- frontend/src/App.jsx +27 -0
frontend/src/App.jsx
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import React from "react";
|
| 2 |
+
import { Routes, Route, Navigate, useLocation } from "react-router-dom";
|
| 3 |
+
import Layout from "./Layout";
|
| 4 |
+
import Dashboard from "./pages/Dashboard";
|
| 5 |
+
import History from "./pages/History";
|
| 6 |
+
|
| 7 |
+
function RoutedApp() {
|
| 8 |
+
const location = useLocation();
|
| 9 |
+
const path = location.pathname;
|
| 10 |
+
|
| 11 |
+
let currentPageName = "Dashboard";
|
| 12 |
+
if (path.startsWith("/history")) currentPageName = "History";
|
| 13 |
+
|
| 14 |
+
return (
|
| 15 |
+
<Layout currentPageName={currentPageName}>
|
| 16 |
+
<Routes>
|
| 17 |
+
<Route path="/" element={<Navigate to="/dashboard" replace />} />
|
| 18 |
+
<Route path="/dashboard" element={<Dashboard />} />
|
| 19 |
+
<Route path="/history" element={<History />} />
|
| 20 |
+
</Routes>
|
| 21 |
+
</Layout>
|
| 22 |
+
);
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
export default function App() {
|
| 26 |
+
return <RoutedApp />;
|
| 27 |
+
}
|