changes
This commit is contained in:
20
app/components/orders/composables/useInvoices.js
Normal file
20
app/components/orders/composables/useInvoices.js
Normal file
@@ -0,0 +1,20 @@
|
||||
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 };
|
||||
}
|
||||
Reference in New Issue
Block a user