/**
 * Created by zhouhuan on 2017/10/30.
 */
import { getData, getMeta } from '../../utils/DataTemplate';

export default {
  namespace: 'obligeeInfo',
  state: {
    detailData: {},
    metas: [],
  },
  effects: {
    *getObligeeDetail({ payload }, { put, call }) {
      const coordinate = {
        containerType: 'module',
        containerName: 'query-DSRInfo',
        datasourceName: 'QueryDSRInfoRelation',
      };
      const result = yield call(getData, coordinate, { params: { pID: payload } });
      yield put({ type: 'getDSRDetail', payload: { ...result[0] } });
      const metas = yield call(getMeta, coordinate);
      yield put({ type: 'setMetas', payload: metas });
    },
  },
  reducers: {
    getDSRDetail(state, { payload }) {
      return {
        ...state,
        detailData: payload,
      };
    },
    setMetas(state, { payload }) {
      return { ...state, metas: payload };
    },
  },
};

