import Spinner from 'client/Components/Spinner';
import { CenterContent } from 'client/Elements/Wrapper';
import { container as resolveContainer } from 'core/tools/resolve';
import { Suspense } from 'react';
import { Route, Switch } from 'react-router-dom';
import paths from './paths';

export default () => (
  <Suspense
    fallback={
      <CenterContent>
        <Spinner />
      </CenterContent>
    }
  >
    <Switch>
      {paths.map((path, i) => (
        <Route
          key={i}
          path={path.route}
          exact={path.exact}
          component={resolveContainer(path.name)}
        />
      ))}
    </Switch>
  </Suspense>
);
