Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

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