Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 6513 | Rev 6515 | Ir a la última revisión | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
6490 stevensc 1
import React, { useEffect, lazy } from 'react'
6514 stevensc 2
import { BrowserRouter as Router, Switch } from 'react-router-dom'
6513 stevensc 3
import { useDispatch, useSelector } from 'react-redux'
6490 stevensc 4
import { getLanguage } from '../../redux/intl/intl.action'
5
 
6512 stevensc 6
import Auth from '../pages/auth/Auth'
6490 stevensc 7
import PrivateRoute from './PrivateRoute'
6512 stevensc 8
import NotificationAlert from '../components/UI/notification/NotificationAlert'
6514 stevensc 9
import PublicRoute from './PublicRoute'
6490 stevensc 10
 
11
const HomeSection = lazy(() =>
12
  import('../../dashboard/components/home-section/HomeSection')
13
)
14
 
15
const AppRouter = () => {
6513 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>
25
      <Switch>
6514 stevensc 26
        <PublicRoute path="/" isAuthenticated={isAuth}>
6490 stevensc 27
          <Auth />
6514 stevensc 28
        </PublicRoute>
6513 stevensc 29
 
30
        <PrivateRoute exact path="/dashboard" isAuthenticated={isAuth}>
6490 stevensc 31
          <HomeSection />
32
        </PrivateRoute>
33
      </Switch>
6512 stevensc 34
 
35
      <NotificationAlert />
6490 stevensc 36
    </Router>
37
  )
38
}
39
 
40
export default AppRouter