Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

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