import { WeaTools } from "ecCom";
import { postFetch } from "../util/request";
import { convertToUrlString } from "../util/url";

export const getForm = params => {
  return WeaTools.callApi("/api/bs/hrmsalary/scheme/getForm", "get", params);
};
export const getTable = params => {
  return postFetch("/api/bs/hrmsalary/scheme/getTable", params);
};
export const createScheme = params => {
  return postFetch("/api/bs/hrmsalary/scheme/insert", params);
};
export const updateScheme = params => {
  return postFetch("/api/bs/hrmsalary/scheme/update", params);
};
export const getCopyForm = params => {
  return WeaTools.callApi("/api/bs/hrmsalary/scheme/copyForm", "get", params);
};
export const copyScheme = params => {
  if (typeof localStorage.access_token === "string" && localStorage.access_token !== "") {
    params.access_token = localStorage.access_token;
  }
  return fetch(`/api/bs/hrmsalary/scheme/copyScheme?${convertToUrlString(params)}`, {
    method: "GET",
    mode: "cors",
    headers: {
      "Content-Type": "application/json"
    }
  }).then(res => res.json());
};
export const deleteScheme = params => {
  return postFetch("/api/bs/hrmsalary/scheme/delete", params);
};

export const getCustomCategoryForm = params => {
  return WeaTools.callApi("/api/bs/hrmsalary/sicategory/customCategoryForm", "get", params);
};
export const getCustomCategoryList = params => {
  return postFetch("/api/bs/hrmsalary/sicategory/customCategoryList", params);
};
export const createSICategory = params => {
  return postFetch("/api/bs/hrmsalary/sicategory/createSICategory", params);
};
export const updateCustomCategory = params => {
  return postFetch("/api/bs/hrmsalary/sicategory/updateCustomCategoryName", params);
};
export const deleteCustomCategory = (params) => {
  return postFetch("/api/bs/hrmsalary/sicategory/deleteCustomCategory", params);
};
export const updateCustomCategoryStatus = params => {
  return postFetch("/api/bs/hrmsalary/sicategory/updateCustomCategoryStatus", params);
};
