23 lines
666 B
JavaScript
23 lines
666 B
JavaScript
export default function useCartData() {
|
|
const { $findapi, $getapi } = useNuxtApp();
|
|
const carts = ref([]);
|
|
const cartItems = ref([]);
|
|
const customers = ref([]);
|
|
const isPending = ref(false);
|
|
|
|
async function getCarts() {
|
|
isPending.value = true;
|
|
const apis = $findapi(["Cart", "Cart_Item", "customer"]);
|
|
const [cartsRes, cartItemsRes, customersRes] = await $getapi(apis);
|
|
isPending.value = false;
|
|
|
|
carts.value = cartsRes.data.rows || [];
|
|
cartItems.value = cartItemsRes.data.rows || [];
|
|
customers.value = customersRes.data.rows || [];
|
|
}
|
|
|
|
onMounted(getCarts);
|
|
|
|
return { carts, cartItems, customers, getCarts, isPending };
|
|
}
|