const URL = "/one-api/mockup/itemout/";

export async function getDivisionByUser(payload) {
  try {
      var resp = await axios.post(URL + 'itemusagev3/getDivisionByUser', payload);
      if (resp.status != 200) {
          return {
              status: "ERR",
              message: resp.statusText
          };
      }
      let data = resp.data;
      return data;
  } catch (e) {
      return {
          status: "ERR",
          message: e.message
      };
  }
}
export async function search(payload) {
  try {
      var resp = await axios.post(URL + 'itemusagev3/search', payload);
      if (resp.status != 200) {
          return {
              status: "ERR",
              message: resp.statusText
          };
      }
      let data = resp.data;
      return data;
  } catch (e) {
      return {
          status: "ERR",
          message: e.message
      };
  }
}
export async function getUnit(payload) {
  try {
      var resp = await axios.post(URL + 'itemusagev3/getUnit', payload);
      if (resp.status != 200) {
          return {
              status: "ERR",
              message: resp.statusText
          };
      }
      let data = resp.data;
      return data;
  } catch (e) {
      return {
          status: "ERR",
          message: e.message
      };
  }
}
export async function saveItemUsage(payload) {
  try {
      var resp = await axios.post(URL + 'itemusagev3/saveItemUsage', payload);
      if (resp.status != 200) {
          return {
              status: "ERR",
              message: resp.statusText
          };
      }
      let data = resp.data;
      return data;
  } catch (e) {
      return {
          status: "ERR",
          message: e.message
      };
  }
}

// item used
export async function getItemUsed(payload) {
  try {
      var resp = await axios.post(URL + 'itemusagev3/getItemUsed', payload);
      if (resp.status != 200) {
          return {
              status: "ERR",
              message: resp.statusText
          };
      }
      let data = resp.data;
      return data;
  } catch (e) {
      return {
          status: "ERR",
          message: e.message
      };
  }
}
export async function updateItemUsed(payload) {
  try {
      var resp = await axios.post(URL + 'itemusagev3/updateItemUsed', payload);
      if (resp.status != 200) {
          return {
              status: "ERR",
              message: resp.statusText
          };
      }
      let data = resp.data;
      return data;
  } catch (e) {
      return {
          status: "ERR",
          message: e.message
      };
  }
}
export async function deleteItemUsed(payload) {
  try {
      var resp = await axios.post(URL + 'itemusagev3/deleteItemUsed', payload);
      if (resp.status != 200) {
          return {
              status: "ERR",
              message: resp.statusText
          };
      }
      let data = resp.data;
      return data;
  } catch (e) {
      return {
          status: "ERR",
          message: e.message
      };
  }
}
export async function confirmItemUsed(payload) {
  try {
      var resp = await axios.post(URL + 'itemusagev3/confirmItemUsed', payload);
      if (resp.status != 200) {
          return {
              status: "ERR",
              message: resp.statusText
          };
      }
      let data = resp.data;
      return data;
  } catch (e) {
      return {
          status: "ERR",
          message: e.message
      };
  }
}
export async function getUnitByItemId(payload) {
  try {
    var resp = await axios.post(URL + 'itemusagev3/getUnitByItemId', payload);
    if (resp.status != 200) {
      return {
        status: "ERR",
        message: resp.statusText
      };
    }
    let data = resp.data;
    return data;
  } catch (e) {
    return {
      status: "ERR",
      message: e.message
    };
  }
}