Skip to content

Commit

Permalink
intial wiring
Browse files Browse the repository at this point in the history
  • Loading branch information
paul-daniel-dempsey committed Oct 13, 2023
1 parent 26ab393 commit d676ad2
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 4 deletions.
33 changes: 33 additions & 0 deletions packages/modules/src/modules/epics/ContributionsEpic.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,39 @@ WithChoiceCardsAndSignInLink.args = {
},
};

export const WithChoiceCardsAndApplePay = Template.bind({});
WithChoiceCardsAndApplePay.args = {
variant: {
...props.variant,
name: 'V1_APPLE_PAY',
showChoiceCards: true,
showApplePay: true,
choiceCardAmounts: {
testName: 'Storybook_test',
variantName: 'Control',
defaultContributionType: 'MONTHLY',
displayContributionType: ['ONE_OFF', 'MONTHLY', 'ANNUAL'],
amountsCardData: {
ONE_OFF: {
amounts: [5, 10, 15, 20],
defaultAmount: 5,
hideChooseYourAmount: false,
},
MONTHLY: {
amounts: [6, 12],
defaultAmount: 12,
hideChooseYourAmount: true,
},
ANNUAL: {
amounts: [50, 100, 150, 200],
defaultAmount: 100,
hideChooseYourAmount: true,
},
},
},
},
};

export const WithSignInLink = Template.bind({});
WithSignInLink.args = {
variant: {
Expand Down
3 changes: 2 additions & 1 deletion packages/modules/src/modules/epics/ContributionsEpic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ const ContributionsEpic: ReactComponent<EpicProps> = ({
hasConsentForArticleCount,
stage,
}: EpicProps) => {
const { image, tickerSettings, showChoiceCards, choiceCardAmounts } = variant;
const { image, tickerSettings, showChoiceCards, choiceCardAmounts, showApplePay } = variant;

const [choiceCardSelection, setChoiceCardSelection] = useState<
ChoiceCardSelection | undefined
Expand Down Expand Up @@ -427,6 +427,7 @@ const ContributionsEpic: ReactComponent<EpicProps> = ({
onReminderOpen={onReminderOpen}
fetchEmail={fetchEmail}
submitComponentEvent={submitComponentEvent}
showApplePay={showApplePay}
showChoiceCards={showChoiceCards}
amountsTestName={choiceCardAmounts?.testName}
amountsVariantName={choiceCardAmounts?.variantName}
Expand Down
15 changes: 12 additions & 3 deletions packages/modules/src/modules/epics/ContributionsEpicButtons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,21 @@ const PrimaryCtaButton = ({
amountsTestName,
amountsVariantName,
numArticles,
showApplePay,
}: {
cta?: Cta;
tracking: Tracking;
countryCode?: string;
amountsTestName?: string;
amountsVariantName?: string;
numArticles: number;
showApplePay?: boolean;
}): JSX.Element | null => {
if (!cta) {
return null;
}

const buttonText = cta.text || 'Support The Guardian';
const buttonText = showApplePay ? 'Support With ' : cta.text || 'Support The Guardian';
const baseUrl = cta.baseUrl || 'https://support.theguardian.com/contribute';
const urlWithRegionAndTracking = addRegionIdAndTrackingParamsToSupportUrl(
baseUrl,
Expand Down Expand Up @@ -85,12 +87,15 @@ const SecondaryCtaButton = ({
tracking,
numArticles,
countryCode,
showApplePay,
}: {
cta: Cta;
tracking: Tracking;
countryCode?: string;
numArticles: number;
showApplePay?: boolean;
}): JSX.Element | null => {
const buttonText = showApplePay ? 'Support With ' : cta.text;
const url = addRegionIdAndTrackingParamsToSupportUrl(
cta.baseUrl,
tracking,
Expand All @@ -101,7 +106,7 @@ const SecondaryCtaButton = ({
return (
<div css={buttonMargins}>
<Button onClickAction={url} showArrow priority="secondary">
{cta.text}
{buttonText}
</Button>
</div>
);
Expand All @@ -120,6 +125,7 @@ interface ContributionsEpicButtonsProps {
amountsVariantName?: string;
choiceCardSelection?: ChoiceCardSelection;
numArticles: number;
showApplePay?: boolean;
}

export const ContributionsEpicButtons = ({
Expand All @@ -135,6 +141,7 @@ export const ContributionsEpicButtons = ({
amountsTestName,
amountsVariantName,
numArticles,
showApplePay,
}: ContributionsEpicButtonsProps): JSX.Element | null => {
const [hasBeenSeen, setNode] = useHasBeenSeen({}, true);
const { cta, secondaryCta, showReminderFields } = variant;
Expand Down Expand Up @@ -183,6 +190,7 @@ export const ContributionsEpicButtons = ({
amountsTestName={amountsTestName}
amountsVariantName={amountsVariantName}
countryCode={countryCode}
showApplePay={showApplePay}
/>

{secondaryCta?.type === SecondaryCtaType.Custom &&
Expand All @@ -193,6 +201,7 @@ export const ContributionsEpicButtons = ({
tracking={tracking}
countryCode={countryCode}
numArticles={numArticles}
showApplePay={showApplePay}
/>
) : (
secondaryCta?.type === SecondaryCtaType.ContributionsReminder &&
Expand All @@ -206,7 +215,7 @@ export const ContributionsEpicButtons = ({
)
)}

{hasSupportCta && (
{hasSupportCta && !showApplePay && (
<img
width={422}
height={60}
Expand Down
3 changes: 3 additions & 0 deletions packages/modules/src/modules/epics/ContributionsEpicCtas.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ interface OnReminderOpen {
}

type ContributionsEpicCtasProps = EpicProps & {
showApplePay?: boolean;
showChoiceCards?: boolean;
choiceCardSelection?: ChoiceCardSelection;
amountsTestName?: string;
Expand All @@ -24,6 +25,7 @@ export const ContributionsEpicCtas: ReactComponent<ContributionsEpicCtasProps> =
submitComponentEvent,
onReminderOpen,
fetchEmail,
showApplePay,
showChoiceCards,
choiceCardSelection,
amountsTestName,
Expand Down Expand Up @@ -69,6 +71,7 @@ export const ContributionsEpicCtas: ReactComponent<ContributionsEpicCtasProps> =
submitComponentEvent={submitComponentEvent}
isReminderActive={isReminderActive}
isSignedIn={Boolean(fetchedEmail)}
showApplePay={showApplePay}
showChoiceCards={showChoiceCards}
choiceCardSelection={choiceCardSelection}
amountsTestName={amountsTestName}
Expand Down
1 change: 1 addition & 0 deletions packages/shared/src/types/abTests/epic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export interface EpicVariant extends Variant {
// with lower priority.
maxViews?: MaxViews;
showSignInLink?: boolean;
showApplePay?: boolean;
}

export type ContributionFrequency = 'ONE_OFF' | 'MONTHLY' | 'ANNUAL';
Expand Down

0 comments on commit d676ad2

Please sign in to comment.