@@ -15,26 +15,19 @@ import { getFormattedCart } from 'utils/functions/functions';
15
15
/**
16
16
* Display and process product object when we click on the Add To Cart button
17
17
* Adds product to shopping cart
18
- * @param {Object } props
18
+ * @param {Object } product
19
19
*/
20
- const AddToCartButton = ( props ) => {
20
+ const AddToCartButton = ( { product } ) => {
21
21
const [ cart , setCart ] = useContext ( AppContext ) ;
22
22
const [ requestError , setRequestError ] = useState ( null ) ;
23
23
const [ showViewCart , setShowViewCart ] = useState ( false ) ;
24
24
const [ showAddToCart , setshowAddToCart ] = useState ( false ) ;
25
25
26
- const product = props . product ;
27
-
28
26
const productId = product . productId ? product . productId : product ;
29
27
30
- console . log ( "Props from Addtocart" ) ;
31
- console . log ( props ) ;
32
-
33
28
const productQueryInput = {
34
29
clientMutationId : uuidv4 ( ) , // Generate a unique id.
35
- //productId: product.productId,
36
- //productId: product
37
- productId : productId
30
+ productId : productId ,
38
31
} ;
39
32
40
33
// Get Cart Data.
@@ -59,8 +52,7 @@ const AddToCartButton = (props) => {
59
52
onCompleted : ( data ) => {
60
53
// If error.
61
54
if ( addToCartError ) {
62
- console . log ( 'Add to cart error' ) ;
63
- //setRequestError(addToCartError.graphQLErrors[0].message);
55
+ setRequestError ( addToCartError . graphQLErrors [ 0 ] . message ) ;
64
56
}
65
57
// Update the cart with new values in React context.
66
58
refetch ( ) ;
@@ -70,9 +62,7 @@ const AddToCartButton = (props) => {
70
62
} ,
71
63
onError : ( error ) => {
72
64
if ( error ) {
73
- console . log ( 'Error inside add to cart' ) ;
74
65
setRequestError ( error ) ;
75
- console . log ( error ) ;
76
66
}
77
67
} ,
78
68
} ) ;
0 commit comments