@financial-times/n-conversion-forms 37.0.0 → 37.1.0

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": "386e3356ff251ce8366db3384b1648521b3fd5b6",
5
- "tag": "v37.0.0"
4
+ "version": "3a1be1fd273d36daf3e20698803a42db3a4d295d",
5
+ "tag": "v37.1.0"
6
6
  }
@@ -35,7 +35,8 @@ export function DeliveryOption({
35
35
  const deliveryOptionValue = getDeliveryOption(
36
36
  productCode,
37
37
  option,
38
- FTShippingZone
38
+ FTShippingZone,
39
+ country
39
40
  );
40
41
 
41
42
  if (!isValidDeliveryOption || !deliveryOptionValue) {
@@ -54,6 +55,12 @@ export function DeliveryOption({
54
55
  defaultChecked: isSelected,
55
56
  };
56
57
 
58
+ const deliveryOptionBoxClassNames = classNames([
59
+ 'o-forms-input__label',
60
+ 'ncf__delivery-option__label',
61
+ { 'no-title__delivery-option__box': !deliveryOptionValue.title },
62
+ ]);
63
+
57
64
  return (
58
65
  <label
59
66
  key={value}
@@ -61,10 +68,12 @@ export function DeliveryOption({
61
68
  htmlFor={id}
62
69
  >
63
70
  <input {...inputProps} />
64
- <span className="o-forms-input__label ncf__delivery-option__label">
65
- <span className="ncf__delivery-option__title o-forms-title__main">
66
- {deliveryOptionValue.title}
67
- </span>
71
+ <span className={deliveryOptionBoxClassNames}>
72
+ {deliveryOptionValue.title && (
73
+ <span className="ncf__delivery-option__title o-forms-title__main">
74
+ {deliveryOptionValue.title}
75
+ </span>
76
+ )}
68
77
  <div className="ncf__delivery-option__description">
69
78
  {deliveryOptionValue.description}
70
79
  </div>
@@ -89,3 +89,18 @@ USWeekendOnlyDeliveryOptions.args = {
89
89
  country: 'USA',
90
90
  productCode: 'NWE',
91
91
  };
92
+
93
+ export const JapanDeliveryOptions = (args) => (
94
+ <div className="ncf">
95
+ <DeliveryOption {...args} />
96
+ </div>
97
+ );
98
+ JapanDeliveryOptions.args = {
99
+ country: 'JPN',
100
+ options: [
101
+ {
102
+ value: 'HD',
103
+ isValidDeliveryOption: true,
104
+ },
105
+ ],
106
+ };
@@ -35,7 +35,7 @@ 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);
38
+ var deliveryOptionValue = (0, _deliveryOptionMessages.getDeliveryOption)(productCode, option, FTShippingZone, country);
39
39
  if (!isValidDeliveryOption || !deliveryOptionValue) {
40
40
  return null;
41
41
  }
@@ -50,13 +50,16 @@ function DeliveryOption(_ref) {
50
50
  className: 'ncf__delivery-option__input',
51
51
  defaultChecked: isSelected
52
52
  };
53
+ var deliveryOptionBoxClassNames = (0, _classnames["default"])(['o-forms-input__label', 'ncf__delivery-option__label', {
54
+ 'no-title__delivery-option__box': !deliveryOptionValue.title
55
+ }]);
53
56
  return /*#__PURE__*/_react["default"].createElement("label", {
54
57
  key: value,
55
58
  className: "ncf__delivery-option__item",
56
59
  htmlFor: id
57
60
  }, /*#__PURE__*/_react["default"].createElement("input", inputProps), /*#__PURE__*/_react["default"].createElement("span", {
58
- className: "o-forms-input__label ncf__delivery-option__label"
59
- }, /*#__PURE__*/_react["default"].createElement("span", {
61
+ className: deliveryOptionBoxClassNames
62
+ }, deliveryOptionValue.title && /*#__PURE__*/_react["default"].createElement("span", {
60
63
  className: "ncf__delivery-option__title o-forms-title__main"
61
64
  }, deliveryOptionValue.title), /*#__PURE__*/_react["default"].createElement("div", {
62
65
  className: "ncf__delivery-option__description"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@financial-times/n-conversion-forms",
3
- "version": "37.0.0",
3
+ "version": "37.1.0",
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": {
@@ -28,6 +28,9 @@
28
28
  background-color: oColorsByName('white');
29
29
  color: oColorsByName('black-80');;
30
30
  }
31
+ .no-title__delivery-option__box {
32
+ min-height: 80px;
33
+ }
31
34
  .o-forms-input__address-type__label {
32
35
  padding: 2px 2px 2px 35px;
33
36
  min-height: 0;
@@ -20,24 +20,37 @@ const HAND_DELIVERY = 'HD';
20
20
  const MAIL = 'ML';
21
21
 
22
22
  // Country codes
23
+ const CANADA_COUNTRY_CODE = 'CAN';
24
+ const JAPAN_COUNTRY_CODE = 'JPN';
23
25
  const UK_COUNTRY_CODE = 'GBR';
24
26
  const USA_COUNTRY_CODE = 'USA';
25
- const CAN_COUNTRY_CODE = 'CAN';
26
27
 
27
- const UKDeliveryOptions = {
28
- PV: {
29
- title: 'Paper vouchers',
30
- description:
31
- '13-week voucher pack delivered quarterly and redeemable at retailers nationwide.',
32
- },
33
- HD: {
34
- title: 'Hand delivery',
35
- description: 'Free delivery to your home or office before 7am.',
28
+ const countryCodeToCustomDeliveryOptionsMap = {
29
+ [JAPAN_COUNTRY_CODE]: {
30
+ HD: {
31
+ description:
32
+ 'Enjoy delivery of the newspaper to your home or office address.',
33
+ },
34
+ ML: {
35
+ description:
36
+ 'Enjoy delivery of the newspaper to your home or office address.',
37
+ },
36
38
  },
37
- EV: {
38
- title: 'Electronic vouchers',
39
- description:
40
- 'Delivered via email and card, redeemable at retailers nationwide.',
39
+ [UK_COUNTRY_CODE]: {
40
+ PV: {
41
+ title: 'Paper vouchers',
42
+ description:
43
+ '13-week voucher pack delivered quarterly and redeemable at retailers nationwide.',
44
+ },
45
+ HD: {
46
+ title: 'Hand delivery',
47
+ description: 'Free delivery to your home or office before 7am.',
48
+ },
49
+ EV: {
50
+ title: 'Electronic vouchers',
51
+ description:
52
+ 'Delivered via email and card, redeemable at retailers nationwide.',
53
+ },
41
54
  },
42
55
  };
43
56
 
@@ -61,7 +74,7 @@ const deliveryOptionMessages = [
61
74
  distributorType: HAND_DELIVERY,
62
75
  deliveryOnPublicationDate: true,
63
76
  flightMarket: true,
64
- country: [USA_COUNTRY_CODE, CAN_COUNTRY_CODE],
77
+ country: [USA_COUNTRY_CODE, CANADA_COUNTRY_CODE],
65
78
  title: 'Hand delivery',
66
79
  description:
67
80
  "Enjoy delivery of the newspaper daily to your home or office address. \nPlease 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 on the next delivery day.",
@@ -74,7 +87,7 @@ const deliveryOptionMessages = [
74
87
  distributorType: HAND_DELIVERY,
75
88
  deliveryOnPublicationDate: true,
76
89
  flightMarket: false,
77
- country: [USA_COUNTRY_CODE, CAN_COUNTRY_CODE],
90
+ country: [USA_COUNTRY_CODE, CANADA_COUNTRY_CODE],
78
91
  title: 'Hand delivery',
79
92
  description:
80
93
  'Enjoy delivery of the newspaper daily to your home or office address.',
@@ -87,7 +100,7 @@ const deliveryOptionMessages = [
87
100
  distributorType: HAND_DELIVERY,
88
101
  deliveryOnPublicationDate: false,
89
102
  flightMarket: true,
90
- country: [USA_COUNTRY_CODE, CAN_COUNTRY_CODE],
103
+ country: [USA_COUNTRY_CODE, CANADA_COUNTRY_CODE],
91
104
  title: 'Hand delivery',
92
105
  description:
93
106
  "Enjoy delivery of the newspaper daily to your home or office address. \nPlease 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 on the next delivery day. Please also be aware that your FT Weekend will be delivered on Sunday.",
@@ -100,7 +113,7 @@ const deliveryOptionMessages = [
100
113
  distributorType: HAND_DELIVERY,
101
114
  deliveryOnPublicationDate: false,
102
115
  flightMarket: false,
103
- country: [USA_COUNTRY_CODE, CAN_COUNTRY_CODE],
116
+ country: [USA_COUNTRY_CODE, CANADA_COUNTRY_CODE],
104
117
  title: 'Hand delivery',
105
118
  description:
106
119
  'Enjoy delivery of the newspaper daily to your home or office address. \nPlease note: Your FT Weekend will be delivered on Sunday or Monday.',
@@ -180,7 +193,7 @@ const deliveryOptionMessages = [
180
193
  SIX_DAYS_WEEK_DELIVERY_FREQ,
181
194
  ],
182
195
  distributorType: MAIL,
183
- country: [USA_COUNTRY_CODE, CAN_COUNTRY_CODE],
196
+ country: [USA_COUNTRY_CODE, CANADA_COUNTRY_CODE],
184
197
  title: 'Mail',
185
198
  customId: 'ML',
186
199
  description:
@@ -191,7 +204,7 @@ const deliveryOptionMessages = [
191
204
  distributorType: HAND_DELIVERY,
192
205
  deliveryOnPublicationDate: true,
193
206
  flightMarket: true,
194
- country: [USA_COUNTRY_CODE, CAN_COUNTRY_CODE],
207
+ country: [USA_COUNTRY_CODE, CANADA_COUNTRY_CODE],
195
208
  title: 'Hand delivery',
196
209
  description:
197
210
  "Enjoy delivery of the newspaper daily to your home or office address. \nPlease note: We fly the newspapers 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.",
@@ -201,7 +214,7 @@ const deliveryOptionMessages = [
201
214
  distributorType: HAND_DELIVERY,
202
215
  deliveryOnPublicationDate: true,
203
216
  flightMarket: false,
204
- country: [USA_COUNTRY_CODE, CAN_COUNTRY_CODE],
217
+ country: [USA_COUNTRY_CODE, CANADA_COUNTRY_CODE],
205
218
  title: 'Hand delivery',
206
219
  description:
207
220
  'Enjoy delivery of the newspaper daily to your home or office address.',
@@ -211,7 +224,7 @@ const deliveryOptionMessages = [
211
224
  distributorType: HAND_DELIVERY,
212
225
  deliveryOnPublicationDate: false,
213
226
  flightMarket: true,
214
- country: [USA_COUNTRY_CODE, CAN_COUNTRY_CODE],
227
+ country: [USA_COUNTRY_CODE, CANADA_COUNTRY_CODE],
215
228
  title: 'Hand delivery',
216
229
  description:
217
230
  "Enjoy delivery of the newspaper daily to your home or office address. \nPlease 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 on the next delivery day. Please also be aware that your FT Weekend will be delivered on Sunday.",
@@ -221,7 +234,7 @@ const deliveryOptionMessages = [
221
234
  distributorType: HAND_DELIVERY,
222
235
  deliveryOnPublicationDate: false,
223
236
  flightMarket: false,
224
- country: [USA_COUNTRY_CODE, CAN_COUNTRY_CODE],
237
+ country: [USA_COUNTRY_CODE, CANADA_COUNTRY_CODE],
225
238
  title: 'Hand delivery',
226
239
  description:
227
240
  'Enjoy delivery of the newspaper daily to your home or office address. \nPlease note: Your FT Weekend will be delivered on Sunday.',
@@ -229,7 +242,7 @@ const deliveryOptionMessages = [
229
242
  {
230
243
  deliveryFrequency: [ONLY_WEEKEND_DELIVERY_FREQ],
231
244
  distributorType: MAIL,
232
- country: [USA_COUNTRY_CODE, CAN_COUNTRY_CODE],
245
+ country: [USA_COUNTRY_CODE, CANADA_COUNTRY_CODE],
233
246
  title: 'Mail',
234
247
  customId: 'ML',
235
248
  description:
@@ -287,10 +300,13 @@ function findCustomDeliveryOption(productCode, option, FTShippingZone) {
287
300
  return deliveryOption;
288
301
  }
289
302
 
290
- function getDeliveryOption(productCode, option, FTShippingZone) {
291
- return FTShippingZone === UK_COUNTRY_CODE
292
- ? UKDeliveryOptions[option.value]
293
- : findCustomDeliveryOption(productCode, option, FTShippingZone);
303
+ function getDeliveryOption(productCode, option, FTShippingZone, country) {
304
+ // Custom delivery messages are displayed for certain countries
305
+ if (Object.keys(countryCodeToCustomDeliveryOptionsMap).includes(country)) {
306
+ return countryCodeToCustomDeliveryOptionsMap[country][option.value];
307
+ }
308
+
309
+ return findCustomDeliveryOption(productCode, option, FTShippingZone);
294
310
  }
295
311
 
296
312
  module.exports = {
@@ -14,14 +14,14 @@ 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')
17
+ getDeliveryOption(sixDaysProductCode, stubOption, 'AAA', 'AAA')
18
18
  ).toBeUndefined();
19
19
  });
20
20
 
21
21
  it('returns undefined when invalid distributor type code', () => {
22
22
  const option = { ...stubOption, value: 'ZZ' };
23
23
  expect(
24
- getDeliveryOption(sixDaysProductCode, option, 'USA')
24
+ getDeliveryOption(sixDaysProductCode, option, 'USA', 'USA')
25
25
  ).toBeUndefined();
26
26
  });
27
27
 
@@ -29,7 +29,7 @@ describe('Find Custom Delivery Option', () => {
29
29
  stubOption.deliveryOnPublicationDate = undefined;
30
30
  stubOption.flightMarket = undefined;
31
31
  expect(
32
- getDeliveryOption(sixDaysProductCode, stubOption, 'AAA')
32
+ getDeliveryOption(sixDaysProductCode, stubOption, 'AAA', 'AAA')
33
33
  ).toBeUndefined();
34
34
  });
35
35
  });
@@ -51,6 +51,7 @@ describe('Find Custom Delivery Option', () => {
51
51
  const deliveryOption = getDeliveryOption(
52
52
  sixDaysProductCode,
53
53
  stubOption,
54
+ 'USA',
54
55
  'USA'
55
56
  );
56
57
 
@@ -69,6 +70,7 @@ describe('Find Custom Delivery Option', () => {
69
70
  const deliveryOption = getDeliveryOption(
70
71
  weekendProductCode,
71
72
  stubOption,
73
+ 'USA',
72
74
  'USA'
73
75
  );
74
76
 
@@ -92,6 +94,7 @@ describe('Find Custom Delivery Option', () => {
92
94
  const deliveryOption = getDeliveryOption(
93
95
  sixDaysProductCode,
94
96
  stubOption,
97
+ 'USA',
95
98
  'USA'
96
99
  );
97
100
 
@@ -109,6 +112,7 @@ describe('Find Custom Delivery Option', () => {
109
112
  const deliveryOption = getDeliveryOption(
110
113
  weekendProductCode,
111
114
  stubOption,
115
+ 'CAN',
112
116
  'CAN'
113
117
  );
114
118
 
@@ -127,6 +131,7 @@ describe('Find Custom Delivery Option', () => {
127
131
  const deliveryOption = getDeliveryOption(
128
132
  sixDaysProductCode,
129
133
  { value: 'EV' },
134
+ 'GBR',
130
135
  'GBR'
131
136
  );
132
137
 
@@ -134,6 +139,24 @@ describe('Find Custom Delivery Option', () => {
134
139
  });
135
140
  });
136
141
 
142
+ describe('Find Japan Delivery Option', () => {
143
+ it('returns Japan HD delivery option', () => {
144
+ const expected = {
145
+ description:
146
+ 'Enjoy delivery of the newspaper to your home or office address.',
147
+ };
148
+
149
+ const deliveryOption = getDeliveryOption(
150
+ sixDaysProductCode,
151
+ stubOption,
152
+ 'APAC',
153
+ 'JPN'
154
+ );
155
+
156
+ expect(deliveryOption).toEqual(expected);
157
+ });
158
+ });
159
+
137
160
  describe('Find CEMEA/APAC Delivery Option', () => {
138
161
  it('returns CEMEA/APAC HD delivery option', () => {
139
162
  stubOption.flightMarket = true;
@@ -145,7 +168,12 @@ describe('Find Custom Delivery Option', () => {
145
168
  '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.',
146
169
  };
147
170
 
148
- const deliveryOption = getDeliveryOption('N6D', stubOption, 'CEMEA_V1');
171
+ const deliveryOption = getDeliveryOption(
172
+ 'N6D',
173
+ stubOption,
174
+ 'CEMEA_V1',
175
+ 'BGR'
176
+ );
149
177
 
150
178
  expect(deliveryOption).toEqual(expected);
151
179
  });
@@ -160,7 +188,12 @@ describe('Find Custom Delivery Option', () => {
160
188
  '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 the each daily edition.',
161
189
  };
162
190
 
163
- const deliveryOption = getDeliveryOption('N6D', stubOption, 'APAC');
191
+ const deliveryOption = getDeliveryOption(
192
+ 'N6D',
193
+ stubOption,
194
+ 'APAC',
195
+ 'HKG'
196
+ );
164
197
 
165
198
  expect(deliveryOption).toEqual(expected);
166
199
  });
@@ -1,11 +0,0 @@
1
- _extends: github-apps-config-next
2
-
3
- branches:
4
- - name: main
5
- protection:
6
- required_pull_request_reviews: null
7
- required_status_checks: null
8
- enforce_admins: true
9
- restrictions:
10
- users: []
11
- teams: []