From ba70a6d4ca828b08be4b8a27d3abb3868d85668f Mon Sep 17 00:00:00 2001
From: "HATEC\\SPVDEV001" <tri.susilo@altama.co.id>
Date: Fri, 4 Aug 2023 09:34:45 +0700
Subject: fixing validasi variant qty

---
 src/lib/product/components/Product/ProductDesktop.jsx | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 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 7e1d0d3b..3b21db6b 100644
--- a/src/lib/product/components/Product/ProductDesktop.jsx
+++ b/src/lib/product/components/Product/ProductDesktop.jsx
@@ -54,9 +54,10 @@ const ProductDesktop = ({ products, wishlist, toggleWishlist }) => {
   const setVariantQuantityRef = (variantId) => (element) => {
     if (element) {
       let variantIndex = product.variants.findIndex((varian) => varian.id == variantId)
-      product.variants[variantIndex].quantity = element.value
+      product.variants[variantIndex].quantity = element?.value
     }
     variantQuantityRefs.current[variantId] = element
+    
   }
 
   const validQuantity = (quantity) => {
@@ -106,6 +107,15 @@ const ProductDesktop = ({ products, wishlist, toggleWishlist }) => {
     setAddCartAlert(true)
   }
 
+  const handleQuantityChange = (variantId) => (event) => {
+    const { value } = event.target;
+    const variantIndex = product.variants.findIndex((variant) => variant.id === variantId);
+    if (variantIndex !== -1) {
+      product.variants[variantIndex].quantity = parseInt(value, 10); // Pastikan untuk mengubah ke tipe number jika diperlukan
+      // Lakukan sesuatu jika nilai quantity diubah
+    }
+  };
+
   const handleBuy = (variant) => {
     const quantity = variantQuantityRefs.current[variant].value
     if (!validQuantity(quantity)) return
@@ -579,7 +589,7 @@ const ProductDesktop = ({ products, wishlist, toggleWishlist }) => {
                           type='number'
                           className='form-input w-16 py-2 text-center bg-gray_r-1'
                           ref={setVariantQuantityRef(variant.id)}
-                          onChange={setVariantQuantityRef(variant.id)}
+                          onChange={handleQuantityChange(variant.id)}
                           defaultValue={1}
                         />
                       </td>
-- 
cgit v1.2.3


From 47d81f5b23a96611db07f92203d03fc761a68db9 Mon Sep 17 00:00:00 2001
From: "HATEC\\SPVDEV001" <tri.susilo@altama.co.id>
Date: Fri, 4 Aug 2023 09:36:50 +0700
Subject: ketinggalan

---
 src/lib/product/components/Product/ProductDesktop.jsx | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(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 3b21db6b..372ad3ba 100644
--- a/src/lib/product/components/Product/ProductDesktop.jsx
+++ b/src/lib/product/components/Product/ProductDesktop.jsx
@@ -422,7 +422,7 @@ const ProductDesktop = ({ products, wishlist, toggleWishlist }) => {
                   type='number'
                   className='form-input w-16 py-2 text-center bg-gray_r-1'
                   ref={setVariantQuantityRef(product.variants[0].id)}
-                  onChange={setVariantQuantityRef(product.variants[0].id)}
+                  onChange={handleQuantityChange(product.variants[0].id)}
                   defaultValue={1}
                 />
                 <button
-- 
cgit v1.2.3


From d9652e77733a24b329f8d849e700222f06c4331e Mon Sep 17 00:00:00 2001
From: "HATEC\\SPVDEV001" <tri.susilo@altama.co.id>
Date: Fri, 4 Aug 2023 13:24:58 +0700
Subject: add image backgournd

---
 .../product/components/Product/ProductDesktop.jsx  | 65 +++++++++++++++-------
 1 file changed, 44 insertions(+), 21 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 f6c998e2..187ab3c9 100644
--- a/src/lib/product/components/Product/ProductDesktop.jsx
+++ b/src/lib/product/components/Product/ProductDesktop.jsx
@@ -36,6 +36,7 @@ const ProductDesktop = ({ products, wishlist, toggleWishlist }) => {
   const [promotionType, setPromotionType] = useState(false)
   const [promotionActiveId, setPromotionActiveId] = useState(null)
   const [selectVariantPromoActive, setSelectVariantPromoActive] = useState(null)
+  const [backgorundFlashSale, setBackgorundFlashSale] = useState(null)
 
   const getLowestPrice = useCallback(() => {
     const prices = product.variants.map((variant) => variant.price)
@@ -50,6 +51,16 @@ const ProductDesktop = ({ products, wishlist, toggleWishlist }) => {
     setLowestPrice(lowest)
   }, [getLowestPrice])
 
+  useEffect(() => {
+    const getBackgound = async () => {
+      const get = await odooApi('GET', '/api/v1/banner?type=flash-sale-background-banner')
+      setBackgorundFlashSale(get[0].image)
+    }
+    getBackgound()
+  }, [])
+
+  console.log('ini set', backgorundFlashSale)
+
   const [informationTab, setInformationTab] = useState(informationTabOptions[0].value)
 
   const variantQuantityRefs = useRef([])
@@ -60,7 +71,6 @@ const ProductDesktop = ({ products, wishlist, toggleWishlist }) => {
       product.variants[variantIndex].quantity = element?.value
     }
     variantQuantityRefs.current[variantId] = element
-    
   }
 
   const validQuantity = (quantity) => {
@@ -111,13 +121,13 @@ const ProductDesktop = ({ products, wishlist, toggleWishlist }) => {
   }
 
   const handleQuantityChange = (variantId) => (event) => {
-    const { value } = event.target;
-    const variantIndex = product.variants.findIndex((variant) => variant.id === variantId);
+    const { value } = event.target
+    const variantIndex = product.variants.findIndex((variant) => variant.id === variantId)
     if (variantIndex !== -1) {
-      product.variants[variantIndex].quantity = parseInt(value, 10); // Pastikan untuk mengubah ke tipe number jika diperlukan
+      product.variants[variantIndex].quantity = parseInt(value, 10) // Pastikan untuk mengubah ke tipe number jika diperlukan
       // Lakukan sesuatu jika nilai quantity diubah
     }
-  };
+  }
 
   const handleBuy = (variant) => {
     const quantity = variantQuantityRefs.current[variant].value
@@ -187,21 +197,32 @@ const ProductDesktop = ({ products, wishlist, toggleWishlist }) => {
             <div className='w-5/12'>
               <div className='relative mb-2'>
                 {product?.flashSale?.remainingTime > 0 && (
-                  <div className='absolute bottom-0 bg-red-600 w-full h-15 grid'>
-                    <div className='flex gap-x-2 items-center p-2'>
-                      <div className='bg-yellow-400 rounded-full p-1 h-9 w-20 flex items-center justify-center '>
-                        <span className='text-lg font-bold'>{product.lowestPrice.discountPercentage}%</span>
-                      </div>
-                      <div className='bg-red-600 border border-solid border-yellow-400 rounded-full h-9 p-2 flex w-[50%] items-center justify-center gap-x-4'>
-                        <ImageNext
-                          src='/images/ICON_FLASH_SALE_WEBSITE_INDOTEKNIK.svg'
-                          width={17}
-                          height={10}
-                        />
-                        <span className='text-white text-lg font-semibold'>{product.flashSale.tag || 'FLASH SALE'}</span>
-                      </div>
-                      <div>
-                        <CountDown2 initialTime={product.flashSale.remainingTime} />
+                  <div className={`absolute bottom-0 w-full`}>
+                    <div className='absolute bottom-0 w-full h-full'>
+                      <ImageNext src={backgorundFlashSale || '/images/GAMBAR-BG-FLASH-SALE.jpg'} width={1000} height={100} />
+                    </div>
+                    <div className='relative'>
+                      <div className='flex gap-x-2 items-center p-2'>
+                        <div className='bg-yellow-400 rounded-full p-1 h-9 w-20 flex items-center justify-center '>
+                          <span className='text-lg font-bold'>
+                            {product.lowestPrice.discountPercentage}%
+                          </span>
+                        </div>
+                        <div
+                          className={`bg-red-600 border border-solid border-yellow-400 rounded-full h-9 p-2 flex w-[50%] items-center justify-center gap-x-4`}
+                        >
+                          <ImageNext
+                            src='/images/ICON_FLASH_SALE_WEBSITE_INDOTEKNIK.svg'
+                            width={17}
+                            height={10}
+                          />
+                          <span className='text-white text-lg font-semibold'>
+                            {product.flashSale.tag || 'FLASH SALE'}
+                          </span>
+                        </div>
+                        <div>
+                          <CountDown2 initialTime={product.flashSale.remainingTime} />
+                        </div>
                       </div>
                     </div>
                   </div>
@@ -426,7 +447,9 @@ const ProductDesktop = ({ products, wishlist, toggleWishlist }) => {
                       width={15}
                       height={10}
                     />
-                    <span className='text-white text-xs font-semibold'>FLASH SALE</span>
+                    <span className='text-white text-xs font-semibold'>
+                      {product.flashSale.tag || 'FLASH SALE'}
+                    </span>
                   </div>
                 )}
               </div>
-- 
cgit v1.2.3

