Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/empty-tigers-serve.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@guardian/support-dotcom-components': minor
---

Replace ChoiceCard destinationUrl with destination
10 changes: 4 additions & 6 deletions src/server/lib/choiceCards/choiceCards.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,15 @@ describe('getChoiceCardsSettings', () => {
supportTier: 'SupporterPlus',
ratePlan: 'Monthly',
});
expect(result?.choiceCards[1].destinationUrl).toBeNull();
expect(result?.choiceCards[1].destination).toEqual('LandingPage');
});

it('preserves custom destinationUrl when provided', () => {
it('preserves custom destination when provided', () => {
const variantChoiceCardSettings: ChoiceCardsSettings = {
choiceCards: [
{
...defaultEpicChoiceCardsSettings('UnitedStates').choiceCards[0],
destinationUrl: 'https://support.theguardian.com/contribute/one-time',
destination: 'Checkout',
},
defaultEpicChoiceCardsSettings('UnitedStates').choiceCards[1],
defaultEpicChoiceCardsSettings('UnitedStates').choiceCards[2],
Expand All @@ -119,9 +119,7 @@ describe('getChoiceCardsSettings', () => {
);

expect(result).toBeDefined();
expect(result?.choiceCards[0].destinationUrl).toEqual(
'https://support.theguardian.com/contribute/one-time',
);
expect(result?.choiceCards[0].destination).toEqual('Checkout');
});

it('returns choice cards with monthly discount (PROMO_B) applied', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/server/lib/choiceCards/choiceCards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ const enrichChoiceCard = (
benefitsLabel: choiceCard.benefitsLabel,
benefits,
pill,
destinationUrl: choiceCard.destinationUrl, // Preserve the destination URL
destination: choiceCard.destination,
};
};

Expand Down
8 changes: 4 additions & 4 deletions src/server/lib/choiceCards/defaultChoiceCardSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const oneOffCard = (countryGroupId: CountryGroupId): ChoiceCard => ({
: 'We welcome support of any size, any time',
},
],
destinationUrl: null, // Will use default CTA behavior
destination: 'LandingPage',
});

const fullChoiceCards = (countryGroupId: CountryGroupId): ChoiceCard[] => [
Expand All @@ -36,7 +36,7 @@ const fullChoiceCards = (countryGroupId: CountryGroupId): ChoiceCard[] => [
copy: 'Give to the Guardian every month with Support',
},
],
destinationUrl: null, // Will use default CTA behavior
destination: 'LandingPage',
},
{
product: {
Expand All @@ -58,7 +58,7 @@ const fullChoiceCards = (countryGroupId: CountryGroupId): ChoiceCard[] => [
pill: {
copy: 'Recommended',
},
destinationUrl: null, // Will use default CTA behavior
destination: 'LandingPage',
},
oneOffCard(countryGroupId),
];
Expand Down Expand Up @@ -91,7 +91,7 @@ const shorterChoiceCards = (countryGroupId: CountryGroupId): ChoiceCard[] => [
pill: {
copy: 'Recommended',
},
destinationUrl: null, // Will use default CTA behavior
destination: 'LandingPage',
},
oneOffCard(countryGroupId),
];
Expand Down
4 changes: 3 additions & 1 deletion src/shared/types/props/choiceCards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,16 @@ const pillSchema = z.object({
backgroundColour: hexColourSchema.nullish(),
});

const destinationSchema = z.union([z.literal('LandingPage'), z.literal('Checkout')]);

const choiceCardSchema = z.object({
product: productSchema,
label: z.string(), // e.g. "Support $15/month"
isDefault: z.boolean(), // default selected choice card
benefitsLabel: z.string().nullish(), // e.g. "Unlock All-access digital benefits:"
benefits: z.array(productBenefitSchema),
pill: pillSchema.nullish(),
destinationUrl: z.string().nullish(), // Optional override URL for this choice card
destination: destinationSchema.nullish(),
});

export type ChoiceCard = z.infer<typeof choiceCardSchema>;
Expand Down