From 410cc16690f97e59b6a93b4196a2c13caf498b4d Mon Sep 17 00:00:00 2001
From: Rafi Zadanly <zadanlyr@gmail.com>
Date: Mon, 19 Feb 2024 13:28:11 +0700
Subject: Add discount price on cart item

---
 src-migrate/modules/cart/components/Item.tsx | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

(limited to 'src-migrate/modules/cart/components/Item.tsx')

diff --git a/src-migrate/modules/cart/components/Item.tsx b/src-migrate/modules/cart/components/Item.tsx
index 7a4c22cc..8a6f8822 100644
--- a/src-migrate/modules/cart/components/Item.tsx
+++ b/src-migrate/modules/cart/components/Item.tsx
@@ -66,15 +66,21 @@ const CartItem = ({ item, editable = true }: Props) => {
               )}
 
               {item.cart_type === 'product' && (
-                <>
+                <div className={style.discPriceSection}>
+                  {item.price.discount_percentage > 0 && (
+                    <span className={style.priceBefore}>
+                      Rp {formatCurrency((item.price.price || 0))}
+                    </span>
+                  )}
+                  
                   <div className={style.price}>
-                    {item.price.price > 0 && `Rp ${formatCurrency(item.price.price)}`}
-                    {item.price.price === 0 && '-'}
+                    {item.price.price_discount > 0 && `Rp ${formatCurrency(item.price.price_discount)}`}
+                    {item.price.price_discount === 0 && '-'}
                   </div>
-                  <div>{item.code}</div>
-                </>
+                </div>
               )}
 
+              <div>{item.cart_type === 'product' && item.code}</div>
               <div>
                 {item.weight} Kg
               </div>
-- 
cgit v1.2.3

