Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 7371 | Rev 7374 | Ir a la última revisión | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
6601 stevensc 1
import React, { lazy, Suspense, useEffect } from 'react'
2
import { useDispatch, useSelector } from 'react-redux'
7364 stevensc 3
import { BrowserRouter as Router, Switch } from 'react-router-dom'
6490 stevensc 4
import { getLanguage } from '../../redux/intl/intl.action'
6753 stevensc 5
import { getPermissions } from '../redux/auth/auth.actions'
6490 stevensc 6
 
6530 stevensc 7
import PublicRoute from './PublicRoute'
6601 stevensc 8
import PrivateRoute from './PrivateRoute'
6707 stevensc 9
import Spinner from '../components/UI/Spinner'
6512 stevensc 10
import NotificationAlert from '../components/UI/notification/NotificationAlert'
6738 stevensc 11
import LoaderContainer from '../components/UI/LoaderContainer'
7364 stevensc 12
import ChatHelper from '../components/chat/helper/ChatHelper'
6490 stevensc 13
 
6707 stevensc 14
const Header = lazy(() => import('../components/navbar/Header'))
6601 stevensc 15
const Auth = lazy(() => import('../pages/auth/Auth'))
16
const DashboardPage = lazy(() => import('../pages/dashboard/DashboardPage'))
6707 stevensc 17
const MyConnectionsPage = lazy(() =>
6719 stevensc 18
  import('../pages/connections/MyConnectionsPage')
6707 stevensc 19
)
6724 stevensc 20
const InvitationsReceivedPage = lazy(() =>
21
  import('../pages/connections/InvitationsReceivedPage')
22
)
6719 stevensc 23
const InvitationsSendPage = lazy(() =>
6724 stevensc 24
  import('../pages/connections/InvitationsSendPage')
6719 stevensc 25
)
6725 stevensc 26
const PeopleYouMayKnowPage = lazy(() =>
27
  import('../pages/connections/PeopleYouMayKnowPage')
28
)
29
const PeopleBlockedPage = lazy(() =>
30
  import('../pages/connections/PeopleBlockedPage')
31
)
6738 stevensc 32
const MyProfilesPage = lazy(() => import('../pages/profiles/MyProfilesPage'))
33
const PeopleViewedMyProfilePage = lazy(() =>
34
  import('../pages/profiles/PeopleViewedMyProfilePage')
35
)
36
const SavedJobsPage = lazy(() => import('../pages/jobs/SavedJobsPage'))
37
const AppliedJobsPage = lazy(() => import('../pages/jobs/AppliedJobsPage'))
38
const GroupsRequestsSendPage = lazy(() =>
39
  import('../pages/groups/GroupsRequestsSendPage')
40
)
41
const GroupsRequestsReceivedPage = lazy(() =>
42
  import('../pages/groups/GroupsRequestsReceivedPage')
43
)
44
const JoinedGroupsPage = lazy(() => import('../pages/groups/JoinedGroupsPage'))
45
const MyGroupsPage = lazy(() => import('../pages/groups/MyGroupsPage'))
6753 stevensc 46
const MyCompanies = lazy(() => import('../pages/company/MyCompaniesPage'))
47
const FollowingCompaniesPage = lazy(() =>
48
  import('../pages/company/FollowingCompaniesPage')
49
)
50
const CompaniesWhenIWorkPage = lazy(() =>
51
  import('../pages/company/CompaniesWhenIWorkPage')
52
)
53
const CompanyRequestSendPage = lazy(() =>
54
  import('../pages/company/CompanyRequestSendPage')
55
)
56
const CompanyInvitationsReceivedPage = lazy(() =>
57
  import('../pages/company/CompanyInvitationsReceivedPage')
58
)
59
const ProfileViewPage = lazy(() => import('../pages/profiles/ProfileViewPage'))
6805 stevensc 60
const ProfileEditPage = lazy(() => import('../pages/profiles/ProfileEditPage'))
6862 stevensc 61
const CompanyViewPage = lazy(() => import('../pages/company/CompanyViewPage'))
62
const GroupViewPage = lazy(() => import('../pages/groups/GroupViewPage'))
6894 stevensc 63
const GroupEditPage = lazy(() => import('../pages/groups/GroupEditPage'))
6920 stevensc 64
const ChatPage = lazy(() => import('../pages/chat/ChatPage'))
6957 stevensc 65
const InmailPage = lazy(() => import('../pages/inmail/InmailPage'))
6993 stevensc 66
const MarketPlacePage = lazy(() =>
67
  import('../pages/marketplace/MarketplacePage')
68
)
7114 stevensc 69
const NotificationsPage = lazy(() =>
70
  import('../pages/notifications/NotificationsPage')
71
)
72
const SearchPage = lazy(() => import('../pages/search/SearchPage'))
73
const KnowledgeAreaPage = lazy(() =>
74
  import('../pages/knowledge-area/KnowledgeAreaPage')
75
)
76
const KnowledgeViewPage = lazy(() =>
77
  import('../pages/knowledge-area/KnowledgeViewPage')
78
)
7268 stevensc 79
const PostViewPage = lazy(() => import('../pages/posts/PostViewPage'))
80
const MyCoachPage = lazy(() => import('../pages/my-coach/MyCoachPage'))
81
const MyCoachViewPage = lazy(() => import('../pages/my-coach/MyCoachViewPage'))
82
const JobViewPage = lazy(() => import('../pages/jobs/JobView'))
7350 stevensc 83
const CalendarPage = lazy(() => import('../pages/calendar/CalendarPage'))
6490 stevensc 84
 
85
const AppRouter = () => {
7371 stevensc 86
  const { theme_id, isAuth, loading } = useSelector(({ auth }) => auth)
6490 stevensc 87
  const dispatch = useDispatch()
88
 
89
  useEffect(() => {
6745 stevensc 90
    dispatch(getPermissions())
6490 stevensc 91
    dispatch(getLanguage())
92
  }, [])
93
 
7371 stevensc 94
  if (loading) {
95
    return (
96
      <LoaderContainer>
97
        <Spinner />
98
      </LoaderContainer>
99
    )
100
  }
101
 
6490 stevensc 102
  return (
103
    <Router>
6753 stevensc 104
      <Suspense fallback={null}>
7373 stevensc 105
        {isAuth ? <Header theme={theme_id} /> : null}
6753 stevensc 106
      </Suspense>
6724 stevensc 107
 
6707 stevensc 108
      <Suspense
109
        fallback={
6738 stevensc 110
          <LoaderContainer>
6707 stevensc 111
            <Spinner />
6738 stevensc 112
          </LoaderContainer>
6707 stevensc 113
        }
114
      >
115
        <Switch>
6601 stevensc 116
          <PrivateRoute exact path="/dashboard" isAuthenticated={isAuth}>
117
            <DashboardPage />
118
          </PrivateRoute>
6738 stevensc 119
 
6994 stevensc 120
          <PrivateRoute
121
            exact
122
            path="/connection/my-connections"
123
            isAuthenticated={isAuth}
124
          >
125
            <MyConnectionsPage />
6707 stevensc 126
          </PrivateRoute>
6719 stevensc 127
          <PrivateRoute
128
            exact
6994 stevensc 129
            path="/connection/invitations-sent"
130
            isAuthenticated={isAuth}
131
          >
132
            <InvitationsSendPage />
133
          </PrivateRoute>
134
          <PrivateRoute
135
            exact
6724 stevensc 136
            path="/connection/invitations-received"
137
            isAuthenticated={isAuth}
138
          >
139
            <InvitationsReceivedPage />
140
          </PrivateRoute>
6725 stevensc 141
          <PrivateRoute
142
            exact
143
            path="/connection/people-you-may-know"
144
            isAuthenticated={isAuth}
145
          >
146
            <PeopleYouMayKnowPage />
147
          </PrivateRoute>
148
          <PrivateRoute
149
            exact
6726 stevensc 150
            path="/connection/people-blocked"
6725 stevensc 151
            isAuthenticated={isAuth}
152
          >
153
            <PeopleBlockedPage />
154
          </PrivateRoute>
6738 stevensc 155
 
6727 stevensc 156
          <PrivateRoute
157
            exact
158
            path="/profile/my-profiles"
159
            isAuthenticated={isAuth}
160
          >
161
            <MyProfilesPage />
162
          </PrivateRoute>
163
          <PrivateRoute
164
            exact
165
            path="/profile/people-viewed-profile"
166
            isAuthenticated={isAuth}
167
          >
168
            <PeopleViewedMyProfilePage />
169
          </PrivateRoute>
6862 stevensc 170
          <PrivateRoute path="/profile/view/:uuid" isAuthenticated={isAuth}>
171
            <ProfileViewPage />
172
          </PrivateRoute>
173
          <PrivateRoute
174
            path="/profile/my-profiles/edit/:uuid"
175
            isAuthenticated={isAuth}
176
          >
177
            <ProfileEditPage />
178
          </PrivateRoute>
6738 stevensc 179
 
6727 stevensc 180
          <PrivateRoute exact path="/job/saved-jobs" isAuthenticated={isAuth}>
181
            <SavedJobsPage />
182
          </PrivateRoute>
183
          <PrivateRoute exact path="/job/applied-jobs" isAuthenticated={isAuth}>
6729 stevensc 184
            <AppliedJobsPage />
6727 stevensc 185
          </PrivateRoute>
6601 stevensc 186
 
6738 stevensc 187
          <PrivateRoute
188
            exact
6740 stevensc 189
            path="/group/requests-sent"
6738 stevensc 190
            isAuthenticated={isAuth}
191
          >
192
            <GroupsRequestsSendPage />
193
          </PrivateRoute>
194
          <PrivateRoute
195
            exact
196
            path="/group/invitations-received"
197
            isAuthenticated={isAuth}
198
          >
199
            <GroupsRequestsReceivedPage />
200
          </PrivateRoute>
201
          <PrivateRoute
202
            exact
203
            path="/group/joined-groups"
204
            isAuthenticated={isAuth}
205
          >
206
            <JoinedGroupsPage />
207
          </PrivateRoute>
208
          <PrivateRoute exact path="/group/my-groups" isAuthenticated={isAuth}>
209
            <MyGroupsPage />
210
          </PrivateRoute>
6862 stevensc 211
          <PrivateRoute path="/group/view/:uuid" isAuthenticated={isAuth}>
212
            <GroupViewPage />
213
          </PrivateRoute>
6894 stevensc 214
          <PrivateRoute
6895 stevensc 215
            path="/group/my-groups/edit/:uuid"
6894 stevensc 216
            isAuthenticated={isAuth}
217
          >
218
            <GroupEditPage />
219
          </PrivateRoute>
6738 stevensc 220
 
6753 stevensc 221
          <PrivateRoute
222
            exact
223
            path="/company/my-companies"
224
            isAuthenticated={isAuth}
225
          >
226
            <MyCompanies />
227
          </PrivateRoute>
228
          <PrivateRoute
229
            exact
230
            path="/company/following-companies"
231
            isAuthenticated={isAuth}
232
          >
233
            <FollowingCompaniesPage />
234
          </PrivateRoute>
235
          <PrivateRoute
236
            exact
237
            path="/company/i-work-with"
238
            isAuthenticated={isAuth}
239
          >
240
            <CompaniesWhenIWorkPage />
241
          </PrivateRoute>
242
          <PrivateRoute
243
            exact
244
            path="/company/requests-sent"
245
            isAuthenticated={isAuth}
246
          >
247
            <CompanyRequestSendPage />
248
          </PrivateRoute>
249
          <PrivateRoute
250
            exact
251
            path="/company/requests-sent"
252
            isAuthenticated={isAuth}
253
          >
254
            <CompanyRequestSendPage />
255
          </PrivateRoute>
256
          <PrivateRoute
257
            exact
258
            path="/company/invitations-received"
259
            isAuthenticated={isAuth}
260
          >
261
            <CompanyInvitationsReceivedPage />
262
          </PrivateRoute>
6830 stevensc 263
          <PrivateRoute path="/company/view/:uuid" isAuthenticated={isAuth}>
264
            <CompanyViewPage />
265
          </PrivateRoute>
266
 
6911 stevensc 267
          <PrivateRoute path="/chat" isAuthenticated={isAuth}>
268
            <ChatPage />
269
          </PrivateRoute>
6983 stevensc 270
          <PrivateRoute path="/inmail/:uuid" isAuthenticated={isAuth}>
6970 stevensc 271
            <InmailPage />
272
          </PrivateRoute>
6983 stevensc 273
          <PrivateRoute path="/inmail" isAuthenticated={isAuth}>
6947 stevensc 274
            <InmailPage />
275
          </PrivateRoute>
6911 stevensc 276
 
6993 stevensc 277
          <PrivateRoute path="/marketplace" isAuthenticated={isAuth}>
278
            <MarketPlacePage />
279
          </PrivateRoute>
6999 stevensc 280
          <PrivateRoute path="/notifications" isAuthenticated={isAuth}>
281
            <NotificationsPage />
282
          </PrivateRoute>
7000 stevensc 283
          <PrivateRoute path="/search" isAuthenticated={isAuth}>
7001 stevensc 284
            <SearchPage />
7000 stevensc 285
          </PrivateRoute>
6993 stevensc 286
 
7062 stevensc 287
          <PrivateRoute
288
            path="/knowledge-area/view/:uuid"
289
            isAuthenticated={isAuth}
290
          >
291
            <KnowledgeViewPage />
292
          </PrivateRoute>
7015 stevensc 293
          <PrivateRoute path="/knowledge-area" isAuthenticated={isAuth}>
294
            <KnowledgeAreaPage />
295
          </PrivateRoute>
296
 
7268 stevensc 297
          <PrivateRoute path="/job/view/:uuid" isAuthenticated={isAuth}>
298
            <JobViewPage />
299
          </PrivateRoute>
300
 
7129 stevensc 301
          <PrivateRoute path="/post/:uuid" isAuthenticated={isAuth}>
302
            <PostViewPage />
303
          </PrivateRoute>
304
 
7279 stevensc 305
          <PrivateRoute path="/calendar" isAuthenticated={isAuth}>
306
            <CalendarPage />
307
          </PrivateRoute>
308
 
7173 stevensc 309
          <PrivateRoute
310
            path="/my-coach/questions/view/:uuid"
311
            isAuthenticated={isAuth}
312
          >
7210 stevensc 313
            <MyCoachViewPage />
7156 stevensc 314
          </PrivateRoute>
7173 stevensc 315
          <PrivateRoute exact path="/my-coach" isAuthenticated={isAuth}>
316
            <MyCoachPage />
317
          </PrivateRoute>
7347 stevensc 318
 
319
          <PublicRoute path="/" isAuthenticated={isAuth}>
320
            <Auth />
321
          </PublicRoute>
7362 stevensc 322
 
323
          <PublicRoute path="*" isAuthenticated={isAuth}>
324
            <h1>404 Not found</h1>
325
          </PublicRoute>
6707 stevensc 326
        </Switch>
327
      </Suspense>
6512 stevensc 328
 
329
      <NotificationAlert />
7319 stevensc 330
      {isAuth && <ChatHelper />}
6490 stevensc 331
    </Router>
332
  )
333
}
334
 
335
export default AppRouter