import { defineStore } from "pinia";
import { store } from "@/stores";
import storage, { actions } from "@/utils/storage";
export const propsStore = defineStore("props", {
  state() {
    return {
      propsData: <Array<any>>[],
    };
  },
  actions: {
    setPropsData(e: any) {
      if (storage.getStorage(actions.PROPS_DATA)) {
        this.propsData = JSON.parse(storage.getStorage(actions.PROPS_DATA) || "")
      }
      if (!this.propsData.find((el: any) => el._id === e._id)) {
        this.propsData.push(e)
      }
      storage.setStorage(actions.PROPS_DATA, JSON.stringify(this.propsData))
    },
  },
});
export const usePropsStoreWithOut = () => {
  return propsStore(store);
};
