lalitmee
3/31/2018 - 10:25 AM

routes.jsx

import React from "react";
import { Route, IndexRoute } from "react-router-dom";

import App from "./app";
import "../../css/app.css";

import HomePage from "./components/pages/HomePage";
import MerchantsPage from "./components/pages/MerchantsPage";
import DealViewPage from "./components/pages/DealViewPage";
import DealDetailViewPage from "./components/pages/DealDetailViewPage";
import MobVerification from "./components/pages/MobVerification";
import MobVerificationOTP from "./components/pages/MobVerificationOTP";
import UserProfileInfo from "./components/pages/UserProfileInfo";
import YourOrder from "./components/pages/YourOrder";
import YourFinalOrder from "./components/pages/YourFinalOrder";
import YourItems from "./components/pages/YourItems";
import CheckOut from "./components/pages/CheckOut";
import TermsOfService from "./components/pages/TermsOfService";
import PrivacyComponent from "./components/pages/PrivacyComponent";
import FaqComponent from "./components/pages/FaqComponent";

const ScrollToTop = () => {
  window.scrollTo(0, 0);
  return null;
};

const Routes = () => (
  <div>
    <App>
      <Route component={ScrollToTop} />
      <Route path="/" exact component={HomePage} />
      <Route path="/merchants" component={MerchantsPage} />
      <Route
        path="/terms-of-service"
        component={TermsOfService}
        onChange={(prevState, nextState) => {
          if (nextState.location.action !== "POP") {
            window.scrollTo(0, 0);
          }
        }}
      />
      <Route
        path="/privacy-policy"
        component={PrivacyComponent}
        onChange={(prevState, nextState) => {
          if (nextState.location.action !== "POP") {
            window.scrollTo(0, 0);
          }
        }}
      />
      <Route
        path="/faqs"
        component={FaqComponent}
        onChange={(prevState, nextState) => {
          if (nextState.location.action !== "POP") {
            window.scrollTo(0, 0);
          }
        }}
      />
    </App>
  </div>
);

export default Routes;