Files
BarangaySystem/resources/js/composables/useGlobalTransactions.js
2026-06-06 18:43:00 +08:00

30 lines
813 B
JavaScript

import { computed, onMounted } from 'vue';
import { useGlobalTransactionStore } from '../stores/globalTransaction';
export function useGlobalTransactions(filters = null) {
const store = useGlobalTransactionStore();
const transactions = computed(() => store.transactions);
const isLoading = computed(() => store.isLoading);
const error = computed(() => store.error);
const fetchTransactions = async (newFilters = null) => {
return await store.fetchTransactions(newFilters || filters || {});
};
const getProductTransactions = (productHash) => {
return computed(() => store.getTransactionsByProduct(productHash));
};
const precache = () => store.precache();
return {
transactions,
isLoading,
error,
fetchTransactions,
getProductTransactions,
precache
};
}