diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/checkout/components/Checkout.jsx | 39 | ||||
| -rw-r--r-- | src/lib/variant/components/VariantCard.jsx | 12 |
2 files changed, 44 insertions, 7 deletions
diff --git a/src/lib/checkout/components/Checkout.jsx b/src/lib/checkout/components/Checkout.jsx index cb96b995..eee679fd 100644 --- a/src/lib/checkout/components/Checkout.jsx +++ b/src/lib/checkout/components/Checkout.jsx @@ -61,6 +61,7 @@ const Checkout = () => { const [products, setProducts] = useState(null) const [totalAmount, setTotalAmount] = useState(0) const [totalDiscountAmount, setTotalDiscountAmount] = useState(0) + const [priceCheck, setPriceCheck] = useState(false) useEffect(() => { const loadProducts = async () => { @@ -77,6 +78,7 @@ const Checkout = () => { const dataProducts = await CartApi({ variantIds }) const productsWithQuantity = dataProducts?.map((product) => { + if (product.price.priceDiscount == 0) setPriceCheck(true) return { ...product, quantity: query.quantity @@ -141,7 +143,6 @@ const Checkout = () => { setIsLoading(false) window.location.href = payment.data.redirectUrl } - const taxTotal = (totalAmount - totalDiscountAmount) * 0.11 return ( @@ -241,11 +242,21 @@ const Checkout = () => { <button className='flex-1 btn-yellow' onClick={checkout} - disabled={isLoading || !products || products?.length == 0} + disabled={isLoading || !products || products?.length == 0 || priceCheck} > {isLoading ? 'Loading...' : 'Lanjut Pembayaran'} </button> </div> + {priceCheck && ( + <div className='px-4 mb-4'> + <span className='text-danger-500'> + *) Terdapat produk yang belum memiliki harga,{' '} + <a href='https://wa.me/628128080622' className='underline'> + Hubungi Kami untuk meminta harga. + </a> + </span> + </div> + )} </MobileView> <DesktopView> @@ -309,12 +320,20 @@ const Checkout = () => { </div> )} <div className='font-normal mt-1'> - {currencyFormat(product?.price?.priceDiscount)} + {product.price.priceDiscount > 0 + ? currencyFormat(product?.price?.priceDiscount) + : 'Call For Price'} </div> </td> <td> <div className='text-danger-500 font-medium'> - {currencyFormat(product?.price?.priceDiscount * product?.quantity)} + {product.price.priceDiscount > 0 ? ( + currencyFormat(product?.price?.priceDiscount * product?.quantity) + ) : ( + <a href='https://wa.me/628128080622' className='underline'> + Call For Price{' '} + </a> + )} </div> </td> </tr> @@ -396,10 +415,20 @@ const Checkout = () => { <button className='w-full btn-yellow mt-4' onClick={checkout} - disabled={isLoading || !products || products?.length == 0} + disabled={isLoading || !products || products?.length == 0 || priceCheck} > {isLoading ? 'Loading...' : 'Lanjut Pembayaran'} </button> + {priceCheck && ( + <div className='mt-4'> + <span className='text-danger-500'> + *) Terdapat produk yang belum memiliki harga,{' '} + <a href='https://wa.me/628128080622' className='underline'> + Hubungi Kami untuk meminta harga. + </a> + </span> + </div> + )} </div> </div> </div> diff --git a/src/lib/variant/components/VariantCard.jsx b/src/lib/variant/components/VariantCard.jsx index 8161473d..8cd70bc0 100644 --- a/src/lib/variant/components/VariantCard.jsx +++ b/src/lib/variant/components/VariantCard.jsx @@ -49,10 +49,18 @@ const VariantCard = ({ product, openOnClick = true, buyMore = false }) => { )} </div> <p className='text-caption-2 text-gray_r-11 mt-1'> - {currencyFormat(product.price.priceDiscount)} × {product.quantity} Barang + {product.price.priceDiscount > 0 + ? currencyFormat(product.price.priceDiscount) + ' × ' + product.quantity + ' Barang' + : ''} </p> <p className='text-caption-2 text-gray_r-12 font-bold mt-2'> - {currencyFormat(product.quantity * product.price.priceDiscount)} + {product.price.priceDiscount > 0 ? ( + currencyFormat(product.quantity * product.price.priceDiscount) + ) : ( + <a href='https://wa.me/628128080622' className='underline text-danger-500'> + Call For Price{' '} + </a> + )} </p> </div> </div> |
