changes
This commit is contained in:
@@ -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 };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user