additional rewards page changes and new verification flow #542

Merged
akinwale merged 9 commits from rewards-rework into master 2019-05-15 12:00:15 +02:00
4 changed files with 30 additions and 14 deletions
Showing only changes of commit ca7e33765f - Show all commits

View file

@ -72,16 +72,7 @@ class RewardCard extends React.PureComponent<Props> {
} }
}}> }}>
<View style={rewardStyle.leftCol}> <View style={rewardStyle.leftCol}>
{!isPending && <TouchableOpacity onPress={() => {
if (!claimed) {
this.onClaimPress();
}
}}>
<Icon name={claimed ? "check-circle" : "circle"}
style={claimed ? rewardStyle.claimed : (canClaim ? rewardStyle.unclaimed : rewardStyle.disabled)}
size={20} />
</TouchableOpacity>}
{isPending && <ActivityIndicator size="small" color={Colors.LbryGreen} />}
</View> </View>
<View style={rewardStyle.midCol}> <View style={rewardStyle.midCol}>
<Text style={rewardStyle.rewardTitle}>{reward.reward_title}</Text> <Text style={rewardStyle.rewardTitle}>{reward.reward_title}</Text>
@ -92,6 +83,16 @@ class RewardCard extends React.PureComponent<Props> {
error={'The transaction URL could not be opened'} />} error={'The transaction URL could not be opened'} />}
</View> </View>
<View style={rewardStyle.rightCol}> <View style={rewardStyle.rightCol}>
{!isPending && <TouchableOpacity onPress={() => {
if (!claimed) {
this.onClaimPress();
}
}}>
<Icon name={claimed ? "check-circle" : "circle"}
style={claimed ? rewardStyle.claimed : (canClaim ? rewardStyle.unclaimed : rewardStyle.disabled)}
size={20} />
</TouchableOpacity>}
{isPending && <ActivityIndicator size="small" color={Colors.LbryGreen} />}
<Text style={rewardStyle.rewardAmount}>{reward.reward_amount}</Text> <Text style={rewardStyle.rewardAmount}>{reward.reward_amount}</Text>
<Text style={rewardStyle.rewardCurrency}>LBC</Text> <Text style={rewardStyle.rewardCurrency}>LBC</Text>
</View> </View>

View file

@ -1,5 +1,6 @@
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { import {
doClaimRewardType,
doRewardList, doRewardList,
selectEmailVerifyErrorMessage, selectEmailVerifyErrorMessage,
selectEmailVerifyIsPending, selectEmailVerifyIsPending,
@ -23,6 +24,7 @@ const select = state => ({
}); });
const perform = dispatch => ({ const perform = dispatch => ({
claimReward: reward => dispatch(doClaimRewardType(reward.reward_type, true)),
fetchRewards: () => dispatch(doRewardList()), fetchRewards: () => dispatch(doRewardList()),
notify: data => dispatch(doToast(data)), notify: data => dispatch(doToast(data)),
pushDrawerStack: () => dispatch(doPushDrawerStack(Constants.DRAWER_ROUTE_REWARDS)) pushDrawerStack: () => dispatch(doPushDrawerStack(Constants.DRAWER_ROUTE_REWARDS))

View file

@ -25,7 +25,8 @@ class RewardsPage extends React.PureComponent {
isIdentityVerified: false, isIdentityVerified: false,
isRewardApproved: false, isRewardApproved: false,
verifyRequestStarted: false, verifyRequestStarted: false,
revealVerification: true revealVerification: true,
firstRewardClaimed: false
}; };
scrollView = null; scrollView = null;
@ -44,7 +45,8 @@ class RewardsPage extends React.PureComponent {
} }
componentWillReceiveProps(nextProps) { componentWillReceiveProps(nextProps) {
const { emailVerifyErrorMessage, emailVerifyPending, user } = nextProps; const { emailVerifyErrorMessage, emailVerifyPending, rewards, user } = nextProps;
const { claimReward } = this.props;
if (emailVerifyPending) { if (emailVerifyPending) {
this.setState({ verifyRequestStarted: true }); this.setState({ verifyRequestStarted: true });
} }
@ -64,6 +66,17 @@ class RewardsPage extends React.PureComponent {
isRewardApproved: (user && user.is_reward_approved) isRewardApproved: (user && user.is_reward_approved)
}); });
} }
if (rewards && rewards.length && this.state.isRewardApproved && !this.state.firstRewardClaimed) {
// claim new_user and new_mobile rewards
for (let i = 0; i < rewards.length; i++) {
const { reward_type: type } = rewards[i];
if ('new_user' === type || 'new_mobile' === type) {
claimReward(rewards[i]);
}
}
this.setState({ firstRewardClaimed: true });
}
} }
renderVerification() { renderVerification() {

View file

@ -135,12 +135,12 @@ const rewardStyle = StyleSheet.create({
color: Colors.LbryGreen color: Colors.LbryGreen
}, },
leftCol: { leftCol: {
width: '15%', width: '5%',
alignItems: 'center', alignItems: 'center',
paddingLeft: 6 paddingLeft: 6
}, },
midCol: { midCol: {
width: '65%' width: '75%'
}, },
rightCol: { rightCol: {
width: '18%', width: '18%',