import React from 'react';
import { connect } from 'umi';
import ProcessReportMobileComponent from '../../../mobile/common/ProcessReportMobile';
import * as commonUtils from '../../../utils/utils';

function ProcessReportMobile({
  dispatch, app, content, location,
}) {
  function removePane(changePanes, currentPane) {
    dispatch({ type: 'app/removePane', payload: { changePanes, currentPane } });
  }
  let param = {};
  if (location.state.sParam) {
    param = commonUtils.convertStrToObj(location.state.sParam);
  } else {
    param = commonUtils.convertStrToObj(location.state);
  }
  const processReportMobileProps = {
    app,
    content,
    dispatch,
    ...param,
    onRemovePane: removePane,
  };

  return (
    <ProcessReportMobileComponent {...processReportMobileProps} />
  );
}

export default connect(({ app, content, routing }) =>
  ({ app, content, routing }))(ProcessReportMobile);
