import {defineStore} from "pinia";
import {apiGet} from "@/utils/http.js";

export const useAutocompleteStore = defineStore('autocomplete', {

  state: () => ({
    categories: null,
  }),

  actions: {
    async fetchCategories() {
      if (this.categories !== null) return;
      const response = await apiGet('getAutocompleteCategories');
      if (response.success) {
        this.categories = response.data;
      }
    },
  }
});
