From e33a7e612a3c2c871f6a0a84d0d04d6f6ddc357a Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Fri, 9 Aug 2024 10:51:10 +0700
Subject: <iman> update template switch & delete console log

---
 .../product-card/components/ProductCard.tsx        | 105 ++++++++++-----------
 1 file changed, 52 insertions(+), 53 deletions(-)

(limited to 'src-migrate/modules/product-card/components/ProductCard.tsx')

diff --git a/src-migrate/modules/product-card/components/ProductCard.tsx b/src-migrate/modules/product-card/components/ProductCard.tsx
index 3e34d5c3..931f8f2f 100644
--- a/src-migrate/modules/product-card/components/ProductCard.tsx
+++ b/src-migrate/modules/product-card/components/ProductCard.tsx
@@ -24,6 +24,9 @@ const ProductCard = ({ product, layout = 'vertical' }: Props) => {
   const utmSource = useUtmSource()
   const router = useRouter();
 
+  const ppnString = process.env.NEXT_PUBLIC_PPN;
+  const ppnNumber = ppnString !== undefined ? Number(ppnString) : 0;
+
   const id = product.id.toString ()
   const callForPriceWhatsapp = whatsappUrl('product', {
     name: product.name,
@@ -169,36 +172,24 @@ const ProductCard = ({ product, layout = 'vertical' }: Props) => {
         >
           {product.name}
         </Link>
-        <div className='h-1.5' />
-        {product?.flash_sale?.id > 0 ? (<div></div>) :
-        (
-          <div className={style['price']}>
-          Rp {formatCurrency(product.lowest_price.price)}
-        </div>
-      )
-    }
-
-        
 
         <div className='h-1.5' />
-
-        {product?.flash_sale?.id > 0 &&
-          product?.lowest_price?.discountPercentage > 0 ? (
+      {product?.lowest_price.discountPercentage === undefined ? (
+        <div>
+          {product?.flash_sale?.id > 0 &&
+          product?.lowest_price.discount_percentage > 0 ? (
             <>
-              {product?.lowest_price.discountPercentage > 0 && (
-                <div className='flex gap-x-1 mb-1 items-center'>
-                  <div className='badge-solid-red'>
-                    {Math.floor(product?.lowest_price.discount_percentage ? product?.lowest_price.discount_percentage : product?.lowest_price.discountPercentage)}%
-                  </div>
-                  <div className='text-gray_r-11 line-through text-caption-2'>
-                    {currencyFormat(product?.lowest_price?.price)}
-                  </div>
+              <div className='flex gap-x-1 mb-1 items-center'>
+                <div className='text-gray_r-11 line-through text-[11px] sm:text-caption-2'>
+                  {currencyFormat(product.lowest_price.price)}
                 </div>
-              )}
-
+                <div className='badge-solid-red'>
+                  {Math.floor(product?.lowest_price.discount_percentage)}%
+                </div>
+              </div>
               <div className='text-danger-500 font-semibold mb-2'>
-                {product?.lowest_price?.price_discount ? product?.lowest_price?.price_discount : product?.lowest_price?.priceDiscount > 0 ? (
-                  currencyFormat(product?.lowest_price?.price_discount ? product?.lowest_price?.price_discount : product?.lowest_price?.priceDiscount)
+                {product?.lowest_price.price_discount > 0 ? (
+                  currencyFormat(product?.lowest_price.price_discount)
                 ) : (
                   <a
                     rel='noopener noreferrer'
@@ -209,41 +200,49 @@ const ProductCard = ({ product, layout = 'vertical' }: Props) => {
                   </a>
                 )}
               </div>
-              <div className='flex w-full items-center gap-x-1 '>
-            {product?.stockTotal > 0 && (
+            </>
+          ) : (
+            <div className='text-danger-500 font-semibold mb-2 min-h-[40px]'>
+              {product?.lowest_price.price > 0 ? (
+                <>
+                  {currencyFormat(product?.lowest_price.price)}
+                  <div className='text-gray_r-9 text-[10px] font-normal mt-2'>
+                    Inc. PPN:{' '}
+                    {currencyFormat(
+                      product.lowest_price.price * ppnNumber
+                    )}
+                  </div>
+                </>
+              ) : (
+                <a
+                  rel='noopener noreferrer'
+                  target='_blank'
+                  href={callForPriceWhatsapp}
+                >
+                  Call for Inquiry
+                </a>
+              )}
+            </div>
+          )}
+
+          <div className='flex w-full items-center gap-x-1 '>
+            {product?.stock_total > 0 && (
               <div className='badge-solid-red'>Ready Stock</div>
             )}
             {/* <div className='badge-gray'>{product?.stockTotal > 5 ? '> 5' : '< 5'}</div> */}
-            {product?.qtySold > 0 && (
+            {product?.qty_sold > 0 && (
               <div className='text-gray_r-9 text-[11px]'>
-                {sellingProductFormat(product?.qtySold) + ' Terjual'}
+                {sellingProductFormat(product?.qty_sold) + ' Terjual'}
               </div>
             )}
           </div>
-            </>
-          ) : (
-            <div>
-              <div className={style['price-inc']}>
-                Inc PPN:
-                Rp {formatCurrency(Math.round(product.lowest_price.price * 1.11))}
-              </div>
-
-              <div className='h-1' />
-
-              <div className='flex items-center gap-x-2.5'>
-                {product.stock_total > 0 && (
-                  <div className={style['ready-stock']}>
-                    Ready Stock
-                  </div>
-                )}
-                {product.qty_sold > 0 && (
-                  <div className={style['sold']}>
-                    {formatToShortText(product.qty_sold)} Terjual
-                  </div>
-                )}
-              </div>
-            </div>
-          )}
+        </div>
+      ) : (
+        <div>
+          
+        </div>
+      )}
+        
 
 
       </div>
-- 
cgit v1.2.3

