Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 7366 | Rev 7371 | 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'
7364 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'
7364 stevensc 12
import ChatHelper from '../components/chat/helper/ChatHelper'
6490 stevensc 13
 
6707 stevensc 14
const Header = lazy(() => import('../components/navbar/Header'))
6601 stevensc 15
const Auth = lazy(() => import('../pages/auth/Auth'))
16
const DashboardPage = lazy(() => import('../pages/dashboard/DashboardPage'))
6707 stevensc 17
const MyConnectionsPage = lazy(() =>
6719 stevensc 18
  import('../pages/connections/MyConnectionsPage')
6707 stevensc 19
)
6724 stevensc 20
const InvitationsReceivedPage = lazy(() =>
21
  import('../pages/connections/InvitationsReceivedPage')
22
)
6719 stevensc 23
const InvitationsSendPage = lazy(() =>
6724 stevensc 24
  import('../pages/connections/InvitationsSendPage')
6719 stevensc 25
)
6725 stevensc 26
const PeopleYouMayKnowPage = lazy(() =>
27
  import('../pages/connections/PeopleYouMayKnowPage')
28
)
29
const PeopleBlockedPage = lazy(() =>
30
  import('../pages/connections/PeopleBlockedPage')
31
)
6738 stevensc 32
const MyProfilesPage = lazy(() => import('../pages/profiles/MyProfilesPage'))
33
const PeopleViewedMyProfilePage = lazy(() =>
34
  import('../pages/profiles/PeopleViewedMyProfilePage')
35
)
36
const SavedJobsPage = lazy(() => import('../pages/jobs/SavedJobsPage'))
37
const AppliedJobsPage = lazy(() => import('../pages/jobs/AppliedJobsPage'))
38
const GroupsRequestsSendPage = lazy(() =>
39
  import('../pages/groups/GroupsRequestsSendPage')
40
)
41
const GroupsRequestsReceivedPage = lazy(() =>
42
  import('../pages/groups/GroupsRequestsReceivedPage')
43
)
44
const JoinedGroupsPage = lazy(() => import('../pages/groups/JoinedGroupsPage'))
45
const MyGroupsPage = lazy(() => import('../pages/groups/MyGroupsPage'))
6753 stevensc 46
const MyCompanies = lazy(() => import('../pages/company/MyCompaniesPage'))
47
const FollowingCompaniesPage = lazy(() =>
48
  import('../pages/company/FollowingCompaniesPage')
49
)
50
const CompaniesWhenIWorkPage = lazy(() =>
51
  import('../pages/company/CompaniesWhenIWorkPage')
52
)
53
const CompanyRequestSendPage = lazy(() =>
54
  import('../pages/company/CompanyRequestSendPage')
55
)
56
const CompanyInvitationsReceivedPage = lazy(() =>
57
  import('../pages/company/CompanyInvitationsReceivedPage')
58
)
59
const ProfileViewPage = lazy(() => import('../pages/profiles/ProfileViewPage'))
6805 stevensc 60
const ProfileEditPage = lazy(() => import('../pages/profiles/ProfileEditPage'))
6862 stevensc 61
const CompanyViewPage = lazy(() => import('../pages/company/CompanyViewPage'))
62
const GroupViewPage = lazy(() => import('../pages/groups/GroupViewPage'))
6894 stevensc 63
const GroupEditPage = lazy(() => import('../pages/groups/GroupEditPage'))
6920 stevensc 64
const ChatPage = lazy(() => import('../pages/chat/ChatPage'))
6957 stevensc 65
const InmailPage = lazy(() => import('../pages/inmail/InmailPage'))
6993 stevensc 66
const MarketPlacePage = lazy(() =>
67
  import('../pages/marketplace/MarketplacePage')
68
)
7114 stevensc 69
const NotificationsPage = lazy(() =>
70
  import('../pages/notifications/NotificationsPage')
71
)
72
const SearchPage = lazy(() => import('../pages/search/SearchPage'))
73
const KnowledgeAreaPage = lazy(() =>
74
  import('../pages/knowledge-area/KnowledgeAreaPage')
75
)
76
const KnowledgeViewPage = lazy(() =>
77
  import('../pages/knowledge-area/KnowledgeViewPage')
78
)
7268 stevensc 79
const PostViewPage = lazy(() => import('../pages/posts/PostViewPage'))
80
const MyCoachPage = lazy(() => import('../pages/my-coach/MyCoachPage'))
81
const MyCoachViewPage = lazy(() => import('../pages/my-coach/MyCoachViewPage'))
82
const JobViewPage = lazy(() => import('../pages/jobs/JobView'))
7350 stevensc 83
const CalendarPage = lazy(() => import('../pages/calendar/CalendarPage'))
6490 stevensc 84
 
85
const AppRouter = () => {
7367 stevensc 86
  const { theme_id, isAuth } = 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>
7362 stevensc 314
 
315
          <PublicRoute path="*" isAuthenticated={isAuth}>
316
            <h1>404 Not found</h1>
317
          </PublicRoute>
6707 stevensc 318
        </Switch>
319
      </Suspense>
6512 stevensc 320
 
321
      <NotificationAlert />
7319 stevensc 322
      {isAuth && <ChatHelper />}
6490 stevensc 323
    </Router>
324
  )
325
}
326
 
327
export default AppRouter