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

type Result = {
  code: number;
  message: string;
  data?: any;
};

type ResultTable = {
  code: number;
  message: string;
  data?: {
    list: Array<any>;
    total: number;
    pageSize: number;
    currentPage: number;
  };
};

export const getActivityList = (params: {
  page?: number;
  pageSize?: number;
  activityName?: string;
  activityType?: number;
  status?: number;
}) => {
  return http.request<ResultTable>("get", "/marketing/activity/list", {
    params
  });
};

export const getActivityById = (id: number) => {
  return http.request<Result>("get", `/marketing/activity/${id}`);
};

export const createActivity = (data: any) => {
  return http.request<Result>("post", "/marketing/activity", { data });
};

export const updateActivity = (id: number, data: any) => {
  return http.request<Result>("put", `/marketing/activity/${id}`, { data });
};

export const publishActivity = (id: number) => {
  return http.request<Result>("put", `/marketing/activity/${id}/publish`);
};

export const pauseActivity = (id: number) => {
  return http.request<Result>("put", `/marketing/activity/${id}/pause`);
};

export const resumeActivity = (id: number) => {
  return http.request<Result>("put", `/marketing/activity/${id}/resume`);
};

export const deleteActivity = (id: number) => {
  return http.request<Result>("delete", `/marketing/activity/${id}`);
};

export const getActivityStatistics = (id: number) => {
  return http.request<Result>("get", `/marketing/activity/${id}/statistics`);
};

export const getOngoingActivities = () => {
  return http.request<Result>("get", "/marketing/activity/ongoing");
};
