Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 6748 | Rev 6805 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 6748 Rev 6753
Línea 1... Línea 1...
1
import React, { lazy, Suspense, useEffect } from 'react'
1
import React, { lazy, Suspense, useEffect } from 'react'
2
import { useDispatch, useSelector } from 'react-redux'
2
import { useDispatch, useSelector } from 'react-redux'
3
import { BrowserRouter as Router, Switch } from 'react-router-dom'
3
import { BrowserRouter as Router, Switch } from 'react-router-dom'
4
import { getLanguage } from '../../redux/intl/intl.action'
4
import { getLanguage } from '../../redux/intl/intl.action'
-
 
5
import { getPermissions } from '../redux/auth/auth.actions'
Línea 5... Línea 6...
5
 
6
 
6
import PublicRoute from './PublicRoute'
7
import PublicRoute from './PublicRoute'
7
import PrivateRoute from './PrivateRoute'
8
import PrivateRoute from './PrivateRoute'
8
import Spinner from '../components/UI/Spinner'
9
import Spinner from '../components/UI/Spinner'
9
import NotificationAlert from '../components/UI/notification/NotificationAlert'
10
import NotificationAlert from '../components/UI/notification/NotificationAlert'
10
import LoaderContainer from '../components/UI/LoaderContainer'
-
 
11
import { getPermissions } from '../redux/auth/auth.actions'
-
 
Línea 12... Línea 11...
12
import useLocalStorage from '../hooks/useLocalStorage'
11
import LoaderContainer from '../components/UI/LoaderContainer'
13
 
12
 
14
const Header = lazy(() => import('../components/navbar/Header'))
13
const Header = lazy(() => import('../components/navbar/Header'))
15
const Auth = lazy(() => import('../pages/auth/Auth'))
14
const Auth = lazy(() => import('../pages/auth/Auth'))
Línea 41... Línea 40...
41
const GroupsRequestsReceivedPage = lazy(() =>
40
const GroupsRequestsReceivedPage = lazy(() =>
42
  import('../pages/groups/GroupsRequestsReceivedPage')
41
  import('../pages/groups/GroupsRequestsReceivedPage')
43
)
42
)
44
const JoinedGroupsPage = lazy(() => import('../pages/groups/JoinedGroupsPage'))
43
const JoinedGroupsPage = lazy(() => import('../pages/groups/JoinedGroupsPage'))
45
const MyGroupsPage = lazy(() => import('../pages/groups/MyGroupsPage'))
44
const MyGroupsPage = lazy(() => import('../pages/groups/MyGroupsPage'))
-
 
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'))
Línea 46... Línea 59...
46
 
59
 
47
const AppRouter = () => {
60
const AppRouter = () => {
48
  const { isAuth, defaultNetwork, theme_id } = useSelector(({ auth }) => auth)
61
  const { isAuth, theme_id } = useSelector(({ auth }) => auth)
Línea 49... Línea -...
49
  const dispatch = useDispatch()
-
 
50
 
-
 
51
  const [, setLocalStorage] = useLocalStorage('config', {
-
 
52
    isAuth,
-
 
53
    defaultNetwork,
-
 
54
    theme_id,
-
 
55
  })
62
  const dispatch = useDispatch()
56
 
63
 
57
  useEffect(() => {
64
  useEffect(() => {
58
    dispatch(getPermissions())
65
    dispatch(getPermissions())
Línea 59... Línea -...
59
    dispatch(getLanguage())
-
 
60
  }, [])
-
 
61
 
-
 
62
  useEffect(() => {
-
 
63
    setLocalStorage({
-
 
64
      isAuth,
-
 
65
      defaultNetwork,
-
 
66
      theme_id,
-
 
67
    })
66
    dispatch(getLanguage())
68
  }, [isAuth, defaultNetwork, theme_id])
67
  }, [])
69
 
68
 
-
 
69
  return (
-
 
70
    <Router>
Línea 70... Línea 71...
70
  return (
71
      <Suspense fallback={null}>
71
    <Router>
72
        {isAuth && <Header theme={theme_id} />}
72
      <Suspense fallback={null}>{isAuth && <Header />}</Suspense>
73
      </Suspense>
73
 
74
 
Línea 164... Línea 165...
164
          </PrivateRoute>
165
          </PrivateRoute>
165
          <PrivateRoute exact path="/group/my-groups" isAuthenticated={isAuth}>
166
          <PrivateRoute exact path="/group/my-groups" isAuthenticated={isAuth}>
166
            <MyGroupsPage />
167
            <MyGroupsPage />
167
          </PrivateRoute>
168
          </PrivateRoute>
Línea -... Línea 169...
-
 
169
 
-
 
170
          <PrivateRoute
-
 
171
            exact
-
 
172
            path="/company/my-companies"
-
 
173
            isAuthenticated={isAuth}
-
 
174
          >
-
 
175
            <MyCompanies />
-
 
176
          </PrivateRoute>
-
 
177
          <PrivateRoute
-
 
178
            exact
-
 
179
            path="/company/following-companies"
-
 
180
            isAuthenticated={isAuth}
-
 
181
          >
-
 
182
            <FollowingCompaniesPage />
-
 
183
          </PrivateRoute>
-
 
184
          <PrivateRoute
-
 
185
            exact
-
 
186
            path="/company/i-work-with"
-
 
187
            isAuthenticated={isAuth}
-
 
188
          >
-
 
189
            <CompaniesWhenIWorkPage />
-
 
190
          </PrivateRoute>
-
 
191
          <PrivateRoute
-
 
192
            exact
-
 
193
            path="/company/requests-sent"
-
 
194
            isAuthenticated={isAuth}
-
 
195
          >
-
 
196
            <CompanyRequestSendPage />
-
 
197
          </PrivateRoute>
-
 
198
          <PrivateRoute
-
 
199
            exact
-
 
200
            path="/company/requests-sent"
-
 
201
            isAuthenticated={isAuth}
-
 
202
          >
-
 
203
            <CompanyRequestSendPage />
-
 
204
          </PrivateRoute>
-
 
205
          <PrivateRoute
-
 
206
            exact
-
 
207
            path="/company/invitations-received"
-
 
208
            isAuthenticated={isAuth}
-
 
209
          >
-
 
210
            <CompanyInvitationsReceivedPage />
-
 
211
          </PrivateRoute>
-
 
212
          <PrivateRoute path="/profile/view/:uuid" isAuthenticated={isAuth}>
-
 
213
            <ProfileViewPage />
-
 
214
          </PrivateRoute>
168
 
215
 
169
          <PublicRoute path="/" isAuthenticated={isAuth}>
216
          <PublicRoute path="/" isAuthenticated={isAuth}>
170
            <Auth />
217
            <Auth />
171
          </PublicRoute>
218
          </PublicRoute>
172
        </Switch>
219
        </Switch>