@@ -3,19 +3,11 @@ import { v4 } from 'uuid';
33
44import SVGX from 'components/SVG/SVGX.component' ;
55
6- import { getUpdatedItems } from '../../../ utils/functions/functions' ;
6+ import { getUpdatedItems } from 'utils/functions/functions' ;
77
8- const CartItem = ( {
9- item,
10- products,
11- handleRemoveProductClick,
12- updateCart,
13- } ) => {
8+ const CartItem = ( { item, products, handleRemoveProductClick, updateCart } ) => {
149 const [ productCount , setProductCount ] = useState ( item . qty ) ;
1510
16- console . log ( "Update cart: " ) ;
17- console . log ( updateCart ) ;
18-
1911 /*
2012 * When user changes the quantity, update the cart in localStorage
2113 * Also update the cart in the global Context
@@ -27,18 +19,17 @@ const CartItem = ({
2719 const handleQuantityChange = ( event , cartKey ) => {
2820 if ( process . browser ) {
2921 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) {
3325 return;
3426 }*/
3527 // 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 )
3628 const newQty = event . target . value ? parseInt ( event . target . value ) : 1 ;
37- // Set the new qty in state.
29+ // Set the new quantity in state.
3830 setProductCount ( newQty ) ;
3931 if ( products . length ) {
4032 const updatedItems = getUpdatedItems ( products , newQty , cartKey ) ;
41-
4233 updateCart ( {
4334 variables : {
4435 input : {
@@ -50,7 +41,6 @@ const CartItem = ({
5041 }
5142 }
5243 } ;
53-
5444 return (
5545 < tr className = "bg-gray-100" >
5646 < td className = "px-4 py-2 border" >
0 commit comments