source: frontend/src/App.jsx@ 708af9e

Last change on this file since 708af9e was 708af9e, checked in by Andrej <asumanovski@…>, 2 months ago

Weight tracking feature complete

  • Property mode set to 100644
File size: 2.8 KB
Line 
1import { Navigate, Route, Routes } from "react-router-dom";
2
3import LandingPage from "./pages/LandingPage/LandingPage.jsx";
4import Login from "./pages/Login/Login.jsx";
5import Register from "./pages/Register/Register.jsx";
6import DashboardLayout from "./pages/Dashboard/DashboardLayout.jsx";
7import ControlCenter from "./pages/Dashboard/pages/ControlCenter/ControlCenter.jsx";
8import Training from "./pages/Dashboard/pages/Training/Training.jsx";
9import TrainingTracking from "./pages/Dashboard/pages/Training/TrainingTracking.jsx";
10import NewTrainingSession from "./pages/Dashboard/pages/Training/NewTrainingSession.jsx";
11import Weight from "./pages/Dashboard/pages/Weight/Weight.jsx";
12import WeightTracking from "./pages/Dashboard/pages/Weight/WeightTracking.jsx";
13import NewWeightIntake from "./pages/Dashboard/pages/Weight/NewWeightIntake.jsx";
14import Finance from "./pages/Dashboard/pages/Finance/Finance.jsx";
15import Investing from "./pages/Dashboard/pages/Investing/Investing.jsx";
16import InvestingTracking from "./pages/Dashboard/pages/Investing/InvestingTracking.jsx";
17import NewInvestment from "./pages/Dashboard/pages/Investing/NewInvestment.jsx";
18import Discipline from "./pages/Dashboard/pages/Discipline/Discipline.jsx";
19
20function RequireAuth({ children }) {
21 const token = localStorage.getItem("authToken");
22 if (!token) return <Navigate to="/login" replace />;
23 return children;
24}
25
26function App() {
27 return (
28 <div data-theme="forest" className="min-h-screen w-full">
29 <Routes>
30 <Route path="/" element={<LandingPage />} />
31 <Route path="/login" element={<Login />} />
32 <Route path="/register" element={<Register />} />
33 <Route
34 path="/dashboard"
35 element={
36 <RequireAuth>
37 <DashboardLayout />
38 </RequireAuth>
39 }
40 >
41 <Route index element={<Navigate to="control-center" replace />} />
42 <Route path="control-center" element={<ControlCenter />} />
43 <Route path="training" element={<Training />} />
44 <Route path="training/tracking" element={<TrainingTracking />} />
45 <Route
46 path="training/sessions/new"
47 element={<NewTrainingSession />}
48 />
49 <Route path="weight" element={<Weight />} />
50 <Route path="weight/tracking" element={<WeightTracking />} />
51 <Route path="weight/intakes/new" element={<NewWeightIntake />} />
52 <Route path="finance" element={<Finance />} />
53 <Route path="investing" element={<Investing />} />
54 <Route path="investing/tracking" element={<InvestingTracking />} />
55 <Route path="investing/assets/new" element={<NewInvestment />} />
56 <Route path="discipline" element={<Discipline />} />
57 </Route>
58 <Route path="*" element={<Navigate to="/" replace />} />
59 </Routes>
60 </div>
61 );
62}
63
64export default App;
Note: See TracBrowser for help on using the repository browser.