import http from "@/utils/http";
import { AppDispatch } from "..";
import { A2tableType } from "@/types";
/**
 * 获取 积分管理（用户活跃、爱心林场） 列表
 */
export const A2_APIgetList = () => {
  return async (dispatch: AppDispatch) => {
    const res = await http.get("cms/rule/getList");
    if (res.code === 0) {
      const list: A2tableType[] = res.data;
      const obj = {
        list1: list.filter((v) => v.type === "user"),
        list2: list.filter((v) => v.type === "game"),
      };
      dispatch({ type: "A2/getList", payload: obj });
    }
  };
};

/**
 * 编辑爱心币和天数
 */
export const A2_APIsave = (data:any) => {
  return http.post('cms/rule/save',data);
};
