import axios from 'axios';
import { ComponentMarketParams, PublishComponentParams, ReviewGroup } from '@/api/interface';

// 公共路径
const urlPrefix = '/api/v1/bpms-workbench';

// 组件审核列表
export function getReviewGroupByNew(params: ReviewGroup) {
  return axios.get(`${urlPrefix}/componentMarket/reviewGroupByNew`, { params });
}

// 复制组件设计
export function copyDesign(params) {
  return axios.post(`${urlPrefix}/componentBase/copyDesign`, params);
}

// 组件市场
export function getComponentMarket(params: ComponentMarketParams) {
  return axios.get(`${urlPrefix}/componentMarket/list`, { params });
}

// 组件发布
export function publishComponent(params: PublishComponentParams) {
  return axios.post(`${urlPrefix}/componentMarket/componentSubmitNew`, params);
}

// 删除市场组件/取消组件发布
export function deleteComponentMarket(id) {
  return axios.delete(`${urlPrefix}/componentMarket/delete/${id}`);
}

// 多文件上传
export function uploadComponentFile(formData: FormData) {
  return axios.post(`${urlPrefix}/componentMarket/multiFileUpload`, formData, {
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  });
}