import { connect } from 'react-redux' ; import ItemBuyFormComponent from '../components/ItemBuyFormComponent' ; import { buyItemAction } from '../actions/buyAction' ; import { AppState } from '../index' ; import { ThunkDispatch } from 'redux-thunk' ; import { ActionTypes } from '../actions/actionTypes' ; const mapStateToProps = ( state ) => ( { item : state . viewingItem . item , errors : state . formError . buyFormError , loadingBuy : state . buyPage . loadingBuy , } ) ; const mapDispatchToProps = ( dispatch ) => ( { onBuyAction : ( itemId , cardNumber ) => { dispatch ( buyItemAction ( itemId , cardNumber ) ) ; } , } ) ; export default connect ( mapStateToProps , mapDispatchToProps ) ( ItemBuyFormComponent ) ;