import Config from '../../../../utils/config';
import { birthcertificateInfo } from '../../services/index';
import { Toast } from 'antd-mobile';
import router from 'umi/router';

export default {
  state: {},
  reducers: {
    updateState(state, { payload }) {
      return {
        ...state,
        ...payload,
      };
    },
    clean(state, { payload }) {
      return {};
    },
  },
  effects: {
    *birthcertificateInfo({ payload }, { call, put }) {
      const { rc, msg, data } = yield call(birthcertificateInfo, { ...payload });
      if (rc === Config.constant.codeSuccess) {
        yield put({
          type: 'updateState',
          payload: {
            ...data,
          },
        });
      } else {
        Toast.fail(msg);
      }
    },
  },
  subscriptions: {
    // setupHistory({ dispatch, history }) {
    //   history.listen(location => {});
    // },
  },
};
