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

// export async function listDataAll(
//   isForSelf,
//   isApproval,
//   page,
//   limit,
//   search,
//   fileTypeFilter,
//   statusFilter,
//   startDate,
//   endDate,
//   needApprovalFromLevel
// ) {
//   const name = search || "";
//   const url = `media/list?title=${name}&enablePage=1&sortBy=createdAt&sort=desc&size=${limit}&page=${page}&isForSelf=${isForSelf}&isApproval=${isApproval}&typeId=${fileTypeFilter}&statusId=${statusFilter}&startDate=${
//     startDate == undefined ? "" : startDate
//   }&endDate=${
//     endDate == undefined ? "" : endDate
//   }&needApprovalFromLevel=${needApprovalFromLevel}`;
//   return httpGetInterceptor({ url });
// }

export async function listDataAll(
  isForSelf: any,
  isApproval: any,
  page: any,
  limit: any,
  search: any,
  fileTypeFilter: any,
  statusFilter: any,
  needApprovalFromLevel: any,
  creator: any,
  source: any,
  startDate: any,
  endDate: any,
  title: string = ""
) {
  return await httpGetInterceptor(
    `media/list?enablePage=1&sortBy=createdAt&sort=desc&size=${limit}&page=${page}&isForSelf=${isForSelf}&isApproval=${isApproval}&typeId=${fileTypeFilter}&statusId=${statusFilter}&needApprovalFromLevel=${needApprovalFromLevel}&title=${title}`
  );
}

export async function listDataImage(
  limit: any,
  page: any,
  isForSelf: any,
  isApproval: any,
  categoryFilter: any,
  statusFilter: any,
  needApprovalFromLevel: any,
  creator: any,
  source: any,
  startDate: any,
  endDate: any,
  title: string = ""
) {
  return await httpGetInterceptor(
    `media/list?enablePage=1&sortBy=createdAt&sort=desc&size=${limit}&page=${page}&typeId=1&isForSelf=${isForSelf}&isApproval=${isApproval}&categoryId=${categoryFilter}&statusId=${statusFilter}&needApprovalFromLevel=${needApprovalFromLevel}&creatorUserLevelName=${source}&creatorName=${creator}&startDate=${startDate}&endDate=${endDate}&title=${title}`
  );
}

export async function listDataVideo(
  limit: any,
  page: any,
  isForSelf: any,
  isApproval: any,
  categoryFilter: any,
  statusFilter: any,
  needApprovalFromLevel: any,
  creator: any,
  source: any,
  startDate: any,
  endDate: any,
  title: string = ""
) {
  return await httpGetInterceptor(
    `media/list?enablePage=1&sortBy=createdAt&sort=desc&size=${limit}&page=${page}&typeId=2&isForSelf=${isForSelf}&isApproval=${isApproval}&categoryId=${categoryFilter}&statusId=${statusFilter}&needApprovalFromLevel=${needApprovalFromLevel}&creatorUserLevelName=${source}&creatorName=${creator}&startDate=${startDate}&endDate=${endDate}&title=${title}`
  );
}

export async function listDataTeks(
  limit: any,
  page: any,
  isForSelf: any,
  isApproval: any,
  categoryFilter: any,
  statusFilter: any,
  needApprovalFromLevel: any,
  creator: any,
  source: any,
  startDate: any,
  endDate: any,
  title: string = ""
) {
  return await httpGetInterceptor(
    `media/list?enablePage=1&sortBy=createdAt&sort=desc&size=${limit}&page=${page}&typeId=3&isForSelf=${isForSelf}&isApproval=${isApproval}&categoryId=${categoryFilter}&statusId=${statusFilter}&needApprovalFromLevel=${needApprovalFromLevel}&creatorUserLevelName=${source}&creatorName=${creator}&startDate=${startDate}&endDate=${endDate}&title=${title}`
  );
}

export async function listDataAudio(
  limit: any,
  page: any,
  isForSelf: any,
  isApproval: any,
  categoryFilter: any,
  statusFilter: any,
  needApprovalFromLevel: any,
  creator: any,
  source: any,
  startDate: any,
  endDate: any,
  title: string = ""
) {
  return await httpGetInterceptor(
    `media/list?enablePage=1&sortBy=createdAt&sort=desc&size=${limit}&page=${page}&typeId=4&isForSelf=${isForSelf}&isApproval=${isApproval}&categoryId=${categoryFilter}&statusId=${statusFilter}&needApprovalFromLevel=${needApprovalFromLevel}&creatorUserLevelName=${source}&creatorName=${creator}&startDate=${startDate}&endDate=${endDate}&title=${title}`
  );
}

export async function listSPIT(
  page: any,
  limit: any,
  title = "",
  isPublish: any
) {
  return await httpGetInterceptor(
    `media/spit/pagination?enablePage=1&page=${page}&size=${limit}&sort=desc&sortBy=contentTitleId&title=${title}&isPublish=${isPublish}`
  );
}

export async function listNulisAI(limit: any, page: any, title: string = "") {
  return await httpGetInterceptor(
    `media/nulis-ai/pagination?enablePage=1&page=${page}&size=${limit}&title=${title}`
  );
}

export async function getTagsBySubCategoryId(subCategory: any) {
  return await httpGetInterceptor(
    `media/tags/list?subCategoryId=${subCategory}`
  );
}

export async function listEnableCategory(type: any) {
  const url = `media/categories/list/enable?enablePage=0&sort=desc&sortBy=id&type=${type}`;
  return httpGetInterceptor(url);
}

export async function listCategory(type: any) {
  const url = `media/categories/list/publish?enablePage=0&sort=desc&sortBy=id&categoryId=${type}`;
  return httpGetInterceptor(url);
}

export async function getTags() {
  const url = "media/tags/list";
  return httpGetInterceptor(url);
}

export async function createMedia(data: any) {
  const url = "media";
  return httpPostInterceptor(url, data);
}

export async function uploadThumbnail(id: any, data: any) {
  const url = `media/upload?id=${id}&operation=thumbnail`;
  const headers = {
    "Content-Type": "multipart/form-data",
  };
  return httpPostInterceptor(url, data, { headers });
}

export async function detailSPIT(id: any) {
  const url = `media/spit?id=${id}`;
  return httpGetInterceptor(url);
}

export async function convertSPIT(data: any) {
  const url = "media/spit/convert";
  return httpPostInterceptor(url, data);
}

export async function submitApproval(data: any) {
  const url = "media/approval";
  return httpPostInterceptor(url, data);
}

export async function rejectFiles(data: any) {
  const url = "media/file/rejects";
  return httpPostInterceptor(url, data);
}

export async function saveContentRewrite(data: any) {
  const url = "media/rewrite";
  return httpPostInterceptor(url, data);
}
export async function saveUserReports(data: any) {
  const url = "public/users/reports";
  return httpPostInterceptor(url, data);
}
