Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 6983 | Rev 6994 | 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'
6993 stevensc 3
import { Route, 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
)
6490 stevensc 68
 
69
const AppRouter = () => {
6753 stevensc 70
  const { isAuth, theme_id } = useSelector(({ auth }) => auth)
6490 stevensc 71
  const dispatch = useDispatch()
72
 
73
  useEffect(() => {
6745 stevensc 74
    dispatch(getPermissions())
6490 stevensc 75
    dispatch(getLanguage())
76
  }, [])
77
 
78
  return (
79
    <Router>
6753 stevensc 80
      <Suspense fallback={null}>
81
        {isAuth && <Header theme={theme_id} />}
82
      </Suspense>
6724 stevensc 83
 
6707 stevensc 84
      <Suspense
85
        fallback={
6738 stevensc 86
          <LoaderContainer>
6707 stevensc 87
            <Spinner />
6738 stevensc 88
          </LoaderContainer>
6707 stevensc 89
        }
90
      >
91
        <Switch>
6601 stevensc 92
          <PrivateRoute exact path="/dashboard" isAuthenticated={isAuth}>
93
            <DashboardPage />
94
          </PrivateRoute>
6738 stevensc 95
 
6993 stevensc 96
          <PrivateRoute isAuthenticated={isAuth}>
97
            <Route exact path="/connection/my-connections">
98
              <MyConnectionsPage />
99
            </Route>
100
            <Route exact path="/connection/invitations-sent">
101
              <InvitationsSendPage />
102
            </Route>
6707 stevensc 103
          </PrivateRoute>
6993 stevensc 104
 
6719 stevensc 105
          <PrivateRoute
106
            exact
6724 stevensc 107
            path="/connection/invitations-received"
108
            isAuthenticated={isAuth}
109
          >
110
            <InvitationsReceivedPage />
111
          </PrivateRoute>
6725 stevensc 112
          <PrivateRoute
113
            exact
114
            path="/connection/people-you-may-know"
115
            isAuthenticated={isAuth}
116
          >
117
            <PeopleYouMayKnowPage />
118
          </PrivateRoute>
119
          <PrivateRoute
120
            exact
6726 stevensc 121
            path="/connection/people-blocked"
6725 stevensc 122
            isAuthenticated={isAuth}
123
          >
124
            <PeopleBlockedPage />
125
          </PrivateRoute>
6738 stevensc 126
 
6727 stevensc 127
          <PrivateRoute
128
            exact
129
            path="/profile/my-profiles"
130
            isAuthenticated={isAuth}
131
          >
132
            <MyProfilesPage />
133
          </PrivateRoute>
134
          <PrivateRoute
135
            exact
136
            path="/profile/people-viewed-profile"
137
            isAuthenticated={isAuth}
138
          >
139
            <PeopleViewedMyProfilePage />
140
          </PrivateRoute>
6862 stevensc 141
          <PrivateRoute path="/profile/view/:uuid" isAuthenticated={isAuth}>
142
            <ProfileViewPage />
143
          </PrivateRoute>
144
          <PrivateRoute
145
            path="/profile/my-profiles/edit/:uuid"
146
            isAuthenticated={isAuth}
147
          >
148
            <ProfileEditPage />
149
          </PrivateRoute>
6738 stevensc 150
 
6727 stevensc 151
          <PrivateRoute exact path="/job/saved-jobs" isAuthenticated={isAuth}>
152
            <SavedJobsPage />
153
          </PrivateRoute>
154
          <PrivateRoute exact path="/job/applied-jobs" isAuthenticated={isAuth}>
6729 stevensc 155
            <AppliedJobsPage />
6727 stevensc 156
          </PrivateRoute>
6601 stevensc 157
 
6738 stevensc 158
          <PrivateRoute
159
            exact
6740 stevensc 160
            path="/group/requests-sent"
6738 stevensc 161
            isAuthenticated={isAuth}
162
          >
163
            <GroupsRequestsSendPage />
164
          </PrivateRoute>
165
          <PrivateRoute
166
            exact
167
            path="/group/invitations-received"
168
            isAuthenticated={isAuth}
169
          >
170
            <GroupsRequestsReceivedPage />
171
          </PrivateRoute>
172
          <PrivateRoute
173
            exact
174
            path="/group/joined-groups"
175
            isAuthenticated={isAuth}
176
          >
177
            <JoinedGroupsPage />
178
          </PrivateRoute>
179
          <PrivateRoute exact path="/group/my-groups" isAuthenticated={isAuth}>
180
            <MyGroupsPage />
181
          </PrivateRoute>
6862 stevensc 182
          <PrivateRoute path="/group/view/:uuid" isAuthenticated={isAuth}>
183
            <GroupViewPage />
184
          </PrivateRoute>
6894 stevensc 185
          <PrivateRoute
6895 stevensc 186
            path="/group/my-groups/edit/:uuid"
6894 stevensc 187
            isAuthenticated={isAuth}
188
          >
189
            <GroupEditPage />
190
          </PrivateRoute>
6738 stevensc 191
 
6753 stevensc 192
          <PrivateRoute
193
            exact
194
            path="/company/my-companies"
195
            isAuthenticated={isAuth}
196
          >
197
            <MyCompanies />
198
          </PrivateRoute>
199
          <PrivateRoute
200
            exact
201
            path="/company/following-companies"
202
            isAuthenticated={isAuth}
203
          >
204
            <FollowingCompaniesPage />
205
          </PrivateRoute>
206
          <PrivateRoute
207
            exact
208
            path="/company/i-work-with"
209
            isAuthenticated={isAuth}
210
          >
211
            <CompaniesWhenIWorkPage />
212
          </PrivateRoute>
213
          <PrivateRoute
214
            exact
215
            path="/company/requests-sent"
216
            isAuthenticated={isAuth}
217
          >
218
            <CompanyRequestSendPage />
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/invitations-received"
230
            isAuthenticated={isAuth}
231
          >
232
            <CompanyInvitationsReceivedPage />
233
          </PrivateRoute>
6830 stevensc 234
          <PrivateRoute path="/company/view/:uuid" isAuthenticated={isAuth}>
235
            <CompanyViewPage />
236
          </PrivateRoute>
237
 
6911 stevensc 238
          <PrivateRoute path="/chat" isAuthenticated={isAuth}>
239
            <ChatPage />
240
          </PrivateRoute>
6983 stevensc 241
          <PrivateRoute path="/inmail/:uuid" isAuthenticated={isAuth}>
6970 stevensc 242
            <InmailPage />
243
          </PrivateRoute>
6983 stevensc 244
          <PrivateRoute path="/inmail" isAuthenticated={isAuth}>
6947 stevensc 245
            <InmailPage />
246
          </PrivateRoute>
6911 stevensc 247
 
6993 stevensc 248
          <PrivateRoute path="/marketplace" isAuthenticated={isAuth}>
249
            <MarketPlacePage />
250
          </PrivateRoute>
251
 
6601 stevensc 252
          <PublicRoute path="/" isAuthenticated={isAuth}>
6546 stevensc 253
            <Auth />
254
          </PublicRoute>
6707 stevensc 255
        </Switch>
256
      </Suspense>
6512 stevensc 257
 
258
      <NotificationAlert />
6490 stevensc 259
    </Router>
260
  )
261
}
262
 
263
export default AppRouter