summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorRafi Zadanly <zadanlyr@gmail.com>2024-01-22 10:41:53 +0700
committerRafi Zadanly <zadanlyr@gmail.com>2024-01-22 10:41:53 +0700
commitfb80b92d502437160e45b237b380071ab102c838 (patch)
tree7af89af778f0038dbd8f984d360d009c700c6c71 /src/lib
parente49eba371229a643588d49d7ef408b6ef9469d53 (diff)
Update disable checkout when has product price 0 and fix filter brand
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/checkout/components/Checkout.jsx22
1 files changed, 17 insertions, 5 deletions
diff --git a/src/lib/checkout/components/Checkout.jsx b/src/lib/checkout/components/Checkout.jsx
index eb31b9dc..85eda80b 100644
--- a/src/lib/checkout/components/Checkout.jsx
+++ b/src/lib/checkout/components/Checkout.jsx
@@ -10,7 +10,7 @@ import {
ClockIcon,
ExclamationCircleIcon,
} from '@heroicons/react/24/outline';
-import React, { useEffect, useRef, useState } from 'react';
+import React, { useEffect, useMemo, useRef, useState } from 'react';
import _ from 'lodash';
import { deleteItemCart } from '@/core/utils/cart';
import currencyFormat from '@/core/utils/currencyFormat';
@@ -411,6 +411,14 @@ const Checkout = () => {
};
// const taxTotal = (totalAmount - totalDiscountAmount - discountVoucher) * 0.11
+ const hasNoPrice = useMemo(() => {
+ if (!products) return false;
+ for (const item of products) {
+ if (item.price.priceDiscount == 0) return true;
+ }
+ return false;
+ }, [products]);
+
return (
<>
<BottomPopup
@@ -995,7 +1003,11 @@ const Checkout = () => {
className='flex-1 btn-yellow'
onClick={checkout}
disabled={
- isLoading || !products || products?.length == 0 || priceCheck
+ isLoading ||
+ !products ||
+ products?.length == 0 ||
+ priceCheck ||
+ hasNoPrice
}
>
{isLoading ? 'Loading...' : 'Lanjut Pembayaran'}
@@ -1090,8 +1102,7 @@ const Checkout = () => {
<div className='flex justify-between items-center'>
<div className='font-medium'>Ringkasan Pesanan</div>
<div className='text-gray_r-11 text-caption-1'>
- {cartCheckout?.totalWeight.kg}{' '}
- Kg
+ {cartCheckout?.totalWeight.kg} Kg
</div>
</div>
@@ -1283,7 +1294,8 @@ const Checkout = () => {
isLoading ||
!products ||
products?.length == 0 ||
- priceCheck
+ priceCheck ||
+ hasNoPrice
}
>
{isLoading ? 'Loading...' : 'Lanjut Pembayaran'}