21 lines
510 B
JavaScript
21 lines
510 B
JavaScript
import { groupBy } from "es-toolkit";
|
|
|
|
const invoices = ref([]);
|
|
const isPending = ref(false);
|
|
|
|
export function useInvoices() {
|
|
const { $getdata } = useNuxtApp();
|
|
|
|
async function fetchInvoices() {
|
|
isPending.value = true;
|
|
invoices.value = await $getdata("Invoice");
|
|
isPending.value = false;
|
|
}
|
|
|
|
const invoicesByStatus = computed(() => {
|
|
return groupBy(invoices.value, (invoice) => invoice.invoice_status__code);
|
|
});
|
|
|
|
return { invoices, isPending, fetchInvoices, invoicesByStatus };
|
|
}
|