make the claim custom reward card always visible

This commit is contained in:
Akinwale Ariwodola 2019-01-22 14:29:59 +01:00
parent eaaa2b97b4
commit 7f54c02a1c

View file

@ -92,6 +92,7 @@ class RewardsPage extends React.PureComponent {
renderUnclaimedRewards() { renderUnclaimedRewards() {
const { claimed, fetching, rewards, user } = this.props; const { claimed, fetching, rewards, user } = this.props;
const unclaimedRewards = (rewards && rewards.length) ? rewards : [];
if (fetching) { if (fetching) {
return ( return (
@ -106,22 +107,12 @@ class RewardsPage extends React.PureComponent {
<Text style={rewardStyle.infoText}>This app is unable to earn rewards due to an authentication failure.</Text> <Text style={rewardStyle.infoText}>This app is unable to earn rewards due to an authentication failure.</Text>
</View> </View>
); );
} else if (!rewards || rewards.length <= 0) {
return (
<View style={rewardStyle.busyContainer}>
<Text style={rewardStyle.infoText}>
{(claimed && claimed.length) ?
"You have claimed all available rewards! We're regularly adding more so be sure to check back later." :
"There are no rewards available at this time, please check back later."}
</Text>
</View>
);
} }
const isNotEligible = !user || !user.primary_email || !user.has_verified_email || !user.is_reward_approved; const isNotEligible = !user || !user.primary_email || !user.has_verified_email || !user.is_reward_approved;
return ( return (
<View> <View>
{rewards.map(reward => <RewardCard key={reward.reward_type} {unclaimedRewards.map(reward => <RewardCard key={reward.reward_type}
canClaim={!isNotEligible} canClaim={!isNotEligible}
reward={reward} reward={reward}
reward_type={reward.reward_type} />)} reward_type={reward.reward_type} />)}