Spaces:
Running
Running
Update frontend/src/App.jsx
Browse files- frontend/src/App.jsx +22 -17
frontend/src/App.jsx
CHANGED
|
@@ -1,27 +1,32 @@
|
|
|
|
|
|
|
|
| 1 |
import React from "react";
|
| 2 |
-
import { Routes, Route
|
| 3 |
import Layout from "./Layout";
|
| 4 |
import Dashboard from "./pages/Dashboard";
|
| 5 |
import History from "./pages/History";
|
| 6 |
|
| 7 |
-
function
|
| 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 |
-
<
|
| 16 |
<Routes>
|
| 17 |
-
<Route
|
| 18 |
-
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
</Routes>
|
| 21 |
-
</
|
| 22 |
);
|
| 23 |
}
|
| 24 |
-
|
| 25 |
-
export default function App() {
|
| 26 |
-
return <RoutedApp />;
|
| 27 |
-
}
|
|
|
|
| 1 |
+
// frontend/src/App.jsx
|
| 2 |
+
|
| 3 |
import React from "react";
|
| 4 |
+
import { BrowserRouter, Routes, Route } from "react-router-dom";
|
| 5 |
import Layout from "./Layout";
|
| 6 |
import Dashboard from "./pages/Dashboard";
|
| 7 |
import History from "./pages/History";
|
| 8 |
|
| 9 |
+
export default function App() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
return (
|
| 11 |
+
<BrowserRouter>
|
| 12 |
<Routes>
|
| 13 |
+
<Route
|
| 14 |
+
path="/"
|
| 15 |
+
element={
|
| 16 |
+
<Layout currentPageName="Dashboard">
|
| 17 |
+
<Dashboard />
|
| 18 |
+
</Layout>
|
| 19 |
+
}
|
| 20 |
+
/>
|
| 21 |
+
<Route
|
| 22 |
+
path="/history"
|
| 23 |
+
element={
|
| 24 |
+
<Layout currentPageName="History">
|
| 25 |
+
<History />
|
| 26 |
+
</Layout>
|
| 27 |
+
}
|
| 28 |
+
/>
|
| 29 |
</Routes>
|
| 30 |
+
</BrowserRouter>
|
| 31 |
);
|
| 32 |
}
|
|
|
|
|
|
|
|
|
|
|
|