changes
This commit is contained in:
@@ -3,32 +3,17 @@ import Address from "~/components/pos/Address.vue";
|
||||
import CartItem from "~/components/pos/CartItem.vue";
|
||||
import CartTabs from "~/components/pos/CartTabs.vue";
|
||||
import useActiveCart from "~/components/pos/composables/useActiveCart";
|
||||
import useCartData from "~/components/pos/composables/useCartData";
|
||||
import useCustomer from "~/components/pos/composables/useCustomer";
|
||||
import useOrderInfo from "~/components/pos/composables/useOrderInfo";
|
||||
import SearchBox from "~/components/SearchBox.vue";
|
||||
|
||||
const store = useStore();
|
||||
const { $insertapi, $formatNum } = useNuxtApp();
|
||||
|
||||
const { carts, cartItems, customers, getCarts, isPending } = useCartData();
|
||||
const posStore = usePosStore();
|
||||
const { carts, isPending, activeCartId, invalidCartItems, addresses, orderInfo } = storeToRefs(posStore);
|
||||
|
||||
const { activeCartId, activeCart, activeCartItems, customerIdsWithNoCart, subtotal, invalidCartItems } = useActiveCart({
|
||||
carts,
|
||||
cartItems,
|
||||
customers,
|
||||
});
|
||||
|
||||
const { addresses, getAddresses, isChangingCus, changeCustomer } = useCustomer({ activeCart, getCarts });
|
||||
|
||||
const { orderInfo, isOrderValid, fullAddress, total } = useOrderInfo({
|
||||
activeCartId,
|
||||
activeCart,
|
||||
activeCartItems,
|
||||
addresses,
|
||||
getAddresses,
|
||||
subtotal,
|
||||
});
|
||||
const { activeCart, activeCartItems, customerIdsWithNoCart, subtotal } = useActiveCart();
|
||||
const { isOrderValid, total } = useOrderInfo();
|
||||
|
||||
const showModal = ref();
|
||||
|
||||
@@ -57,19 +42,6 @@ function openAddAddressModal() {
|
||||
height: "auto",
|
||||
};
|
||||
}
|
||||
provide("pos", {
|
||||
carts,
|
||||
activeCartId,
|
||||
activeCart,
|
||||
activeCartItems,
|
||||
invalidCartItems,
|
||||
isChangingCus,
|
||||
orderInfo,
|
||||
fullAddress,
|
||||
getCarts,
|
||||
subtotal,
|
||||
total,
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -170,7 +142,7 @@ provide("pos", {
|
||||
placeholder: 'Khách hàng',
|
||||
optionid: activeCart?.customer,
|
||||
onOption: (e) => {
|
||||
if (e?.id !== activeCart?.customer) changeCustomer(e?.id || null);
|
||||
if (e?.id !== activeCart?.customer) posStore.changeCustomer(e?.id || null);
|
||||
},
|
||||
addon: {
|
||||
component: 'customer/CustomerQuickAdd',
|
||||
@@ -250,7 +222,7 @@ provide("pos", {
|
||||
:address="address"
|
||||
:selected="orderInfo.address?.id === address.id"
|
||||
@selectAddress="orderInfo.address = $event"
|
||||
@submit="getAddresses"
|
||||
@submit="posStore.getAddresses(activeCart.customer)"
|
||||
/>
|
||||
</div>
|
||||
<div
|
||||
@@ -379,7 +351,7 @@ provide("pos", {
|
||||
async () => {
|
||||
const newCart = await $insertapi('Cart', { notify: false });
|
||||
activeCartId = newCart.id;
|
||||
getCarts();
|
||||
posStore.getCarts();
|
||||
}
|
||||
"
|
||||
class="button is-primary"
|
||||
|
||||
Reference in New Issue
Block a user