From 285e91d4b63ca8dbd0a9f55e9c7db8b833749c0a Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Thu, 1 Aug 2024 13:28:41 +0700
Subject: <iman> update popup cart

---
 .../modules/product-detail/components/AddToCart.tsx      | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

(limited to 'src-migrate/modules/product-detail/components/AddToCart.tsx')

diff --git a/src-migrate/modules/product-detail/components/AddToCart.tsx b/src-migrate/modules/product-detail/components/AddToCart.tsx
index b2fed55d..42586032 100644
--- a/src-migrate/modules/product-detail/components/AddToCart.tsx
+++ b/src-migrate/modules/product-detail/components/AddToCart.tsx
@@ -10,6 +10,7 @@ import LazyLoad from 'react-lazy-load';
 import ProductSimilar from '../../../../src/lib/product/components/ProductSimilar';
 import { IProductDetail } from '~/types/product';
 import ImageNext from 'next/image';
+import { useProductCartContext } from '@/contexts/ProductCartContext'
 
 type Props = {
   variantId: number | null,
@@ -31,7 +32,9 @@ const AddToCart = ({
     isClosable: true
   })
   const [product, setProducts] = useState(products);
-  
+  const { productCart, setRefreshCart, setProductCart, refreshCart, isLoading, setIsloading } =
+    useProductCartContext()
+
   const productSimilarQuery = [
     product?.name,
     `fq=-product_id_i:${product.id}`,
@@ -53,7 +56,7 @@ const AddToCart = ({
       typeof auth !== 'object'
     ) return;
     setAddCartAlert(true);
-
+    setRefreshCart(true)
     toast.promise(
       upsertUserCart({
         userId: auth.id,
@@ -100,10 +103,11 @@ const AddToCart = ({
           active={addCartAlert}
           close={() => {
             setAddCartAlert(false);
-            setTimeout(() => {
-              window.location.reload();
-            }, 1500);
-          }}
+            // setTimeout(() => {
+            //   window.location.reload();
+            // }, 1500);
+          }
+        }
         >
           <div className='flex mt-4'>
             <div className='w-[10%]'>
-- 
cgit v1.2.3


From 42829a0907590139ecf4328a7a9ff9f6504a9113 Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Thu, 1 Aug 2024 13:40:57 +0700
Subject: <iman> update pop up cart

---
 src-migrate/modules/product-detail/components/AddToCart.tsx | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

(limited to 'src-migrate/modules/product-detail/components/AddToCart.tsx')

diff --git a/src-migrate/modules/product-detail/components/AddToCart.tsx b/src-migrate/modules/product-detail/components/AddToCart.tsx
index 42586032..644d5b90 100644
--- a/src-migrate/modules/product-detail/components/AddToCart.tsx
+++ b/src-migrate/modules/product-detail/components/AddToCart.tsx
@@ -56,7 +56,7 @@ const AddToCart = ({
       typeof auth !== 'object'
     ) return;
     setAddCartAlert(true);
-    setRefreshCart(true)
+    setRefreshCart(true);
     toast.promise(
       upsertUserCart({
         userId: auth.id,
@@ -103,9 +103,6 @@ const AddToCart = ({
           active={addCartAlert}
           close={() => {
             setAddCartAlert(false);
-            // setTimeout(() => {
-            //   window.location.reload();
-            // }, 1500);
           }
         }
         >
-- 
cgit v1.2.3

