feat(client): add patreon ga (#44179)

* feat: add patreon ga

* Apply suggestions from code review

Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>

Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>
This commit is contained in:
Ahmad Abdolsaheb
2021-11-16 17:26:56 +03:00
committed by GitHub
parent 2aa95a4b85
commit 56a60700b7
2 changed files with 19 additions and 2 deletions

View File

@ -131,6 +131,7 @@ class DonateForm extends Component<DonateFormProps, DonateFormComponentState> {
this.resetDonation = this.resetDonation.bind(this);
this.postStripeDonation = this.postStripeDonation.bind(this);
this.postStripeCardDonation = this.postStripeCardDonation.bind(this);
this.postPatreonRedirect = this.postPatreonRedirect.bind(this);
this.handlePaymentButtonLoad = this.handlePaymentButtonLoad.bind(this);
}
@ -241,6 +242,15 @@ class DonateForm extends Component<DonateFormProps, DonateFormComponentState> {
});
}
postPatreonRedirect() {
const { donationAmount: amount, donationDuration: duration } = this.state;
this.props.handleProcessing(
duration,
amount,
'Patreon payment redirection'
);
}
handleSelectAmount(donationAmount: number) {
this.setState({ donationAmount });
}
@ -337,7 +347,7 @@ class DonateForm extends Component<DonateFormProps, DonateFormComponentState> {
onDonationStateChange={this.onDonationStateChange}
theme={priorityTheme}
/>
<PatreonButton />
<PatreonButton postPatreonRedirect={this.postPatreonRedirect} />
{isMinimalForm && (
<>
<div className='separator'>{t('donate.or-card')}</div>

View File

@ -10,7 +10,13 @@ const { patreonClientId }: { patreonClientId: string | null } = envData as {
patreonClientId: string | null;
};
const PatreonButton = (): JSX.Element | null => {
interface PatreonButtonProps {
postPatreonRedirect: () => void;
}
const PatreonButton = ({
postPatreonRedirect
}: PatreonButtonProps): JSX.Element | null => {
if (
!patreonClientId ||
!patreonDefaultPledgeAmount ||
@ -30,6 +36,7 @@ const PatreonButton = (): JSX.Element | null => {
className='patreon-button link-button'
data-patreon-widget-type='become-patron-button'
href={href}
onClick={postPatreonRedirect}
rel='noreferrer'
target='_blank'
>