/**
 * @Date:   2019-05-20T16:45:00+08:00
 * @Last modified time: 2019-06-26T18:40:44+08:00
 */

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

function commobilePrintPdf({
  dispatch, app, content, location,
}) {
  if (location.state === null) {
    return (<div />);
  }
  // const param = commonUtils.convertStrToObj(location.state.sParam);
  let param = {};
  if (location.state.sParam) {
    param = commonUtils.convertStrToObj(location.state.sParam);
  } else {
    param = commonUtils.convertStrToObj(location.state);
  }
  const commobilePrintPdfProps = {
    app,
    content,
    ...param,
    dispatch,
  };
  return (
    <CommobilePrintPdf {...commobilePrintPdfProps} style={{ height: '100%' }} />
  );
}

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