import {
  getAPI,
  getAPIInterceptor,
  postAPI,
  postAPIInterceptor,
} from "@/config/api";
import {
  httpGetInterceptor,
  httpGetInterceptorWithToken,
} from "../http-config/http-interceptor-service";

export async function listDataImage(
  page: any,
  limit: any,
  isForSelf: any,
  isApproval: any,
  categoryFilter: any,
  statusFilter: any,
  needApprovalFromLevel: any,
  creator: any,
  source: any,
  startDate: any,
  endDate: any
) {
  return await getAPIInterceptor(
    `media/list?enablePage=0&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}`
  );
}

export async function listDataVideo(
  page: any,
  limit: any,
  isForSelf: any,
  isApproval: any,
  categoryFilter: any,
  statusFilter: any,
  needApprovalFromLevel: any,
  creator: any,
  source: any,
  startDate: any,
  endDate: any
) {
  return await getAPIInterceptor(
    `media/list?enablePage=0&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}`
  );
}

export async function listDataTeks(
  page: any,
  limit: any,
  isForSelf: any,
  isApproval: any,
  categoryFilter: any,
  statusFilter: any,
  needApprovalFromLevel: any,
  creator: any,
  source: any,
  startDate: any,
  endDate: any
) {
  return await getAPIInterceptor(
    `media/list?enablePage=0&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}`
  );
}

export async function listDataAudio(
  page: any,
  limit: any,
  isForSelf: any,
  isApproval: any,
  categoryFilter: any,
  statusFilter: any,
  needApprovalFromLevel: any,
  creator: any,
  source: any,
  startDate: any,
  endDate: any
) {
  return await getAPIInterceptor(
    `media/list?enablePage=0&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}`
  );
}

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 getTagsBySubCategoryId(subCategory: any) {
  return await getAPIInterceptor(
    `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 getAPIInterceptor(url);
}

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

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