Merge pull request #2206 from lbryio/rewards-fix
Fix: Allow multiple rewards of same type to be claimed and remove reward error modal
This commit is contained in:
commit
50028e4d9b
9 changed files with 15 additions and 51 deletions
|
@ -53,7 +53,7 @@
|
|||
"keytar": "^4.2.1",
|
||||
"lbry-format": "https://github.com/lbryio/lbry-format.git",
|
||||
"lbry-redux": "lbryio/lbry-redux#a22f8284110f957f3f645d42abc457ab8fb3fa8a",
|
||||
"lbryinc": "lbryio/lbryinc#b3bb8c67745235ef54baea95accaedaa4bb86d4d",
|
||||
"lbryinc": "lbryio/lbryinc#83c275da7a44f346ce9e796d06f30126f02b4c63",
|
||||
"localforage": "^1.7.1",
|
||||
"mammoth": "^1.4.6",
|
||||
"mime": "^2.3.1",
|
||||
|
|
|
@ -1,35 +1,19 @@
|
|||
import { connect } from 'react-redux';
|
||||
import {
|
||||
makeSelectClaimRewardError,
|
||||
makeSelectRewardByType,
|
||||
makeSelectIsRewardClaimPending,
|
||||
doClaimRewardType,
|
||||
doClaimRewardClearError,
|
||||
} from 'lbryinc';
|
||||
import { makeSelectRewardByType, makeSelectIsRewardClaimPending, doClaimRewardType } from 'lbryinc';
|
||||
import { doNavigate } from 'redux/actions/navigation';
|
||||
import RewardLink from './view';
|
||||
|
||||
const makeSelect = () => {
|
||||
const selectIsPending = makeSelectIsRewardClaimPending();
|
||||
const selectReward = makeSelectRewardByType();
|
||||
const selectError = makeSelectClaimRewardError();
|
||||
|
||||
const select = (state, props) => ({
|
||||
errorMessage: selectError(state, props),
|
||||
isPending: selectIsPending(state, props),
|
||||
reward: selectReward(state, props.reward_type),
|
||||
isPending: makeSelectIsRewardClaimPending()(state, props),
|
||||
reward: makeSelectRewardByType()(state, props.reward_type),
|
||||
});
|
||||
|
||||
return select;
|
||||
};
|
||||
|
||||
const perform = dispatch => ({
|
||||
claimReward: reward => dispatch(doClaimRewardType(reward.reward_type)),
|
||||
clearError: reward => dispatch(doClaimRewardClearError(reward)),
|
||||
claimReward: reward => dispatch(doClaimRewardType(reward.reward_type, { notifyError: true })),
|
||||
navigate: path => dispatch(doNavigate(path)),
|
||||
});
|
||||
|
||||
export default connect(
|
||||
makeSelect,
|
||||
select,
|
||||
perform
|
||||
)(RewardLink);
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
// @flow
|
||||
import React from 'react';
|
||||
import { Modal } from 'modal/modal';
|
||||
import Button from 'component/button';
|
||||
|
||||
type Reward = {
|
||||
|
@ -10,15 +9,13 @@ type Reward = {
|
|||
type Props = {
|
||||
isPending: boolean,
|
||||
label: ?string,
|
||||
errorMessage: ?string,
|
||||
reward: Reward,
|
||||
button: ?boolean,
|
||||
clearError: Reward => void,
|
||||
claimReward: Reward => void,
|
||||
};
|
||||
|
||||
const RewardLink = (props: Props) => {
|
||||
const { reward, claimReward, clearError, errorMessage, label, isPending, button } = props;
|
||||
const { reward, claimReward, label, isPending, button } = props;
|
||||
|
||||
return !reward ? null : (
|
||||
<div className="reward-link">
|
||||
|
@ -30,23 +27,6 @@ const RewardLink = (props: Props) => {
|
|||
claimReward(reward);
|
||||
}}
|
||||
/>
|
||||
{errorMessage ? (
|
||||
// TODO: This should be moved to redux
|
||||
<Modal
|
||||
isOpen
|
||||
title={__('Error Claiming Reward')}
|
||||
contentLabel="Reward Claim Error"
|
||||
onConfirmed={() => {
|
||||
clearError(reward);
|
||||
}}
|
||||
>
|
||||
<section className="card__content">
|
||||
<div className="error-modal__error-list">{errorMessage}</div>
|
||||
</section>
|
||||
</Modal>
|
||||
) : (
|
||||
''
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
|
|
@ -51,7 +51,6 @@ class UserEmailNew extends React.PureComponent<Props, State> {
|
|||
'In addition, your email address will never be sold and you can unsubscribe at any time.'
|
||||
)}
|
||||
</p>
|
||||
|
||||
<Form onSubmit={this.handleSubmit}>
|
||||
<FormRow>
|
||||
<FormField
|
||||
|
|
|
@ -22,7 +22,7 @@ class ModalFirstReward extends React.PureComponent<Props> {
|
|||
<p>{__('You just earned your first reward!')}</p>
|
||||
<p>
|
||||
{__(
|
||||
"This reward will show in your Wallet in the top right momentarily (if it hasn't already)."
|
||||
"This reward will show in your Wallet in the top left momentarily (if it hasn't already)."
|
||||
)}
|
||||
</p>
|
||||
<p>
|
||||
|
|
|
@ -152,7 +152,7 @@ class RewardsPage extends PureComponent<Props> {
|
|||
'card--disabled': isNotEligible,
|
||||
})}
|
||||
>
|
||||
{rewards.map(reward => <RewardTile key={reward.reward_type} reward={reward} />)}
|
||||
{rewards.map(reward => <RewardTile key={reward.claim_code} reward={reward} />)}
|
||||
{this.renderCustomRewardCode()}
|
||||
</div>
|
||||
);
|
||||
|
|
|
@ -83,7 +83,7 @@
|
|||
.card__content {
|
||||
font-size: 1.15rem;
|
||||
|
||||
p:not(:last-of-type) {
|
||||
p:not(:last-child) {
|
||||
margin-bottom: var(--spacing-vertical-medium);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,4 +11,5 @@ export type Reward = {
|
|||
reward_version: ?string,
|
||||
transaction_id: ?string,
|
||||
updated_at: ?string,
|
||||
claim_code: string,
|
||||
};
|
||||
|
|
|
@ -5698,9 +5698,9 @@ lbry-redux@lbryio/lbry-redux#a22f8284110f957f3f645d42abc457ab8fb3fa8a:
|
|||
reselect "^3.0.0"
|
||||
uuid "^3.3.2"
|
||||
|
||||
lbryinc@lbryio/lbryinc#b3bb8c67745235ef54baea95accaedaa4bb86d4d:
|
||||
lbryinc@lbryio/lbryinc#83c275da7a44f346ce9e796d06f30126f02b4c63:
|
||||
version "0.0.1"
|
||||
resolved "https://codeload.github.com/lbryio/lbryinc/tar.gz/b3bb8c67745235ef54baea95accaedaa4bb86d4d"
|
||||
resolved "https://codeload.github.com/lbryio/lbryinc/tar.gz/83c275da7a44f346ce9e796d06f30126f02b4c63"
|
||||
dependencies:
|
||||
lbry-redux lbryio/lbry-redux#84b7d396934d57a37802aadbef71db91230a9404
|
||||
reselect "^3.0.0"
|
||||
|
|
Loading…
Reference in a new issue