From 46c208194cb80be3a4ce2d42ad817551b9b2a18d Mon Sep 17 00:00:00 2001
From: "HATEC\\SPVDEV001" <tri.susilo@altama.co.id>
Date: Thu, 27 Jul 2023 10:08:28 +0700
Subject: bugs fix variant page

---
 .../product/components/Product/ProductDesktop.jsx  | 38 +++++++++++++++++-----
 1 file changed, 30 insertions(+), 8 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 cf4d9b0d..dfff91d7 100644
--- a/src/lib/product/components/Product/ProductDesktop.jsx
+++ b/src/lib/product/components/Product/ProductDesktop.jsx
@@ -1,5 +1,4 @@
 import Image from '@/core/components/elements/Image/Image'
-import ImageNext from 'next/image'
 import Link from '@/core/components/elements/Link/Link'
 import DesktopView from '@/core/components/views/DesktopView'
 import currencyFormat from '@/core/utils/currencyFormat'
@@ -15,10 +14,7 @@ import BottomPopup from '@/core/components/elements/Popup/BottomPopup'
 import ProductCard from '../ProductCard'
 import productSimilarApi from '../../api/productSimilarApi'
 import whatsappUrl from '@/core/utils/whatsappUrl'
-import { gtagAddToCart } from '@/core/utils/googleTag'
 import odooApi from '@/core/api/odooApi'
-import { last } from 'lodash-contrib'
-import { m } from 'framer-motion'
 import { Button, Spinner } from 'flowbite-react'
 import PromotionType from '@/lib/promotinProgram/components/PromotionType'
 import useAuth from '@/core/hooks/useAuth'
@@ -81,16 +77,15 @@ const ProductDesktop = ({ products, wishlist, toggleWishlist }) => {
         quantity,
         programLineId: product.variants[variantIndex].programActive,
         selected: true,
-        source : source === 'buy' ? 'buy' : null 
+        source: source === 'buy' ? 'buy' : null
       }
-   
     } else {
       dataUpdate = {
         productId: variantId,
         quantity,
         programLineId: promotionActiveId,
         selected: true,
-        source : source === 'buy' ? 'buy' : null 
+        source: source === 'buy' ? 'buy' : null
       }
     }
     updateItemCart(dataUpdate)
@@ -269,7 +264,34 @@ const ProductDesktop = ({ products, wishlist, toggleWishlist }) => {
                     )}
                   </div>
                 </div>
-                <div className='flex p-3 '>
+                {product.variants.length === 1 && (
+                  <div className='flex p-3 '>
+                    <div className='w-1/4 text-gray_r-12/70'>Stock</div>
+                    <div className='w-3/4'>
+                      {isLoadingSLA && (
+                        <div className=''>
+                          <Spinner aria-label='Center-aligned spinner example' />
+                        </div>
+                      )}
+                      {product?.variants[0].sla?.qty > 0 && (
+                        <span>{product?.variants[0].sla?.qty}</span>
+                      )}
+                      {product?.variants[0].sla?.qty == 0 && (
+                        <a
+                          href={whatsappUrl('product', {
+                            name: product.name,
+                            manufacture: product?.manufacture?.name,
+                            url: createSlug('/shop/product/', product.name, product.id, true)
+                          })}
+                          className='text-danger-500 font-medium'
+                        >
+                          Tanya Admin
+                        </a>
+                      )}
+                    </div>
+                  </div>
+                )}
+                <div className={`flex p-3 ${product.variants.length > 1 ? '' : 'bg-gray_r-4'} `}>
                   <div className='w-1/4 text-gray_r-12/70'>Berat Barang</div>
                   <div className='w-3/4'>
                     {product?.weight > 0 && <span>{product?.weight} KG</span>}
-- 
cgit v1.2.3


From e24275fc16ba143d18a054c6b7f11338015d4165 Mon Sep 17 00:00:00 2001
From: "HATEC\\SPVDEV001" <tri.susilo@altama.co.id>
Date: Thu, 27 Jul 2023 11:27:14 +0700
Subject: bugs fix button kerang

---
 src/lib/product/components/Product/ProductDesktop.jsx | 3 ++-
 1 file changed, 2 insertions(+), 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 dfff91d7..7e1d0d3b 100644
--- a/src/lib/product/components/Product/ProductDesktop.jsx
+++ b/src/lib/product/components/Product/ProductDesktop.jsx
@@ -96,6 +96,7 @@ const ProductDesktop = ({ products, wishlist, toggleWishlist }) => {
       router.push(`/login?next=/shop/product/${slug}`)
       return
     }
+    
     const quantity = variantQuantityRefs.current[variantId].value
 
     if (!validQuantity(quantity)) return
@@ -615,7 +616,7 @@ const ProductDesktop = ({ products, wishlist, toggleWishlist }) => {
                         )} */}
                         <button
                           type='button'
-                          onClick={() => handleAddToCart(variant)}
+                          onClick={() => handleAddToCart(variant.id)}
                           className='flex-1 py-2 btn-yellow'
                         >
                           Keranjang
-- 
cgit v1.2.3

