uncommitted work from last night
This commit is contained in:
parent
a17d19038e
commit
b6881c829c
4 changed files with 20 additions and 6 deletions
|
@ -5,8 +5,12 @@ import {
|
||||||
import {
|
import {
|
||||||
makeSelectHasClaimedReward,
|
makeSelectHasClaimedReward,
|
||||||
makeSelectClaimRewardError,
|
makeSelectClaimRewardError,
|
||||||
makeSelectIsRewardClaimPending
|
makeSelectIsRewardClaimPending,
|
||||||
|
selectIsRewardEligible,
|
||||||
} from 'selectors/rewards'
|
} from 'selectors/rewards'
|
||||||
|
import {
|
||||||
|
doNavigate
|
||||||
|
} from 'actions/app'
|
||||||
import {
|
import {
|
||||||
doClaimReward,
|
doClaimReward,
|
||||||
doClaimRewardClearError
|
doClaimRewardClearError
|
||||||
|
@ -20,6 +24,7 @@ const makeSelect = () => {
|
||||||
|
|
||||||
const select = (state, props) => ({
|
const select = (state, props) => ({
|
||||||
isClaimed: selectHasClaimedReward(state, props),
|
isClaimed: selectHasClaimedReward(state, props),
|
||||||
|
isEligible: selectIsRewardEligible(state),
|
||||||
errorMessage: selectError(state, props),
|
errorMessage: selectError(state, props),
|
||||||
isPending: selectIsPending(state, props)
|
isPending: selectIsPending(state, props)
|
||||||
})
|
})
|
||||||
|
@ -29,7 +34,8 @@ const makeSelect = () => {
|
||||||
|
|
||||||
const perform = (dispatch) => ({
|
const perform = (dispatch) => ({
|
||||||
claimReward: (reward) => dispatch(doClaimReward(reward)),
|
claimReward: (reward) => dispatch(doClaimReward(reward)),
|
||||||
clearError: (reward) => dispatch(doClaimRewardClearError(reward))
|
clearError: (reward) => dispatch(doClaimRewardClearError(reward)),
|
||||||
|
navigate: (path) => dispatch(doNavigate(path)),
|
||||||
})
|
})
|
||||||
|
|
||||||
export default connect(makeSelect, perform)(RewardLink)
|
export default connect(makeSelect, perform)(RewardLink)
|
||||||
|
|
|
@ -11,9 +11,10 @@ const RewardLink = (props) => {
|
||||||
clearError,
|
clearError,
|
||||||
errorMessage,
|
errorMessage,
|
||||||
isClaimed,
|
isClaimed,
|
||||||
|
isEligible,
|
||||||
isPending
|
isPending
|
||||||
} = props
|
} = props
|
||||||
console.log(props)
|
|
||||||
return (
|
return (
|
||||||
<div className="reward-link">
|
<div className="reward-link">
|
||||||
{isClaimed
|
{isClaimed
|
||||||
|
|
|
@ -33,8 +33,16 @@ reducers[types.FETCH_REWARDS_COMPLETED] = function(state, action) {
|
||||||
function setClaimRewardState(state, reward, isClaiming, errorMessage="") {
|
function setClaimRewardState(state, reward, isClaiming, errorMessage="") {
|
||||||
const newClaimPendingByType = Object.assign({}, state.claimPendingByType)
|
const newClaimPendingByType = Object.assign({}, state.claimPendingByType)
|
||||||
const newClaimErrorsByType = Object.assign({}, state.claimErrorsByType)
|
const newClaimErrorsByType = Object.assign({}, state.claimErrorsByType)
|
||||||
newClaimPendingByType[reward.reward_type] = isClaiming
|
if (isClaiming) {
|
||||||
newClaimErrorsByType[reward.reward_type] = errorMessage
|
newClaimPendingByType[reward.reward_type] = isClaiming
|
||||||
|
} else {
|
||||||
|
delete newClaimPendingByType[reward.reward_type]
|
||||||
|
}
|
||||||
|
if (errorMessage) {
|
||||||
|
newClaimErrorsByType[reward.reward_type] = errorMessage
|
||||||
|
} else {
|
||||||
|
delete newClaimErrorsByType[reward.reward_type]
|
||||||
|
}
|
||||||
|
|
||||||
return Object.assign({}, state, {
|
return Object.assign({}, state, {
|
||||||
claimPendingByType: newClaimPendingByType,
|
claimPendingByType: newClaimPendingByType,
|
||||||
|
|
|
@ -70,7 +70,6 @@ export const selectClaimErrorsByType = createSelector(
|
||||||
)
|
)
|
||||||
|
|
||||||
const selectClaimRewardError = (state, props) => {
|
const selectClaimRewardError = (state, props) => {
|
||||||
console.log(selectClaimErrorsByType(state, props));
|
|
||||||
return selectClaimErrorsByType(state, props)[props.reward.reward_type]
|
return selectClaimErrorsByType(state, props)[props.reward.reward_type]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue