summaryrefslogtreecommitdiff
path: root/src/lib/cart/components
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/cart/components')
-rw-r--r--src/lib/cart/components/Cart.jsx56
1 files changed, 37 insertions, 19 deletions
diff --git a/src/lib/cart/components/Cart.jsx b/src/lib/cart/components/Cart.jsx
index 41efffe9..efbcf76b 100644
--- a/src/lib/cart/components/Cart.jsx
+++ b/src/lib/cart/components/Cart.jsx
@@ -21,6 +21,7 @@ import useAuth from '@/core/hooks/useAuth'
import LogoSpinner from '@/core/components/elements/Spinner/LogoSpinner'
import { getPromotionProgram } from '@/lib/promotinProgram/api/homepageApi'
import PromotionType from '@/lib/promotinProgram/components/PromotionType'
+import { gtagBeginCheckout } from '@/core/utils/googleTag'
const Cart = () => {
const router = useRouter()
@@ -205,6 +206,15 @@ const Cart = () => {
setPromotionActiveId(promoId)
}
+ const handleCheckout = () => {
+ gtagBeginCheckout(products)
+ router.push('/shop/checkout')
+ }
+
+ const totalOrder = totalPriceBeforeTax - totalDiscountAmount + totalTaxAmount
+ const tax = totalOrder * 0.11
+ const totalPrice = totalOrder + tax
+
return (
<>
<BottomPopup
@@ -473,15 +483,19 @@ const Cart = () => {
))}
<div className='sticky bottom-0 left-0 w-full p-4 mt-auto border-t border-gray_r-6 bg-white'>
- <div className='flex justify-between mb-4'>
- <div className='text-gray_r-11'>
- Total:
- <span className='text-danger-500 font-semibold'>
- &nbsp;
- {selectedProduct().length > 0
- ? currencyFormat(totalPriceBeforeTax - totalDiscountAmount + totalTaxAmount)
- : '-'}
- </span>
+ <div className='flex flex-col gap-y-3 mb-4'>
+ <div className='text-gray_r-11 flex justify-between'>
+ <span>Total Pesanan</span>
+ <span className='text-gray_r-12'>{currencyFormat(totalOrder)}</span>
+ </div>
+ <div className='text-gray_r-11 flex justify-between'>
+ PPN 11%
+ <span className='text-gray_r-12'>{currencyFormat(tax)}</span>
+ </div>
+ <hr />
+ <div className='text-gray_r-12 flex font-semibold justify-between'>
+ Total Harga:
+ <span className='text-danger-500'>{currencyFormat(totalPrice)}</span>
</div>
</div>
<div className='flex gap-x-3'>
@@ -783,15 +797,19 @@ const Cart = () => {
<div className='col-span-3 pl-4'>
<div className='sticky top-48 w-full p-4 rounded border border-gray_r-6 bg-white'>
<h1 className='text-title-sm font-semibold mb-6'>Ringkasan Belanja</h1>
- <div className='flex justify-between mb-4'>
- <div className='text-gray_r-11'>
- Total:
- <span className='text-danger-500 font-semibold'>
- &nbsp;
- {selectedProduct().length > 0
- ? currencyFormat(totalPriceBeforeTax - totalDiscountAmount + totalTaxAmount)
- : '-'}
- </span>
+ <div className='flex flex-col gap-y-3 mb-4'>
+ <div className='text-gray_r-11 flex justify-between'>
+ <span>Total Pesanan</span>
+ <span className='text-gray_r-12'>{currencyFormat(totalOrder)}</span>
+ </div>
+ <div className='text-gray_r-11 flex justify-between'>
+ PPN 11%
+ <span className='text-gray_r-12'>{currencyFormat(tax)}</span>
+ </div>
+ <hr />
+ <div className='text-gray_r-12 flex font-semibold justify-between'>
+ Total Harga:
+ <span className='text-danger-500'>{currencyFormat(totalPrice)}</span>
</div>
</div>
<div className='flex gap-x-3'>
@@ -807,7 +825,7 @@ const Cart = () => {
type='button'
className='btn-solid-red flex-1'
disabled={selectedProduct().length == 0}
- onClick={() => router.push('/shop/checkout')}
+ onClick={handleCheckout}
>
Checkout
</button>