import axios from "../../../../config/axios";
import {
  CreateTaskCommentResponse,
  CreateTaskCommentType,
  GetTaskCommentsResponse,
  UpdateTaskCommentResponse,
  UpdateTaskCommentType,
} from "../types/TaskCommentTypes";

export const getTaskComments = async (taskId: string): Promise<GetTaskCommentsResponse> => {
  const { data } = await axios.get(`/task-manager/comments/task/${taskId}`);
  return data;
};

export const createTaskComment = async (params: CreateTaskCommentType): Promise<CreateTaskCommentResponse> => {
  const { data } = await axios.post(`/task-manager/comments`, params);
  return data;
};

export const updateTaskComment = async (
  id: string,
  params: UpdateTaskCommentType,
): Promise<UpdateTaskCommentResponse> => {
  const { data } = await axios.patch(`/task-manager/comments/${id}`, params);
  return data;
};

export const deleteTaskComment = async (id: string) => {
  const { data } = await axios.delete(`/task-manager/comments/${id}`);
  return data;
};
