From 4f285349adec93a040e41d1d8c0c1c7b57749397 Mon Sep 17 00:00:00 2001
From: "HATEC\\SPVDEV001" <tri.susilo@altama.co.id>
Date: Thu, 21 Sep 2023 14:56:35 +0700
Subject: add context for list product popup cart

---
 src/lib/product/components/Product/ProductDesktop.jsx | 4 ++++
 1 file changed, 4 insertions(+)

(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 937f2746..6da289bc 100644
--- a/src/lib/product/components/Product/ProductDesktop.jsx
+++ b/src/lib/product/components/Product/ProductDesktop.jsx
@@ -22,6 +22,7 @@ import ImageNext from 'next/image'
 import CountDown2 from '@/core/components/elements/CountDown/CountDown2'
 import { LazyLoadComponent } from 'react-lazy-load-image-component'
 import ColumnsSLA from './ColumnsSLA'
+import { useProductCartContext } from '@/contexts/ProductCartContext'
 
 const ProductDesktop = ({ products, wishlist, toggleWishlist }) => {
   const router = useRouter()
@@ -39,6 +40,8 @@ const ProductDesktop = ({ products, wishlist, toggleWishlist }) => {
   const [selectVariantPromoActive, setSelectVariantPromoActive] = useState(null)
   const [backgorundFlashSale, setBackgorundFlashSale] = useState(null)
 
+  const {setRefreshCart , refreshCart} = useProductCartContext()
+
   const getLowestPrice = useCallback(() => {
     const prices = product.variants.map((variant) => variant.price)
     const lowest = prices.reduce((lowest, price) => {
@@ -116,6 +119,7 @@ const ProductDesktop = ({ products, wishlist, toggleWishlist }) => {
 
     let source = 'cart'
     updateCart(variantId, quantity, source)
+    setRefreshCart(true)
     setAddCartAlert(true)
   }
 
-- 
cgit v1.2.3

