Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

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