import { api } from "../utils/axiosClient";

export const TasksRepository = {
  getTaskList: (projectId, pageSize, pageNumber, serviceId, filter) => {
    const payloadJsonString = JSON.stringify(filter);
    let url = `api/task/list?projectId=${projectId}&pageSize=${pageSize}&pageNumber=${pageNumber}`;

    if (serviceId) {
      url += `&serviceId=${serviceId}`;
    }
    if (filter && Object.keys(filter).length > 0) {
      const payloadJsonString = encodeURIComponent(JSON.stringify(filter));
      url += `&filter=${payloadJsonString}`;
    }

    return api.get(url);
  },

  getTaskListFilter:(projectId)=>api.get(`/api/task/filter/${projectId}`),

  getTaskById: (id) => api.get(`/api/task/get/${id}`),
  reportTask: (data) => api.post("api/task/report", data),
  taskComments: (data) => api.post("api/task/comment", data),
  auditTask: (data) => api.post("/api/task/approve", data),

  assignTask: (data) => api.post("/api/task/assign", data),
};
