Skip to content

Commit 2c93e78

Browse files
author
“LAKSHMIRPILLAI”
committed
Initial changes
1 parent 3c7ca4d commit 2c93e78

File tree

7 files changed

+94
-12
lines changed

7 files changed

+94
-12
lines changed

dotcom-rendering/src/components/marketing/banners/designableBanner/DesignableBannerV2.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,9 +450,11 @@ const DesignableBannerV2: ReactComponent<BannerRenderProps> = ({
450450
}
451451
choices={getChoiceCardData(
452452
isTabletOrAbove,
453+
false,
453454
countryCode,
454455
)}
455456
id={'banner'}
457+
isDiscountActive={false}
456458
/>
457459

458460
<div css={styles.ctaContainer}>

dotcom-rendering/src/components/marketing/epics/ContributionsEpic.stories.tsx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,24 @@ export const WithThreeTierDiscountChoiceCards: Story = {
349349
},
350350
};
351351

352+
export const WithThreeTierDiscountChoiceCardsNonUS: Story = {
353+
name: 'ContributionsEpic with discounted three tier choice cards For Non US',
354+
args: {
355+
...meta.args,
356+
countryCode: 'GB',
357+
variant: {
358+
...props.variant,
359+
name: 'THREE_TIER_CHOICE_CARDS',
360+
secondaryCta: undefined,
361+
showChoiceCards: true,
362+
cta: {
363+
text: 'Support the Guardian',
364+
baseUrl: 'https://support.theguardian.com/contribute',
365+
},
366+
},
367+
},
368+
};
369+
352370
export const WithChoiceCardsAndSignInLink: Story = {
353371
name: 'ContributionsEpic with choice cards and sign-in link',
354372
args: {

dotcom-rendering/src/components/marketing/epics/ThreeTierChoiceCardData.tsx

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import type { ChoiceInfo } from './ThreeTierChoiceCards';
33

44
export const ChoiceCardTestData_REGULAR = (
55
longerBenefits: boolean,
6+
isDiscountActive: boolean,
67
): ChoiceInfo[] => [
78
{
89
supportTier: 'Contribution',
@@ -22,15 +23,25 @@ export const ChoiceCardTestData_REGULAR = (
2223
discount?: number,
2324
): JSX.Element | string => {
2425
if (!isUndefined(discount)) {
25-
return (
26+
return isDiscountActive ? (
2627
<>
2728
Support{' '}
2829
<s>
2930
{currencySymbol}
3031
{amount}
3132
</s>{' '}
3233
{currencySymbol}
33-
{amount * discount}/month{' '}
34+
{amount * (1 - discount)}/year{' '}
35+
</>
36+
) : (
37+
<>
38+
Support{' '}
39+
<s>
40+
{currencySymbol}
41+
{amount}
42+
</s>{' '}
43+
{currencySymbol}
44+
{amount * (1 - discount)}/month{' '}
3445
</>
3546
);
3647
} else {

dotcom-rendering/src/components/marketing/epics/ThreeTierChoiceCards.tsx

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ type ThreeTierChoiceCardsProps = {
184184
choices: ChoiceInfo[];
185185
supporterPlusDiscount?: number;
186186
id: string; // uniquely identify this choice cards component to avoid conflicting with others
187+
isDiscountActive: boolean;
187188
};
188189

189190
export const ThreeTierChoiceCards = ({
@@ -193,6 +194,7 @@ export const ThreeTierChoiceCards = ({
193194
choices,
194195
supporterPlusDiscount,
195196
id,
197+
isDiscountActive = false,
196198
}: ThreeTierChoiceCardsProps) => {
197199
const currencySymbol = getLocalCurrencySymbol(countryCode);
198200
const countryGroupId = countryCodeToCountryGroupId(countryCode);
@@ -217,6 +219,12 @@ export const ThreeTierChoiceCards = ({
217219
'Monthly',
218220
countryGroupId,
219221
);
222+
const choiceAmountYearly = getChoiceAmount(
223+
supportTier,
224+
'Annual',
225+
countryGroupId,
226+
);
227+
220228
const selected = selectedProduct === supportTier;
221229

222230
const hasDiscount =
@@ -225,14 +233,20 @@ export const ThreeTierChoiceCards = ({
225233

226234
const radioId = `choicecard-${id}-${supportTier}`;
227235

236+
const finalChoiceAmount =
237+
isDiscountActive && hasDiscount
238+
? choiceAmountYearly
239+
: choiceAmount;
240+
console.log('finalChoiceAmount', finalChoiceAmount);
241+
228242
return (
229243
<div
230244
key={supportTier}
231245
css={css`
232246
position: relative;
233247
`}
234248
>
235-
{hasDiscount && (
249+
{hasDiscount && countryCode !== 'US' && (
236250
<DiscountedPill
237251
discount={supporterPlusDiscount * 100}
238252
/>
@@ -246,7 +260,7 @@ export const ThreeTierChoiceCards = ({
246260
>
247261
<Radio
248262
label={label(
249-
choiceAmount,
263+
finalChoiceAmount,
250264
currencySymbol,
251265
supporterPlusDiscount,
252266
)}

dotcom-rendering/src/components/marketing/epics/ctas/ContributionsEpicButtons.tsx

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ interface ContributionsEpicButtonsProps {
150150
amountsTestName?: string;
151151
amountsVariantName?: string;
152152
numArticles: number;
153+
isDiscountActive?: boolean;
153154
}
154155

155156
export const ContributionsEpicButtons = ({
@@ -165,6 +166,7 @@ export const ContributionsEpicButtons = ({
165166
amountsTestName,
166167
amountsVariantName,
167168
numArticles,
169+
isDiscountActive,
168170
}: ContributionsEpicButtonsProps): JSX.Element | null => {
169171
const [hasBeenSeen, setNode] = useIsInView({
170172
debounce: true,
@@ -194,6 +196,28 @@ export const ContributionsEpicButtons = ({
194196
baseUrl: addChoiceCardsOneTimeParams(cta.baseUrl),
195197
};
196198
}
199+
if (
200+
threeTierChoiceCardSelectedProduct === 'SupporterPlus' &&
201+
isDiscountActive &&
202+
countryCode !== 'US'
203+
) {
204+
const countryGroupId = countryCodeToCountryGroupId(countryCode);
205+
const contributionAmount =
206+
threeTierChoiceCardSelectedProduct === 'SupporterPlus'
207+
? threeTierChoiceCardAmounts['Annual'][countryGroupId]
208+
.SupporterPlus
209+
: undefined;
210+
211+
return {
212+
text: cta.text,
213+
baseUrl: addChoiceCardsProductParams(
214+
cta.baseUrl,
215+
threeTierChoiceCardSelectedProduct,
216+
'Annual',
217+
contributionAmount,
218+
),
219+
};
220+
}
197221

198222
/** Contribution amount is variable, unlike the SupporterPlus amount which is fixed */
199223
const countryGroupId = countryCodeToCountryGroupId(countryCode);

dotcom-rendering/src/components/marketing/epics/ctas/ContributionsEpicCtasContainer.tsx

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ interface OnReminderOpen {
1414
type Props = EpicProps & {
1515
amountsTestName?: string;
1616
amountsVariantName?: string;
17+
now?: Date;
1718
};
1819

1920
export const ContributionsEpicCtasContainer: ReactComponent<Props> = ({
@@ -26,6 +27,7 @@ export const ContributionsEpicCtasContainer: ReactComponent<Props> = ({
2627
fetchEmail,
2728
amountsTestName,
2829
amountsVariantName,
30+
now = new Date(),
2931
}: Props): JSX.Element => {
3032
// reminders
3133
const [fetchedEmail, setFetchedEmail] = useState<string | undefined>(
@@ -53,21 +55,30 @@ export const ContributionsEpicCtasContainer: ReactComponent<Props> = ({
5355
setThreeTierChoiceCardSelectedProduct,
5456
] = useState<SupportTier>('SupporterPlus');
5557

56-
const hasSupporterPlusPromoCode =
57-
variant.cta?.baseUrl.includes('BLACK_FRIDAY_DISCOUNT_2024') ?? false;
58-
58+
//Check the dates
59+
const isDiscountActive =
60+
(now >= new Date('2025-04-10T00:00:01') &&
61+
now < new Date('2025-04-21T23:59:59') &&
62+
countryCode !== 'US') ??
63+
false;
64+
// const isDiscountActive = (true && countryCode !=='US') ?? false;
65+
console.log('currentDate', now);
66+
console.log('activeDate', isDiscountActive);
5967
return (
6068
<>
6169
{showChoiceCards && (
6270
<ThreeTierChoiceCards
6371
countryCode={countryCode}
6472
selectedProduct={threeTierChoiceCardSelectedProduct}
6573
setSelectedProduct={setThreeTierChoiceCardSelectedProduct}
66-
choices={getChoiceCardData(true, countryCode)}
67-
supporterPlusDiscount={
68-
hasSupporterPlusPromoCode ? 0.5 : undefined
69-
}
74+
choices={getChoiceCardData(
75+
true,
76+
isDiscountActive,
77+
countryCode,
78+
)}
79+
supporterPlusDiscount={isDiscountActive ? 0.3 : undefined}
7080
id={'epic'}
81+
isDiscountActive={isDiscountActive}
7182
/>
7283
)}
7384
<ContributionsEpicButtons
@@ -108,6 +119,7 @@ export const ContributionsEpicCtasContainer: ReactComponent<Props> = ({
108119
amountsTestName={amountsTestName}
109120
amountsVariantName={amountsVariantName}
110121
numArticles={articleCounts.for52Weeks}
122+
isDiscountActive={isDiscountActive}
111123
/>
112124
{isReminderActive && showReminderFields && (
113125
<ContributionsEpicReminder

dotcom-rendering/src/components/marketing/lib/choiceCards.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,10 @@ export const contributionType: ContributionType = {
3535

3636
export const getChoiceCardData = (
3737
longerBenefits: boolean,
38+
isDiscountActive: boolean,
3839
countryCode?: string,
3940
): ChoiceInfo[] => {
4041
return countryCode === 'US'
4142
? ChoiceCardTestData_US(longerBenefits)
42-
: ChoiceCardTestData_REGULAR(longerBenefits);
43+
: ChoiceCardTestData_REGULAR(longerBenefits, isDiscountActive);
4344
};

0 commit comments

Comments
 (0)