2017-05-26 10:53:32 +02:00
|
|
|
import React from 'react'
|
|
|
|
import {
|
|
|
|
connect,
|
|
|
|
} from 'react-redux'
|
|
|
|
import {
|
|
|
|
makeSelectHasClaimedReward,
|
2017-06-02 02:51:52 +02:00
|
|
|
makeSelectClaimRewardError,
|
|
|
|
makeSelectIsRewardClaimPending
|
2017-05-26 10:53:32 +02:00
|
|
|
} from 'selectors/rewards'
|
|
|
|
import {
|
|
|
|
doClaimReward,
|
2017-06-02 02:51:52 +02:00
|
|
|
doClaimRewardClearError
|
2017-05-26 10:53:32 +02:00
|
|
|
} from 'actions/rewards'
|
|
|
|
import RewardLink from './view'
|
|
|
|
|
|
|
|
const makeSelect = () => {
|
|
|
|
const selectHasClaimedReward = makeSelectHasClaimedReward()
|
2017-06-02 02:51:52 +02:00
|
|
|
const selectIsPending = makeSelectIsRewardClaimPending()
|
|
|
|
const selectError = makeSelectClaimRewardError()
|
2017-05-26 10:53:32 +02:00
|
|
|
|
|
|
|
const select = (state, props) => ({
|
2017-06-02 02:51:52 +02:00
|
|
|
isClaimed: selectHasClaimedReward(state, props),
|
|
|
|
errorMessage: selectError(state, props),
|
|
|
|
isPending: selectIsPending(state, props)
|
2017-05-26 10:53:32 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
return select
|
|
|
|
}
|
|
|
|
|
|
|
|
const perform = (dispatch) => ({
|
|
|
|
claimReward: (reward) => dispatch(doClaimReward(reward)),
|
2017-06-02 02:51:52 +02:00
|
|
|
clearError: (reward) => dispatch(doClaimRewardClearError(reward))
|
2017-05-26 10:53:32 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
export default connect(makeSelect, perform)(RewardLink)
|