ordering-ui-react-native 0.14.97 → 0.14.98
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -96,11 +96,24 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
|
|
|
96
96
|
}
|
|
97
97
|
|
|
98
98
|
const onProductClick = (product: any) => {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
99
|
+
const cartProduct = currentCart?.products?.find((cproduct: any) => cproduct?.id === product?.id)
|
|
100
|
+
if (cartProduct) {
|
|
101
|
+
onRedirect('ProductDetails', {
|
|
102
|
+
businessId: business.id,
|
|
103
|
+
isCartProduct: true,
|
|
104
|
+
productCart: cartProduct,
|
|
105
|
+
businessSlug: business?.slug,
|
|
106
|
+
categoryId: cartProduct?.category_id,
|
|
107
|
+
productId: cartProduct?.id,
|
|
108
|
+
})
|
|
109
|
+
} else {
|
|
110
|
+
onRedirect('ProductDetails', {
|
|
111
|
+
product: product,
|
|
112
|
+
businessSlug: business.slug,
|
|
113
|
+
businessId: business.id,
|
|
114
|
+
})
|
|
115
|
+
}
|
|
116
|
+
|
|
104
117
|
}
|
|
105
118
|
|
|
106
119
|
const handleCancel = () => {
|
|
@@ -77,25 +77,18 @@ export const SingleProductCard = (props: SingleProductCardParams) => {
|
|
|
77
77
|
const editMode = typeof product?.code !== 'undefined';
|
|
78
78
|
|
|
79
79
|
const removeToBalance = editMode ? product?.quantity : 0;
|
|
80
|
-
const
|
|
81
|
-
const
|
|
82
|
-
|
|
83
|
-
)
|
|
84
|
-
const totalBalance = (productCart?.quantity || 0) - removeToBalance;
|
|
80
|
+
const cartProducts: any = Object.values(orderState.carts).reduce((products: any, _cart: any) => [...products, ..._cart?.products], [])
|
|
81
|
+
const productBalance = cartProducts.reduce((sum: any, _product: any) => sum + (_product.id === product?.id ? _product.quantity : 0), 0)
|
|
82
|
+
|
|
83
|
+
const totalBalance = (productBalance || 0) - removeToBalance
|
|
85
84
|
|
|
86
85
|
const maxCartProductConfig =
|
|
87
86
|
(stateConfig.configs.max_product_amount
|
|
88
87
|
? parseInt(stateConfig.configs.max_product_amount)
|
|
89
88
|
: 100) - totalBalance;
|
|
90
89
|
|
|
91
|
-
const productBalance =
|
|
92
|
-
(cart?.products?.reduce(
|
|
93
|
-
(sum: any, _product: any) =>
|
|
94
|
-
sum + (product && _product.id === product?.id ? _product.quantity : 0),
|
|
95
|
-
0,
|
|
96
|
-
) || 0) - removeToBalance;
|
|
97
90
|
let maxCartProductInventory =
|
|
98
|
-
(product?.inventoried ? product?.quantity : undefined) -
|
|
91
|
+
(product?.inventoried ? product?.quantity : undefined) - totalBalance;
|
|
99
92
|
maxCartProductInventory = !isNaN(maxCartProductInventory)
|
|
100
93
|
? maxCartProductInventory
|
|
101
94
|
: maxCartProductConfig;
|