From 55c8f1c3c6c3566afe6555b7e3714f2738d0bb8e Mon Sep 17 00:00:00 2001
From: Mqdd <ahmadmiqdad27@gmail.com>
Date: Fri, 13 Mar 2026 09:56:07 +0700
Subject: <Miqdad> fix selected variant

---
 .../product-detail/components/PriceAction.tsx      | 27 +++++++++++-----------
 1 file changed, 14 insertions(+), 13 deletions(-)

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

diff --git a/src-migrate/modules/product-detail/components/PriceAction.tsx b/src-migrate/modules/product-detail/components/PriceAction.tsx
index ea65b3d1..37ee5055 100644
--- a/src-migrate/modules/product-detail/components/PriceAction.tsx
+++ b/src-migrate/modules/product-detail/components/PriceAction.tsx
@@ -80,7 +80,8 @@ const PriceAction = ({ product, onCompare }: Props) => {
     const validJsonString = stringVoucher.replace(/'/g, '"');
     voucherPastiHemat = JSON.parse(validJsonString);
   }
-  const hasPrice = Number(product?.lowest_price?.price) > 0;
+  const hasPrice = Number(selectedVariant?.price?.price_discount || 0) > 0;
+  const price = selectedVariant?.price;
 
   return (
     <div
@@ -90,59 +91,59 @@ const PriceAction = ({ product, onCompare }: Props) => {
       }`}
       id='price-section'
     >
-      {!!activePrice && activePrice.price > 0 && (
+    {!!price && price.price > 0 && (
         <>
           <DesktopView>
             <div className='flex items-end gap-x-2'>
-              {activePrice.discount_percentage > 0 && (
+              {price.discount_percentage > 0 && (
                 <>
                   <div className={style['disc-badge']}>
-                    {Math.floor(activePrice.discount_percentage)}%
+                    {Math.floor(price.discount_percentage)}%
                   </div>
                   <div className={style['disc-price']}>
-                    Rp {formatCurrency(activePrice.price || 0)}
+                    Rp {formatCurrency(price.price || 0)}
                   </div>
                 </>
               )}
               <div className={style['main-price']}>
-                Rp {formatCurrency(activePrice.price_discount || 0)}
+                Rp {formatCurrency(price.price_discount || 0)}
               </div>
             </div>
             <div className='h-1' />
             <div className={style['secondary-text']}>
               Termasuk PPN: Rp{' '}
-              {formatCurrency(Math.round(activePrice.price_discount * PPN))}
+              {formatCurrency(Math.round(price.price_discount * PPN))}
             </div>
           </DesktopView>
           <MobileView>
             <div className='flex items-end gap-x-2'>
-              {activePrice.discount_percentage > 0 ? (
+              {price.discount_percentage > 0 ? (
                 <>
                   <div className={style['disc-badge']}>
-                    {Math.floor(activePrice.discount_percentage)}%
+                    {Math.floor(price.discount_percentage)}%
                   </div>
 
                   {/* harga setelah diskon (main-price) di kiri */}
                   <div className={style['main-price']}>
-                    Rp {formatCurrency(activePrice.price_discount || 0)}
+                    Rp {formatCurrency(price.price_discount || 0)}
                   </div>
 
                   {/* harga coret di kanan */}
                   <div className={style['disc-price']}>
-                    Rp {formatCurrency(activePrice.price || 0)}
+                    Rp {formatCurrency(price.price || 0)}
                   </div>
                 </>
               ) : (
                 // kalau tidak ada diskon, tampilkan harga normal saja
                 <div className={style['main-price']}>
-                  Rp {formatCurrency(activePrice.price || 0)}
+                  Rp {formatCurrency(price.price || 0)}
                 </div>
               )}
             </div>
 
             <div className='text-md text-gray-500 shadow-0'>
               Termasuk PPN: Rp{' '}
-              {formatCurrency(Math.round(activePrice.price_discount * PPN))}
+              {formatCurrency(Math.round(price.price_discount * PPN))}
             </div>
           </MobileView>
         </>
-- 
cgit v1.2.3

