Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 7376 | Rev 7378 | 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'))
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>
6994 stevensc 119
          <PrivateRoute
120
            exact
121
            path="/connection/my-connections"
122
            isAuthenticated={isAuth}
123
          >
124
            <MyConnectionsPage />
6707 stevensc 125
          </PrivateRoute>
6719 stevensc 126
          <PrivateRoute
127
            exact
6994 stevensc 128
            path="/connection/invitations-sent"
129
            isAuthenticated={isAuth}
130
          >
131
            <InvitationsSendPage />
132
          </PrivateRoute>
133
          <PrivateRoute
134
            exact
6724 stevensc 135
            path="/connection/invitations-received"
136
            isAuthenticated={isAuth}
137
          >
138
            <InvitationsReceivedPage />
139
          </PrivateRoute>
6725 stevensc 140
          <PrivateRoute
141
            exact
142
            path="/connection/people-you-may-know"
143
            isAuthenticated={isAuth}
144
          >
145
            <PeopleYouMayKnowPage />
146
          </PrivateRoute>
147
          <PrivateRoute
148
            exact
6726 stevensc 149
            path="/connection/people-blocked"
6725 stevensc 150
            isAuthenticated={isAuth}
151
          >
152
            <PeopleBlockedPage />
153
          </PrivateRoute>
6727 stevensc 154
          <PrivateRoute
155
            exact
156
            path="/profile/my-profiles"
157
            isAuthenticated={isAuth}
158
          >
159
            <MyProfilesPage />
160
          </PrivateRoute>
161
          <PrivateRoute
162
            exact
163
            path="/profile/people-viewed-profile"
164
            isAuthenticated={isAuth}
165
          >
166
            <PeopleViewedMyProfilePage />
167
          </PrivateRoute>
6862 stevensc 168
          <PrivateRoute path="/profile/view/:uuid" isAuthenticated={isAuth}>
169
            <ProfileViewPage />
170
          </PrivateRoute>
171
          <PrivateRoute
172
            path="/profile/my-profiles/edit/:uuid"
173
            isAuthenticated={isAuth}
174
          >
175
            <ProfileEditPage />
176
          </PrivateRoute>
6727 stevensc 177
          <PrivateRoute exact path="/job/saved-jobs" isAuthenticated={isAuth}>
178
            <SavedJobsPage />
179
          </PrivateRoute>
180
          <PrivateRoute exact path="/job/applied-jobs" isAuthenticated={isAuth}>
6729 stevensc 181
            <AppliedJobsPage />
6727 stevensc 182
          </PrivateRoute>
6738 stevensc 183
          <PrivateRoute
184
            exact
6740 stevensc 185
            path="/group/requests-sent"
6738 stevensc 186
            isAuthenticated={isAuth}
187
          >
188
            <GroupsRequestsSendPage />
189
          </PrivateRoute>
190
          <PrivateRoute
191
            exact
192
            path="/group/invitations-received"
193
            isAuthenticated={isAuth}
194
          >
195
            <GroupsRequestsReceivedPage />
196
          </PrivateRoute>
197
          <PrivateRoute
198
            exact
199
            path="/group/joined-groups"
200
            isAuthenticated={isAuth}
201
          >
202
            <JoinedGroupsPage />
203
          </PrivateRoute>
204
          <PrivateRoute exact path="/group/my-groups" isAuthenticated={isAuth}>
205
            <MyGroupsPage />
206
          </PrivateRoute>
6862 stevensc 207
          <PrivateRoute path="/group/view/:uuid" isAuthenticated={isAuth}>
208
            <GroupViewPage />
209
          </PrivateRoute>
6894 stevensc 210
          <PrivateRoute
6895 stevensc 211
            path="/group/my-groups/edit/:uuid"
6894 stevensc 212
            isAuthenticated={isAuth}
213
          >
214
            <GroupEditPage />
215
          </PrivateRoute>
6753 stevensc 216
          <PrivateRoute
217
            exact
218
            path="/company/my-companies"
219
            isAuthenticated={isAuth}
220
          >
221
            <MyCompanies />
222
          </PrivateRoute>
223
          <PrivateRoute
224
            exact
225
            path="/company/following-companies"
226
            isAuthenticated={isAuth}
227
          >
228
            <FollowingCompaniesPage />
229
          </PrivateRoute>
230
          <PrivateRoute
231
            exact
232
            path="/company/i-work-with"
233
            isAuthenticated={isAuth}
234
          >
235
            <CompaniesWhenIWorkPage />
236
          </PrivateRoute>
237
          <PrivateRoute
238
            exact
239
            path="/company/requests-sent"
240
            isAuthenticated={isAuth}
241
          >
242
            <CompanyRequestSendPage />
243
          </PrivateRoute>
244
          <PrivateRoute
245
            exact
246
            path="/company/requests-sent"
247
            isAuthenticated={isAuth}
248
          >
249
            <CompanyRequestSendPage />
250
          </PrivateRoute>
251
          <PrivateRoute
252
            exact
253
            path="/company/invitations-received"
254
            isAuthenticated={isAuth}
255
          >
256
            <CompanyInvitationsReceivedPage />
257
          </PrivateRoute>
6830 stevensc 258
          <PrivateRoute path="/company/view/:uuid" isAuthenticated={isAuth}>
259
            <CompanyViewPage />
260
          </PrivateRoute>
6911 stevensc 261
          <PrivateRoute path="/chat" isAuthenticated={isAuth}>
262
            <ChatPage />
263
          </PrivateRoute>
6983 stevensc 264
          <PrivateRoute path="/inmail/:uuid" isAuthenticated={isAuth}>
6970 stevensc 265
            <InmailPage />
266
          </PrivateRoute>
6983 stevensc 267
          <PrivateRoute path="/inmail" isAuthenticated={isAuth}>
6947 stevensc 268
            <InmailPage />
269
          </PrivateRoute>
6993 stevensc 270
          <PrivateRoute path="/marketplace" isAuthenticated={isAuth}>
271
            <MarketPlacePage />
272
          </PrivateRoute>
6999 stevensc 273
          <PrivateRoute path="/notifications" isAuthenticated={isAuth}>
274
            <NotificationsPage />
275
          </PrivateRoute>
7000 stevensc 276
          <PrivateRoute path="/search" isAuthenticated={isAuth}>
7001 stevensc 277
            <SearchPage />
7000 stevensc 278
          </PrivateRoute>
7062 stevensc 279
          <PrivateRoute
280
            path="/knowledge-area/view/:uuid"
281
            isAuthenticated={isAuth}
282
          >
283
            <KnowledgeViewPage />
284
          </PrivateRoute>
7015 stevensc 285
          <PrivateRoute path="/knowledge-area" isAuthenticated={isAuth}>
286
            <KnowledgeAreaPage />
287
          </PrivateRoute>
7268 stevensc 288
          <PrivateRoute path="/job/view/:uuid" isAuthenticated={isAuth}>
289
            <JobViewPage />
290
          </PrivateRoute>
7129 stevensc 291
          <PrivateRoute path="/post/:uuid" isAuthenticated={isAuth}>
292
            <PostViewPage />
293
          </PrivateRoute>
7279 stevensc 294
          <PrivateRoute path="/calendar" isAuthenticated={isAuth}>
295
            <CalendarPage />
296
          </PrivateRoute>
7173 stevensc 297
          <PrivateRoute
298
            path="/my-coach/questions/view/:uuid"
299
            isAuthenticated={isAuth}
300
          >
7210 stevensc 301
            <MyCoachViewPage />
7156 stevensc 302
          </PrivateRoute>
7173 stevensc 303
          <PrivateRoute exact path="/my-coach" isAuthenticated={isAuth}>
304
            <MyCoachPage />
305
          </PrivateRoute>
7347 stevensc 306
 
7375 stevensc 307
          {/* Authorization routes */}
7376 stevensc 308
          <AuthRoute path="/" isAuthenticated={isAuth}>
7375 stevensc 309
            <SigninPage />
310
          </AuthRoute>
7376 stevensc 311
          {/* <AuthRoute exact path="/signin" isAuthenticated={isAuth}>
312
            <SigninPage />
313
          </AuthRoute>
7375 stevensc 314
          <AuthRoute exact path="/signup" isAuthenticated={isAuth}>
315
            <SignupPage />
316
          </AuthRoute>
317
          <AuthRoute exact path="/reset-password" isAuthenticated={isAuth}>
318
            <ResetPasswordPage />
319
          </AuthRoute>
320
          <AuthRoute exact path="/forgot-password" isAuthenticated={isAuth}>
321
            <ForgotPasswordPage />
7376 stevensc 322
          </AuthRoute> */}
7362 stevensc 323
 
7375 stevensc 324
          <Route path="*">
7362 stevensc 325
            <h1>404 Not found</h1>
7375 stevensc 326
          </Route>
6707 stevensc 327
        </Switch>
328
      </Suspense>
6512 stevensc 329
 
330
      <NotificationAlert />
7374 stevensc 331
 
332
      <Suspense fallback={null}>{isAuth ? <ChatHelper /> : null}</Suspense>
6490 stevensc 333
    </Router>
334
  )
335
}
336
 
337
export default AppRouter