Skip to content

Commit ccbb00b

Browse files
committed
Return if cart is processing
1 parent dffbe55 commit ccbb00b

File tree

3 files changed

+16
-15
lines changed

3 files changed

+16
-15
lines changed

components/Cart/CartPage/CartItem.component.jsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,13 @@ import { v4 } from 'uuid';
44
import SVGX from 'components/SVG/SVGX.component';
55
import { getUpdatedItems } from 'utils/functions/functions';
66

7-
const CartItem = ({ item, products, handleRemoveProductClick, updateCart }) => {
7+
const CartItem = ({
8+
item,
9+
products,
10+
handleRemoveProductClick,
11+
updateCart,
12+
updateCartProcessing,
13+
}) => {
814
const [productCount, setProductCount] = useState(item.qty);
915

1016
/*
@@ -19,10 +25,10 @@ const CartItem = ({ item, products, handleRemoveProductClick, updateCart }) => {
1925
if (process.browser) {
2026
event.stopPropagation();
2127
// Return if the previous update cart mutation request is still processing
22-
/*
28+
2329
if (updateCartProcessing) {
2430
return;
25-
}*/
31+
}
2632
// If the user tries to delete the count of product, set that to 1 by default ( This will not allow him to reduce it less than zero )
2733
const newQty = event.target.value ? parseInt(event.target.value) : 1;
2834

components/Cart/CartPage/CartItemsContainer.component.jsx

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import Link from 'next/link';
22
import { v4 } from 'uuid';
33
import { useContext, useState } from 'react';
4-
54
import { useQuery, useMutation } from '@apollo/react-hooks';
65

76
import { AppContext } from 'utils/context/AppContext';
@@ -74,17 +73,12 @@ const CartItemsContainer = () => {
7473
const updatedCart = getFormattedCart(data);
7574
localStorage.setItem('woocommerce-cart', JSON.stringify(updatedCart));
7675
// Update cart data in React Context.
77-
78-
79-
8076
setCart(updatedCart);
8177
},
82-
onError: (error) => {
83-
console.warn('Error fetching cart');
78+
onError: (error) => {
8479
setRequestError(error);
8580
},
8681
});
87-
8882
return (
8983
<>
9084
<section className="py-8 bg-white">
@@ -95,14 +89,14 @@ const CartItemsContainer = () => {
9589
<RegularCart
9690
cart={cart}
9791
updateCartProcessing={updateCartProcessing}
98-
handleRemoveProductClick={handleRemoveProductClick}
99-
updateCart={updateCart}
92+
handleRemoveProductClick={handleRemoveProductClick}
93+
updateCart={updateCart}
10094
/>
10195
<MobileCart
10296
cart={cart}
10397
updateCartProcessing={updateCartProcessing}
104-
handleRemoveProductClick={handleRemoveProductClick}
105-
updateCart={updateCart}
98+
handleRemoveProductClick={handleRemoveProductClick}
99+
updateCart={updateCart}
106100
/>
107101
<div className="mt-4">
108102
<Link href="/kasse">

components/Cart/CartPage/RegularCart.component.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import CartItem from './CartItem.component';
22

3-
const RegularCart = ({ cart, handleRemoveProductClick, updateCart }) => {
3+
const RegularCart = ({ cart, handleRemoveProductClick, updateCart, updateCartProcessing }) => {
44
return (
55
<table className="hidden table-auto md:block lg:block xl:block">
66
<thead>
@@ -30,6 +30,7 @@ const RegularCart = ({ cart, handleRemoveProductClick, updateCart }) => {
3030
products={cart.products}
3131
handleRemoveProductClick={handleRemoveProductClick}
3232
updateCart={updateCart}
33+
updateCartProcessing={updateCartProcessing}
3334
/>
3435
))}
3536
</tbody>

0 commit comments

Comments
 (0)