import { connect } from 'react-redux' ; import Redux from 'redux' ; import { checkoutSetState , checkoutSubmit } from '../../actions/Checkout' ; import { openSnackbar } from '../../actions/Snackbar' ; import { logEvent } from '../../Logging' ; import { AppState , CheckoutState , UserState } from '../../reducers/StateTypes' ; import CheckoutEntry , { DispatchProps , StateProps } from './CheckoutEntry' ; const mapStateToProps = ( state ) : StateProps => { return { checkout : state . checkout , quest : state . quest , user : state . user , } ; } ; const mapDispatchToProps = ( dispatch ) : DispatchProps => { return { onError : ( err ) : void => { logEvent ( 'error' , 'checkout_err' , { label : err } ) ; dispatch ( openSnackbar ( Error ( 'Error encountered: ' + err ) ) ) ; } , onStripeLoad : ( stripe ) : void => { dispatch ( checkoutSetState ( { stripe } ) ) ; } , onSubmit : ( stripeToken , checkout , user ) : void => { dispatch ( checkoutSubmit ( stripeToken , checkout , user ) ) ; } , } ; } ; const CheckoutEntryContainer = connect ( mapStateToProps , mapDispatchToProps ) ( CheckoutEntry ) ; export default CheckoutEntryContainer ;