import { getGoodsSupplyListAPI } from "../services/api";
import { getCustomer } from "@/utils/request.js";

export default {
  namespace: "goodsSupplyList",

  state: {},

  effects: {
    // 获取费用类型列表
    *getGoodsSupplyList({ payload }, { call, put }) {
      payload.customerId = getCustomer().id;
      const response = yield call(getGoodsSupplyListAPI, payload);
      // const response = [
      //   {
      //     id: "GS20180508001",
      //     type: "2018年货补兑付类型A",
      //     amount: "1000"
      //   },
      //   {
      //     id: "GS20180508002",
      //     type: "2018年货补兑付类型B",
      //     amount: "1000"
      //   },
      //   {
      //     id: "GS20180508003",
      //     type: "2018年货补兑付类型C",
      //     amount: "1000"
      //   },
      //   {
      //     id: "GS20180508004",
      //     type: "2018年货补兑付类型D",
      //     amount: "1000"
      //   }
      // ];
      yield put({
        type: "goodsSupplyListData",
        goodsSupplyListData: response
      });
    }
  },

  reducers: {
    goodsSupplyListData(state, payload) {
      return {
        ...state,
        goodsSupplyListData: payload.goodsSupplyListData
      };
    }
  }
};
