// @ts-ignore
import { defineStore } from "pinia";

export const useCategoryStore = defineStore("category", {
  state: () => ({
    categories: [],
  }),

  actions: {
    async fetchCategories() {
      // @ts-ignore
      const { $api } = useNuxtApp();

      // @ts-ignore
      await $api.post("/category", { index: 1 }).then((res) => {
        // @ts-ignore
        this.categories = res.data.data; // دقیقاً مثل قبلی
      });
    },
  },

  getters: {
    // @ts-ignore
    getCategories: (state) => state.categories,
  },
});
