index.tsx 1.9 KB
import * as React from "react";
import { Switch, Route } from "react-router-dom";
import RequestPage from "components/pages/RequestPage";
import DronePage from "components/pages/DronePage";
import HomePage from "components/pages/HomePage";
import RegisterPage from "components/pages/RegisterPage";
import MyPage from "components/pages/MyPage";
import ContractPage from "components/pages/ContractPage";
import LoginPage from "components/pages/LoginPage";
import OrgPage from "components/pages/OrgPage";
import BuyPage from "components/pages/BuyPage";
import DatasetPage from "components/pages/DatasetPage";
import SearchPage from "components/pages/SearchPage";
import JudgePage from "components/pages/JudgePage";
import { withRouter, RouteComponentProps } from "react-router-dom";


require("./styles.scss");

interface MyProps extends RouteComponentProps<{}> {}

class Main extends React.Component<MyProps> {
  componentDidUpdate(prevProps) {
    if (this.props.location !== prevProps.location) window.scrollTo(0, 0);
  }

  public render() {
    return (
      <main className="Main">
        <Switch>
          <Route exact path="/" component={HomePage} />
          <Route exact path="/request" component={RequestPage} />
          <Route exact path="/drone" component={DronePage} />
          <Route exact path="/register" component={RegisterPage} />
          <Route exact path="/my-page" component={MyPage} />
          <Route exact path="/contract/:id" component={ContractPage} />
          <Route exact path="/org" component={OrgPage} />
          <Route exact path="/buy" component={BuyPage} />
          <Route exact path="/judge/:id" component={JudgePage} />
          <Route exact path="/search/:id" component={SearchPage} />
          <Route exact path="/dataset" component={DatasetPage} />
          <Route exact path="/login" component={LoginPage} />
        </Switch>
      </main>
    );
  }
}

export default withRouter(Main);