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,23 @@
export default function useCustomer({ activeCart, getCarts }) {
const { $getdata, $patchapi } = useNuxtApp();
const addresses = ref([]);
async function getAddresses() {
addresses.value = await $getdata("Customer_Address", {
filter: { customer: activeCart.value.customer },
});
}
const isChangingCus = ref(false);
async function changeCustomer(cusId) {
isChangingCus.value = true;
const updatedCart = await $patchapi("Cart", {
id: activeCart.value.id,
customer: cusId,
});
await getCarts();
isChangingCus.value = false;
}
return { addresses, getAddresses, isChangingCus, changeCustomer };
}