feat(client): optimize donation form for holiday alert (#44482)

* feat(client): optmize donation form for holiday alert

* feat: remove key from i18n
This commit is contained in:
Ahmad Abdolsaheb
2021-12-13 19:25:21 +03:00
committed by GitHub
parent 129083de97
commit cd9c57a8c5
3 changed files with 14 additions and 6 deletions

View File

@ -32,7 +32,6 @@
"profile": "Profile", "profile": "Profile",
"news": "News", "news": "News",
"donate": "Donate", "donate": "Donate",
"support-our-nonprofit": "Support our non-profit",
"update-settings": "Update my account settings", "update-settings": "Update my account settings",
"sign-me-out": "Sign me out of freeCodeCamp", "sign-me-out": "Sign me out of freeCodeCamp",
"flag-user": "Flag This User's Account for Abuse", "flag-user": "Flag This User's Account for Abuse",

View File

@ -16,6 +16,7 @@ import {
} from '../../../../config/donation-settings'; } from '../../../../config/donation-settings';
import { import {
isSignedInSelector, isSignedInSelector,
isDonatingSelector,
signInLoadingSelector, signInLoadingSelector,
donationFormStateSelector, donationFormStateSelector,
addDonation, addDonation,
@ -70,6 +71,7 @@ type DonateFormProps = {
donationFormState: DonateFormState; donationFormState: DonateFormState;
isMinimalForm?: boolean; isMinimalForm?: boolean;
isSignedIn: boolean; isSignedIn: boolean;
isDonating: boolean;
showLoading: boolean; showLoading: boolean;
t: ( t: (
label: string, label: string,
@ -82,15 +84,18 @@ type DonateFormProps = {
const mapStateToProps = createSelector( const mapStateToProps = createSelector(
signInLoadingSelector, signInLoadingSelector,
isSignedInSelector, isSignedInSelector,
isDonatingSelector,
donationFormStateSelector, donationFormStateSelector,
userSelector, userSelector,
( (
showLoading: DonateFormProps['showLoading'], showLoading: DonateFormProps['showLoading'],
isSignedIn: DonateFormProps['isSignedIn'], isSignedIn: DonateFormProps['isSignedIn'],
isDonating: DonateFormProps['isDonating'],
donationFormState: DonateFormState, donationFormState: DonateFormState,
{ email, theme }: { email: string; theme: Themes } { email, theme }: { email: string; theme: Themes }
) => ({ ) => ({
isSignedIn, isSignedIn,
isDonating,
showLoading, showLoading,
donationFormState, donationFormState,
email, email,
@ -310,7 +315,8 @@ class DonateForm extends Component<DonateFormProps, DonateFormComponentState> {
theme, theme,
t, t,
isMinimalForm, isMinimalForm,
isSignedIn isSignedIn,
isDonating
} = this.props; } = this.props;
const priorityTheme = defaultTheme ? defaultTheme : theme; const priorityTheme = defaultTheme ? defaultTheme : theme;
const isOneTime = donationDuration === 'onetime'; const isOneTime = donationDuration === 'onetime';
@ -318,6 +324,7 @@ class DonateForm extends Component<DonateFormProps, DonateFormComponentState> {
isOneTime ? 'donate.wallet-label' : 'donate.wallet-label-1', isOneTime ? 'donate.wallet-label' : 'donate.wallet-label-1',
{ usd: donationAmount / 100 } { usd: donationAmount / 100 }
)}:`; )}:`;
const showMinimalPayments = isMinimalForm || !isDonating;
return ( return (
<> <>
@ -342,14 +349,16 @@ class DonateForm extends Component<DonateFormProps, DonateFormComponentState> {
donationDuration={donationDuration} donationDuration={donationDuration}
handlePaymentButtonLoad={this.handlePaymentButtonLoad} handlePaymentButtonLoad={this.handlePaymentButtonLoad}
handleProcessing={handleProcessing} handleProcessing={handleProcessing}
isMinimalForm={isMinimalForm} isMinimalForm={showMinimalPayments}
isPaypalLoading={loading.paypal} isPaypalLoading={loading.paypal}
isSignedIn={isSignedIn} isSignedIn={isSignedIn}
onDonationStateChange={this.onDonationStateChange} onDonationStateChange={this.onDonationStateChange}
theme={priorityTheme} theme={priorityTheme}
/> />
{(!loading.stripe || !loading.paypal) && (
<PatreonButton postPatreonRedirect={this.postPatreonRedirect} /> <PatreonButton postPatreonRedirect={this.postPatreonRedirect} />
{isMinimalForm && ( )}
{showMinimalPayments && (
<> <>
<div className='separator'>{t('donate.or-card')}</div> <div className='separator'>{t('donate.or-card')}</div>
<StripeCardForm <StripeCardForm

View File

@ -92,7 +92,7 @@ const Intro = ({
sameTab={false} sameTab={false}
to='/donate' to='/donate'
> >
{t('buttons.support-our-nonprofit')} {t('buttons.donate')}
</Link> </Link>
</p> </p>
</Alert> </Alert>