11import { useState , useContext } from 'react' ;
2-
32import { v4 as uuidv4 } from 'uuid' ;
4-
53import { useQuery , useMutation } from '@apollo/client' ;
64
75import { AppContext } from 'utils/context/AppContext' ;
@@ -18,9 +16,9 @@ import { getFormattedCart } from 'utils/functions/functions';
1816 * @param {Object } product
1917 */
2018const AddToCartButton = ( { product } ) => {
21- const [ cart , setCart ] = useContext ( AppContext ) ;
22- const [ requestError , setRequestError ] = useState ( null ) ;
23- const [ showViewCart , setShowViewCart ] = useState ( false ) ;
19+ const [ , setCart ] = useContext ( AppContext ) ;
20+ const [ , setRequestError ] = useState ( null ) ;
21+ const [ , setShowViewCart ] = useState ( false ) ;
2422 const [ showAddToCart , setshowAddToCart ] = useState ( false ) ;
2523
2624 const productId = product . databaseId ? product . databaseId : product ;
@@ -31,7 +29,7 @@ const AddToCartButton = ({ product }) => {
3129 } ;
3230
3331 // Get Cart Data.
34- const { loading , error , data, refetch } = useQuery ( GET_CART , {
32+ const { data, refetch } = useQuery ( GET_CART , {
3533 notifyOnNetworkStatusChange : true ,
3634 onCompleted : ( ) => {
3735 // Update cart in the localStorage.
@@ -44,12 +42,12 @@ const AddToCartButton = ({ product }) => {
4442
4543 const [
4644 addToCart ,
47- { data : addToCartRes , loading : addToCartLoading , error : addToCartError } ,
45+ { loading : addToCartLoading , error : addToCartError } ,
4846 ] = useMutation ( ADD_TO_CART , {
4947 variables : {
5048 input : productQueryInput ,
5149 } ,
52- onCompleted : ( data ) => {
50+ onCompleted : ( ) => {
5351 // If error.
5452 if ( addToCartError ) {
5553 setRequestError ( addToCartError . graphQLErrors [ 0 ] . message ) ;
0 commit comments