import axios from "../../../../config/axios";
import { CreateProjectType, GetProjectResponse, UpdateProjectType } from "../types/ProjectTypes";

export const getProjectsByWorkspace = async (workspaceId: string) => {
  const { data } = await axios.get(`/task-manager/projects/user/workspace/${workspaceId}`);
  return data;
};

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

export const getProject = async (id: string): Promise<GetProjectResponse> => {
  const { data } = await axios.get(`/task-manager/projects/detail/${id}`);
  return data;
};

export const createProject = async (params: CreateProjectType) => {
  const { data } = await axios.post(`/task-manager/projects`, params);
  return data;
};

export const updateProject = async (id: string, params: UpdateProjectType) => {
  const { data } = await axios.patch(`/task-manager/projects/${id}`, params);
  return data;
};

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