Skip to content
Snippets Groups Projects
App.tsx 1.37 KiB
Newer Older
Defendi Alberto's avatar
Defendi Alberto committed
import React, { FC } from 'react';
import { BrowserRouter as Router, Switch, Route } from 'react-router-dom';
Defendi Alberto's avatar
Defendi Alberto committed
import { HomePage } from 'components/HomePage/HomePage';
import { AuthUser } from 'components/AuthUser/AuthUser';
import { LandingPage } from 'components/LandingPage/LandingPage';
import { PrivateRoute } from 'components/api/PrivateRoute/PrivateRoute';
import { AuthRoutes, NonAuthRoutes } from 'components/api/routes';
import { NotFound } from 'components/NotFound/NotFound';
Defendi Alberto's avatar
Defendi Alberto committed
import { ProfilePage } from 'components/ProfilePage/ProfilePage';
import { Roles } from 'components/api/userRoles';
import { Unauthorized } from 'components/Unauthorized/Unauthorized';
Defendi Alberto's avatar
Defendi Alberto committed

Defendi Alberto's avatar
Defendi Alberto committed
export const App: FC = () => (
  <Router>
Defendi Alberto's avatar
Defendi Alberto committed
    <div data-testid="App">
      <Switch>
        <Route path={NonAuthRoutes.auth} component={AuthUser} />
        <Route exact path={NonAuthRoutes.home} component={LandingPage} />
        <PrivateRoute
          path={AuthRoutes.dashboard}
          Component={HomePage}
          requiredRoles={[Roles.admin, Roles.operator, Roles.senior]}
        />
Defendi Alberto's avatar
Defendi Alberto committed
        <PrivateRoute
          path={AuthRoutes.profile}
          Component={ProfilePage}
          requiredRoles={[Roles.admin, Roles.operator, Roles.senior]}
        />
        <Route path={NonAuthRoutes.unauthorized} component={Unauthorized} />
        <Route component={NotFound} />
Defendi Alberto's avatar
Defendi Alberto committed
      </Switch>
    </div>
Defendi Alberto's avatar
Defendi Alberto committed
  </Router>