import {
  SETFAMILYTEXTMODEVALUE,
  REFAMILYTEXTDATA,
  CLEARFAMILYTEXTDATA,
} from '../types/familyHistory';
import { setTextModeValue, reFamilyData } from '../actions/familyHistory';
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 SETFAMILYTEXTMODEVALUE:
      return setTextModeValue(state, action);
    case REFAMILYTEXTDATA:
      return reFamilyData(state, action);
    case CLEARFAMILYTEXTDATA:
      res.saveText = [];
      return res;
    default:
      return res;
  }
}