|
1 | | - |
2 | | -import { Routes, Route, useLocation, matchRoutes } from 'react-router-dom'; |
| 1 | +import { Routes, Route, useLocation, matchRoutes } from "react-router-dom"; |
3 | 2 | import { Suspense, lazy } from "react"; |
4 | | -import Loading from './utils/Global-Loading/Loading'; |
5 | | -import useRouteProgress from './hooks/useRouteProgress.js'; |
6 | | -import './styles/nprogress-custom.css'; |
7 | | -const LandingPage = lazy(() => import('./pages/landingPage/LandingPage')); |
8 | | -const Home = lazy(() => import('./pages/Home')); |
9 | | -const Branch = lazy(() => import('./pages/Branch')); |
10 | | -const Semester = lazy(() => import('./pages/Semester')); |
11 | | -const Subject = lazy(() => import('./pages/Subject')); |
12 | | -const AdminDashboard = lazy(() => import('./pages/AdminDashboard')); |
13 | | -const NotFound = lazy(() => import('./pages/404/NotFound')); |
14 | | -const LoginPage = lazy(() => import('./pages/Login/Login')); |
15 | | -const SignUp = lazy(() => import('./pages/SignUp/SignUp')); |
| 3 | +import Loading from "./utils/Global-Loading/Loading"; |
| 4 | +import useRouteProgress from "./hooks/useRouteProgress.js"; |
| 5 | +import "./styles/nprogress-custom.css"; |
| 6 | +const LandingPage = lazy(() => import("./pages/landingPage/LandingPage")); |
| 7 | +const Home = lazy(() => import("./pages/Home/Home.jsx")); |
| 8 | +const Branch = lazy(() => import("./pages/Branch")); |
| 9 | +const Semester = lazy(() => import("./pages/Semester")); |
| 10 | +const Subject = lazy(() => import("./pages/Subject")); |
| 11 | +const AdminDashboard = lazy(() => import("./pages/AdminDashboard")); |
| 12 | +const NotFound = lazy(() => import("./pages/404/NotFound")); |
| 13 | +const LoginPage = lazy(() => import("./pages/Login/Login")); |
| 14 | +const SignUp = lazy(() => import("./pages/SignUp/SignUp")); |
16 | 15 |
|
17 | | -import Header from './components/Header/Header'; |
18 | | -import Footer from './components/Footer/Footer'; |
| 16 | +import Header from "./components/Header/Header"; |
| 17 | +import Footer from "./components/Footer/Footer"; |
19 | 18 | const routes = [ |
20 | | - { path: '/' }, |
21 | | - { path: '/home' }, |
22 | | - { path: '/branch/:branchId' }, |
23 | | - { path: '/branch/:branchId/semester/:semesterId' }, |
24 | | - { path: '/branch/:branchId/semester/:semesterId/subject/:subjectId' }, |
25 | | - { path: '/admin' }, |
26 | | - { path: '/login' }, |
27 | | - { path: '/signup' } |
| 19 | + { path: "/" }, |
| 20 | + { path: "/home" }, |
| 21 | + { path: "/branch/:branchId" }, |
| 22 | + { path: "/branch/:branchId/semester/:semesterId" }, |
| 23 | + { path: "/branch/:branchId/semester/:semesterId/subject/:subjectId" }, |
| 24 | + { path: "/admin" }, |
| 25 | + { path: "/login" }, |
| 26 | + { path: "/signup" }, |
28 | 27 | ]; |
29 | 28 |
|
30 | 29 | export default function App() { |
31 | | - |
32 | | - const location = useLocation(); |
33 | | - const matched = matchRoutes(routes, location.pathname); |
34 | | - const is404 = !matched; |
35 | | - |
36 | | - useRouteProgress(); |
| 30 | + const location = useLocation(); |
| 31 | + const matched = matchRoutes(routes, location.pathname); |
| 32 | + const is404 = !matched; |
| 33 | + |
| 34 | + useRouteProgress(); |
37 | 35 |
|
38 | | - return ( |
39 | | - <> |
40 | | - {!is404 && <Header />} |
41 | | - <main className="main-content"> |
42 | | - <Suspense fallback={<Loading />}> |
43 | | - <Routes> |
44 | | - <Route path="/home" element={<Home />} /> |
45 | | - <Route path="/" element={<LandingPage />} /> |
46 | | - <Route path="/branch/:branchId" element={<Branch />} /> |
47 | | - <Route path="/branch/:branchId/semester/:semesterId" element={<Semester />} /> |
48 | | - <Route path="/branch/:branchId/semester/:semesterId/subject/:subjectId" element={<Subject />} /> |
49 | | - <Route path="/admin" element={<AdminDashboard />} /> |
50 | | - <Route path="/login" element={<LoginPage />} /> |
51 | | - <Route path="/signup" element={<SignUp />} /> |
52 | | - <Route path="*" element={<NotFound />}/> |
53 | | - </Routes> |
54 | | - </Suspense> |
55 | | - </main> |
56 | | - {!is404 && <Footer />} |
57 | | - </> |
58 | | - ); |
| 36 | + return ( |
| 37 | + <> |
| 38 | + {!is404 && <Header />} |
| 39 | + <main className="main-content"> |
| 40 | + <Suspense fallback={<Loading />}> |
| 41 | + <Routes> |
| 42 | + <Route path="/home" element={<Home />} /> |
| 43 | + <Route path="/" element={<LandingPage />} /> |
| 44 | + <Route path="/branch/:branchId" element={<Branch />} /> |
| 45 | + <Route |
| 46 | + path="/branch/:branchId/semester/:semesterId" |
| 47 | + element={<Semester />} |
| 48 | + /> |
| 49 | + <Route |
| 50 | + path="/branch/:branchId/semester/:semesterId/subject/:subjectId" |
| 51 | + element={<Subject />} |
| 52 | + /> |
| 53 | + <Route path="/admin" element={<AdminDashboard />} /> |
| 54 | + <Route path="/login" element={<LoginPage />} /> |
| 55 | + <Route path="/signup" element={<SignUp />} /> |
| 56 | + <Route path="*" element={<NotFound />} /> |
| 57 | + </Routes> |
| 58 | + </Suspense> |
| 59 | + </main> |
| 60 | + {!is404 && <Footer />} |
| 61 | + </> |
| 62 | + ); |
59 | 63 | } |
0 commit comments