export default function useBuildingLevel() {


  function batchUpdateLevels(levels: { _id: string; name: string }[]) {

    const formattedPayloadLevels = levels.map(level => ({
      _id: level._id,
      value: {
        name: level.name
      }
    }));

    return useNuxtApp().$api(`/api/building-levels/batch`, {
      method: "PATCH",
      body: 
        [...formattedPayloadLevels]
    });
  }

  function deleteById(id: string) {
    return useNuxtApp().$api(`/api/building-levels/${id}`, {
      method: "PUT",
    });
  }


  return {
    deleteById,
    batchUpdateLevels
  };
}
