diff options
| author | IT Fixcomart <it@fixcomart.co.id> | 2024-08-15 08:01:04 +0000 |
|---|---|---|
| committer | IT Fixcomart <it@fixcomart.co.id> | 2024-08-15 08:01:04 +0000 |
| commit | 0c2f4f66314ea216d3ce5b8f6c698855e3cb9386 (patch) | |
| tree | b7df107707ec24d66c4324d307e2c8fff23bc66e | |
| parent | 492e4a875ec7259be80bb4b501bc62e7afa0c9c7 (diff) | |
| parent | 2fa9b3df2a33917d681bfc16181f53841847464f (diff) | |
Merged in bug-select-cart (pull request #241)
Bug select cart
| -rw-r--r-- | src-migrate/pages/shop/cart/index.tsx | 13 | ||||
| -rw-r--r-- | src/lib/transaction/components/Transaction.jsx | 6 |
2 files changed, 14 insertions, 5 deletions
diff --git a/src-migrate/pages/shop/cart/index.tsx b/src-migrate/pages/shop/cart/index.tsx index cfb20284..5aac64cf 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]); @@ -116,8 +121,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); } @@ -167,8 +174,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) @@ -285,7 +294,7 @@ const CartPage = () => { <Button colorScheme='yellow' w='full' - isDisabled={hasSelectedPromo || !hasSelected} + isDisabled={hasSelectedPromo || !hasSelected || isLoadQuantity} onClick={handleQuotation} > Quotation @@ -301,7 +310,7 @@ const CartPage = () => { <Button colorScheme='red' w='full' - isDisabled={!hasSelected || hasSelectNoPrice} + isDisabled={!hasSelected || hasSelectNoPrice || isLoadQuantity} onClick={handleCheckout} > Checkout diff --git a/src/lib/transaction/components/Transaction.jsx b/src/lib/transaction/components/Transaction.jsx index 88f11fd4..a9e04c0e 100644 --- a/src/lib/transaction/components/Transaction.jsx +++ b/src/lib/transaction/components/Transaction.jsx @@ -872,8 +872,8 @@ const Transaction = ({ id }) => { </div> )} - {transaction?.data?.products?.map((product) => ( - <div className='flex justify-end mt-4' key={product.id}> + {transaction?.data?.products?.length > 0 && ( + <div className='flex justify-end mt-4'> <div className='w-1/4 grid grid-cols-2 gap-y-3 text-gray_r-12/80'> <div className='text-right'>Subtotal</div> <div className='text-right font-medium'> @@ -898,7 +898,7 @@ const Transaction = ({ id }) => { </div> </div> </div> - ))} + )} {transaction?.data?.productsRejectLine.length > 0 && ( <div className='text-h-sm font-semibold mt-10 mb-4'> |
