import { connect } from 'umi';
import IndexCenterComponent from '../../components/IndexCenter/IndexCenter';

function IndexCenter({
  dispatch, app, content, loading,
}) {
  const indexCenterProps = {
    app,
    content,
    dispatch,
    loading,
    onGetComParameter: getComParameter, /* 获取常用操作 */
    onDelParameter: getDelParameter, /* 删除常用操作 */
    onAddPane: getAddPane, /* 增加标签 */
    onGetModelCenter: getModelCenter, /* 获取KPI工作中心 */
  };

  function getComParameter(url) {
    /* 获取常用操作 */
    dispatch({ type: 'app/getComParameter', payload: { url } });
  }

  function getDelParameter(value, url) {
    /* 删除常用操作 */
    dispatch({ type: 'app/getDelParameter', payload: { value, url } });
  }

  function getAddPane(pane) {
    /* 增加标签 */
    dispatch({ type: 'app/addPane', payload: { pane } });
  }

  function getModelCenter(value, url) {
    /* 获取KPI工作中心 */
    dispatch({ type: 'app/getModelCenter', payload: { value, url, dispatch } });
  }

  return (
    <IndexCenterComponent {...indexCenterProps} />
  );
}

export default connect(({ app, content, loading }) =>
  ({ app, content, loading }))(IndexCenter);
