Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

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