import React from 'react';

import { Helmet } from 'react-helmet';
import { connect } from 'react-redux';
import { renderRoutes } from 'react-router-config';
import {
  BrowserRouter as Router,
  Switch,
} from 'react-router-dom';

import { dyRoutes } from '../../routes/config';

function App(props) {  
  return (
    <>
      <Helmet title={`${props.global && props.global.title}`}>
        <title>{`${props.global && props.global.title}`}</title>
        <link
          rel="shortcut icon"
          href={`https://panda-water.cn/web4/${props.global &&
            props.global.shortcutIcon}`}
        />
        <meta
          name="description"
          content={`${props.global && props.global.title}`}
        />
      </Helmet>
      <Router basename="civbase">
        <Switch>
          {renderRoutes(dyRoutes(props.menu || []).routes)}
          {/* <Redirect to="/notFound" />  */}
        </Switch>

      </Router>
    </>
  );
}

const mapStateToProps = state => ({
  global: state.getIn(['global', 'globalConfig']),
  menu: state.getIn(['global', 'menu']),
});
export default connect(
  mapStateToProps,
  null,
)(App);
