import {
  SETMARRIAGETEXTMODEVALUE,
  REMARRIAGETEXTDATA,
  CLEARMARRIAGETEXTDATA,
} from '../types/marriageHistory';
import { setTextModeValue, reMarriageData } from '../actions/marriageHistory';
import config from '@config/index';
const block = Object.assign(JSON.parse(config.textLabel), { full: true });//空白时保留一个自由文本标签
const initState = {
  data: [block],
  isEmpty: true,
  saveText: [],
  deledTags: {},
  focusIndex: '',
  editClear: true
};

export default function (state = initState, action) {//console.log(state)
  const res = Object.assign({}, state);
  switch (action.type) {
    case SETMARRIAGETEXTMODEVALUE:
      return setTextModeValue(state, action);
    case REMARRIAGETEXTDATA:
      return reMarriageData(state, action);
    case CLEARMARRIAGETEXTDATA:
      res.saveText = [];
      return res;
    default:
      return res;
  }
}