Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 6512 | Rev 6514 | Ir a la última revisión | Autoría | Comparar con el anterior | Ultima modificación | Ver Log |

import React, { useEffect, lazy } from 'react'
import { BrowserRouter as Router, Route, Switch } from 'react-router-dom'
import { useDispatch, useSelector } from 'react-redux'
import { getLanguage } from '../../redux/intl/intl.action'

import Auth from '../pages/auth/Auth'
import PrivateRoute from './PrivateRoute'
import NotificationAlert from '../components/UI/notification/NotificationAlert'

const HomeSection = lazy(() =>
  import('../../dashboard/components/home-section/HomeSection')
)

const AppRouter = () => {
  const { isAuth } = useSelector(({ auth }) => auth)
  const dispatch = useDispatch()

  useEffect(() => {
    dispatch(getLanguage())
  }, [])

  return (
    <Router>
      <Switch>
        <Route path="/">
          <Auth />
        </Route>

        <PrivateRoute exact path="/dashboard" isAuthenticated={isAuth}>
          <HomeSection />
        </PrivateRoute>
      </Switch>

      <NotificationAlert />
    </Router>
  )
}

export default AppRouter