Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

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

import React, { lazy, useEffect } from 'react'
import { useDispatch, useSelector } from 'react-redux'
import { BrowserRouter as Router, Switch } from 'react-router-dom'

import { getLanguage } from '../../redux/intl/intl.action'

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

const DashboardPage = lazy(() => import('../pages/dashboard/DashboardPage'))

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

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

  return (
    <Router>
      <Switch>
        <PrivateRoute exact path="/home" isAuthenticated={isAuth}>
          <DashboardPage />
        </PrivateRoute>

        <PublicRoute path="/" isAuthenticated={isAuth}>
          <Auth />
        </PublicRoute>
      </Switch>

      <NotificationAlert />
    </Router>
  )
}

export default AppRouter