@financial-times/n-conversion-forms 37.2.1 → 37.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "branch": "",
3
3
  "repo": "n-conversion-forms",
4
- "version": "56f6ac0285fa7afa997c8bee965da17a69a9315d",
5
- "tag": "v37.2.1"
4
+ "version": "c9dd25fe954591fd5d8e7167bdd51ff78d765bb3",
5
+ "tag": "v37.2.2"
6
6
  }
@@ -9,7 +9,7 @@ import {
9
9
 
10
10
  export function DeliveryOption({
11
11
  fieldId = 'deliveryOptionField',
12
- country,
12
+ country: countryCode,
13
13
  productCode = undefined,
14
14
  options = [],
15
15
  isSingle = false,
@@ -20,7 +20,7 @@ export function DeliveryOption({
20
20
  { 'ncf__delivery-option--single': isSingle },
21
21
  ]);
22
22
 
23
- const FTShippingZone = identifyFTShippingZone(country);
23
+ const shippingZone = identifyFTShippingZone(countryCode);
24
24
 
25
25
  return (
26
26
  <div
@@ -32,12 +32,12 @@ export function DeliveryOption({
32
32
  <span className="o-forms-input o-forms-input--radio-round">
33
33
  {options.map((option) => {
34
34
  const { value, isValidDeliveryOption, isSelected } = option;
35
- const deliveryOptionValue = getDeliveryOption(
35
+ const deliveryOptionValue = getDeliveryOption({
36
36
  productCode,
37
37
  option,
38
- FTShippingZone,
39
- country
40
- );
38
+ shippingZone,
39
+ countryCode,
40
+ });
41
41
 
42
42
  if (!isValidDeliveryOption || !deliveryOptionValue) {
43
43
  return null;
@@ -13,7 +13,7 @@ var _supportedCountries = require("../helpers/supportedCountries");
13
13
  function DeliveryOption(_ref) {
14
14
  var _ref$fieldId = _ref.fieldId,
15
15
  fieldId = _ref$fieldId === void 0 ? 'deliveryOptionField' : _ref$fieldId,
16
- country = _ref.country,
16
+ countryCode = _ref.country,
17
17
  _ref$productCode = _ref.productCode,
18
18
  productCode = _ref$productCode === void 0 ? undefined : _ref$productCode,
19
19
  _ref$options = _ref.options,
@@ -23,7 +23,7 @@ function DeliveryOption(_ref) {
23
23
  var divClassName = (0, _classnames["default"])(['o-forms-field', 'ncf__delivery-option', {
24
24
  'ncf__delivery-option--single': isSingle
25
25
  }]);
26
- var FTShippingZone = (0, _supportedCountries.identifyFTShippingZone)(country);
26
+ var shippingZone = (0, _supportedCountries.identifyFTShippingZone)(countryCode);
27
27
  return /*#__PURE__*/_react["default"].createElement("div", {
28
28
  id: fieldId,
29
29
  className: divClassName,
@@ -35,7 +35,12 @@ function DeliveryOption(_ref) {
35
35
  var value = option.value,
36
36
  isValidDeliveryOption = option.isValidDeliveryOption,
37
37
  isSelected = option.isSelected;
38
- var deliveryOptionValue = (0, _deliveryOptionMessages.getDeliveryOption)(productCode, option, FTShippingZone, country);
38
+ var deliveryOptionValue = (0, _deliveryOptionMessages.getDeliveryOption)({
39
+ productCode: productCode,
40
+ option: option,
41
+ shippingZone: shippingZone,
42
+ countryCode: countryCode
43
+ });
39
44
  if (!isValidDeliveryOption || !deliveryOptionValue) {
40
45
  return null;
41
46
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@financial-times/n-conversion-forms",
3
- "version": "37.2.1",
3
+ "version": "37.2.2",
4
4
  "description": "Containing jsx components and styles for forms included on Accounts and Acquisition apps (next-signup, next-profile, next-retention, etc).",
5
5
  "main": "./dist/index.js",
6
6
  "scripts": {
@@ -257,38 +257,38 @@ function includesDeliveryFrequency(productCode = '', item) {
257
257
  });
258
258
  }
259
259
 
260
- function mailStrategy(productCode, option, FTShippingZone, item) {
260
+ function mailStrategy(productCode, shippingZone, item) {
261
261
  return (
262
262
  includesDeliveryFrequency(productCode, item) &&
263
263
  item.distributorType === MAIL &&
264
- item.country.includes(FTShippingZone)
264
+ item.country.includes(shippingZone)
265
265
  );
266
266
  }
267
267
 
268
- function handDeliveryStrategy(productCode, option, FTShippingZone, item) {
268
+ function handDeliveryStrategy(productCode, option, shippingZone, item) {
269
269
  return (
270
270
  includesDeliveryFrequency(productCode, item) &&
271
271
  item.distributorType === HAND_DELIVERY &&
272
272
  item.deliveryOnPublicationDate === option.deliveryOnPublicationDate &&
273
273
  item.flightMarket === option.flightMarket &&
274
- item.country.includes(FTShippingZone)
274
+ item.country.includes(shippingZone)
275
275
  );
276
276
  }
277
277
 
278
278
  /**
279
- * Method to find a specific delivery option based on the delivery frequency, FTShippingZone and option values.
279
+ * Method to find a specific delivery option based on the delivery frequency, shippingZone and option values.
280
280
  * There are two different strategies, one for options with mailDelivery = true and other by the opposite.
281
281
  * Both cases are represented by system option code 'HD', but differ on the mailDelivery property value.
282
282
  * If no message matchs, then undefined is returned.
283
283
  */
284
- function findCustomDeliveryOption(productCode, option, FTShippingZone) {
284
+ function findCustomDeliveryOption(productCode, option, shippingZone) {
285
285
  let deliveryOption;
286
286
 
287
287
  if (option.value === HAND_DELIVERY) {
288
288
  const filteredMessages = deliveryOptionMessages.filter((item) => {
289
289
  return option.mailDelivery
290
- ? mailStrategy(productCode, option, FTShippingZone, item)
291
- : handDeliveryStrategy(productCode, option, FTShippingZone, item);
290
+ ? mailStrategy(productCode, shippingZone, item)
291
+ : handDeliveryStrategy(productCode, option, shippingZone, item);
292
292
  });
293
293
 
294
294
  if (filteredMessages.length) {
@@ -300,13 +300,15 @@ function findCustomDeliveryOption(productCode, option, FTShippingZone) {
300
300
  return deliveryOption;
301
301
  }
302
302
 
303
- function getDeliveryOption(productCode, option, FTShippingZone, country) {
303
+ function getDeliveryOption({ productCode, option, shippingZone, countryCode }) {
304
304
  // Custom delivery messages are displayed for certain countries
305
- if (Object.keys(countryCodeToCustomDeliveryOptionsMap).includes(country)) {
306
- return countryCodeToCustomDeliveryOptionsMap[country][option.value];
305
+ if (
306
+ Object.keys(countryCodeToCustomDeliveryOptionsMap).includes(countryCode)
307
+ ) {
308
+ return countryCodeToCustomDeliveryOptionsMap[countryCode][option.value];
307
309
  }
308
310
 
309
- return findCustomDeliveryOption(productCode, option, FTShippingZone);
311
+ return findCustomDeliveryOption(productCode, option, shippingZone);
310
312
  }
311
313
 
312
314
  module.exports = {
@@ -14,14 +14,24 @@ describe('Find Custom Delivery Option', () => {
14
14
 
15
15
  it('returns undefined when other country than custom messages', () => {
16
16
  expect(
17
- getDeliveryOption(sixDaysProductCode, stubOption, 'AAA', 'AAA')
17
+ getDeliveryOption({
18
+ productCode: sixDaysProductCode,
19
+ option: stubOption,
20
+ shippingZone: 'AAA',
21
+ countryCode: 'AAA',
22
+ })
18
23
  ).toBeUndefined();
19
24
  });
20
25
 
21
26
  it('returns undefined when invalid distributor type code', () => {
22
27
  const option = { ...stubOption, value: 'ZZ' };
23
28
  expect(
24
- getDeliveryOption(sixDaysProductCode, option, 'USA', 'USA')
29
+ getDeliveryOption({
30
+ productCode: sixDaysProductCode,
31
+ option: option,
32
+ shippingZone: 'USA',
33
+ countryCode: 'USA',
34
+ })
25
35
  ).toBeUndefined();
26
36
  });
27
37
 
@@ -29,7 +39,12 @@ describe('Find Custom Delivery Option', () => {
29
39
  stubOption.deliveryOnPublicationDate = undefined;
30
40
  stubOption.flightMarket = undefined;
31
41
  expect(
32
- getDeliveryOption(sixDaysProductCode, stubOption, 'AAA', 'AAA')
42
+ getDeliveryOption({
43
+ productCode: sixDaysProductCode,
44
+ option: stubOption,
45
+ shippingZone: 'AAA',
46
+ countryCode: 'AAA',
47
+ })
33
48
  ).toBeUndefined();
34
49
  });
35
50
  });
@@ -48,12 +63,12 @@ describe('Find Custom Delivery Option', () => {
48
63
  'Enjoy delivery of the newspaper daily to your home or office address.',
49
64
  };
50
65
 
51
- const deliveryOption = getDeliveryOption(
52
- sixDaysProductCode,
53
- stubOption,
54
- 'USA',
55
- 'USA'
56
- );
66
+ const deliveryOption = getDeliveryOption({
67
+ productCode: sixDaysProductCode,
68
+ option: stubOption,
69
+ shippingZone: 'USA',
70
+ countryCode: 'USA',
71
+ });
57
72
 
58
73
  expect(deliveryOption).toEqual(expected);
59
74
  });
@@ -67,12 +82,12 @@ describe('Find Custom Delivery Option', () => {
67
82
  'Enjoy delivery of the newspaper daily to your home or office address. \nPlease note: Your FT Weekend will be delivered on Sunday.',
68
83
  };
69
84
 
70
- const deliveryOption = getDeliveryOption(
71
- weekendProductCode,
72
- stubOption,
73
- 'USA',
74
- 'USA'
75
- );
85
+ const deliveryOption = getDeliveryOption({
86
+ productCode: weekendProductCode,
87
+ option: stubOption,
88
+ shippingZone: 'USA',
89
+ countryCode: 'USA',
90
+ });
76
91
 
77
92
  expect(deliveryOption).toEqual(expected);
78
93
  });
@@ -91,12 +106,12 @@ describe('Find Custom Delivery Option', () => {
91
106
  "We can only deliver the newspaper to your location by postal mail which means your delivery will arrive up to 5 business days after the date of publication and will not include the HTSI Magazine. We also fly the newspaper to your location which means delivery is subject to flight delays/cancellations outside the FT's control. If you prefer to read the printed content on the day of publication, please proceed to subscribe to the FT ePaper - a digital replica of the print edition.",
92
107
  };
93
108
 
94
- const deliveryOption = getDeliveryOption(
95
- sixDaysProductCode,
96
- stubOption,
97
- 'USA',
98
- 'USA'
99
- );
109
+ const deliveryOption = getDeliveryOption({
110
+ productCode: sixDaysProductCode,
111
+ option: stubOption,
112
+ shippingZone: 'USA',
113
+ countryCode: 'USA',
114
+ });
100
115
 
101
116
  expect(deliveryOption).toEqual(expected);
102
117
  });
@@ -109,12 +124,12 @@ describe('Find Custom Delivery Option', () => {
109
124
  "We can only deliver the FT Weekend newspaper to your location by postal mail which means your delivery will arrive up to 5 business days after the date of publication and will not include the HTSI Magazine. We also fly the newspaper to your location which means delivery is subject to flight delays/cancellations outside the FT's control. If you prefer to read the printed content on the day of publication, please proceed to subscribe to the FT ePaper - a digital replica of the print edition.",
110
125
  };
111
126
 
112
- const deliveryOption = getDeliveryOption(
113
- weekendProductCode,
114
- stubOption,
115
- 'CAN',
116
- 'CAN'
117
- );
127
+ const deliveryOption = getDeliveryOption({
128
+ productCode: weekendProductCode,
129
+ option: stubOption,
130
+ shippingZone: 'CAN',
131
+ countryCode: 'CAN',
132
+ });
118
133
 
119
134
  expect(deliveryOption).toEqual(expected);
120
135
  });
@@ -128,12 +143,12 @@ describe('Find Custom Delivery Option', () => {
128
143
  'Delivered via email and card, redeemable at retailers nationwide.',
129
144
  };
130
145
 
131
- const deliveryOption = getDeliveryOption(
132
- sixDaysProductCode,
133
- { value: 'EV' },
134
- 'GBR',
135
- 'GBR'
136
- );
146
+ const deliveryOption = getDeliveryOption({
147
+ productCode: sixDaysProductCode,
148
+ option: { value: 'EV' },
149
+ shippingZone: 'GBR',
150
+ countryCode: 'GBR',
151
+ });
137
152
 
138
153
  expect(deliveryOption).toEqual(expected);
139
154
  });
@@ -146,12 +161,12 @@ describe('Find Custom Delivery Option', () => {
146
161
  'Enjoy delivery of the newspaper to your home or office address.',
147
162
  };
148
163
 
149
- const deliveryOption = getDeliveryOption(
150
- sixDaysProductCode,
151
- stubOption,
152
- 'APAC',
153
- 'JPN'
154
- );
164
+ const deliveryOption = getDeliveryOption({
165
+ productCode: sixDaysProductCode,
166
+ option: stubOption,
167
+ shippingZone: 'APAC',
168
+ countryCode: 'JPN',
169
+ });
155
170
 
156
171
  expect(deliveryOption).toEqual(expected);
157
172
  });
@@ -168,12 +183,12 @@ describe('Find Custom Delivery Option', () => {
168
183
  'Enjoy the delivery of the newspaper to your home or office address. Please note we fly the newspaper to your location which means delivery is subject to flight delays/cancellations outside of the FT’s control. In those circumstances, your newspaper will be delivered the next delivery day. Please also be aware that your FT weekend will be delivered on Sunday.',
169
184
  };
170
185
 
171
- const deliveryOption = getDeliveryOption(
172
- 'N6D',
173
- stubOption,
174
- 'CEMEA_V1',
175
- 'BGR'
176
- );
186
+ const deliveryOption = getDeliveryOption({
187
+ productCode: 'N6D',
188
+ option: stubOption,
189
+ shippingZone: 'CEMEA_V1',
190
+ countryCode: 'BGR',
191
+ });
177
192
 
178
193
  expect(deliveryOption).toEqual(expected);
179
194
  });
@@ -188,12 +203,12 @@ describe('Find Custom Delivery Option', () => {
188
203
  'Enjoy delivery of the newspaper to your home or office address. Note this is a postal delivery - expect delivery after the day of publication. If you would prefer to read the newspaper on the day of publication, purchase an FT ePaper subscription, our digital replica of each daily edition.',
189
204
  };
190
205
 
191
- const deliveryOption = getDeliveryOption(
192
- 'N6D',
193
- stubOption,
194
- 'APAC',
195
- 'HKG'
196
- );
206
+ const deliveryOption = getDeliveryOption({
207
+ productCode: 'N6D',
208
+ option: stubOption,
209
+ shippingZone: 'APAC',
210
+ countryCode: 'HKG',
211
+ });
197
212
 
198
213
  expect(deliveryOption).toEqual(expected);
199
214
  });