Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

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

Rev 6697 Rev 6707
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
 
-
 
-
 
4
import styled from 'styled-components'
5
import { getLanguage } from '../../redux/intl/intl.action'
5
import { getLanguage } from '../../redux/intl/intl.action'
Línea 6... Línea 6...
6
 
6
 
7
import PublicRoute from './PublicRoute'
7
import PublicRoute from './PublicRoute'
8
import PrivateRoute from './PrivateRoute'
-
 
-
 
8
import PrivateRoute from './PrivateRoute'
9
import NotificationAlert from '../components/UI/notification/NotificationAlert'
9
 
10
import Spinner from '../components/UI/Spinner'
10
import Spinner from '../components/UI/Spinner'
Línea -... Línea 11...
-
 
11
import NotificationAlert from '../components/UI/notification/NotificationAlert'
11
import Header from '../components/navbar/Header'
12
 
12
 
13
const Header = lazy(() => import('../components/navbar/Header'))
-
 
14
const Auth = lazy(() => import('../pages/auth/Auth'))
-
 
15
const DashboardPage = lazy(() => import('../pages/dashboard/DashboardPage'))
-
 
16
const MyConnectionsPage = lazy(() =>
-
 
17
  import('../pages/my-connections/MyConnectionsPage')
-
 
18
)
-
 
19
 
-
 
20
const StyledSpinnerContainer = styled.div`
-
 
21
  position: absolute;
-
 
22
  left: 0;
-
 
23
  top: 0;
-
 
24
  width: 100%;
-
 
25
  height: 100%;
-
 
26
  background: rgba(255, 255, 255, 0.4);
-
 
27
  display: flex;
-
 
28
  justify-content: center;
-
 
29
  align-items: center;
Línea 13... Línea 30...
13
const Auth = lazy(() => import('../pages/auth/Auth'))
30
  z-index: 300;
14
const DashboardPage = lazy(() => import('../pages/dashboard/DashboardPage'))
31
`
15
 
32
 
Línea 21... Línea 38...
21
    dispatch(getLanguage())
38
    dispatch(getLanguage())
22
  }, [])
39
  }, [])
Línea 23... Línea 40...
23
 
40
 
24
  return (
41
  return (
-
 
42
    <Router>
-
 
43
      <Suspense
-
 
44
        fallback={
25
    <Router>
45
          <StyledSpinnerContainer>
-
 
46
            <Spinner />
-
 
47
          </StyledSpinnerContainer>
26
      {isAuth && <Header />}
48
        }
27
      <Switch>
49
      >
-
 
50
        {isAuth && <Header />}
-
 
51
 
28
        <Suspense fallback={<Spinner />}>
52
        <Switch>
29
          <PrivateRoute exact path="/dashboard" isAuthenticated={isAuth}>
53
          <PrivateRoute exact path="/dashboard" isAuthenticated={isAuth}>
30
            <DashboardPage />
54
            <DashboardPage />
-
 
55
          </PrivateRoute>
-
 
56
          <PrivateRoute
-
 
57
            exact
-
 
58
            path="/connection/my-connections"
-
 
59
            isAuthenticated={isAuth}
-
 
60
          >
-
 
61
            <MyConnectionsPage />
Línea 31... Línea 62...
31
          </PrivateRoute>
62
          </PrivateRoute>
32
 
63
 
33
          <PublicRoute path="/" isAuthenticated={isAuth}>
64
          <PublicRoute path="/" isAuthenticated={isAuth}>
34
            <Auth />
65
            <Auth />
35
          </PublicRoute>
66
          </PublicRoute>
Línea 36... Línea 67...
36
        </Suspense>
67
        </Switch>
37
      </Switch>
68
      </Suspense>
38
 
69
 
39
      <NotificationAlert />
70
      <NotificationAlert />