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 {
|
||||
makeSelectHasClaimedReward,
|
||||
makeSelectClaimRewardError,
|
||||
makeSelectIsRewardClaimPending
|
||||
makeSelectIsRewardClaimPending,
|
||||
selectIsRewardEligible,
|
||||
} from 'selectors/rewards'
|
||||
import {
|
||||
doNavigate
|
||||
} from 'actions/app'
|
||||
import {
|
||||
doClaimReward,
|
||||
doClaimRewardClearError
|
||||
|
@ -20,6 +24,7 @@ const makeSelect = () => {
|
|||
|
||||
const select = (state, props) => ({
|
||||
isClaimed: selectHasClaimedReward(state, props),
|
||||
isEligible: selectIsRewardEligible(state),
|
||||
errorMessage: selectError(state, props),
|
||||
isPending: selectIsPending(state, props)
|
||||
})
|
||||
|
@ -29,7 +34,8 @@ const makeSelect = () => {
|
|||
|
||||
const perform = (dispatch) => ({
|
||||
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)
|
||||
|
|
|
@ -11,9 +11,10 @@ const RewardLink = (props) => {
|
|||
clearError,
|
||||
errorMessage,
|
||||
isClaimed,
|
||||
isEligible,
|
||||
isPending
|
||||
} = props
|
||||
console.log(props)
|
||||
|
||||
return (
|
||||
<div className="reward-link">
|
||||
{isClaimed
|
||||
|
|
|
@ -33,8 +33,16 @@ reducers[types.FETCH_REWARDS_COMPLETED] = function(state, action) {
|
|||
function setClaimRewardState(state, reward, isClaiming, errorMessage="") {
|
||||
const newClaimPendingByType = Object.assign({}, state.claimPendingByType)
|
||||
const newClaimErrorsByType = Object.assign({}, state.claimErrorsByType)
|
||||
newClaimPendingByType[reward.reward_type] = isClaiming
|
||||
newClaimErrorsByType[reward.reward_type] = errorMessage
|
||||
if (isClaiming) {
|
||||
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, {
|
||||
claimPendingByType: newClaimPendingByType,
|
||||
|
|
|
@ -70,7 +70,6 @@ export const selectClaimErrorsByType = createSelector(
|
|||
)
|
||||
|
||||
const selectClaimRewardError = (state, props) => {
|
||||
console.log(selectClaimErrorsByType(state, props));
|
||||
return selectClaimErrorsByType(state, props)[props.reward.reward_type]
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue