@@ -4,10 +4,7 @@ import { useContext, useState } from 'react';
4
4
import { useQuery , useMutation } from '@apollo/client' ;
5
5
6
6
import { AppContext } from 'utils/context/AppContext' ;
7
- import {
8
- getFormattedCart ,
9
- getUpdatedItems ,
10
- } from 'utils/functions/functions' ;
7
+ import { getFormattedCart , getUpdatedItems } from 'utils/functions/functions' ;
11
8
12
9
import RegularCart from './RegularCart.component' ;
13
10
import MobileCart from './MobileCart.component' ;
@@ -21,23 +18,19 @@ const CartItemsContainer = () => {
21
18
const [ requestError , setRequestError ] = useState ( null ) ;
22
19
23
20
// Update Cart Mutation.
24
- const [
25
- updateCart ,
21
+ const [ updateCart , { loading : updateCartProcessing } ] = useMutation (
22
+ UPDATE_CART ,
26
23
{
27
- data : updateCartResponse ,
28
- loading : updateCartProcessing ,
29
- error : updateCartError ,
30
- } ,
31
- ] = useMutation ( UPDATE_CART , {
32
- onCompleted : ( ) => {
33
- refetch ( ) ;
34
- } ,
35
- onError : ( error ) => {
36
- if ( error ) {
37
- setRequestError ( error ) ;
38
- }
39
- } ,
40
- } ) ;
24
+ onCompleted : ( ) => {
25
+ refetch ( ) ;
26
+ } ,
27
+ onError : ( error ) => {
28
+ if ( error ) {
29
+ setRequestError ( error ) ;
30
+ }
31
+ } ,
32
+ }
33
+ ) ;
41
34
42
35
/*
43
36
* Handle remove product click.
@@ -65,7 +58,7 @@ const CartItemsContainer = () => {
65
58
}
66
59
} ;
67
60
68
- const { loading , error , data, refetch } = useQuery ( GET_CART , {
61
+ const { data, refetch } = useQuery ( GET_CART , {
69
62
notifyOnNetworkStatusChange : true ,
70
63
onCompleted : ( ) => {
71
64
// Update cart in the localStorage.
@@ -82,6 +75,7 @@ const CartItemsContainer = () => {
82
75
< >
83
76
< section className = "py-8 bg-white" >
84
77
< div className = "container flex flex-wrap items-center mx-auto" >
78
+ { requestError && < div className = "p-6 mx-auto mt-5" > Error ... </ div > }
85
79
{ cart ? (
86
80
< div className = "p-6 mx-auto mt-5" >
87
81
< RegularCart
0 commit comments