Skip to content

Commit 617049f

Browse files
authored
Merge pull request #1402 from guardian/voucher-subs-holiday-stop-bug-fix
voucher subs holiday stop bug fix
2 parents 2b66f2b + 586fb4a commit 617049f

File tree

14 files changed

+645
-410
lines changed

14 files changed

+645
-410
lines changed

client/__tests__/components/identity/__snapshots__/NewsletterPreference.test.tsx.snap

+446-177
Large diffs are not rendered by default.

client/components/mma/holiday/HolidayReview.tsx

+21-17
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import { css } from '@emotion/react';
22
import { space, until } from '@guardian/source/foundations';
3-
import { Button, InlineError } from '@guardian/source/react-components';
3+
import {
4+
Button,
5+
Checkbox,
6+
InlineError,
7+
} from '@guardian/source/react-components';
48
import { useContext, useState } from 'react';
59
import { Link, Navigate, useLocation } from 'react-router-dom';
610
import type { DateRange } from '../../../../shared/dates';
@@ -12,7 +16,6 @@ import { fetchWithDefaultParameters } from '../../../utilities/fetch';
1216
import { CallCentreNumbers } from '../../shared/CallCentreNumbers';
1317
import { InfoIcon } from '../shared/assets/InfoIcon';
1418
import { LinkButton } from '../shared/Buttons';
15-
import { Checkbox } from '../shared/Checkbox';
1619
import { ProgressIndicator } from '../shared/ProgressIndicator';
1720
import { buttonBarCss, cancelLinkCss } from './HolidayDateChooser';
1821
import {
@@ -138,15 +141,17 @@ export const HolidayReview = () => {
138141
}}
139142
>
140143
<Checkbox
141-
checked={isCheckboxConfirmed}
142-
onChange={(newValue) =>
143-
setIsCheckboxConfirmed(newValue)
144-
}
145144
label={
146145
productType.holidayStops
147146
.explicitConfirmationRequired
148147
.checkboxLabel
149148
}
149+
checked={isCheckboxConfirmed}
150+
onChange={() => {
151+
setIsCheckboxConfirmed(
152+
!isCheckboxConfirmed,
153+
);
154+
}}
150155
/>
151156
</div>
152157
<Modal
@@ -212,17 +217,12 @@ export const HolidayReview = () => {
212217
</div>
213218
) : (
214219
<div
215-
css={[
216-
buttonBarCss,
217-
{
218-
justifyContent: 'flex-end',
219-
marginTop: '20px',
220-
[until.mobileMedium]: {
221-
flexDirection: 'column',
222-
marginTop: 0,
223-
},
220+
css={{
221+
marginTop: '20px',
222+
[until.mobileMedium]: {
223+
marginTop: 0,
224224
},
225-
]}
225+
}}
226226
>
227227
<div
228228
css={[
@@ -253,7 +253,11 @@ export const HolidayReview = () => {
253253
{!!productType.holidayStops
254254
.explicitConfirmationRequired &&
255255
!isCheckboxConfirmed && (
256-
<InlineError>
256+
<InlineError
257+
cssOverrides={css`
258+
margin-top: ${space[3]}px;
259+
`}
260+
>
257261
Please confirm you will destroy the affected
258262
vouchers by checking the box.
259263
</InlineError>

client/components/mma/identity/MarketingCheckbox.tsx

+8-16
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
import { Checkbox } from '@guardian/source/react-components';
12
import type { FC } from 'react';
2-
import { Checkbox } from '../shared/Checkbox';
33
import { standardSansText } from './sharedStyles';
44

55
interface MarketingCheckboxProps {
@@ -41,29 +41,21 @@ export const MarketingCheckbox: FC<MarketingCheckboxProps> = (props) => {
4141

4242
return (
4343
<div
44+
key={id}
4445
data-cy={id}
45-
onClick={() => {
46-
onClick(id);
47-
}}
4846
css={[
4947
standardSansText,
5048
{
5149
marginTop: '12px',
52-
paddingLeft: '30px',
53-
position: 'relative',
5450
},
5551
]}
5652
>
57-
<div css={{ position: 'absolute', left: 0 }}>
58-
<Checkbox
59-
checked={!!selected}
60-
onChange={() => onClick(id)}
61-
label={title}
62-
hideLabel={true}
63-
/>
64-
</div>
65-
{title && getTitle(title)}
66-
{description && getDescription(description)}
53+
<Checkbox
54+
checked={!!selected}
55+
onChange={() => onClick(id)}
56+
label={getTitle(title)}
57+
supporting={getDescription(description)}
58+
/>
6759
</div>
6860
);
6961
};

client/components/mma/identity/MarketingToggle.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export const MarketingToggle: FC<MarketingToggleProps> = (props) => {
2121
const { id, description, selected, title, onClick } = props;
2222
return (
2323
<div
24+
key={id}
2425
data-cy={id}
2526
css={[
2627
standardSansText,

client/components/mma/identity/NewsletterPreference.tsx

+19-16
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
import { css } from '@emotion/react';
12
import { palette } from '@guardian/source/foundations';
3+
import { Checkbox } from '@guardian/source/react-components';
24
import type { FC } from 'react';
35
import { sans } from '../../../styles/fonts';
4-
import { Checkbox } from '../shared/Checkbox';
56

67
interface NewsletterPreferenceProps {
78
id: string;
@@ -113,29 +114,31 @@ export const NewsletterPreference: FC<NewsletterPreferenceProps> = (props) => {
113114

114115
return (
115116
<div
116-
data-cy={id}
117-
onClick={interact}
117+
key={id}
118118
css={[
119119
standardText,
120120
{
121121
lineHeight: '1.333',
122122
marginTop: '12px',
123-
paddingLeft: '30px',
124-
position: 'relative',
125123
},
126124
]}
127125
>
128-
<div css={{ position: 'absolute', left: 0 }}>
129-
<Checkbox
130-
checked={!!selected}
131-
onChange={interact}
132-
label={accessibleLabel}
133-
hideLabel={true}
134-
/>
135-
</div>
136-
{title && getTitle(title)}
137-
{getDescription(description)}
138-
{frequency && getFrequency(frequency)}
126+
<Checkbox
127+
data-cy={id}
128+
checked={!!selected}
129+
onChange={interact}
130+
label={title && getTitle(title)}
131+
aria-label={accessibleLabel}
132+
supporting={
133+
<div>
134+
{getDescription(description)}
135+
{frequency && getFrequency(frequency)}
136+
</div>
137+
}
138+
cssOverrides={css`
139+
align-items: start;
140+
`}
141+
/>
139142
</div>
140143
);
141144
};

client/components/mma/identity/emailAndMarketing/ConsentSection.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ const consentPreference = (
4747
const { id, name, description, subscribed } = consent;
4848
const props = {
4949
id,
50-
key: id,
5150
title: name,
5251
description,
5352
selected: subscribed,

client/components/mma/shared/Checkbox.stories.tsx

-52
This file was deleted.

client/components/mma/shared/Checkbox.tsx

-89
This file was deleted.

0 commit comments

Comments
 (0)