Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 7378 | | 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'
7382 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
 
7375 stevensc 7
import AuthRoute from './AuthRoute'
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'
6490 stevensc 12
 
7382 stevensc 13
import ChatHelper from '../components/chat/helper/ChatHelper'
14
import Header from '../components/navbar/Header'
15
 
6601 stevensc 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'))
7375 stevensc 84
const SigninPage = lazy(() => import('../pages/auth/SigninPage'))
7378 stevensc 85
const ImpersonatePage = lazy(() =>
86
  import('../pages/impersonate/InpersonatePage')
87
)
6490 stevensc 88
 
89
const AppRouter = () => {
7371 stevensc 90
  const { theme_id, isAuth, loading } = useSelector(({ auth }) => auth)
6490 stevensc 91
  const dispatch = useDispatch()
92
 
93
  useEffect(() => {
6745 stevensc 94
    dispatch(getPermissions())
6490 stevensc 95
    dispatch(getLanguage())
96
  }, [])
97
 
7371 stevensc 98
  if (loading) {
99
    return (
100
      <LoaderContainer>
101
        <Spinner />
102
      </LoaderContainer>
103
    )
104
  }
105
 
6490 stevensc 106
  return (
107
    <Router>
7382 stevensc 108
      {isAuth ? <Header theme={theme_id} /> : null}
6724 stevensc 109
 
6707 stevensc 110
      <Suspense
111
        fallback={
6738 stevensc 112
          <LoaderContainer>
6707 stevensc 113
            <Spinner />
6738 stevensc 114
          </LoaderContainer>
6707 stevensc 115
        }
116
      >
117
        <Switch>
6601 stevensc 118
          <PrivateRoute exact path="/dashboard" isAuthenticated={isAuth}>
119
            <DashboardPage />
120
          </PrivateRoute>
6994 stevensc 121
          <PrivateRoute
122
            exact
123
            path="/connection/my-connections"
124
            isAuthenticated={isAuth}
125
          >
126
            <MyConnectionsPage />
6707 stevensc 127
          </PrivateRoute>
6719 stevensc 128
          <PrivateRoute
129
            exact
6994 stevensc 130
            path="/connection/invitations-sent"
131
            isAuthenticated={isAuth}
132
          >
133
            <InvitationsSendPage />
134
          </PrivateRoute>
135
          <PrivateRoute
136
            exact
6724 stevensc 137
            path="/connection/invitations-received"
138
            isAuthenticated={isAuth}
139
          >
140
            <InvitationsReceivedPage />
141
          </PrivateRoute>
6725 stevensc 142
          <PrivateRoute
143
            exact
144
            path="/connection/people-you-may-know"
145
            isAuthenticated={isAuth}
146
          >
147
            <PeopleYouMayKnowPage />
148
          </PrivateRoute>
149
          <PrivateRoute
150
            exact
6726 stevensc 151
            path="/connection/people-blocked"
6725 stevensc 152
            isAuthenticated={isAuth}
153
          >
154
            <PeopleBlockedPage />
155
          </PrivateRoute>
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>
6727 stevensc 179
          <PrivateRoute exact path="/job/saved-jobs" isAuthenticated={isAuth}>
180
            <SavedJobsPage />
181
          </PrivateRoute>
182
          <PrivateRoute exact path="/job/applied-jobs" isAuthenticated={isAuth}>
6729 stevensc 183
            <AppliedJobsPage />
6727 stevensc 184
          </PrivateRoute>
6738 stevensc 185
          <PrivateRoute
186
            exact
6740 stevensc 187
            path="/group/requests-sent"
6738 stevensc 188
            isAuthenticated={isAuth}
189
          >
190
            <GroupsRequestsSendPage />
191
          </PrivateRoute>
192
          <PrivateRoute
193
            exact
194
            path="/group/invitations-received"
195
            isAuthenticated={isAuth}
196
          >
197
            <GroupsRequestsReceivedPage />
198
          </PrivateRoute>
199
          <PrivateRoute
200
            exact
201
            path="/group/joined-groups"
202
            isAuthenticated={isAuth}
203
          >
204
            <JoinedGroupsPage />
205
          </PrivateRoute>
206
          <PrivateRoute exact path="/group/my-groups" isAuthenticated={isAuth}>
207
            <MyGroupsPage />
208
          </PrivateRoute>
6862 stevensc 209
          <PrivateRoute path="/group/view/:uuid" isAuthenticated={isAuth}>
210
            <GroupViewPage />
211
          </PrivateRoute>
6894 stevensc 212
          <PrivateRoute
6895 stevensc 213
            path="/group/my-groups/edit/:uuid"
6894 stevensc 214
            isAuthenticated={isAuth}
215
          >
216
            <GroupEditPage />
217
          </PrivateRoute>
6753 stevensc 218
          <PrivateRoute
219
            exact
220
            path="/company/my-companies"
221
            isAuthenticated={isAuth}
222
          >
223
            <MyCompanies />
224
          </PrivateRoute>
225
          <PrivateRoute
226
            exact
227
            path="/company/following-companies"
228
            isAuthenticated={isAuth}
229
          >
230
            <FollowingCompaniesPage />
231
          </PrivateRoute>
232
          <PrivateRoute
233
            exact
234
            path="/company/i-work-with"
235
            isAuthenticated={isAuth}
236
          >
237
            <CompaniesWhenIWorkPage />
238
          </PrivateRoute>
239
          <PrivateRoute
240
            exact
241
            path="/company/requests-sent"
242
            isAuthenticated={isAuth}
243
          >
244
            <CompanyRequestSendPage />
245
          </PrivateRoute>
246
          <PrivateRoute
247
            exact
248
            path="/company/requests-sent"
249
            isAuthenticated={isAuth}
250
          >
251
            <CompanyRequestSendPage />
252
          </PrivateRoute>
253
          <PrivateRoute
254
            exact
255
            path="/company/invitations-received"
256
            isAuthenticated={isAuth}
257
          >
258
            <CompanyInvitationsReceivedPage />
259
          </PrivateRoute>
6830 stevensc 260
          <PrivateRoute path="/company/view/:uuid" isAuthenticated={isAuth}>
261
            <CompanyViewPage />
262
          </PrivateRoute>
6911 stevensc 263
          <PrivateRoute path="/chat" isAuthenticated={isAuth}>
264
            <ChatPage />
265
          </PrivateRoute>
6983 stevensc 266
          <PrivateRoute path="/inmail/:uuid" isAuthenticated={isAuth}>
6970 stevensc 267
            <InmailPage />
268
          </PrivateRoute>
6983 stevensc 269
          <PrivateRoute path="/inmail" isAuthenticated={isAuth}>
6947 stevensc 270
            <InmailPage />
271
          </PrivateRoute>
6993 stevensc 272
          <PrivateRoute path="/marketplace" isAuthenticated={isAuth}>
273
            <MarketPlacePage />
274
          </PrivateRoute>
6999 stevensc 275
          <PrivateRoute path="/notifications" isAuthenticated={isAuth}>
276
            <NotificationsPage />
277
          </PrivateRoute>
7000 stevensc 278
          <PrivateRoute path="/search" isAuthenticated={isAuth}>
7001 stevensc 279
            <SearchPage />
7000 stevensc 280
          </PrivateRoute>
7062 stevensc 281
          <PrivateRoute
282
            path="/knowledge-area/view/:uuid"
283
            isAuthenticated={isAuth}
284
          >
285
            <KnowledgeViewPage />
286
          </PrivateRoute>
7015 stevensc 287
          <PrivateRoute path="/knowledge-area" isAuthenticated={isAuth}>
288
            <KnowledgeAreaPage />
289
          </PrivateRoute>
7268 stevensc 290
          <PrivateRoute path="/job/view/:uuid" isAuthenticated={isAuth}>
291
            <JobViewPage />
292
          </PrivateRoute>
7129 stevensc 293
          <PrivateRoute path="/post/:uuid" isAuthenticated={isAuth}>
294
            <PostViewPage />
295
          </PrivateRoute>
7279 stevensc 296
          <PrivateRoute path="/calendar" isAuthenticated={isAuth}>
297
            <CalendarPage />
298
          </PrivateRoute>
7173 stevensc 299
          <PrivateRoute
300
            path="/my-coach/questions/view/:uuid"
301
            isAuthenticated={isAuth}
302
          >
7210 stevensc 303
            <MyCoachViewPage />
7156 stevensc 304
          </PrivateRoute>
7173 stevensc 305
          <PrivateRoute exact path="/my-coach" isAuthenticated={isAuth}>
306
            <MyCoachPage />
307
          </PrivateRoute>
7347 stevensc 308
 
7378 stevensc 309
          <PrivateRoute
310
            exact
311
            path="/signin/impersonate"
312
            isAuthenticated={isAuth}
313
          >
314
            <ImpersonatePage />
315
          </PrivateRoute>
316
 
7375 stevensc 317
          {/* Authorization routes */}
7376 stevensc 318
          <AuthRoute path="/" isAuthenticated={isAuth}>
7375 stevensc 319
            <SigninPage />
320
          </AuthRoute>
7376 stevensc 321
          {/* <AuthRoute exact path="/signin" isAuthenticated={isAuth}>
322
            <SigninPage />
323
          </AuthRoute>
7375 stevensc 324
          <AuthRoute exact path="/signup" isAuthenticated={isAuth}>
325
            <SignupPage />
326
          </AuthRoute>
327
          <AuthRoute exact path="/reset-password" isAuthenticated={isAuth}>
328
            <ResetPasswordPage />
329
          </AuthRoute>
330
          <AuthRoute exact path="/forgot-password" isAuthenticated={isAuth}>
331
            <ForgotPasswordPage />
7376 stevensc 332
          </AuthRoute> */}
6707 stevensc 333
        </Switch>
334
      </Suspense>
6512 stevensc 335
 
336
      <NotificationAlert />
7382 stevensc 337
      {isAuth ? <ChatHelper /> : null}
6490 stevensc 338
    </Router>
339
  )
340
}
341
 
342
export default AppRouter