import { defineStore } from "pinia";
import { ref } from "vue";

export const useServicePackageStore = defineStore("servicePackage", () => {
  const items = ref([]);

  const lastCreatedGroup = ref(null);

  const addItem = (item) => {
    items.value.push(item);
  };

  const removeItem = (index) => {
    items.value.splice(index, 1);
  };

  const clear = () => {
    items.value = [];
  };

  const setLastCreatedGroup = (group) => {
    lastCreatedGroup.value = group;
  };

  return {
    items,
    lastCreatedGroup,
    addItem,
    removeItem,
    clear,
    setLastCreatedGroup,
  };
});
