@@ -3,19 +3,11 @@ import { v4 } from 'uuid';
3
3
4
4
import SVGX from 'components/SVG/SVGX.component' ;
5
5
6
- import { getUpdatedItems } from '../../../ utils/functions/functions' ;
6
+ import { getUpdatedItems } from 'utils/functions/functions' ;
7
7
8
- const CartItem = ( {
9
- item,
10
- products,
11
- handleRemoveProductClick,
12
- updateCart,
13
- } ) => {
8
+ const CartItem = ( { item, products, handleRemoveProductClick, updateCart } ) => {
14
9
const [ productCount , setProductCount ] = useState ( item . qty ) ;
15
10
16
- console . log ( "Update cart: " ) ;
17
- console . log ( updateCart ) ;
18
-
19
11
/*
20
12
* When user changes the quantity, update the cart in localStorage
21
13
* Also update the cart in the global Context
@@ -27,18 +19,17 @@ const CartItem = ({
27
19
const handleQuantityChange = ( event , cartKey ) => {
28
20
if ( process . browser ) {
29
21
event . stopPropagation ( ) ;
30
- // If the previous update cart mutation request is still processing, then return.
31
-
32
- /* if (updateCartProcessing) {
22
+ // Return if the previous update cart mutation request is still processing
23
+ /*
24
+ if (updateCartProcessing) {
33
25
return;
34
26
}*/
35
27
// 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 )
36
28
const newQty = event . target . value ? parseInt ( event . target . value ) : 1 ;
37
- // Set the new qty in state.
29
+ // Set the new quantity in state.
38
30
setProductCount ( newQty ) ;
39
31
if ( products . length ) {
40
32
const updatedItems = getUpdatedItems ( products , newQty , cartKey ) ;
41
-
42
33
updateCart ( {
43
34
variables : {
44
35
input : {
@@ -50,7 +41,6 @@ const CartItem = ({
50
41
}
51
42
}
52
43
} ;
53
-
54
44
return (
55
45
< tr className = "bg-gray-100" >
56
46
< td className = "px-4 py-2 border" >
0 commit comments