import React from 'react';
import { Route, Switch, Redirect } from 'react-router-dom';

import NoMatch from './modules/NoMatch';
import InitPage from './modules/login/index';
import CheckLogin from './components/CheckLogin';
import Dashboard from './modules/dashborad';
import List from './modules/list';
import HelpDoc from './modules/helpdoc';
import paths from './common/path';

export default (
  <div>
    <Switch>
      <Route exact path="/login" component={InitPage} />
      <Redirect from="/home" to="/" />
      <CheckLogin>
        <Switch>
          <Redirect exact from="/" to={paths.dashboard.index} />
          <Route exact path={paths.dashboard.index} component={Dashboard} />
          <Route exact path={paths.list.index} component={List} />
          <Route exact path={paths.helpDoc.index} component={HelpDoc} />
          <Route component={NoMatch} />
        </Switch>
      </CheckLogin>
    </Switch>
  </div>
);
