| 1 | import { Navigate, Route, Routes } from "react-router-dom";
|
|---|
| 2 |
|
|---|
| 3 | import LandingPage from "./pages/LandingPage/LandingPage.jsx";
|
|---|
| 4 | import Login from "./pages/Login/Login.jsx";
|
|---|
| 5 | import Register from "./pages/Register/Register.jsx";
|
|---|
| 6 | import DashboardLayout from "./pages/Dashboard/DashboardLayout.jsx";
|
|---|
| 7 | import ControlCenter from "./pages/Dashboard/pages/ControlCenter/ControlCenter.jsx";
|
|---|
| 8 | import Training from "./pages/Dashboard/pages/Training/Training.jsx";
|
|---|
| 9 | import TrainingTracking from "./pages/Dashboard/pages/Training/TrainingTracking.jsx";
|
|---|
| 10 | import NewTrainingSession from "./pages/Dashboard/pages/Training/NewTrainingSession.jsx";
|
|---|
| 11 | import Weight from "./pages/Dashboard/pages/Weight/Weight.jsx";
|
|---|
| 12 | import WeightTracking from "./pages/Dashboard/pages/Weight/WeightTracking.jsx";
|
|---|
| 13 | import NewWeightIntake from "./pages/Dashboard/pages/Weight/NewWeightIntake.jsx";
|
|---|
| 14 | import Finance from "./pages/Dashboard/pages/Finance/Finance.jsx";
|
|---|
| 15 | import FinanceTracking from "./pages/Dashboard/pages/Finance/FinanceTracking.jsx";
|
|---|
| 16 | import NewIncome from "./pages/Dashboard/pages/Finance/NewIncome.jsx";
|
|---|
| 17 | import Investing from "./pages/Dashboard/pages/Investing/Investing.jsx";
|
|---|
| 18 | import InvestingTracking from "./pages/Dashboard/pages/Investing/InvestingTracking.jsx";
|
|---|
| 19 | import NewInvestment from "./pages/Dashboard/pages/Investing/NewInvestment.jsx";
|
|---|
| 20 | import Discipline from "./pages/Dashboard/pages/Discipline/Discipline.jsx";
|
|---|
| 21 | import DisciplineTracking from "./pages/Dashboard/pages/Discipline/DisciplineTracking.jsx";
|
|---|
| 22 |
|
|---|
| 23 | function RequireAuth({ children }) {
|
|---|
| 24 | const token = localStorage.getItem("authToken");
|
|---|
| 25 | if (!token) return <Navigate to="/login" replace />;
|
|---|
| 26 | return children;
|
|---|
| 27 | }
|
|---|
| 28 |
|
|---|
| 29 | function 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 |
|
|---|
| 70 | export default App;
|
|---|