Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

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