This commit is contained in:
Viet An
2026-06-25 09:14:51 +07:00
parent 66ffa01c57
commit 07151bf78e
4 changed files with 48 additions and 25 deletions

View File

@@ -1,12 +1,15 @@
export default function useOrderInfo({ activeCartId, activeCart, activeCartItems, addresses, getAddresses }) {
export default function useOrderInfo({ activeCartId, activeCart, activeCartItems, addresses, getAddresses, subtotal }) {
const orderInfo = ref({
address: null,
receiver_name: null,
receiver_phone: null,
shipping_fee: null,
deliveryMethod: null,
paymentMethod: null,
});
const total = computed(() => subtotal.value + orderInfo.value.shipping_fee);
watch(activeCartId, () => {
// reset fields when tab is switched
orderInfo.value.deliveryMethod = null;
@@ -51,5 +54,10 @@ export default function useOrderInfo({ activeCartId, activeCart, activeCartItems
return true;
});
return { orderInfo, isOrderValid };
const fullAddress = computed(() => {
if (!orderInfo.value.address) return "";
return `${orderInfo.value.address.address_detail}, ${orderInfo.value.address.ward}, ${orderInfo.value.address.district}, ${orderInfo.value.address.city}`;
});
return { orderInfo, isOrderValid, fullAddress, total };
}