From a2221f7b66f259cddc83ae95c159b30d7e5612ce Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Sat, 31 Aug 2024 12:28:43 +0700
Subject: <iman> update new cart pop up image

---
 .../modules/product-promo/components/AddToCart.tsx | 23 +++++++++++++++-------
 1 file changed, 16 insertions(+), 7 deletions(-)

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

diff --git a/src-migrate/modules/product-promo/components/AddToCart.tsx b/src-migrate/modules/product-promo/components/AddToCart.tsx
index a3938142..757253f7 100644
--- a/src-migrate/modules/product-promo/components/AddToCart.tsx
+++ b/src-migrate/modules/product-promo/components/AddToCart.tsx
@@ -34,6 +34,7 @@ const ProductPromoAddToCart = ({product, promotion }: Props) => {
 
   const {askAdminUrl} = useProductDetail();
   const [status, setStatus] = useState<Status>('idle')
+  const [idProduct, setidProduct] = useState<number>()
   const { productCart, setRefreshCart, setProductCart, refreshCart, isLoading, setIsloading } =
     useProductCartContext()
 
@@ -61,6 +62,7 @@ const ProductPromoAddToCart = ({product, promotion }: Props) => {
       source: 'add_to_cart',
       qtyAppend: true
     })
+    setidProduct(promotion?.products[0]?.product_id)
     setStatus('idle')
     setRefreshCart(true);
     setAddCartAlert(true);
@@ -123,13 +125,20 @@ const ProductPromoAddToCart = ({product, promotion }: Props) => {
         >
           <div className='flex mt-4'>
             <div className='w-[10%]'>
-              <ImageNext
-                  src={product.image}
-                  alt={product.name}
-                  className='h-32 object-contain object-center w-full border border-gray_r-4'
-                  width={80}
-                  height={80}
-                />
+            <ImageNext
+                src={
+                  product?.image
+                    ? product.image
+                    : idProduct
+                    ? `https://erp.indoteknik.com/api/image/product.product/image_256/${idProduct}`
+                    : `https://erp.indoteknik.com/api/image/product.template/image_256/${idProduct}`
+                }
+                alt={product.name}
+                className='h-32 object-contain object-center w-full border border-gray_r-4'
+                width={80}
+                height={80}
+              />
+
             </div>
             <div className='ml-3 flex flex-1 items-start font-medium justify-center flex-col gap-y-1'>
               {!!product?.manufacture?.name ? (
-- 
cgit v1.2.3

