This commit is contained in:
Viet An
2026-06-16 11:35:43 +07:00
parent a9c37cfff5
commit a8aa9a3dce
6 changed files with 153 additions and 109 deletions

View File

@@ -0,0 +1,22 @@
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 };
}