diff options
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/cart/components/Cart.jsx | 4 | ||||
| -rw-r--r-- | src/lib/cart/components/Cartheader.jsx | 28 |
2 files changed, 29 insertions, 3 deletions
diff --git a/src/lib/cart/components/Cart.jsx b/src/lib/cart/components/Cart.jsx index efbcf76b..b5976a1b 100644 --- a/src/lib/cart/components/Cart.jsx +++ b/src/lib/cart/components/Cart.jsx @@ -22,6 +22,7 @@ import LogoSpinner from '@/core/components/elements/Spinner/LogoSpinner' import { getPromotionProgram } from '@/lib/promotinProgram/api/homepageApi' import PromotionType from '@/lib/promotinProgram/components/PromotionType' import { gtagBeginCheckout } from '@/core/utils/googleTag' +import { useProductCartContext } from '@/contexts/ProductCartContext' const Cart = () => { const router = useRouter() @@ -31,6 +32,8 @@ const Cart = () => { const [cart, setCart] = useState(null) + const {setRefreshCart} = useProductCartContext() + useEffect(() => { if (!auth) return }, [auth]) @@ -196,6 +199,7 @@ const Cart = () => { deleteItemCart({ productId }) setDeleteConfirmation(null) setProducts([...productsToUpdate]) + setRefreshCart(true) toast.success('Berhasil menghapus barang dari keranjang') } diff --git a/src/lib/cart/components/Cartheader.jsx b/src/lib/cart/components/Cartheader.jsx index 3fc959d4..dd6c276e 100644 --- a/src/lib/cart/components/Cartheader.jsx +++ b/src/lib/cart/components/Cartheader.jsx @@ -7,6 +7,7 @@ import useAuth from '@/core/hooks/useAuth' import { useRouter } from 'next/router' import odooApi from '@/core/api/odooApi' import { useProductCartContext } from '@/contexts/ProductCartContext' +import whatsappUrl from '@/core/utils/whatsappUrl' const { ShoppingCartIcon, PhotoIcon } = require('@heroicons/react/24/outline') const { default: Link } = require('next/link') @@ -27,7 +28,6 @@ const Cardheader = (cartCount) => { return productCart?.products || [] }, [productCart]) - const handleMouseEnter = () => { setIsHovered(true) getCart() @@ -79,7 +79,7 @@ const Cardheader = (cartCount) => { useEffect(() => { setCountCart(cartCount.cartCount) - }, []) + }, [cartCount]) const handleCheckout = async () => { SetButtonTerapkan(true) @@ -216,7 +216,29 @@ const Cardheader = (cartCount) => { )} <div className='flex justify-between items-center'> <div className='font-semibold text-sm text-red-600'> - {currencyFormat(product?.price?.priceDiscount)} + {product?.price?.priceDiscount > 0 ? ( + currencyFormat(product?.price?.priceDiscount) + ) : ( + <span className='text-gray_r-12/90 font-normal text-caption-1'> + <a + href={whatsappUrl('product', { + name: product.name, + manufacture: product.manufacture?.name, + url: createSlug( + '/shop/product/', + product.name, + product.id, + true + ) + })} + className='text-danger-500 underline' + rel='noopener noreferrer' + target='_blank' + > + Call For Price + </a> + </span> + )} </div> </div> </div> |
