Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 6894 | Rev 6911 | 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'))
6894 stevensc 62
const GroupEditPage = lazy(() => import('../pages/groups/GroupEditPage'))
6490 stevensc 63
 
64
const AppRouter = () => {
6753 stevensc 65
  const { isAuth, theme_id } = useSelector(({ auth }) => auth)
6490 stevensc 66
  const dispatch = useDispatch()
67
 
68
  useEffect(() => {
6745 stevensc 69
    dispatch(getPermissions())
6490 stevensc 70
    dispatch(getLanguage())
71
  }, [])
72
 
73
  return (
74
    <Router>
6753 stevensc 75
      <Suspense fallback={null}>
76
        {isAuth && <Header theme={theme_id} />}
77
      </Suspense>
6724 stevensc 78
 
6707 stevensc 79
      <Suspense
80
        fallback={
6738 stevensc 81
          <LoaderContainer>
6707 stevensc 82
            <Spinner />
6738 stevensc 83
          </LoaderContainer>
6707 stevensc 84
        }
85
      >
86
        <Switch>
6601 stevensc 87
          <PrivateRoute exact path="/dashboard" isAuthenticated={isAuth}>
88
            <DashboardPage />
89
          </PrivateRoute>
6738 stevensc 90
 
6707 stevensc 91
          <PrivateRoute
92
            exact
93
            path="/connection/my-connections"
94
            isAuthenticated={isAuth}
95
          >
96
            <MyConnectionsPage />
97
          </PrivateRoute>
6719 stevensc 98
          <PrivateRoute
99
            exact
100
            path="/connection/invitations-sent"
101
            isAuthenticated={isAuth}
102
          >
103
            <InvitationsSendPage />
104
          </PrivateRoute>
6724 stevensc 105
          <PrivateRoute
106
            exact
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
 
6601 stevensc 238
          <PublicRoute path="/" isAuthenticated={isAuth}>
6546 stevensc 239
            <Auth />
240
          </PublicRoute>
6707 stevensc 241
        </Switch>
242
      </Suspense>
6512 stevensc 243
 
244
      <NotificationAlert />
6490 stevensc 245
    </Router>
246
  )
247
}
248
 
249
export default AppRouter