From d0bcb9f205b67173e2758a1095d6aef52031131e Mon Sep 17 00:00:00 2001 From: Sean Yesmunt Date: Mon, 4 Feb 2019 12:45:30 -0500 Subject: [PATCH] feat: auto claim all referral rewards --- package.json | 4 +- src/renderer/component/inviteList/index.js | 3 +- src/renderer/component/inviteList/view.jsx | 72 ++++++++++++++-------- src/renderer/component/rewardLink/view.jsx | 19 +++--- src/renderer/page/subscriptions/view.jsx | 1 + src/renderer/scss/component/_card.scss | 5 ++ src/renderer/scss/component/_table.scss | 7 +++ yarn.lock | 8 +-- 8 files changed, 77 insertions(+), 42 deletions(-) diff --git a/package.json b/package.json index d8b74b19b..93aa80e0a 100644 --- a/package.json +++ b/package.json @@ -52,8 +52,8 @@ "hast-util-sanitize": "^1.1.2", "keytar": "^4.2.1", "lbry-format": "https://github.com/lbryio/lbry-format.git", - "lbry-redux": "lbryio/lbry-redux#e94de324876185561b4f38b18fabb2aa58b8e3ed", - "lbryinc": "lbryio/lbryinc#83c275da7a44f346ce9e796d06f30126f02b4c63", + "lbry-redux": "lbryio/lbry-redux#973bbd780a774ba48f4e22861b6accb706cf3835", + "lbryinc": "lbryio/lbryinc#da78018f7253d5e73dbc86f2edae62d1ec173484", "localforage": "^1.7.1", "mammoth": "^1.4.6", "mime": "^2.3.1", diff --git a/src/renderer/component/inviteList/index.js b/src/renderer/component/inviteList/index.js index d8df4a4b3..c332d49b7 100644 --- a/src/renderer/component/inviteList/index.js +++ b/src/renderer/component/inviteList/index.js @@ -1,10 +1,11 @@ import { connect } from 'react-redux'; -import { selectUserInvitees, selectUserInviteStatusIsPending } from 'lbryinc'; +import { selectReferralReward, selectUserInvitees, selectUserInviteStatusIsPending } from 'lbryinc'; import InviteList from './view'; const select = state => ({ invitees: selectUserInvitees(state), isPending: selectUserInviteStatusIsPending(state), + referralReward: selectReferralReward(state), }); const perform = () => ({}); diff --git a/src/renderer/component/inviteList/view.jsx b/src/renderer/component/inviteList/view.jsx index 5872b4f44..4c9893b92 100644 --- a/src/renderer/component/inviteList/view.jsx +++ b/src/renderer/component/inviteList/view.jsx @@ -1,10 +1,11 @@ // @flow -import * as ICONS from 'constants/icons'; +import type { Reward } from 'types/reward'; import React from 'react'; -import Icon from 'component/common/icon'; import RewardLink from 'component/rewardLink'; import Yrbl from 'component/common/yrbl'; import { rewards } from 'lbryinc'; +import Icon from 'component/common/icon'; +import * as ICONS from 'constants/icons'; type Props = { invitees: ?Array<{ @@ -13,11 +14,12 @@ type Props = { invite_reward_claimed: boolean, invite_reward_claimable: boolean, }>, + referralReward: ?Reward, }; class InviteList extends React.PureComponent { render() { - const { invitees } = this.props; + const { invitees, referralReward } = this.props; if (!invitees) { return null; @@ -35,50 +37,72 @@ class InviteList extends React.PureComponent { ); } + let rewardAmount = 0; + let rewardHelp = __( + "Woah, you have a lot of friends! You've claimed the maximum amount of referral rewards. Check back soon to see if more are available!." + ); + + if (referralReward) { + rewardAmount = referralReward.reward_amount; + rewardHelp = referralReward.reward_description; + } + const showClaimable = invitees.some( + invite => invite.invite_reward_claimable && !invite.invite_reward_claimed + ); + return (
-

{__('Invite History')}

+

+ {__('Invite History')} + {referralReward && + showClaimable && ( + + )} +

- +
- - + + {invitees.map(invitee => ( - - ))}
{__('Invitee Email')}{__('Invite Status')}{__('Reward')}{__('Invite Status')}{__('Reward')}
{invitee.email} - {invitee.invite_accepted ? ( - - ) : ( - {__('unused')} - )} + + {invitee.invite_accepted ? __('Accepted') : __('Not Accepted')} - {invitee.invite_reward_claimed && } - {!invitee.invite_reward_claimed && invitee.invite_reward_claimable ? ( - - ) : ( - {__('unclaimable')} + + {invitee.invite_reward_claimed && ( + + {__('Claimed')} + + )} + + {!invitee.invite_reward_claimed && + (invitee.invite_reward_claimable ? ( + {__('Claimable')} + ) : ( + __('Unclaimable') + ))}
-
- {__( - 'The maximum number of invite rewards is currently limited. Invite reward can only be claimed if the invitee passes the humanness test.' - )} -
+
{rewardHelp}
); diff --git a/src/renderer/component/rewardLink/view.jsx b/src/renderer/component/rewardLink/view.jsx index b8de1d65b..d2e0bdfd3 100644 --- a/src/renderer/component/rewardLink/view.jsx +++ b/src/renderer/component/rewardLink/view.jsx @@ -16,18 +16,15 @@ type Props = { const RewardLink = (props: Props) => { const { reward, claimReward, label, isPending, button } = props; - return !reward ? null : ( -
-
+