diff options
Diffstat (limited to 'src-migrate/pages')
| -rw-r--r-- | src-migrate/pages/shop/cart/index.tsx | 18 | ||||
| -rw-r--r-- | src-migrate/pages/shop/promo/index.tsx | 2 |
2 files changed, 5 insertions, 15 deletions
diff --git a/src-migrate/pages/shop/cart/index.tsx b/src-migrate/pages/shop/cart/index.tsx index 5aac64cf..5e3e042a 100644 --- a/src-migrate/pages/shop/cart/index.tsx +++ b/src-migrate/pages/shop/cart/index.tsx @@ -34,7 +34,6 @@ 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 = () => { @@ -49,18 +48,14 @@ 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]); @@ -83,7 +78,6 @@ const CartPage = () => { setHasChanged(false) } - // Update the ref to the current cart state prevCartRef.current = cart ? [...cart.products] : null; }, [cart]); @@ -121,10 +115,8 @@ 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); } @@ -148,7 +140,7 @@ const CartPage = () => { const handleChange = async (e: React.ChangeEvent<HTMLInputElement>) => { - // Ensure that cart is not null before attempting to update + if (cart) { const updatedCart = { ...cart, @@ -158,7 +150,7 @@ const CartPage = () => { })) }; - updateCartItem(updatedCart); // Pass only valid CartProps to updateCartItem + updateCartItem(updatedCart); if(hasSelectedAll){ setIsSelectedAll(false); }else{ @@ -174,10 +166,8 @@ 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) @@ -294,7 +284,7 @@ const CartPage = () => { <Button colorScheme='yellow' w='full' - isDisabled={hasSelectedPromo || !hasSelected || isLoadQuantity} + isDisabled={hasSelectedPromo || !hasSelected} onClick={handleQuotation} > Quotation @@ -310,7 +300,7 @@ const CartPage = () => { <Button colorScheme='red' w='full' - isDisabled={!hasSelected || hasSelectNoPrice || isLoadQuantity} + isDisabled={!hasSelected || hasSelectNoPrice} onClick={handleCheckout} > Checkout diff --git a/src-migrate/pages/shop/promo/index.tsx b/src-migrate/pages/shop/promo/index.tsx index 2ebfc008..3bc2afb4 100644 --- a/src-migrate/pages/shop/promo/index.tsx +++ b/src-migrate/pages/shop/promo/index.tsx @@ -24,10 +24,10 @@ const PromoPage = () => { /> <PromoList selectedPromo={selectedPromo} /> </LazyLoadComponent> - <h1 className='sm:h-1'></h1> <LazyLoadComponent> <FlashSale /> </LazyLoadComponent> + <h1 className='h-1'></h1> <LazyLoadComponent> <FlashSaleNonDisplay /> </LazyLoadComponent> |
