Skip to content

Commit 1190dbb

Browse files
Merge pull request #1229 from guardian/cc/natdel/block-address-update
Block address update for national delivery
2 parents 9249ab7 + 622eb43 commit 1190dbb

File tree

1 file changed

+85
-23
lines changed

1 file changed

+85
-23
lines changed

client/components/mma/delivery/address/DeliveryAddressForm.tsx

+85-23
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import { css } from '@emotion/react';
22
import {
3-
brand,
43
from,
54
headline,
6-
neutral,
5+
palette,
76
space,
87
textSans,
98
until,
@@ -17,23 +16,20 @@ import {
1716
import type { ChangeEvent, Dispatch, FormEvent, SetStateAction } from 'react';
1817
import { useContext, useState } from 'react';
1918
import { Link, useLocation, useNavigate } from 'react-router-dom';
20-
import type { DeliveryAddress } from '../../../../../shared/productResponse';
21-
import type {
22-
ProductType,
23-
WithProductType,
24-
} from '../../../../../shared/productTypes';
25-
import { GROUPED_PRODUCT_TYPES } from '../../../../../shared/productTypes';
26-
import { addressChangeAffectedInfo } from '../../../../utilities/deliveryAddress';
27-
import { flattenEquivalent } from '../../../../utilities/utils';
19+
import { addressChangeAffectedInfo } from '@/client/utilities/deliveryAddress';
20+
import { flattenEquivalent } from '@/client/utilities/utils';
21+
import type { DeliveryAddress } from '@/shared/productResponse';
22+
import type { ProductType, WithProductType } from '@/shared/productTypes';
23+
import { GROUPED_PRODUCT_TYPES } from '@/shared/productTypes';
2824
import { CallCentreEmailAndNumbers } from '../../../shared/CallCenterEmailAndNumbers';
2925
import { CallCentreNumbers } from '../../../shared/CallCentreNumbers';
3026
import { Input } from '../../../shared/Input';
3127
import { NAV_LINKS } from '../../../shared/nav/NavConfig';
3228
import { COUNTRIES } from '../../identity/models';
3329
import { InfoIconDark } from '../../shared/assets/InfoIconDark';
3430
import { InfoSection } from '../../shared/InfoSection';
35-
import { ProductDescriptionListTable } from '../../shared/ProductDescriptionListTable';
3631
import type { ProductDescriptionListKeyValue } from '../../shared/ProductDescriptionListTable';
32+
import { ProductDescriptionListTable } from '../../shared/ProductDescriptionListTable';
3733
import { ProgressIndicator } from '../../shared/ProgressIndicator';
3834
import type { AddressSetStateObject } from './DeliveryAddressFormContext';
3935
import {
@@ -142,7 +138,7 @@ const Form = (props: FormProps) => {
142138
<form action="#" onSubmit={handleFormSubmit}>
143139
<fieldset
144140
css={{
145-
border: `1px solid ${neutral['86']}`,
141+
border: `1px solid ${palette.neutral['86']}`,
146142
padding: '48px 14px 14px',
147143
position: 'relative',
148144
marginBottom: `${space[5]}px`,
@@ -161,8 +157,8 @@ const Form = (props: FormProps) => {
161157
${textSans.medium()};
162158
font-weight: bold;
163159
line-height: 48px;
164-
background-color: ${neutral['97']};
165-
border-bottom: 1px solid ${neutral['86']};
160+
background-color: ${palette.neutral['97']};
161+
border-bottom: 1px solid ${palette.neutral['86']};
166162
`}
167163
>
168164
Delivery address
@@ -242,7 +238,7 @@ const Form = (props: FormProps) => {
242238
<label
243239
css={css`
244240
display: block;
245-
color: ${neutral['7']};
241+
color: ${palette.neutral['7']};
246242
${textSans.medium()};
247243
font-weight: bold;
248244
`}
@@ -276,7 +272,8 @@ const Form = (props: FormProps) => {
276272
}}
277273
css={css`
278274
width: 100%;
279-
border: 2px solid ${neutral['60']};
275+
border: 2px solid
276+
${palette.neutral['60']};
280277
padding: 12px;
281278
resize: vertical;
282279
${textSans.medium()};
@@ -287,7 +284,7 @@ const Form = (props: FormProps) => {
287284
display: block;
288285
text-align: right;
289286
${textSans.small()};
290-
color: ${neutral[46]};
287+
color: ${palette.neutral[46]};
291288
`}
292289
>
293290
{instructionsRemainingCharacters}{' '}
@@ -298,7 +295,7 @@ const Form = (props: FormProps) => {
298295
css={css`
299296
display: block;
300297
${textSans.medium()};
301-
border: 4px solid ${brand[500]};
298+
border: 4px solid ${palette.brand[500]};
302299
padding: ${space[5]}px ${space[5]}px
303300
${space[5]}px 49px;
304301
margin: ${space[3]}px 0;
@@ -324,7 +321,9 @@ const Form = (props: FormProps) => {
324321
left: ${space[5]}px;
325322
`}
326323
>
327-
<InfoIconDark fillColor={brand[500]} />
324+
<InfoIconDark
325+
fillColor={palette.brand[500]}
326+
/>
328327
</i>
329328
Delivery instructions are only applicable
330329
for newspaper deliveries. They do not apply
@@ -376,7 +375,7 @@ const Form = (props: FormProps) => {
376375
${textSans.medium()};
377376
font-weight: bold;
378377
margin-left: 22px;
379-
color: ${brand[400]};
378+
color: ${palette.brand[400]};
380379
`}
381380
>
382381
Cancel
@@ -389,15 +388,15 @@ const Form = (props: FormProps) => {
389388
css={css`
390389
${textSans.medium()};
391390
margin: ${space[12]}px 0 0;
392-
color: ${neutral[46]};
391+
color: ${palette.neutral[46]};
393392
`}
394393
>
395394
If you need separate delivery addresses for each of your
396395
subscriptions, please{' '}
397396
<span
398397
css={css`
399398
cursor: pointer;
400-
color: ${brand[500]};
399+
color: ${palette.brand[500]};
401400
text-decoration: underline;
402401
`}
403402
onClick={() =>
@@ -421,9 +420,11 @@ export const DeliveryAddressUpdate = (props: WithProductType<ProductType>) => {
421420
const [formErrors, setFormErrors] = useState({ isValid: false });
422421
const contactIdToArrayOfProductDetailAndProductType =
423422
useContext(ContactIdContext);
423+
const [showTopCallCentreNumbers, setTopCallCentreNumbersVisibility] =
424+
useState<boolean>(false);
424425

425426
const subHeadingCss = `
426-
border-top: 1px solid ${neutral['86']};
427+
border-top: 1px solid ${palette.neutral['86']};
427428
${headline.small()};
428429
font-weight: bold;
429430
margin-top: 50px;
@@ -433,6 +434,67 @@ export const DeliveryAddressUpdate = (props: WithProductType<ProductType>) => {
433434
};
434435
`;
435436

437+
const hasNationalDelivery = Object.values(
438+
contactIdToArrayOfProductDetailAndProductType,
439+
)
440+
.flatMap(flattenEquivalent)
441+
.some(({ productDetail }) => {
442+
return GROUPED_PRODUCT_TYPES.subscriptions
443+
.mapGroupedToSpecific(productDetail)
444+
.productType === 'nationaldelivery';
445+
});
446+
447+
if (hasNationalDelivery) {
448+
return (
449+
<>
450+
<p
451+
css={css`
452+
display: block;
453+
${textSans.medium()};
454+
border: 4px solid ${palette.brand['500']};
455+
padding: ${space[5]}px ${space[5]}px ${space[5]}px 49px;
456+
margin-top: 12px;
457+
position: relative;
458+
${from.tablet} {
459+
display: inline-block;
460+
vertical-align: top;
461+
width: calc(100% - (30ch + ${space[3]}px + 2px));
462+
}
463+
`}
464+
>
465+
<i
466+
css={css`
467+
width: 17px;
468+
height: 17px;
469+
position: absolute;
470+
top: ${space[5]}px;
471+
left: ${space[5]}px;
472+
`}
473+
>
474+
<InfoIconDark fillColor={palette.brand[500]} />
475+
</i>
476+
Changed address? Please{' '}
477+
<span
478+
css={css`
479+
cursor: pointer;
480+
color: ${palette.brand[500]};
481+
text-decoration: underline;
482+
`}
483+
onClick={() =>
484+
setTopCallCentreNumbersVisibility(
485+
!showTopCallCentreNumbers,
486+
)
487+
}
488+
>
489+
call our customer support team
490+
</span>{' '}
491+
to update your delivery details.
492+
</p>
493+
{showTopCallCentreNumbers && <CallCentreEmailAndNumbers />}
494+
</>
495+
);
496+
}
497+
436498
return (
437499
<>
438500
<ProgressIndicator

0 commit comments

Comments
 (0)