import { defineStore } from "pinia";
import ajax from "@/plugins/ajax.js";

export const useResourceStore = defineStore("ResourceStore", {
  state: () => ({
    shipment: {},
    returned: {},
    cargoIntegration: {},
    cargoIntegrations: window.gcargo.cargo_integrations || [],
    warehouses: window.gcargo.warehouses || [],
    shipments: window.gcargo.shipments || [],
    returneds: window.gcargo.returneds || [],
    productCategories: window.gcargo.product_categories || [],
    apiKey: window.gcargo.api_key || "",
    mpSellers: window.gcargo.mp_sellers || [],
  }),
  actions: {
    index: async (contex) => {
      return await ajax.post("index_resource", contex);
    },
    show: async (contex) => {
      return await ajax.post("show_resource", contex);
    },
    store: async (contex) => {
      return await ajax.post("store_resource", contex);
    },
    update: async (contex) => {
      return await ajax.post("update_resource", contex);
    },
    destroy: async (contex) => {
      return await ajax.post("destroy_resource", contex);
    },
  },
});
