source: frontend/src/App.jsx@ 4f85b41

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

Daily discipline feature done

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