App.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. import {Router, Route} from 'react-router-dom';
  2. import createHistory from "history/createBrowserHistory";
  3. import MainPage from "./pages/MainPage";
  4. import Page404 from "./pages/404Page";
  5. import ContactPage from "./pages/ContactPage";
  6. import Switch from "react-router-dom/es/Switch";
  7. import PrivacyPolicy from "./pages/PrivacyPolicyPage";
  8. import FAQPage from "./pages/FAQPage";
  9. import OurTeamPage from "./pages/OurTeamPage";
  10. import AboutUsPage from "./pages/AboutUsPage";
  11. import {Provider} from "react-redux";
  12. import MyAccountPage from "./pages/MyAccountPage";
  13. import {store} from "./reducers";
  14. import ProfilePage from "./pages/ProfilePage";
  15. import CatalogPage from "./pages/CatalogPage";
  16. import Header from "./components/Header";
  17. import Footer from "./components/Footer";
  18. import ProductPage from "./pages/ProductPage";
  19. import WishListPage from "./pages/WishListPage";
  20. import SearchPage from "./pages/SearchPage";
  21. import MyOrdersPage from "./pages/MyOrdersPage";
  22. import CartPage from "./pages/CartPage";
  23. import {CPRoute} from "./components/CPRoute";
  24. import AdminPage from "./pages/AdminPage";
  25. const history = createHistory();
  26. function App() {
  27. return (
  28. <Router history={history}>
  29. <Provider store={store}>
  30. <Header/>
  31. <Switch>
  32. <Route path="/" component={MainPage} exact/>
  33. <Route path="/catalog" component={CatalogPage} />
  34. <Route path="/good" component={ProductPage} />
  35. <Route path="/about-us" component={AboutUsPage} />
  36. <Route path="/our-team" component={OurTeamPage} />
  37. <Route path="/faq" component={FAQPage} />
  38. <Route path="/contact" component={ContactPage} />
  39. <Route path="/my-account" component={MyAccountPage} />
  40. <Route path="/privacy-policy" component={PrivacyPolicy} />
  41. <Route path="/search" component={SearchPage} />
  42. <Route path="/basket" component={CartPage} />
  43. <Route path="/wish-list" component={WishListPage} />
  44. <Route path="/my-orders" component={MyOrdersPage} />
  45. <CPRoute roles={["user", "admin"]} path="/profile" fallback='/my-account' component={ProfilePage} />
  46. <CPRoute roles={["admin"]} path="/admin" fallback='/my-account' component={AdminPage} />
  47. <Route path="*" component={Page404} />
  48. </Switch>
  49. <Footer/>
  50. </Provider>
  51. </Router>
  52. )
  53. }
  54. export default App;