File tree Expand file tree Collapse file tree 4 files changed +22
-11
lines changed Expand file tree Collapse file tree 4 files changed +22
-11
lines changed Original file line number Diff line number Diff line change @@ -25,7 +25,8 @@ import {
2525const AddToCartButton = ( props ) => {
2626 const [ cart , setCart ] = useContext ( AppContext ) ;
2727 const [ requestError , setRequestError ] = useState ( null ) ;
28- const [ showViewCart , setShowViewCart ] = useState ( false ) ;
28+ const [ showViewCart , setShowViewCart ] = useState ( false ) ;
29+ const [ showAddToCart , setshowAddToCart ] = useState ( false ) ;
2930
3031 const product = props . product ;
3132
@@ -63,7 +64,8 @@ const AddToCartButton = (props) => {
6364 refetch ( ) ;
6465 // Show View Cart Button
6566 setShowViewCart ( true ) ;
66- console . warn ( 'Completed ADD_TO_CART' , data ) ;
67+ setshowAddToCart ( true )
68+
6769 } ,
6870 onError : ( error ) => {
6971 if ( error ) {
@@ -81,14 +83,14 @@ const AddToCartButton = (props) => {
8183
8284 return (
8385 < >
84- { ! addToCartLoading && (
85- < button
86- onClick = { handleAddToCartClick }
87- className = "px-4 py-2 font-bold bg-white border border-gray-400 border-solid rounded hover:bg-gray-400"
88- >
89- KJØP
90- </ button >
91- ) }
86+ < button
87+ onClick = { handleAddToCartClick }
88+ className = { `px-4 py-2 font-bold bg-white border border-gray-400 border-solid rounded hover:bg-gray-400 ${
89+ addToCartLoading && `animate__animated animate__fadeOut` } ${ showAddToCart && `animate__animated animate__fadeIn` } ` }
90+ >
91+ KJØP
92+ </ button >
93+
9294 { addToCartLoading && (
9395 < >
9496 < div className = "mt-4 text-xl text-left" >
Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ import Footer from '../components/Footer/Footer.component';
99
1010import '../styles/index.css' ;
1111import '../styles/algolia.min.css' ;
12+ import '../styles/animate.min.css' ;
1213import 'nprogress/nprogress.css' ;
1314
1415import client from '../utils/apollo/ApolloClient' ;
Original file line number Diff line number Diff line change 1- import { request } from 'graphql-request' ;
21import { withRouter } from 'next/router' ;
32
43import SingleProduct from 'components/Product/SingleProduct.component' ;
You can’t perform that action at this time.
0 commit comments