summaryrefslogtreecommitdiff
path: root/src/lib/product/components
diff options
context:
space:
mode:
authortrisusilo <tri.susilo@altama.co.id>2023-07-26 07:03:56 +0000
committertrisusilo <tri.susilo@altama.co.id>2023-07-26 07:03:56 +0000
commitcea5468a29e70aec335e2e80c7fa03e35a3c73bf (patch)
treeb96995779374d24d3bfb498ec12f574d3aa37f3a /src/lib/product/components
parent3f9acbd9ee447fb5cf45cbd07821ad60c9d2f331 (diff)
parent019068a387c29ec61b53031b68cf81000063186e (diff)
Merged in Hotfix/action_click_button_beli (pull request #28)
add condition source
Diffstat (limited to 'src/lib/product/components')
-rw-r--r--src/lib/product/components/Product/ProductDesktop.jsx23
1 files changed, 14 insertions, 9 deletions
diff --git a/src/lib/product/components/Product/ProductDesktop.jsx b/src/lib/product/components/Product/ProductDesktop.jsx
index 9be65bfb..cf4d9b0d 100644
--- a/src/lib/product/components/Product/ProductDesktop.jsx
+++ b/src/lib/product/components/Product/ProductDesktop.jsx
@@ -72,25 +72,28 @@ const ProductDesktop = ({ products, wishlist, toggleWishlist }) => {
return isValid
}
- const updateCart = (variantId, quantity) => {
+ const updateCart = (variantId, quantity, source) => {
+ let dataUpdate
if (product.variants.length > 1) {
let variantIndex = product.variants.findIndex((varian) => varian.id == variantId)
- updateItemCart({
+ dataUpdate = {
productId: variantId,
quantity,
programLineId: product.variants[variantIndex].programActive,
selected: true,
- source: 'buy'
- })
+ source : source === 'buy' ? 'buy' : null
+ }
+
} else {
- updateItemCart({
+ dataUpdate = {
productId: variantId,
quantity,
programLineId: promotionActiveId,
selected: true,
- source: 'buy'
- })
+ source : source === 'buy' ? 'buy' : null
+ }
}
+ updateItemCart(dataUpdate)
}
const handleAddToCart = (variantId) => {
@@ -102,7 +105,8 @@ const ProductDesktop = ({ products, wishlist, toggleWishlist }) => {
if (!validQuantity(quantity)) return
- updateCart(variantId, quantity)
+ let source = 'cart'
+ updateCart(variantId, quantity, source)
setAddCartAlert(true)
}
@@ -110,7 +114,8 @@ const ProductDesktop = ({ products, wishlist, toggleWishlist }) => {
const quantity = variantQuantityRefs.current[variant].value
if (!validQuantity(quantity)) return
- updateCart(variant, quantity)
+ let source = 'buy'
+ updateCart(variant, quantity, source)
router.push(`/shop/checkout?source=buy`)
}