import http from "@/utils/http";
import { AppDispatch } from "..";

/**
 *活动-志愿者-列表
 */

export const B2_APIgetList = (
  data: any,
  type: "activity" | "volunteer"
): any => {
  return async (dispatch: AppDispatch) => {
    const res = await http.post("cms/bookInfo/pageList", { ...data, type });
    if (res.code === 0) {
      const obj = {
        list: res.data.records,
        total: res.data.total,
      };

      dispatch({
        type: type === "activity" ? "B2/getList1" : "B2/getList2",
        payload: obj,
      });
    }
  };
};

/**
 * 活动-志愿者-删除
 */
export const B2_APIdel = (id: number) => {
  return http.get(`cms/bookInfo/removes/${id}`);
};

/**
 * 活动-志愿者-处理状态
 */

export const B2_APIsetStatus = (id: number, status: 0 | 1) => {
  return http.get(`cms/bookInfo/update/${id}/${status}`);
};
