|
1 | 1 | /* eslint-disable react/no-array-index-key */
|
2 |
| -import React, { lazy, Suspense, Fragment } from 'react'; |
3 |
| -import { Switch, Redirect, Route } from 'react-router-dom'; |
| 2 | +import React, { Suspense } from 'react'; |
| 3 | +import { Switch, Route } from 'react-router-dom'; |
4 | 4 | import MainLayout from 'src/layouts/MainLayout';
|
5 |
| -import DocsLayout from 'src/layouts/DocsLayout'; |
6 | 5 | import HomeView from 'src/views/pages/HomeView';
|
7 | 6 | import CAView from 'src/views/pages/CLView';
|
8 | 7 | import EventsView from 'src/views/pages/EventsView';
|
9 | 8 | import LoadingScreen from 'src/components/LoadingScreen';
|
10 | 9 | import Courses from 'src/views/pages/Courses';
|
11 |
| -import ProfileView from 'src/views/pages/ProfileView' |
12 |
| -import ApplicationsView from 'src/views/pages/ApplicationsView' |
| 10 | +import CoursesView from 'src/views/pages/CoursesView'; |
| 11 | +import ProfileView from 'src/views/pages/ProfileView'; |
| 12 | +import ApplicationsView from 'src/views/pages/ApplicationsView'; |
13 | 13 |
|
14 |
| -const routesConfig = [ |
15 |
| - { |
16 |
| - exact: true, |
17 |
| - path: '/', |
18 |
| - component: () => <Redirect to="/home" /> |
19 |
| - }, |
20 |
| - { |
21 |
| - exact: true, |
22 |
| - path: '/404', |
23 |
| - component: lazy(() => import('src/views/pages/Error404View')) |
24 |
| - }, |
25 |
| - { |
26 |
| - path: '/privacy', |
27 |
| - layout: DocsLayout, |
28 |
| - routes: [ |
29 |
| - { |
30 |
| - exact: true, |
31 |
| - path: '/privacy', |
32 |
| - component: lazy(() => import('src/views/pages/documents/privacyView')) |
33 |
| - } |
34 |
| - ] |
35 |
| - }, |
36 |
| - { |
37 |
| - path: '/terms', |
38 |
| - layout: DocsLayout, |
39 |
| - routes: [ |
40 |
| - { |
41 |
| - exact: true, |
42 |
| - path: '/terms', |
43 |
| - component: lazy(() => import('src/views/pages/documents/termsView')) |
44 |
| - }, |
45 |
| - { |
46 |
| - component: () => <Redirect to="/404" /> |
47 |
| - } |
48 |
| - ] |
49 |
| - }, |
50 |
| - { |
51 |
| - path: '/refundpolicies', |
52 |
| - layout: DocsLayout, |
53 |
| - routes: [ |
54 |
| - { |
55 |
| - exact: true, |
56 |
| - path: '/refundpolicies', |
57 |
| - component: lazy(() => import('src/views/pages/documents/refundView')) |
58 |
| - }, |
59 |
| - { |
60 |
| - component: () => <Redirect to="/404" /> |
61 |
| - } |
62 |
| - ] |
63 |
| - }, |
64 |
| - { |
65 |
| - path: '/campusLeaders', |
66 |
| - layout: MainLayout, |
67 |
| - routes: [ |
68 |
| - { |
69 |
| - exact: true, |
70 |
| - path: '/campusLeaders', |
71 |
| - component: CAView |
72 |
| - }, |
73 |
| - { |
74 |
| - component: () => <Redirect to="/404" /> |
75 |
| - } |
76 |
| - ] |
77 |
| - }, |
78 |
| - { |
79 |
| - path: '/events', |
80 |
| - layout: MainLayout, |
81 |
| - routes: [ |
82 |
| - { |
83 |
| - exact: true, |
84 |
| - path: '/events', |
85 |
| - component: EventsView |
86 |
| - }, |
87 |
| - { |
88 |
| - component: () => <Redirect to="/404" /> |
89 |
| - } |
90 |
| - ] |
91 |
| - }, |
92 |
| - { |
93 |
| - path: '/courses', |
94 |
| - layout: MainLayout, |
95 |
| - routes: [ |
96 |
| - { |
97 |
| - path: '/courses', |
98 |
| - component: Courses |
99 |
| - }, |
100 |
| - { |
101 |
| - component: () => <Redirect to="/404" /> |
102 |
| - } |
103 |
| - ] |
104 |
| - }, |
105 |
| - { |
106 |
| - path: '/profile', |
107 |
| - layout: MainLayout, |
108 |
| - routes: [ |
109 |
| - { |
110 |
| - exact: true, |
111 |
| - path: '/profile', |
112 |
| - component: ProfileView |
113 |
| - }, |
114 |
| - { |
115 |
| - component: () => <Redirect to="/404" /> |
116 |
| - } |
117 |
| - ] |
118 |
| - }, |
119 |
| - { |
120 |
| - path: '/applications', |
121 |
| - layout: MainLayout, |
122 |
| - routes: [ |
123 |
| - { |
124 |
| - path: '/applications', |
125 |
| - component: ApplicationsView |
126 |
| - }, |
127 |
| - { |
128 |
| - component: () => <Redirect to="/404" /> |
129 |
| - } |
130 |
| - ] |
131 |
| - }, |
| 14 | +const renderRoutes = () => |
132 | 15 |
|
133 |
| - { |
134 |
| - path: '*', |
135 |
| - layout: MainLayout, |
136 |
| - routes: [ |
137 |
| - { |
138 |
| - exact: true, |
139 |
| - path: '/home', |
140 |
| - component: HomeView |
141 |
| - }, |
142 |
| - { |
143 |
| - component: () => <Redirect to="/404" /> |
144 |
| - } |
145 |
| - ] |
146 |
| - } |
147 |
| -]; |
148 |
| - |
149 |
| -const renderRoutes = routes => |
150 |
| - routes ? ( |
151 | 16 | <Suspense fallback={<LoadingScreen />}>
|
152 | 17 | <Switch>
|
153 |
| - {routes.map((route, i) => { |
154 |
| - const Guard = route.guard || Fragment; |
155 |
| - const Layout = route.layout || Fragment; |
156 |
| - const Component = route.component; |
| 18 | + <Route |
| 19 | + path="/" |
| 20 | + exact |
| 21 | + render={props => ( |
| 22 | + <MainLayout> |
| 23 | + <HomeView {...props} /> |
| 24 | + </MainLayout> |
| 25 | + )} |
| 26 | + /> |
| 27 | + |
| 28 | + <Route |
| 29 | + path="/applications" |
| 30 | + exact |
| 31 | + render={props => ( |
| 32 | + <MainLayout> |
| 33 | + <ApplicationsView {...props} /> |
| 34 | + </MainLayout> |
| 35 | + )} |
| 36 | + /> |
| 37 | + |
| 38 | + <Route |
| 39 | + path="/events" |
| 40 | + exact |
| 41 | + render={props => ( |
| 42 | + <MainLayout> |
| 43 | + <EventsView {...props} /> |
| 44 | + </MainLayout> |
| 45 | + )} |
| 46 | + /> |
| 47 | + |
| 48 | + <Route |
| 49 | + path="/profile" |
| 50 | + exact |
| 51 | + render={props => ( |
| 52 | + <MainLayout> |
| 53 | + <ProfileView {...props} /> |
| 54 | + </MainLayout> |
| 55 | + )} |
| 56 | + /> |
| 57 | + |
| 58 | + <Route |
| 59 | + path="/courses" |
| 60 | + render={props => ( |
| 61 | + <MainLayout> |
| 62 | + <Courses {...props} /> |
| 63 | + </MainLayout> |
| 64 | + )} |
| 65 | + /> |
157 | 66 |
|
158 |
| - return ( |
159 |
| - <Route |
160 |
| - key={i} |
161 |
| - path={route.path} |
162 |
| - exact={route.exact} |
163 |
| - render={props => ( |
164 |
| - <Guard> |
165 |
| - <Layout> |
166 |
| - {route.routes ? ( |
167 |
| - renderRoutes(route.routes) |
168 |
| - ) : ( |
169 |
| - <Component {...props} /> |
170 |
| - )} |
171 |
| - </Layout> |
172 |
| - </Guard> |
173 |
| - )} |
174 |
| - /> |
175 |
| - ); |
176 |
| - })} |
| 67 | + <Route |
| 68 | + path="/gallary" |
| 69 | + render={props => ( |
| 70 | + <MainLayout> |
| 71 | + <CoursesView {...props} /> |
| 72 | + </MainLayout> |
| 73 | + )} |
| 74 | + /> |
| 75 | + <Route |
| 76 | + path="/campusLeaders" |
| 77 | + exact |
| 78 | + render={props => ( |
| 79 | + <MainLayout> |
| 80 | + <CAView {...props} /> |
| 81 | + </MainLayout> |
| 82 | + )} |
| 83 | + /> |
177 | 84 | </Switch>
|
178 | 85 | </Suspense>
|
179 |
| - ) : null; |
180 | 86 |
|
181 | 87 | function Routes() {
|
182 |
| - return renderRoutes(routesConfig); |
| 88 | + return renderRoutes({}); |
183 | 89 | }
|
184 | 90 |
|
185 | 91 | export default Routes;
|
0 commit comments