router.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. import React, { Suspense } from "react";
  2. import { Switch } from "react-router-dom";
  3. import ProtectedRoute from './components/common/protectedRoute';
  4. import config from './configs/routerConfig';
  5. import Header from './components/public/Header';
  6. import Spinner from './components/common/spinner';
  7. const router = props => (
  8. <div className="app w-100 img slider-image ">
  9. <Header />
  10. <Suspense fallback={<Spinner />}>
  11. <Switch>
  12. {config.map(route =>
  13. <ProtectedRoute
  14. path={route.path}
  15. component={route.component}
  16. access={route.access}
  17. key={route.path}
  18. exact
  19. />
  20. )}
  21. </Switch>
  22. </Suspense>
  23. </div>
  24. )
  25. export default router;
  26. // class Router extends React.Component {
  27. // render() {
  28. // const { user, tokenAuth } = this.props;
  29. // // TODO: add footer
  30. // return (
  31. // <div className="app w-100 img slider-image ">
  32. // <Header />
  33. // <Suspense fallback={<Spinner />}>
  34. // <Switch>
  35. // {config.map(route =>
  36. // <ProtectedRoute
  37. // path={route.path}
  38. // component={route.component}
  39. // access={route.access}
  40. // user={user}
  41. // key={route}
  42. // exact
  43. // />
  44. // )}
  45. // </Switch>
  46. // </Suspense>
  47. // </div>
  48. // )
  49. // }
  50. // }
  51. // const mapStateToProps = state => ({
  52. // user: state.signIn
  53. // })
  54. // // const mapDispatchToProps = dispatch => bindActionCreators({ tokenAuth }, dispatch);
  55. // export default withRouter(connect(mapStateToProps, null)(Router));
  56. // >>>>>>> new_Sveta