diff options
Diffstat (limited to 'src/lib/checkout/components/Checkout.jsx')
| -rw-r--r-- | src/lib/checkout/components/Checkout.jsx | 53 |
1 files changed, 17 insertions, 36 deletions
diff --git a/src/lib/checkout/components/Checkout.jsx b/src/lib/checkout/components/Checkout.jsx index 048bb24e..ffb33eb7 100644 --- a/src/lib/checkout/components/Checkout.jsx +++ b/src/lib/checkout/components/Checkout.jsx @@ -78,7 +78,7 @@ const Checkout = () => { } const dataProducts = await CartApi({ variantIds }) - const productsWithQuantity = dataProducts.map(async (product) => { + const productsWithQuantity = dataProducts?.map(async (product) => { const productPrice = await variantPriceApi({ id: product.id }) return { ...product, @@ -87,12 +87,16 @@ const Checkout = () => { discountPercentage: productPrice.discount, priceDiscount: productPrice.priceExcludeAfterDiscount }, - quantity: query.quantity ? query.quantity : getItemCart({ productId: product.id }).quantity + quantity: query.quantity + ? query.quantity + : getItemCart({ productId: product.id }).quantity } }) - Promise.all(productsWithQuantity).then((resolvedProducts) => { - setProducts(resolvedProducts) - }) + if (productsWithQuantity) { + Promise.all(productsWithQuantity).then((resolvedProducts) => { + setProducts(resolvedProducts) + }) + } } loadProducts() }, [router]) @@ -150,6 +154,8 @@ const Checkout = () => { window.location.href = payment.data.redirectUrl } + const taxTotal = (totalAmount - totalDiscountAmount) * 0.11 + return ( <> <MobileView> @@ -202,14 +208,14 @@ const Checkout = () => { </div> <div className='flex gap-x-2 justify-between'> <div className='text-gray_r-11'>PPN 11% (Incl.)</div> - <div>{currencyFormat((totalAmount - totalDiscountAmount) * 0.11)}</div> + <div>{currencyFormat(taxTotal)}</div> </div> </div> <hr className='my-4 border-gray_r-6' /> <div className='flex gap-x-2 justify-between mb-4'> <div>Grand Total</div> <div className='font-semibold text-gray_r-12'> - {currencyFormat(totalAmount - totalDiscountAmount)} + {currencyFormat(totalAmount - totalDiscountAmount + taxTotal)} </div> </div> <p className='text-caption-2 text-gray_r-10 mb-2'>*) Belum termasuk biaya pengiriman</p> @@ -233,31 +239,6 @@ const Checkout = () => { <Divider /> <div className='p-4'> - <div className='font-medium mb-4'>Metode Pembayaran</div> - <div className='flex flex-col gap-y-3'> - <div - className={`p-2 idt-transition border rounded text-gray_r-12/80 ${ - paymentMethod == 'manual' ? 'border-yellow_r-8 bg-yellow_r-2' : 'border-gray_r-6' - }`} - onClick={() => setPaymentMethod('manual')} - > - Bank BCA (PT. Indoteknik Dotcom) - <div className='mt-1'>8870-4000-81</div> - </div> - <div - className={`p-2 idt-transition border rounded ${ - paymentMethod == 'midtrans' ? 'border-yellow_r-8 bg-yellow_r-2' : 'border-gray_r-6' - }`} - onClick={() => setPaymentMethod('midtrans')} - > - <Image src='/images/payments/midtrans.jpg' alt='Midtrans Payment' /> - </div> - </div> - </div> - - <Divider /> - - <div className='p-4'> <div className='font-medium'>Purchase Order</div> <div className='mt-4 flex gap-x-3'> @@ -286,7 +267,7 @@ const Checkout = () => { onClick={checkout} disabled={isLoading || !products || products?.length == 0} > - {isLoading ? 'Loading...' : 'Bayar'} + {isLoading ? 'Loading...' : 'Lanjut Pembayaran'} </button> </div> </MobileView> @@ -402,8 +383,8 @@ const Checkout = () => { <div>{currencyFormat(totalAmount - totalDiscountAmount)}</div> </div> <div className='flex gap-x-2 justify-between'> - <div className='text-gray_r-11'>PPN 11% (Incl.)</div> - <div>{currencyFormat((totalAmount - totalDiscountAmount) * 0.11)}</div> + <div className='text-gray_r-11'>PPN 11%</div> + <div>{currencyFormat(taxTotal)}</div> </div> </div> @@ -412,7 +393,7 @@ const Checkout = () => { <div className='flex gap-x-2 justify-between mb-4'> <div>Grand Total</div> <div className='font-semibold text-gray_r-12'> - {currencyFormat(totalAmount - totalDiscountAmount)} + {currencyFormat(totalAmount - totalDiscountAmount + taxTotal)} </div> </div> <p className='text-caption-2 text-gray_r-11 mb-2'> |
