change: remove error modal from rewards

This commit is contained in:
Sean Yesmunt 2019-01-17 01:34:31 -05:00
parent ea9658b578
commit afe82c478e
6 changed files with 11 additions and 47 deletions

View file

@ -1,35 +1,19 @@
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { import { makeSelectRewardByType, makeSelectIsRewardClaimPending, doClaimRewardType } from 'lbryinc';
makeSelectClaimRewardError,
makeSelectRewardByType,
makeSelectIsRewardClaimPending,
doClaimRewardType,
doClaimRewardClearError,
} from 'lbryinc';
import { doNavigate } from 'redux/actions/navigation'; import { doNavigate } from 'redux/actions/navigation';
import RewardLink from './view'; import RewardLink from './view';
const makeSelect = () => { const select = (state, props) => ({
const selectIsPending = makeSelectIsRewardClaimPending(); isPending: makeSelectIsRewardClaimPending()(state, props),
const selectReward = makeSelectRewardByType(); reward: makeSelectRewardByType()(state, props.reward_type),
const selectError = makeSelectClaimRewardError(); });
const select = (state, props) => ({
errorMessage: selectError(state, props),
isPending: selectIsPending(state, props),
reward: selectReward(state, props.reward_type),
});
return select;
};
const perform = dispatch => ({ const perform = dispatch => ({
claimReward: reward => dispatch(doClaimRewardType(reward.reward_type)), claimReward: reward => dispatch(doClaimRewardType(reward.reward_type, { notifyError: true })),
clearError: reward => dispatch(doClaimRewardClearError(reward)),
navigate: path => dispatch(doNavigate(path)), navigate: path => dispatch(doNavigate(path)),
}); });
export default connect( export default connect(
makeSelect, select,
perform perform
)(RewardLink); )(RewardLink);

View file

@ -1,6 +1,5 @@
// @flow // @flow
import React from 'react'; import React from 'react';
import { Modal } from 'modal/modal';
import Button from 'component/button'; import Button from 'component/button';
type Reward = { type Reward = {
@ -10,15 +9,13 @@ type Reward = {
type Props = { type Props = {
isPending: boolean, isPending: boolean,
label: ?string, label: ?string,
errorMessage: ?string,
reward: Reward, reward: Reward,
button: ?boolean, button: ?boolean,
clearError: Reward => void,
claimReward: Reward => void, claimReward: Reward => void,
}; };
const RewardLink = (props: Props) => { const RewardLink = (props: Props) => {
const { reward, claimReward, clearError, errorMessage, label, isPending, button } = props; const { reward, claimReward, label, isPending, button } = props;
return !reward ? null : ( return !reward ? null : (
<div className="reward-link"> <div className="reward-link">
@ -30,23 +27,6 @@ const RewardLink = (props: Props) => {
claimReward(reward); 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> </div>
); );
}; };

View file

@ -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.' 'In addition, your email address will never be sold and you can unsubscribe at any time.'
)} )}
</p> </p>
<Form onSubmit={this.handleSubmit}> <Form onSubmit={this.handleSubmit}>
<FormRow> <FormRow>
<FormField <FormField

View file

@ -22,7 +22,7 @@ class ModalFirstReward extends React.PureComponent<Props> {
<p>{__('You just earned your first reward!')}</p> <p>{__('You just earned your first reward!')}</p>
<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>
<p> <p>

View file

@ -152,7 +152,7 @@ class RewardsPage extends PureComponent<Props> {
'card--disabled': isNotEligible, '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()} {this.renderCustomRewardCode()}
</div> </div>
); );

View file

@ -11,4 +11,5 @@ export type Reward = {
reward_version: ?string, reward_version: ?string,
transaction_id: ?string, transaction_id: ?string,
updated_at: ?string, updated_at: ?string,
claim_code: string,
}; };