import api from "./client";

export const ProjectsApi = {
  list: (params) => {
    return api.get(`/projects`, { params }).then((r) => r.data);
  },

  get: (id) => {
    return api.get(`/projects/${id}`).then((r) => r.data);
  },

  create: (data) => {
    return api.post("/projects", data).then((r) => r.data);
  },

  update: (id, data) => {
    return api.patch(`/projects/${id}`, data).then((r) => r.data);
  },

  delete: (id) => {
    return api.delete(`/projects/${id}`).then((r) => r.data);
  },

  getTableData: (id, sheetName, year) => {
    return api
      .get(`/projects/${id}/report/${year}/${sheetName}`)
      .then((r) => r.data);
  },
  export: (id, year, sheetName) => {
    return api.get(`/export/project/${id}/report/${year}/${sheetName}`, {
      responseType: "blob",
    });
  },
};
