Merge pull request #411 from lbryio/show-custom-reward-always

Always show the custom reward card
This commit is contained in:
Akinwale Ariwodola 2019-01-22 20:23:34 +01:00 committed by GitHub
commit 4e22b53907
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 15 deletions

View file

@ -1,6 +1,6 @@
// @flow // @flow
import React from 'react'; import React from 'react';
import { ActivityIndicator, Text, TextInput, TouchableOpacity, View } from 'react-native'; import { ActivityIndicator, Keyboard, Text, TextInput, TouchableOpacity, View } from 'react-native';
import Colors from '../../styles/colors'; import Colors from '../../styles/colors';
import Icon from 'react-native-vector-icons/FontAwesome5'; import Icon from 'react-native-vector-icons/FontAwesome5';
import Button from '../button'; import Button from '../button';
@ -31,6 +31,8 @@ class CustomRewardCard extends React.PureComponent<Props> {
const { canClaim, notify, submitRewardCode } = this.props; const { canClaim, notify, submitRewardCode } = this.props;
const { rewardCode } = this.state; const { rewardCode } = this.state;
Keyboard.dismiss();
if (!canClaim) { if (!canClaim) {
notify({ message: 'Unfortunately, you are not eligible to claim this reward at this time.' }); notify({ message: 'Unfortunately, you are not eligible to claim this reward at this time.' });
return; return;

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} />)}