import {bindActionCreators} from 'redux'
import PaymentPage from './with-policy'
import connectPage from '../connect-page'
import {
    cancelSubscriptions,
    getCoupon,
    getPaymentPlans,
    makePayment,
} from 'store/actions'
import {getPaymentPlans as selectPaymentPlans, getUser} from 'store/selectors'

const mapStateToProps = (state) => {
    return {
        plans: selectPaymentPlans(state),
        user: getUser(state),
    }
}

const mapDispatchToProps = (dispatch) => {
    return bindActionCreators(
        {
            cancelSubscriptions,
            getCoupon,
            getPaymentPlans,
            makePayment,
        },
        dispatch
    )
}

export default connectPage(PaymentPage, mapStateToProps, mapDispatchToProps)
