summaryrefslogtreecommitdiff
path: root/src-migrate
diff options
context:
space:
mode:
authorit-fixcomart <it@fixcomart.co.id>2024-08-15 14:59:53 +0700
committerit-fixcomart <it@fixcomart.co.id>2024-08-15 14:59:53 +0700
commit2fa9b3df2a33917d681bfc16181f53841847464f (patch)
treef3f2d7e503d05461384dbb6a72a7eb426bab7bb8 /src-migrate
parentf4410218351a2f263ca9bbae81f30e1531d40d59 (diff)
<iman> update select cart, if loading button disabled
Diffstat (limited to 'src-migrate')
-rw-r--r--src-migrate/pages/shop/cart/index.tsx13
1 files changed, 11 insertions, 2 deletions
diff --git a/src-migrate/pages/shop/cart/index.tsx b/src-migrate/pages/shop/cart/index.tsx
index 5e3e042a..bd023e1b 100644
--- a/src-migrate/pages/shop/cart/index.tsx
+++ b/src-migrate/pages/shop/cart/index.tsx
@@ -34,6 +34,7 @@ const CartPage = () => {
const [isTop, setIsTop] = useState(true);
const [hasChanged, setHasChanged] = useState(false);
const prevCartRef = useRef<CartItem[] | null>(null);
+ const [isLoadQuantity, setIsLoadQuantity] = useState<boolean>(false)
useEffect(() => {
const handleScroll = () => {
@@ -48,14 +49,18 @@ const CartPage = () => {
useEffect(() => {
if (typeof auth === 'object' && !cart) {
+ setIsLoadQuantity(true)
loadCart(auth.id);
+ setIsLoadQuantity(false)
setIsStepApproval(auth?.feature?.soApproval);
}
}, [auth, loadCart, cart, isButtonChek]);
useEffect(() => {
if (typeof auth === 'object' && !cart) {
+ setIsLoadQuantity(true)
loadCart(auth.id);
+ setIsLoadQuantity(false)
setIsStepApproval(auth?.feature?.soApproval);
}
}, [auth, loadCart, cart, isButtonChek]);
@@ -115,8 +120,10 @@ const CartPage = () => {
})
);
try {
+ setIsLoadQuantity(true)
await Promise.all(upsertPromises);
await loadCart(auth.id);
+ setIsLoadQuantity(false)
} catch (error) {
console.error('Failed to update cart items:', error);
}
@@ -166,8 +173,10 @@ const CartPage = () => {
setIsLoadDelete(true)
for (const item of cart.products) {
if(item.selected === true){
+ setIsLoadQuantity(true)
await deleteUserCart(auth.id, [item.cart_id])
await loadCart(auth.id)
+ setIsLoadQuantity(false)
}
}
setIsLoadDelete(false)
@@ -284,7 +293,7 @@ const CartPage = () => {
<Button
colorScheme='yellow'
w='full'
- isDisabled={hasSelectedPromo || !hasSelected}
+ isDisabled={hasSelectedPromo || !hasSelected || isLoadQuantity}
onClick={handleQuotation}
>
Quotation
@@ -300,7 +309,7 @@ const CartPage = () => {
<Button
colorScheme='red'
w='full'
- isDisabled={!hasSelected || hasSelectNoPrice}
+ isDisabled={!hasSelected || hasSelectNoPrice || isLoadQuantity}
onClick={handleCheckout}
>
Checkout