Skip to content

Commit 1a8b474

Browse files
authored
Replace ChoiceCard destinationUrl with destination (#1431)
* Replace ChoiceCard destinationUrl with destination * changeset * prettier
1 parent 0515277 commit 1a8b474

File tree

5 files changed

+17
-12
lines changed

5 files changed

+17
-12
lines changed

.changeset/empty-tigers-serve.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@guardian/support-dotcom-components': minor
3+
---
4+
5+
Replace ChoiceCard destinationUrl with destination

src/server/lib/choiceCards/choiceCards.test.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,15 +93,15 @@ describe('getChoiceCardsSettings', () => {
9393
supportTier: 'SupporterPlus',
9494
ratePlan: 'Monthly',
9595
});
96-
expect(result?.choiceCards[1].destinationUrl).toBeNull();
96+
expect(result?.choiceCards[1].destination).toEqual('LandingPage');
9797
});
9898

99-
it('preserves custom destinationUrl when provided', () => {
99+
it('preserves custom destination when provided', () => {
100100
const variantChoiceCardSettings: ChoiceCardsSettings = {
101101
choiceCards: [
102102
{
103103
...defaultEpicChoiceCardsSettings('UnitedStates').choiceCards[0],
104-
destinationUrl: 'https://support.theguardian.com/contribute/one-time',
104+
destination: 'Checkout',
105105
},
106106
defaultEpicChoiceCardsSettings('UnitedStates').choiceCards[1],
107107
defaultEpicChoiceCardsSettings('UnitedStates').choiceCards[2],
@@ -119,9 +119,7 @@ describe('getChoiceCardsSettings', () => {
119119
);
120120

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

127125
it('returns choice cards with monthly discount (PROMO_B) applied', () => {

src/server/lib/choiceCards/choiceCards.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ const enrichChoiceCard = (
8383
benefitsLabel: choiceCard.benefitsLabel,
8484
benefits,
8585
pill,
86-
destinationUrl: choiceCard.destinationUrl, // Preserve the destination URL
86+
destination: choiceCard.destination,
8787
};
8888
};
8989

src/server/lib/choiceCards/defaultChoiceCardSettings.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const oneOffCard = (countryGroupId: CountryGroupId): ChoiceCard => ({
2020
: 'We welcome support of any size, any time',
2121
},
2222
],
23-
destinationUrl: null, // Will use default CTA behavior
23+
destination: 'LandingPage',
2424
});
2525

2626
const fullChoiceCards = (countryGroupId: CountryGroupId): ChoiceCard[] => [
@@ -36,7 +36,7 @@ const fullChoiceCards = (countryGroupId: CountryGroupId): ChoiceCard[] => [
3636
copy: 'Give to the Guardian every month with Support',
3737
},
3838
],
39-
destinationUrl: null, // Will use default CTA behavior
39+
destination: 'LandingPage',
4040
},
4141
{
4242
product: {
@@ -58,7 +58,7 @@ const fullChoiceCards = (countryGroupId: CountryGroupId): ChoiceCard[] => [
5858
pill: {
5959
copy: 'Recommended',
6060
},
61-
destinationUrl: null, // Will use default CTA behavior
61+
destination: 'LandingPage',
6262
},
6363
oneOffCard(countryGroupId),
6464
];
@@ -91,7 +91,7 @@ const shorterChoiceCards = (countryGroupId: CountryGroupId): ChoiceCard[] => [
9191
pill: {
9292
copy: 'Recommended',
9393
},
94-
destinationUrl: null, // Will use default CTA behavior
94+
destination: 'LandingPage',
9595
},
9696
oneOffCard(countryGroupId),
9797
];

src/shared/types/props/choiceCards.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,16 @@ const pillSchema = z.object({
2929
backgroundColour: hexColourSchema.nullish(),
3030
});
3131

32+
const destinationSchema = z.union([z.literal('LandingPage'), z.literal('Checkout')]);
33+
3234
const choiceCardSchema = z.object({
3335
product: productSchema,
3436
label: z.string(), // e.g. "Support $15/month"
3537
isDefault: z.boolean(), // default selected choice card
3638
benefitsLabel: z.string().nullish(), // e.g. "Unlock All-access digital benefits:"
3739
benefits: z.array(productBenefitSchema),
3840
pill: pillSchema.nullish(),
39-
destinationUrl: z.string().nullish(), // Optional override URL for this choice card
41+
destination: destinationSchema.nullish(),
4042
});
4143

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

0 commit comments

Comments
 (0)