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

export const useStatsStore = defineStore('stats', {
  state: () => ({
    items: {
      orders_count: null,
      orders_total_amount: null,
      customers_count: null,
    }
  }),

  actions: {
    async fetchStats() {
      const response = await apiPost('getDashboardStats');
      this.items.orders_count = response.data?.data?.orders_count;
      this.items.orders_total_amount = response.data?.data?.orders_total_amount;
      this.items.customers_count = response.data?.data?.customers_count;
    }
  },

});
