Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

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