mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-01-05 21:03:24 -05:00
feat(client): clean extra call function (#50894)
This commit is contained in:
@@ -5,6 +5,7 @@ import { withTranslation } from 'react-i18next';
|
||||
import { connect } from 'react-redux';
|
||||
import Spinner from 'react-spinkit';
|
||||
import { createSelector } from 'reselect';
|
||||
import type { TFunction } from 'i18next';
|
||||
|
||||
import {
|
||||
amountsConfig,
|
||||
@@ -88,10 +89,7 @@ type DonateFormProps = {
|
||||
isSignedIn: boolean;
|
||||
isDonating: boolean;
|
||||
showLoading: boolean;
|
||||
t: (
|
||||
label: string,
|
||||
{ usd, hours }?: { usd?: string | number; hours?: string }
|
||||
) => string;
|
||||
t: TFunction;
|
||||
theme: Themes;
|
||||
updateDonationFormState: (state: DonationApprovalData) => unknown;
|
||||
paymentContext: PaymentContext;
|
||||
@@ -238,17 +236,6 @@ class DonateForm extends Component<DonateFormProps, DonateFormComponentState> {
|
||||
return this.props.updateDonationFormState({ ...defaultDonationFormState });
|
||||
}
|
||||
|
||||
renderCompletion(props: {
|
||||
processing: boolean;
|
||||
redirecting: boolean;
|
||||
success: boolean;
|
||||
error: string | null;
|
||||
isSignedIn: boolean;
|
||||
reset: () => unknown;
|
||||
}) {
|
||||
return <DonateCompletion {...props} />;
|
||||
}
|
||||
|
||||
renderButtonGroup() {
|
||||
const { donationAmount, donationDuration } = this.state;
|
||||
const {
|
||||
@@ -349,28 +336,31 @@ class DonateForm extends Component<DonateFormProps, DonateFormComponentState> {
|
||||
} = this.props;
|
||||
|
||||
if (success || error) {
|
||||
return this.renderCompletion({
|
||||
processing,
|
||||
redirecting,
|
||||
success,
|
||||
error,
|
||||
isSignedIn,
|
||||
reset: this.resetDonation
|
||||
});
|
||||
return (
|
||||
<DonateCompletion
|
||||
processing={processing}
|
||||
redirecting={redirecting}
|
||||
success={success}
|
||||
error={error}
|
||||
isSignedIn={isSignedIn}
|
||||
reset={this.resetDonation}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
// keep payment provider elements on DOM during processing and redirect to avoid errors.
|
||||
return (
|
||||
<>
|
||||
{(processing || redirecting) &&
|
||||
this.renderCompletion({
|
||||
processing,
|
||||
redirecting,
|
||||
success,
|
||||
error,
|
||||
isSignedIn,
|
||||
reset: this.resetDonation
|
||||
})}
|
||||
{(processing || redirecting) && (
|
||||
<DonateCompletion
|
||||
processing={processing}
|
||||
redirecting={redirecting}
|
||||
success={success}
|
||||
error={error}
|
||||
isSignedIn={isSignedIn}
|
||||
reset={this.resetDonation}
|
||||
/>
|
||||
)}
|
||||
<div className={processing || redirecting ? 'hide' : ''}>
|
||||
{isMinimalForm ? this.renderButtonGroup() : this.renderPageForm()}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user