import {connect} from 'react-redux';
import ScaleTable from '@components/ScaleTable';
import {getFormulaResult} from '@store/async-actions/fetchModules.js';
import {SET_SCALE_INFO,SAVE_TABLE_RESULT} from '@store/types/pushMessage';

function mapStateToProps (state){
  return {
    scaleInfo: state.pushMessage.scaleInfo,//量表内容
    formulaResult:state.pushMessage.formulaResult //计算结果
  }
}

function mapDispatchToProps (dispatch){
  return {
    getResult(obj){//计算结果
      dispatch({
        type:SAVE_TABLE_RESULT,
        id:obj.id,  //量表id
        data:Object.assign({},obj.data,{pIndex:obj.pIndex})
      })
    },
    saveScaleData(obj){//储存表格数据
      dispatch({
        type:SET_SCALE_INFO,
        data:obj.data,
        id:obj.id //量表id
      })
    }
  }
}

const ScaleTableContainer = connect(mapStateToProps,mapDispatchToProps)(ScaleTable);
export default ScaleTableContainer;