summaryrefslogtreecommitdiff
path: root/src/lib/quotation
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/quotation')
-rw-r--r--src/lib/quotation/components/Quotation.jsx37
1 files changed, 26 insertions, 11 deletions
diff --git a/src/lib/quotation/components/Quotation.jsx b/src/lib/quotation/components/Quotation.jsx
index 3054616c..a95a149a 100644
--- a/src/lib/quotation/components/Quotation.jsx
+++ b/src/lib/quotation/components/Quotation.jsx
@@ -15,6 +15,7 @@ import VariantGroupCard from '@/lib/variant/components/VariantGroupCard'
import MobileView from '@/core/components/views/MobileView'
import DesktopView from '@/core/components/views/DesktopView'
import Image from '@/core/components/elements/Image/Image'
+import variantPriceApi from '@/lib/variant/api/variantPriceApi'
const Quotation = () => {
const router = useRouter()
@@ -31,11 +32,23 @@ const Quotation = () => {
.map((o) => o.productId)
.join(',')
const dataProducts = await CartApi({ variantIds })
- const dataProductsQuantity = _.map(dataProducts, (o) => ({
- ...o,
- quantity: getItemCart({ productId: o.id }).quantity
- }))
- setProducts(dataProductsQuantity)
+ const productsWithQuantity = dataProducts?.map(async (product) => {
+ const productPrice = await variantPriceApi({ id: product.id })
+ return {
+ ...product,
+ price: {
+ price: productPrice.priceExclude,
+ discountPercentage: productPrice.discount,
+ priceDiscount: productPrice.priceExcludeAfterDiscount
+ },
+ quantity: getItemCart({ productId: product.id }).quantity
+ }
+ })
+ if (productsWithQuantity) {
+ Promise.all(productsWithQuantity).then((resolvedProducts) => {
+ setProducts(resolvedProducts)
+ })
+ }
}
loadProducts()
}, [])
@@ -78,6 +91,8 @@ const Quotation = () => {
toast.error('Gagal melakukan transaksi, terjadi kesalahan internal')
}
+ const taxTotal = (totalAmount - totalDiscountAmount) * 0.11
+
return (
<>
<MobileView>
@@ -121,15 +136,15 @@ const Quotation = () => {
<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>
<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>
@@ -244,8 +259,8 @@ const Quotation = () => {
<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>
@@ -254,7 +269,7 @@ const Quotation = () => {
<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'>