From 596c019af400cc21d2890f875a7570f044866210 Mon Sep 17 00:00:00 2001
From: Rafi Zadanly <zadanlyr@gmail.com>
Date: Mon, 3 Apr 2023 10:52:08 +0700
Subject: fix price display in checkout

---
 src/lib/transaction/components/Transaction.jsx | 35 +++++++++++++++++---------
 1 file changed, 23 insertions(+), 12 deletions(-)

(limited to 'src/lib/transaction/components/Transaction.jsx')

diff --git a/src/lib/transaction/components/Transaction.jsx b/src/lib/transaction/components/Transaction.jsx
index 51c89b28..e992580a 100644
--- a/src/lib/transaction/components/Transaction.jsx
+++ b/src/lib/transaction/components/Transaction.jsx
@@ -103,14 +103,14 @@ const Transaction = ({ id }) => {
           <p className='text-gray_r-12/70'>Total Diskon</p>
           <p>{currencyFormat(-totalDiscountAmount)}</p>
         </div>
+        <div className='flex justify-between mt-1'>
+          <p className='text-gray_r-12/70'>PPN 11%</p>
+          <p>{currencyFormat(transaction.data?.amountTax)}</p>
+        </div>
         <div className='flex justify-between mt-1 font-medium'>
           <p>Total Belanja</p>
           <p>{currencyFormat(transaction.data?.amountTotal)}</p>
         </div>
-        <div className='flex justify-between mt-1'>
-          <p className='text-gray_r-12/70'>PPN 11% (Incl.)</p>
-          <p>{currencyFormat(totalAmount * 0.11)}</p>
-        </div>
       </div>
     ),
     [transaction.data, totalAmount, totalDiscountAmount]
@@ -144,7 +144,11 @@ const Transaction = ({ id }) => {
             >
               Ya, Batalkan
             </button>
-            <button className='btn-light w-full md:w-fit' type='button' onClick={closeCancelTransaction}>
+            <button
+              className='btn-light w-full md:w-fit'
+              type='button'
+              onClick={closeCancelTransaction}
+            >
               Batal
             </button>
           </div>
@@ -392,35 +396,42 @@ const Transaction = ({ id }) => {
                         </div>
                       </td>
                       <td>{product.quantity}</td>
-                      <td>{currencyFormat(product.price.price)}</td>
+                      <td>
+                        {product.price.discountPercentage > 0 && (
+                          <div className='line-through mb-1 text-caption-1 text-gray_r-12/70'>
+                            {currencyFormat(product.price.price)}
+                          </div>
+                        )}
+                        <div>{currencyFormat(product.price.priceDiscount)}</div>
+                      </td>
                       <td>
                         {product.price.discountPercentage > 0
                           ? `${product.price.discountPercentage}%`
                           : ''}
                       </td>
-                      <td>{currencyFormat(product.price.priceDiscount * product.quantity)}</td>
+                      <td>{currencyFormat(product.price.subtotal)}</td>
                     </tr>
                   ))}
                 </tbody>
               </table>
 
               <div className='flex justify-end mt-4'>
-                <div className='w-1/4 grid grid-cols-2 gap-y-2 text-gray_r-12/80'>
+                <div className='w-1/4 grid grid-cols-2 gap-y-3 text-gray_r-12/80'>
                   <div className='text-right'>Subtotal</div>
                   <div className='text-right font-medium'>{currencyFormat(totalAmount)}</div>
 
                   <div className='text-right'>Total Diskon</div>
-                  <div className='text-right font-medium'>
+                  <div className='text-right font-medium text-red_r-11'>
                     {currencyFormat(-totalDiscountAmount)}
                   </div>
 
+                  <div className='text-right'>PPN 11%</div>
+                  <div className='text-right font-medium'>{currencyFormat(transaction.data?.amountTax)}</div>
+
                   <div className='text-right'>Grand Total</div>
                   <div className='text-right font-medium text-gray_r-12'>
                     {currencyFormat(transaction.data?.amountTotal)}
                   </div>
-
-                  <div className='text-right'>PPN 11% (Incl.)</div>
-                  <div className='text-right font-medium'>{currencyFormat(totalAmount * 0.11)}</div>
                 </div>
               </div>
 
-- 
cgit v1.2.3

