import {
  httpDeleteInterceptor,
  httpGetInterceptor,
  httpPostInterceptor,
} from "../http-config/http-interceptor-service";

export async function listDataMedia(
  page: number,
  limit: string,
  search: string,
  categoryFilter: string,
  statusFilter: string
) {
  const name = search || "";
  const url = `media/list?isForAdmin=true&title=${name}&enablePage=1&sortBy=createdAt&sort=desc&size=${limit}&page=${page}&typeId=1&categoryId=${categoryFilter}&statusId=${statusFilter}`;
  return httpGetInterceptor(url);
}

export async function getMediaBlastCampaignPage(page: number) {
  const url = `media/blast/campaign/list?enablePage=1&page=${page}`;
  return httpGetInterceptor(url);
}

export async function getMediaBlastAccountPage(page: number, category: string) {
  const url = `media/blast/account/list?enablePage=1&size=10&page=${page}&category=${category}`;
  return httpGetInterceptor(url);
}

export async function saveMediaBlastCampaign(data: {
  title: string;
  sendTime: string;
  status: string;
  id?: string;
}) {
  const url = `media/blast/campaign`;
  return httpPostInterceptor(url, data);
}

export async function getMediaBlastCampaignById(id: string) {
  const url = `media/blast/campaign?id=${id}`;
  return httpGetInterceptor(url);
}

export async function getMediaBlastCampaignList() {
  const url = `media/blast/campaign/list?enablePage=0&status=waiting`;
  return httpGetInterceptor(url);
}

export async function detailMediaSummary(id: string) {
  const url = `media?id=${id}&isSummary=true`;
  return httpGetInterceptor(url);
}

export async function saveMediaBlastAccount(data: {
  accountName: string;
  accountType: string;
  accountCategory: string;
  emailAddress: string;
  whatsappNumber: string;
  id?: string;
}) {
  const url = `media/blast/account`;
  return httpPostInterceptor(url, data);
}

export async function getMediaBlastAccount(id: string) {
  const url = `media/blast/account?id=${id}`;
  return httpGetInterceptor(url);
}

export async function deleteMediaBlastAccount(id: string) {
  const url = `media/blast/account?id=${id}`;
  return httpDeleteInterceptor(url);
}

export async function saveMediaBlastBroadcast(data: any) {
  const url = `media/blast/broadcast`;
  return httpPostInterceptor(url, data);
}
