Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

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