fix(donate): remove call to verification when not signed in

This commit is contained in:
Mrugesh Mohapatra
2020-03-20 13:07:02 +05:30
parent 08ec29fa1b
commit 8866ed74c2
2 changed files with 37 additions and 23 deletions

View File

@ -233,7 +233,7 @@ class DonateForm extends Component {
render() { render() {
const { donationAmount, donationDuration } = this.state; const { donationAmount, donationDuration } = this.state;
const { handleProcessing } = this.props; const { handleProcessing, isSignedIn } = this.props;
const { const {
donationState: { processing, success, error } donationState: { processing, success, error }
} = this.state; } = this.state;
@ -268,6 +268,7 @@ class DonateForm extends Component {
donationDuration={donationDuration} donationDuration={donationDuration}
handleProcessing={handleProcessing} handleProcessing={handleProcessing}
onDonationStateChange={this.onDonationStateChange} onDonationStateChange={this.onDonationStateChange}
skipAddDonation={!isSignedIn}
/> />
</Col> </Col>

View File

@ -33,27 +33,39 @@ export class PaypalButton extends Component {
handleApproval = data => { handleApproval = data => {
const { amount, duration } = this.state; const { amount, duration } = this.state;
this.props.handleProcessing(duration, amount, 'Paypal payment submission'); const { skipAddDonation = false } = this.props;
this.props.onDonationStateChange(false, true, ''); if (!skipAddDonation) {
verifySubscriptionPaypal(data) this.props.handleProcessing(
.then(response => { duration,
const data = response && response.data; amount,
this.props.onDonationStateChange( 'Paypal payment submission'
true, );
false, this.props.onDonationStateChange(false, true, '');
data.error ? data.error : '' verifySubscriptionPaypal(data)
); .then(response => {
}) const data = response && response.data;
.catch(error => { this.props.onDonationStateChange(
const data = true,
error.response && error.response.data false,
? error.response.data data.error ? data.error : ''
: { );
error: })
'Something is not right. Please contact team@freecodecamp.org' .catch(error => {
}; const data =
this.props.onDonationStateChange(false, false, data.error); error.response && error.response.data
}); ? error.response.data
: {
error: `Something is not right. Please contact team@freecodecamp.org`
};
this.props.onDonationStateChange(false, false, data.error);
});
} else {
this.props.onDonationStateChange(
true,
false,
data.error ? data.error : ''
);
}
}; };
render() { render() {
@ -101,7 +113,8 @@ const propTypes = {
donationDuration: PropTypes.string, donationDuration: PropTypes.string,
handleProcessing: PropTypes.func, handleProcessing: PropTypes.func,
isDonating: PropTypes.bool, isDonating: PropTypes.bool,
onDonationStateChange: PropTypes.func onDonationStateChange: PropTypes.func,
skipAddDonation: PropTypes.bool
}; };
const mapStateToProps = createSelector( const mapStateToProps = createSelector(