Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 6592 | Rev 6632 | 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'
6530 stevensc 4
 
6490 stevensc 5
import { getLanguage } from '../../redux/intl/intl.action'
6
 
6530 stevensc 7
import PublicRoute from './PublicRoute'
6601 stevensc 8
import PrivateRoute from './PrivateRoute'
6512 stevensc 9
import NotificationAlert from '../components/UI/notification/NotificationAlert'
6546 stevensc 10
import Spinner from '../components/UI/Spinner'
6490 stevensc 11
 
6601 stevensc 12
const Auth = lazy(() => import('../pages/auth/Auth'))
13
const DashboardPage = lazy(() => import('../pages/dashboard/DashboardPage'))
6490 stevensc 14
 
15
const AppRouter = () => {
6601 stevensc 16
  const { isAuth } = useSelector(({ auth }) => auth)
6490 stevensc 17
  const dispatch = useDispatch()
18
 
19
  useEffect(() => {
20
    dispatch(getLanguage())
21
  }, [])
22
 
23
  return (
24
    <Router>
6601 stevensc 25
      {}
26
      <Switch>
27
        <Suspense fallback={<Spinner />}>
28
          <PrivateRoute exact path="/dashboard" isAuthenticated={isAuth}>
29
            <DashboardPage />
30
          </PrivateRoute>
31
 
32
          <PublicRoute path="/" isAuthenticated={isAuth}>
6546 stevensc 33
            <Auth />
34
          </PublicRoute>
6601 stevensc 35
        </Suspense>
36
      </Switch>
6512 stevensc 37
 
38
      <NotificationAlert />
6490 stevensc 39
    </Router>
40
  )
41
}
42
 
43
export default AppRouter