diff --git a/client/src/App.jsx b/client/src/App.jsx index baeaf18..05b62b2 100644 --- a/client/src/App.jsx +++ b/client/src/App.jsx @@ -1,56 +1,61 @@ -import { Route, Routes, Navigate } from "react-router-dom"; -import { AuthProvider } from "./Context/AuthContext.jsx"; -import { ThemeProvider } from "./Context/ThemeContext.jsx"; -import { ProtectedRoute } from "./routes/ProtectedRoute.jsx"; +// client/src/App.jsx +import React, { lazy, Suspense } from "react"; +import { BrowserRouter as Router, Routes, Route } from "react-router-dom"; -import { Landing } from "./pages/Landing.jsx"; -import { AuthPage } from "./pages/AuthPage.jsx"; -import { AppLayout } from "./pages/app/AppLayout.jsx"; -import { DashboardHome } from "./pages/app/DashboardHome.jsx"; -import { EventsPage } from "./pages/app/EventsPage.jsx"; -import { TasksPage } from "./pages/app/TasksPage.jsx"; -import { ShopPage } from "./pages/app/ShopPage.jsx"; -import { LeaderboardPage } from "./pages/app/LeaderboardPage.jsx"; -import { PointsPage } from "./pages/app/PointsPage.jsx"; -import { ProfilePage } from "./pages/app/ProfilePage.jsx"; -import { ModerationPage } from "./pages/app/ModerationPage.jsx"; -import { UsersPage } from "./pages/app/UsersPage.jsx"; -import { NewsletterPage } from "./pages/app/NewsletterPage.jsx"; +import Navbar from "./components/Navbar"; +import Footer from "./components/Footer"; +import ScrollToTop from "./components/ScrollToTop"; +import Home from "./components/Home"; +import ProtectedRoute from "./routes/ProtectedRoute"; +import { AuthProvider } from "./Context/AuthContext"; +import LoadingSpinner from "./components/LoadingSpinner"; -export default function App() { - return ( - - - - {/* Public */} - } /> - } /> +// ✅ Lazy-loaded route components +const Dashboard = lazy(() => import("./pages/Dashboard")); +const Profile = lazy(() => import("./pages/Profile")); +const AuthForms = lazy(() => import("./pages/AuthForms")); +const About = lazy(() => import("./pages/About")); +const Contact = lazy(() => import("./pages/Contact")); - {/* Legacy redirect: /dashboard → /app */} - } /> +function App() { + return ( + + + + - {/* Protected App */} - }> - }> - } /> - } /> - } /> - } /> - } /> - } /> - } /> - {/* Moderator+ */} - } /> - {/* Admin / Organisation */} - } /> - } /> - - + {/* ✅ Wrap all Routes in Suspense with fallback */} + }> + + } /> + } /> + } /> + } /> - {/* 404 fallback */} - } /> - - - - ); + {/* Protected routes */} + + + + } + /> + + + + } + /> + + + +