Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 7347 | Rev 7362 | 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'
6994 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
 
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 = () => {
7350 stevensc 86
  const { is_logged_in: isAuth, theme_id } = useSelector(({ auth }) => auth)
6490 stevensc 87
  const dispatch = useDispatch()
88
 
89
  useEffect(() => {
6745 stevensc 90
    dispatch(getPermissions())
6490 stevensc 91
    dispatch(getLanguage())
92
  }, [])
93
 
94
  return (
95
    <Router>
6753 stevensc 96
      <Suspense fallback={null}>
97
        {isAuth && <Header theme={theme_id} />}
98
      </Suspense>
6724 stevensc 99
 
6707 stevensc 100
      <Suspense
101
        fallback={
6738 stevensc 102
          <LoaderContainer>
6707 stevensc 103
            <Spinner />
6738 stevensc 104
          </LoaderContainer>
6707 stevensc 105
        }
106
      >
107
        <Switch>
6601 stevensc 108
          <PrivateRoute exact path="/dashboard" isAuthenticated={isAuth}>
109
            <DashboardPage />
110
          </PrivateRoute>
6738 stevensc 111
 
6994 stevensc 112
          <PrivateRoute
113
            exact
114
            path="/connection/my-connections"
115
            isAuthenticated={isAuth}
116
          >
117
            <MyConnectionsPage />
6707 stevensc 118
          </PrivateRoute>
6719 stevensc 119
          <PrivateRoute
120
            exact
6994 stevensc 121
            path="/connection/invitations-sent"
122
            isAuthenticated={isAuth}
123
          >
124
            <InvitationsSendPage />
125
          </PrivateRoute>
126
          <PrivateRoute
127
            exact
6724 stevensc 128
            path="/connection/invitations-received"
129
            isAuthenticated={isAuth}
130
          >
131
            <InvitationsReceivedPage />
132
          </PrivateRoute>
6725 stevensc 133
          <PrivateRoute
134
            exact
135
            path="/connection/people-you-may-know"
136
            isAuthenticated={isAuth}
137
          >
138
            <PeopleYouMayKnowPage />
139
          </PrivateRoute>
140
          <PrivateRoute
141
            exact
6726 stevensc 142
            path="/connection/people-blocked"
6725 stevensc 143
            isAuthenticated={isAuth}
144
          >
145
            <PeopleBlockedPage />
146
          </PrivateRoute>
6738 stevensc 147
 
6727 stevensc 148
          <PrivateRoute
149
            exact
150
            path="/profile/my-profiles"
151
            isAuthenticated={isAuth}
152
          >
153
            <MyProfilesPage />
154
          </PrivateRoute>
155
          <PrivateRoute
156
            exact
157
            path="/profile/people-viewed-profile"
158
            isAuthenticated={isAuth}
159
          >
160
            <PeopleViewedMyProfilePage />
161
          </PrivateRoute>
6862 stevensc 162
          <PrivateRoute path="/profile/view/:uuid" isAuthenticated={isAuth}>
163
            <ProfileViewPage />
164
          </PrivateRoute>
165
          <PrivateRoute
166
            path="/profile/my-profiles/edit/:uuid"
167
            isAuthenticated={isAuth}
168
          >
169
            <ProfileEditPage />
170
          </PrivateRoute>
6738 stevensc 171
 
6727 stevensc 172
          <PrivateRoute exact path="/job/saved-jobs" isAuthenticated={isAuth}>
173
            <SavedJobsPage />
174
          </PrivateRoute>
175
          <PrivateRoute exact path="/job/applied-jobs" isAuthenticated={isAuth}>
6729 stevensc 176
            <AppliedJobsPage />
6727 stevensc 177
          </PrivateRoute>
6601 stevensc 178
 
6738 stevensc 179
          <PrivateRoute
180
            exact
6740 stevensc 181
            path="/group/requests-sent"
6738 stevensc 182
            isAuthenticated={isAuth}
183
          >
184
            <GroupsRequestsSendPage />
185
          </PrivateRoute>
186
          <PrivateRoute
187
            exact
188
            path="/group/invitations-received"
189
            isAuthenticated={isAuth}
190
          >
191
            <GroupsRequestsReceivedPage />
192
          </PrivateRoute>
193
          <PrivateRoute
194
            exact
195
            path="/group/joined-groups"
196
            isAuthenticated={isAuth}
197
          >
198
            <JoinedGroupsPage />
199
          </PrivateRoute>
200
          <PrivateRoute exact path="/group/my-groups" isAuthenticated={isAuth}>
201
            <MyGroupsPage />
202
          </PrivateRoute>
6862 stevensc 203
          <PrivateRoute path="/group/view/:uuid" isAuthenticated={isAuth}>
204
            <GroupViewPage />
205
          </PrivateRoute>
6894 stevensc 206
          <PrivateRoute
6895 stevensc 207
            path="/group/my-groups/edit/:uuid"
6894 stevensc 208
            isAuthenticated={isAuth}
209
          >
210
            <GroupEditPage />
211
          </PrivateRoute>
6738 stevensc 212
 
6753 stevensc 213
          <PrivateRoute
214
            exact
215
            path="/company/my-companies"
216
            isAuthenticated={isAuth}
217
          >
218
            <MyCompanies />
219
          </PrivateRoute>
220
          <PrivateRoute
221
            exact
222
            path="/company/following-companies"
223
            isAuthenticated={isAuth}
224
          >
225
            <FollowingCompaniesPage />
226
          </PrivateRoute>
227
          <PrivateRoute
228
            exact
229
            path="/company/i-work-with"
230
            isAuthenticated={isAuth}
231
          >
232
            <CompaniesWhenIWorkPage />
233
          </PrivateRoute>
234
          <PrivateRoute
235
            exact
236
            path="/company/requests-sent"
237
            isAuthenticated={isAuth}
238
          >
239
            <CompanyRequestSendPage />
240
          </PrivateRoute>
241
          <PrivateRoute
242
            exact
243
            path="/company/requests-sent"
244
            isAuthenticated={isAuth}
245
          >
246
            <CompanyRequestSendPage />
247
          </PrivateRoute>
248
          <PrivateRoute
249
            exact
250
            path="/company/invitations-received"
251
            isAuthenticated={isAuth}
252
          >
253
            <CompanyInvitationsReceivedPage />
254
          </PrivateRoute>
6830 stevensc 255
          <PrivateRoute path="/company/view/:uuid" isAuthenticated={isAuth}>
256
            <CompanyViewPage />
257
          </PrivateRoute>
258
 
6911 stevensc 259
          <PrivateRoute path="/chat" isAuthenticated={isAuth}>
260
            <ChatPage />
261
          </PrivateRoute>
6983 stevensc 262
          <PrivateRoute path="/inmail/:uuid" isAuthenticated={isAuth}>
6970 stevensc 263
            <InmailPage />
264
          </PrivateRoute>
6983 stevensc 265
          <PrivateRoute path="/inmail" isAuthenticated={isAuth}>
6947 stevensc 266
            <InmailPage />
267
          </PrivateRoute>
6911 stevensc 268
 
6993 stevensc 269
          <PrivateRoute path="/marketplace" isAuthenticated={isAuth}>
270
            <MarketPlacePage />
271
          </PrivateRoute>
6999 stevensc 272
          <PrivateRoute path="/notifications" isAuthenticated={isAuth}>
273
            <NotificationsPage />
274
          </PrivateRoute>
7000 stevensc 275
          <PrivateRoute path="/search" isAuthenticated={isAuth}>
7001 stevensc 276
            <SearchPage />
7000 stevensc 277
          </PrivateRoute>
6993 stevensc 278
 
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>
288
 
7268 stevensc 289
          <PrivateRoute path="/job/view/:uuid" isAuthenticated={isAuth}>
290
            <JobViewPage />
291
          </PrivateRoute>
292
 
7129 stevensc 293
          <PrivateRoute path="/post/:uuid" isAuthenticated={isAuth}>
294
            <PostViewPage />
295
          </PrivateRoute>
296
 
7279 stevensc 297
          <PrivateRoute path="/calendar" isAuthenticated={isAuth}>
298
            <CalendarPage />
299
          </PrivateRoute>
300
 
7173 stevensc 301
          <PrivateRoute
302
            path="/my-coach/questions/view/:uuid"
303
            isAuthenticated={isAuth}
304
          >
7210 stevensc 305
            <MyCoachViewPage />
7156 stevensc 306
          </PrivateRoute>
7173 stevensc 307
          <PrivateRoute exact path="/my-coach" isAuthenticated={isAuth}>
308
            <MyCoachPage />
309
          </PrivateRoute>
7347 stevensc 310
 
311
          <PublicRoute path="/" isAuthenticated={isAuth}>
312
            <Auth />
313
          </PublicRoute>
6707 stevensc 314
        </Switch>
315
      </Suspense>
6512 stevensc 316
 
317
      <NotificationAlert />
7319 stevensc 318
      {isAuth && <ChatHelper />}
6490 stevensc 319
    </Router>
320
  )
321
}
322
 
323
export default AppRouter