import {SETDATA,CONFIRMSELECTED,SETRADIO,SETNUMBER,SETOTHERCHECKBOX,SETOTHERTEXT,SETOTHERSEARCHDATA,
  SELECTOTHERSEARCHDATA,CLEAROTHERHISTORY,CHANGEOTHERTEXTLABEL,SETOTHERINPUT,SETTEXTMODEVALUE,OTHER_FOCUS_INDEX,OTHERHIS_CLEAR,OTHERADDLABELITEM,OTHEREDICLEAR} from '../types/otherHistory';
import {confirm,setRadioValue,setNumberValue,setCheckBoxValue,setCheckText,setSearchData,insertLabelData,clearOtherHistory,changeTextLabel,setOtherInput,setTextModeValue,addLabelItem,otherEditClear} from '../actions/otherHistory';

const initState = {data:[],saveText:[],selecteds:[],focusIndex:'',editClear:true};/*mockData.OtherHis.moduleDetailDTOList;[
    mockData.radioData,
    mockData.inputData,
    mockData.spreadData,
    mockData.inpRadioData,
    mockData.spreadMultData,
  ];*/

export default function(state=initState,action){//console.log(state)
  const res = Object.assign({},state);
  switch (action.type){
    case SETDATA:
      res.data = action.data;
      res.saveText = action.save||[];
      return res;
    case SETRADIO:
      return setRadioValue(state,action);
    case SETNUMBER:
      return setNumberValue(state,action);
    case CONFIRMSELECTED:
      return confirm(state,action);
    case SETOTHERTEXT:
      return setCheckText(state,action);
    case SETOTHERSEARCHDATA:
      return setSearchData(state,action);
    case SETOTHERCHECKBOX:
      return setCheckBoxValue(state,action);
    case SELECTOTHERSEARCHDATA:
      return insertLabelData(state,action);
    case CLEAROTHERHISTORY:
      return clearOtherHistory(state,action);
    case CHANGEOTHERTEXTLABEL:
      return changeTextLabel(state,action);
    case SETOTHERINPUT:
      return setOtherInput(state,action);
    case SETTEXTMODEVALUE:
      return setTextModeValue(state,action);
    case OTHERADDLABELITEM:
      return addLabelItem(state,action);
    case OTHER_FOCUS_INDEX:
      res.focusIndex = action.index;
      res.span = action.$span;
    case OTHERHIS_CLEAR:
        res.searchData = [];
        return res;
    case OTHEREDICLEAR:
        return otherEditClear(state,action);;
    default:
      return res;
  }
}