import axios from "../system/axios.js";

export const getScapeConfigs = async () => {
  try {
    const { data } = await axios({
      method: "GET",
      url: "scrap-configs",
    });

    if (!data || !data?.data) {
      return [];
    }

    return data.data;
  } catch (error) {
    console.log("❌ ERROR IN SERVER (getScapeConfigs): ", error);
    return [];
  }
};

export const upsertScapeItems = async (values) => {
  try {
    const { data } = await axios({
      method: "POST",
      url: "scrap-items/upsert",
      data: values,
    });

    if (!data || !data?.data) {
      return [];
    }

    return data.data;
  } catch (error) {
    console.log("❌ ERROR IN SERVER (upsertScapeItems): ", error);
    return [];
  }
};
