import { connect } from 'react-redux' ; import ItemPage from '../pages/ItemPage' ; import { fetchItemAction } from '../actions/fetchItemAction' ; import { AppState } from '../index' ; import { push } from 'connected-react-router' ; import { routes } from '../routes/Route' ; import { postBumpAction } from '../actions/postBumpAction' ; const mapStateToProps = ( state ) => ( { loading : state . page . isItemLoading , item : state . viewingItem . item , viewer : { userId : state . authStatus . userId || 0 , } , errorType : state . error . errorType , } ) ; const mapDispatchToProps = ( dispatch ) => ( { load : ( itemId ) => { dispatch ( fetchItemAction ( itemId ) ) ; } , onClickBuy : ( itemId ) => { dispatch ( push ( routes . buy . getPath ( itemId ) ) ) ; } , onClickItemEdit : ( itemId ) => { dispatch ( push ( routes . itemEdit . getPath ( itemId ) ) ) ; } , onClickBump : ( itemId ) => { dispatch ( postBumpAction ( itemId ) ) ; } , onClickTransaction : ( itemId ) => { dispatch ( push ( routes . transaction . getPath ( itemId ) ) ) ; } , } ) ; export default connect ( mapStateToProps , mapDispatchToProps ) ( ItemPage ) ;