Seth0330's picture
Create frontend/src/App.jsx
1dff54f verified
raw
history blame
767 Bytes
import React from "react";
import { Routes, Route, Navigate, useLocation } from "react-router-dom";
import Layout from "./Layout";
import Dashboard from "./pages/Dashboard";
import History from "./pages/History";
function RoutedApp() {
const location = useLocation();
const path = location.pathname;
let currentPageName = "Dashboard";
if (path.startsWith("/history")) currentPageName = "History";
return (
<Layout currentPageName={currentPageName}>
<Routes>
<Route path="/" element={<Navigate to="/dashboard" replace />} />
<Route path="/dashboard" element={<Dashboard />} />
<Route path="/history" element={<History />} />
</Routes>
</Layout>
);
}
export default function App() {
return <RoutedApp />;
}