diff options
| author | Rafi Zadanly <zadanlyr@gmail.com> | 2023-03-28 16:32:45 +0700 |
|---|---|---|
| committer | Rafi Zadanly <zadanlyr@gmail.com> | 2023-03-28 16:32:45 +0700 |
| commit | f15a7f8a4387d215abd1051ee520adca8944fa05 (patch) | |
| tree | a51a50ba27a53ff03da38c388e36a17149ad60fa /src/lib/quotation | |
| parent | 8ca9069251873e87338f1c7f581b418bebb11e9a (diff) | |
checkout, quotation
Diffstat (limited to 'src/lib/quotation')
| -rw-r--r-- | src/lib/quotation/components/Quotation.jsx | 37 |
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'> |
