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

// export async function listTask(size: number, page: number) {
//   return await httpGetInterceptor(
//     `assignment/list?enablePage=1&title=${title}&size=${limit}&page=${page}`
//   );
// }

export async function listTask(
  title: string = "",
  page: any,
  size: any,
  taskType: string
) {
  const url = `assignment/list?enablePage=1&size=${size}&page=${page}&title=${title}&taskType=${taskType}`;
  return httpGetInterceptor(url);
}

// export async function createTask(data: any) {
//   const url = "assignment";
//   return httpPostInterceptor(url, data);
// }

export async function createTask(data: any) {
  const pathUrl = "assignment";
  return httpPostInterceptor(pathUrl, data);
}

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

export async function forwardTask(data: any) {
  const url = "assignment/forward";
  return httpPostInterceptor(url, data);
}

export async function finishTask(id: any) {
  const url = `assignment/finish?id=${id}`;
  return httpPostInterceptor(url, id);
}

export async function deleteTask(id: any) {
  const url = `assignment?id=${id}`;
  return httpDeleteInterceptor(url);
}

export async function getUserLevelForAssignments() {
  const url = "/users/user-levels/assignment";
  return httpGetInterceptor(url);
}

export async function getAssignmentResponseList(id: any) {
  const url = `assignment/response?assignmentId=${id}`;
  return httpGetInterceptor({ url });
}

export async function createAssignmentResponse(data: any) {
  const url = "assignment/response";
  return httpPostInterceptor(url, data);
}

export async function deleteAssignmentResponse(id: any) {
  const url = `assignment/response?id=${id}`;
  return httpDeleteInterceptor(url);
}

export async function getAcceptance(id: any, isAccept: any) {
  const url = `assignment/acceptance?id=${id}&isAccept=${isAccept}`;
  return httpGetInterceptor({ url });
}

export async function acceptAssignment(id: any, isAccept: any) {
  const url = `assignment/acceptance?id=${id}`;
  return httpPostInterceptor(url, id);
}

export async function postFinishAcceptance(id: any) {
  const url = `assignment/finish-acceptance?id=${id}`;
  return httpPostInterceptor(url, id);
}

export async function getAcceptanceAssignmentStatus(id: any) {
  const url = `assignment/acceptance/status?id=${id}`;
  return httpGetInterceptor({ url });
}

export async function getListAttachment(assignmentId: any, isForCreator: any) {
  const url = `media/list?&enablePage=0&assignmentId=${assignmentId}&isForAdmin=${isForCreator}`;
  return httpGetInterceptor({ url });
}
