From 019068a387c29ec61b53031b68cf81000063186e Mon Sep 17 00:00:00 2001 From: "HATEC\\SPVDEV001" Date: Wed, 26 Jul 2023 14:05:53 +0700 Subject: add condition source --- .../product/components/Product/ProductDesktop.jsx | 23 +++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'src/lib/product/components/Product/ProductDesktop.jsx') 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`) } -- cgit v1.2.3 From 46c208194cb80be3a4ce2d42ad817551b9b2a18d Mon Sep 17 00:00:00 2001 From: "HATEC\\SPVDEV001" Date: Thu, 27 Jul 2023 10:08:28 +0700 Subject: bugs fix variant page --- .../product/components/Product/ProductDesktop.jsx | 38 +++++++++++++++++----- 1 file changed, 30 insertions(+), 8 deletions(-) (limited to 'src/lib/product/components/Product/ProductDesktop.jsx') diff --git a/src/lib/product/components/Product/ProductDesktop.jsx b/src/lib/product/components/Product/ProductDesktop.jsx index cf4d9b0d..dfff91d7 100644 --- a/src/lib/product/components/Product/ProductDesktop.jsx +++ b/src/lib/product/components/Product/ProductDesktop.jsx @@ -1,5 +1,4 @@ import Image from '@/core/components/elements/Image/Image' -import ImageNext from 'next/image' import Link from '@/core/components/elements/Link/Link' import DesktopView from '@/core/components/views/DesktopView' import currencyFormat from '@/core/utils/currencyFormat' @@ -15,10 +14,7 @@ import BottomPopup from '@/core/components/elements/Popup/BottomPopup' import ProductCard from '../ProductCard' import productSimilarApi from '../../api/productSimilarApi' import whatsappUrl from '@/core/utils/whatsappUrl' -import { gtagAddToCart } from '@/core/utils/googleTag' import odooApi from '@/core/api/odooApi' -import { last } from 'lodash-contrib' -import { m } from 'framer-motion' import { Button, Spinner } from 'flowbite-react' import PromotionType from '@/lib/promotinProgram/components/PromotionType' import useAuth from '@/core/hooks/useAuth' @@ -81,16 +77,15 @@ const ProductDesktop = ({ products, wishlist, toggleWishlist }) => { quantity, programLineId: product.variants[variantIndex].programActive, selected: true, - source : source === 'buy' ? 'buy' : null + source: source === 'buy' ? 'buy' : null } - } else { dataUpdate = { productId: variantId, quantity, programLineId: promotionActiveId, selected: true, - source : source === 'buy' ? 'buy' : null + source: source === 'buy' ? 'buy' : null } } updateItemCart(dataUpdate) @@ -269,7 +264,34 @@ const ProductDesktop = ({ products, wishlist, toggleWishlist }) => { )} -
+ {product.variants.length === 1 && ( +
+
Stock
+
+ {isLoadingSLA && ( +
+ +
+ )} + {product?.variants[0].sla?.qty > 0 && ( + {product?.variants[0].sla?.qty} + )} + {product?.variants[0].sla?.qty == 0 && ( + + Tanya Admin + + )} +
+
+ )} +
1 ? '' : 'bg-gray_r-4'} `}>
Berat Barang
{product?.weight > 0 && {product?.weight} KG} -- cgit v1.2.3