File tree Expand file tree Collapse file tree 1 file changed +3
-7
lines changed Expand file tree Collapse file tree 1 file changed +3
-7
lines changed Original file line number Diff line number Diff line change @@ -96,7 +96,7 @@ const AddToCart = ({
9696 variationId,
9797 fullWidth = false ,
9898} : IProductRootObject ) => {
99- const { setCart, cart } = useContext ( CartContext ) ;
99+ const { setCart, isLoading : isCartLoading } = useContext ( CartContext ) ;
100100 const [ requestError , setRequestError ] = useState < boolean > ( false ) ;
101101
102102 const productId = product ?. databaseId ? product ?. databaseId : variationId ;
@@ -141,10 +141,6 @@ const AddToCart = ({
141141 } ) ;
142142
143143 const handleAddToCart = ( ) => {
144- if ( ! cart ) {
145- console . log ( 'Cart is not yet initialized. Please wait.' ) ;
146- return ;
147- }
148144 addToCart ( ) ;
149145 // Refetch cart after 2 seconds
150146 setTimeout ( ( ) => {
@@ -156,10 +152,10 @@ const AddToCart = ({
156152 < >
157153 < Button
158154 handleButtonClick = { ( ) => handleAddToCart ( ) }
159- buttonDisabled = { addToCartLoading || requestError || ! cart }
155+ buttonDisabled = { addToCartLoading || requestError || isCartLoading }
160156 fullWidth = { fullWidth }
161157 >
162- { ! cart ? 'Loading...' : 'KJØP' }
158+ { isCartLoading ? 'Loading...' : 'KJØP' }
163159 </ Button >
164160 </ >
165161 ) ;
You can’t perform that action at this time.
0 commit comments