import React from 'react';
import {connect} from 'react-redux';
import {SETRADIO,CLEARSELECTED,CONFIRMSELECTED,SETOTHERINPUT} from '@types/otherHistory';
import {SETMAININPUT} from '@types/mainSuit';
import {SETCURRENTINPUT,CURRENT_TEXT_LABEL} from '@types/currentIll';
import {SETCHECKINPUT} from "@types/checkBody";
import InlineTag from "../common/components/InlineTag";
import {getLabelIndex} from '@utils/tools.js';

function mapStateToProps(state){
  return {
    mainSaveText:state.mainSuit.saveText,
  }
}

const tagInpActions = {
  1:SETMAININPUT,
  2:SETCURRENTINPUT,
  3:SETOTHERINPUT,
  4:SETCHECKINPUT
};

function mapDispatchToProps(dispatch,store){
  return {
    handleInput(params) {
      const type = params.ikey.substr(0,1);    //当前所在的项目
      const {ikey,text,prefix,suffix} = params;
      const i = getLabelIndex(ikey);
      const inner = params.ikey.split("-")[2];
      dispatch({
        type:tagInpActions[+type],
        i,
        text,
        prefix,
        suffix,
        subIndex:inner
      })
    },
  }
}

const InlineTagCont = connect(mapStateToProps,mapDispatchToProps)(InlineTag);

export default InlineTagCont;
