uncommitted work from last night

This commit is contained in:
Jeremy Kauffman 2017-06-02 11:45:37 -04:00
parent a17d19038e
commit b6881c829c
4 changed files with 20 additions and 6 deletions

View file

@ -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)

View file

@ -11,9 +11,10 @@ const RewardLink = (props) => {
clearError,
errorMessage,
isClaimed,
isEligible,
isPending
} = props
console.log(props)
return (
<div className="reward-link">
{isClaimed

View file

@ -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,

View file

@ -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]
}