Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 7000 | Rev 7015 | 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'
6999 stevensc 12
import NotificationsPage from '../pages/notifications/NotificationsPage'
7001 stevensc 13
import SearchPage from '../pages/search/SearchPage'
6490 stevensc 14
 
6707 stevensc 15
const Header = lazy(() => import('../components/navbar/Header'))
6601 stevensc 16
const Auth = lazy(() => import('../pages/auth/Auth'))
17
const DashboardPage = lazy(() => import('../pages/dashboard/DashboardPage'))
6707 stevensc 18
const MyConnectionsPage = lazy(() =>
6719 stevensc 19
  import('../pages/connections/MyConnectionsPage')
6707 stevensc 20
)
6724 stevensc 21
const InvitationsReceivedPage = lazy(() =>
22
  import('../pages/connections/InvitationsReceivedPage')
23
)
6719 stevensc 24
const InvitationsSendPage = lazy(() =>
6724 stevensc 25
  import('../pages/connections/InvitationsSendPage')
6719 stevensc 26
)
6725 stevensc 27
const PeopleYouMayKnowPage = lazy(() =>
28
  import('../pages/connections/PeopleYouMayKnowPage')
29
)
30
const PeopleBlockedPage = lazy(() =>
31
  import('../pages/connections/PeopleBlockedPage')
32
)
6738 stevensc 33
const MyProfilesPage = lazy(() => import('../pages/profiles/MyProfilesPage'))
34
const PeopleViewedMyProfilePage = lazy(() =>
35
  import('../pages/profiles/PeopleViewedMyProfilePage')
36
)
37
const SavedJobsPage = lazy(() => import('../pages/jobs/SavedJobsPage'))
38
const AppliedJobsPage = lazy(() => import('../pages/jobs/AppliedJobsPage'))
39
const GroupsRequestsSendPage = lazy(() =>
40
  import('../pages/groups/GroupsRequestsSendPage')
41
)
42
const GroupsRequestsReceivedPage = lazy(() =>
43
  import('../pages/groups/GroupsRequestsReceivedPage')
44
)
45
const JoinedGroupsPage = lazy(() => import('../pages/groups/JoinedGroupsPage'))
46
const MyGroupsPage = lazy(() => import('../pages/groups/MyGroupsPage'))
6753 stevensc 47
const MyCompanies = lazy(() => import('../pages/company/MyCompaniesPage'))
48
const FollowingCompaniesPage = lazy(() =>
49
  import('../pages/company/FollowingCompaniesPage')
50
)
51
const CompaniesWhenIWorkPage = lazy(() =>
52
  import('../pages/company/CompaniesWhenIWorkPage')
53
)
54
const CompanyRequestSendPage = lazy(() =>
55
  import('../pages/company/CompanyRequestSendPage')
56
)
57
const CompanyInvitationsReceivedPage = lazy(() =>
58
  import('../pages/company/CompanyInvitationsReceivedPage')
59
)
60
const ProfileViewPage = lazy(() => import('../pages/profiles/ProfileViewPage'))
6805 stevensc 61
const ProfileEditPage = lazy(() => import('../pages/profiles/ProfileEditPage'))
6862 stevensc 62
const CompanyViewPage = lazy(() => import('../pages/company/CompanyViewPage'))
63
const GroupViewPage = lazy(() => import('../pages/groups/GroupViewPage'))
6894 stevensc 64
const GroupEditPage = lazy(() => import('../pages/groups/GroupEditPage'))
6920 stevensc 65
const ChatPage = lazy(() => import('../pages/chat/ChatPage'))
6957 stevensc 66
const InmailPage = lazy(() => import('../pages/inmail/InmailPage'))
6993 stevensc 67
const MarketPlacePage = lazy(() =>
68
  import('../pages/marketplace/MarketplacePage')
69
)
6490 stevensc 70
 
71
const AppRouter = () => {
6753 stevensc 72
  const { isAuth, theme_id } = useSelector(({ auth }) => auth)
6490 stevensc 73
  const dispatch = useDispatch()
74
 
75
  useEffect(() => {
6745 stevensc 76
    dispatch(getPermissions())
6490 stevensc 77
    dispatch(getLanguage())
78
  }, [])
79
 
80
  return (
81
    <Router>
6753 stevensc 82
      <Suspense fallback={null}>
83
        {isAuth && <Header theme={theme_id} />}
84
      </Suspense>
6724 stevensc 85
 
6707 stevensc 86
      <Suspense
87
        fallback={
6738 stevensc 88
          <LoaderContainer>
6707 stevensc 89
            <Spinner />
6738 stevensc 90
          </LoaderContainer>
6707 stevensc 91
        }
92
      >
93
        <Switch>
6601 stevensc 94
          <PrivateRoute exact path="/dashboard" isAuthenticated={isAuth}>
95
            <DashboardPage />
96
          </PrivateRoute>
6738 stevensc 97
 
6994 stevensc 98
          <PrivateRoute
99
            exact
100
            path="/connection/my-connections"
101
            isAuthenticated={isAuth}
102
          >
103
            <MyConnectionsPage />
6707 stevensc 104
          </PrivateRoute>
6719 stevensc 105
          <PrivateRoute
106
            exact
6994 stevensc 107
            path="/connection/invitations-sent"
108
            isAuthenticated={isAuth}
109
          >
110
            <InvitationsSendPage />
111
          </PrivateRoute>
112
          <PrivateRoute
113
            exact
6724 stevensc 114
            path="/connection/invitations-received"
115
            isAuthenticated={isAuth}
116
          >
117
            <InvitationsReceivedPage />
118
          </PrivateRoute>
6725 stevensc 119
          <PrivateRoute
120
            exact
121
            path="/connection/people-you-may-know"
122
            isAuthenticated={isAuth}
123
          >
124
            <PeopleYouMayKnowPage />
125
          </PrivateRoute>
126
          <PrivateRoute
127
            exact
6726 stevensc 128
            path="/connection/people-blocked"
6725 stevensc 129
            isAuthenticated={isAuth}
130
          >
131
            <PeopleBlockedPage />
132
          </PrivateRoute>
6738 stevensc 133
 
6727 stevensc 134
          <PrivateRoute
135
            exact
136
            path="/profile/my-profiles"
137
            isAuthenticated={isAuth}
138
          >
139
            <MyProfilesPage />
140
          </PrivateRoute>
141
          <PrivateRoute
142
            exact
143
            path="/profile/people-viewed-profile"
144
            isAuthenticated={isAuth}
145
          >
146
            <PeopleViewedMyProfilePage />
147
          </PrivateRoute>
6862 stevensc 148
          <PrivateRoute path="/profile/view/:uuid" isAuthenticated={isAuth}>
149
            <ProfileViewPage />
150
          </PrivateRoute>
151
          <PrivateRoute
152
            path="/profile/my-profiles/edit/:uuid"
153
            isAuthenticated={isAuth}
154
          >
155
            <ProfileEditPage />
156
          </PrivateRoute>
6738 stevensc 157
 
6727 stevensc 158
          <PrivateRoute exact path="/job/saved-jobs" isAuthenticated={isAuth}>
159
            <SavedJobsPage />
160
          </PrivateRoute>
161
          <PrivateRoute exact path="/job/applied-jobs" isAuthenticated={isAuth}>
6729 stevensc 162
            <AppliedJobsPage />
6727 stevensc 163
          </PrivateRoute>
6601 stevensc 164
 
6738 stevensc 165
          <PrivateRoute
166
            exact
6740 stevensc 167
            path="/group/requests-sent"
6738 stevensc 168
            isAuthenticated={isAuth}
169
          >
170
            <GroupsRequestsSendPage />
171
          </PrivateRoute>
172
          <PrivateRoute
173
            exact
174
            path="/group/invitations-received"
175
            isAuthenticated={isAuth}
176
          >
177
            <GroupsRequestsReceivedPage />
178
          </PrivateRoute>
179
          <PrivateRoute
180
            exact
181
            path="/group/joined-groups"
182
            isAuthenticated={isAuth}
183
          >
184
            <JoinedGroupsPage />
185
          </PrivateRoute>
186
          <PrivateRoute exact path="/group/my-groups" isAuthenticated={isAuth}>
187
            <MyGroupsPage />
188
          </PrivateRoute>
6862 stevensc 189
          <PrivateRoute path="/group/view/:uuid" isAuthenticated={isAuth}>
190
            <GroupViewPage />
191
          </PrivateRoute>
6894 stevensc 192
          <PrivateRoute
6895 stevensc 193
            path="/group/my-groups/edit/:uuid"
6894 stevensc 194
            isAuthenticated={isAuth}
195
          >
196
            <GroupEditPage />
197
          </PrivateRoute>
6738 stevensc 198
 
6753 stevensc 199
          <PrivateRoute
200
            exact
201
            path="/company/my-companies"
202
            isAuthenticated={isAuth}
203
          >
204
            <MyCompanies />
205
          </PrivateRoute>
206
          <PrivateRoute
207
            exact
208
            path="/company/following-companies"
209
            isAuthenticated={isAuth}
210
          >
211
            <FollowingCompaniesPage />
212
          </PrivateRoute>
213
          <PrivateRoute
214
            exact
215
            path="/company/i-work-with"
216
            isAuthenticated={isAuth}
217
          >
218
            <CompaniesWhenIWorkPage />
219
          </PrivateRoute>
220
          <PrivateRoute
221
            exact
222
            path="/company/requests-sent"
223
            isAuthenticated={isAuth}
224
          >
225
            <CompanyRequestSendPage />
226
          </PrivateRoute>
227
          <PrivateRoute
228
            exact
229
            path="/company/requests-sent"
230
            isAuthenticated={isAuth}
231
          >
232
            <CompanyRequestSendPage />
233
          </PrivateRoute>
234
          <PrivateRoute
235
            exact
236
            path="/company/invitations-received"
237
            isAuthenticated={isAuth}
238
          >
239
            <CompanyInvitationsReceivedPage />
240
          </PrivateRoute>
6830 stevensc 241
          <PrivateRoute path="/company/view/:uuid" isAuthenticated={isAuth}>
242
            <CompanyViewPage />
243
          </PrivateRoute>
244
 
6911 stevensc 245
          <PrivateRoute path="/chat" isAuthenticated={isAuth}>
246
            <ChatPage />
247
          </PrivateRoute>
6983 stevensc 248
          <PrivateRoute path="/inmail/:uuid" isAuthenticated={isAuth}>
6970 stevensc 249
            <InmailPage />
250
          </PrivateRoute>
6983 stevensc 251
          <PrivateRoute path="/inmail" isAuthenticated={isAuth}>
6947 stevensc 252
            <InmailPage />
253
          </PrivateRoute>
6911 stevensc 254
 
6993 stevensc 255
          <PrivateRoute path="/marketplace" isAuthenticated={isAuth}>
256
            <MarketPlacePage />
257
          </PrivateRoute>
6999 stevensc 258
          <PrivateRoute path="/notifications" isAuthenticated={isAuth}>
259
            <NotificationsPage />
260
          </PrivateRoute>
7000 stevensc 261
          <PrivateRoute path="/search" isAuthenticated={isAuth}>
7001 stevensc 262
            <SearchPage />
7000 stevensc 263
          </PrivateRoute>
6993 stevensc 264
 
6601 stevensc 265
          <PublicRoute path="/" isAuthenticated={isAuth}>
6546 stevensc 266
            <Auth />
267
          </PublicRoute>
6707 stevensc 268
        </Switch>
269
      </Suspense>
6512 stevensc 270
 
271
      <NotificationAlert />
6490 stevensc 272
    </Router>
273
  )
274
}
275
 
276
export default AppRouter