summaryrefslogtreecommitdiff
path: root/src/lib/checkout/components
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/checkout/components')
-rw-r--r--src/lib/checkout/components/Checkout.jsx39
1 files changed, 34 insertions, 5 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>