import {bindActionCreators} from 'redux'
import Component from './component'
import {connect} from 'react-redux'
import {getRankings, showAlert, showModal} from 'store/actions'
import {makeGetChallengeRankings} from 'store/selectors'

const mapStateToProps = (state, props) => {
    const {course} = props
    const getChallengeRankings = makeGetChallengeRankings(course?.id)

    return {
        challengeRankings: getChallengeRankings(state),
    }
}

const mapDispatchToProps = (dispatch) => {
    return bindActionCreators(
        {
            getRankings,
            showAlert,
            showModal,
        },
        dispatch
    )
}

export default connect(mapStateToProps, mapDispatchToProps)(Component)
