import {bindActionCreators} from 'redux'
import SettingsPage from './component'
import connectPage from '../connect-page'
import searchKeys from 'global/constants/search-keys'
import {
    getBillingCharges,
    getBillingOrders,
    getBillingSubscriptions,
    getNotificationSettings,
    showAlert,
    showModal,
    updateNotificationSettings,
    updateSearch,
} from 'store/actions'
import {getBilling, getUser} from 'store/selectors'

const mapStateToProps = (state) => {
    return {
        billing: getBilling(state),
        user: getUser(state),
    }
}

const mapDispatchToProps = (dispatch) => {
    return {
        updateSchoolSearch: (params, ...rest) =>
            dispatch(
                updateSearch({...params, searchKey: searchKeys.SCHOOL}, ...rest)
            ),
        ...bindActionCreators(
            {
                getBillingCharges,
                getBillingSubscriptions,
                getBillingOrders,
                getNotificationSettings,
                showAlert,
                showModal,
                updateNotificationSettings,
            },
            dispatch
        ),
    }
}

export default connectPage(SettingsPage, mapStateToProps, mapDispatchToProps)
