File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -61,8 +61,15 @@ const CheckoutForm = () => {
6161 notifyOnNetworkStatusChange : true ,
6262 onCompleted : ( data ) => {
6363 const updatedCart = getFormattedCart ( data ) as RootObject | undefined ;
64- setCart ( updatedCart || null ) ;
64+ if ( ! cart || cart . totalProductsCount !== updatedCart ?. totalProductsCount ) {
65+ setCart ( updatedCart || null ) ;
66+ }
6567 } ,
68+ onError : ( error ) => {
69+ console . error ( 'Error fetching cart:' , error ) ;
70+ // On error, we'll show the cached cart data instead of setting to null
71+ } ,
72+ fetchPolicy : 'cache-and-network' ,
6673 } ) ;
6774
6875 // Checkout GraphQL mutation
@@ -100,7 +107,7 @@ const CheckoutForm = () => {
100107
101108 return (
102109 < >
103- { cart && ! orderCompleted ? (
110+ { ( cart || orderCompleted ) ? (
104111 < div className = "container mx-auto" >
105112 { /* Order*/ }
106113 < CartContents />
@@ -122,7 +129,7 @@ const CheckoutForm = () => {
122129 </ div >
123130 ) : (
124131 < >
125- { ! cart && ! orderCompleted && (
132+ { ! cart && (
126133 < h1 className = "text-2xl m-12 mt-24 font-bold text-center" >
127134 Ingen produkter i handlekurven
128135 </ h1 >
You can’t perform that action at this time.
0 commit comments