import { useLocalStore } from 'mobx-react-lite';
import { axios } from '@choerodon/boot';
import map from 'lodash/map';
import { handlePromptError } from "../../../utils";
export default function useStore() {
  return useLocalStore(function () {
    return {
      /**
       * 强制失败流水线
       * @param projectId
       * @param id
       * @returns {*}
       */
      manualStop: function manualStop(projectId, id) {
        return axios.get("/devops//v1/projects/".concat(projectId, "/pipeline/failed?pipeline_record_id=").concat(id));
      },

      /**
       ** 流水线重试
       * @param projectId
       * @param id 执行记录id
       */
      retry: function retry(projectId, id) {
        return axios.get("/devops/v1/projects/".concat(projectId, "/pipeline/").concat(id, "/retry"));
      },

      /**
       ** 人工审核阶段或任务
       * @param projectId
       * @param data
       */
      checkData: function checkData(projectId, data) {
        return axios.post("/devops/v1/projects/".concat(projectId, "/pipeline/audit"), JSON.stringify(data));
      },

      /**
       ** 人工审核预检，判断是否可以审核
       * @param projectId
       * @param data
       */
      canCheck: function canCheck(projectId, data) {
        return axios.post("/devops/v1/projects/".concat(projectId, "/pipeline/check_audit"), JSON.stringify(data));
      }
    };
  });
}