@financial-times/n-conversion-forms 27.0.7 → 27.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.
- package/components/delivery-address-map.jsx +2 -1
- package/components/delivery-address-type.jsx +2 -0
- package/dist/delivery-address-map.js +3 -2
- package/dist/delivery-address-type.js +4 -1
- package/package.json +1 -1
- package/utils/delivery-option-messages.js +38 -13
- package/utils/delivery-option-messages.spec.js +41 -0
|
@@ -31,7 +31,7 @@ const deliveryAddressMap = {
|
|
|
31
31
|
APAC: 'District/County/Province/Ward',
|
|
32
32
|
},
|
|
33
33
|
addressLine1Title:{
|
|
34
|
-
|
|
34
|
+
ARE: 'PO Box',
|
|
35
35
|
},
|
|
36
36
|
addressLine3Title: {
|
|
37
37
|
GBR: 'Address line 3',
|
|
@@ -39,6 +39,7 @@ const deliveryAddressMap = {
|
|
|
39
39
|
CAN: 'APT/FL/STE',
|
|
40
40
|
CEMEA_V1: 'Address line 3',
|
|
41
41
|
CEMEA_V2: 'Address line 3',
|
|
42
|
+
APAC: 'Address line 3',
|
|
42
43
|
},
|
|
43
44
|
addressLine3Prompt: {
|
|
44
45
|
USA: 'Max. 6 characters. Please enter “Apartment 2C” as “Apt 2C”, “Floor 10 as FL 10”',
|
|
@@ -12,6 +12,7 @@ export function DeliveryAddressType ({
|
|
|
12
12
|
fieldId = 'deliveryAddressTypeField',
|
|
13
13
|
inputName = 'deliveryAddressType',
|
|
14
14
|
options = ['home', 'company', 'pobox'],
|
|
15
|
+
editMode = false,
|
|
15
16
|
}) {
|
|
16
17
|
return (
|
|
17
18
|
<div
|
|
@@ -36,6 +37,7 @@ export function DeliveryAddressType ({
|
|
|
36
37
|
name={inputName}
|
|
37
38
|
value={type.id}
|
|
38
39
|
className="ncf__delivery-address-type__input"
|
|
40
|
+
disabled={editMode && (type.id !== value)}
|
|
39
41
|
defaultChecked={type.id === value}
|
|
40
42
|
/>
|
|
41
43
|
<span
|
|
@@ -30,14 +30,15 @@ var deliveryAddressMap = {
|
|
|
30
30
|
APAC: 'District/County/Province/Ward'
|
|
31
31
|
},
|
|
32
32
|
addressLine1Title: {
|
|
33
|
-
|
|
33
|
+
ARE: 'PO Box'
|
|
34
34
|
},
|
|
35
35
|
addressLine3Title: {
|
|
36
36
|
GBR: 'Address line 3',
|
|
37
37
|
USA: 'APT/FL/STE',
|
|
38
38
|
CAN: 'APT/FL/STE',
|
|
39
39
|
CEMEA_V1: 'Address line 3',
|
|
40
|
-
CEMEA_V2: 'Address line 3'
|
|
40
|
+
CEMEA_V2: 'Address line 3',
|
|
41
|
+
APAC: 'Address line 3'
|
|
41
42
|
},
|
|
42
43
|
addressLine3Prompt: {
|
|
43
44
|
USA: 'Max. 6 characters. Please enter “Apartment 2C” as “Apt 2C”, “Floor 10 as FL 10”',
|
|
@@ -30,7 +30,9 @@ function DeliveryAddressType(_ref) {
|
|
|
30
30
|
_ref$inputName = _ref.inputName,
|
|
31
31
|
inputName = _ref$inputName === void 0 ? 'deliveryAddressType' : _ref$inputName,
|
|
32
32
|
_ref$options = _ref.options,
|
|
33
|
-
options = _ref$options === void 0 ? ['home', 'company', 'pobox'] : _ref$options
|
|
33
|
+
options = _ref$options === void 0 ? ['home', 'company', 'pobox'] : _ref$options,
|
|
34
|
+
_ref$editMode = _ref.editMode,
|
|
35
|
+
editMode = _ref$editMode === void 0 ? false : _ref$editMode;
|
|
34
36
|
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
35
37
|
id: fieldId,
|
|
36
38
|
className: "o-forms-field ncf__delivery-address-type",
|
|
@@ -56,6 +58,7 @@ function DeliveryAddressType(_ref) {
|
|
|
56
58
|
name: inputName,
|
|
57
59
|
value: type.id,
|
|
58
60
|
className: "ncf__delivery-address-type__input",
|
|
61
|
+
disabled: editMode && type.id !== value,
|
|
59
62
|
defaultChecked: type.id === value
|
|
60
63
|
}), /*#__PURE__*/_react["default"].createElement("span", {
|
|
61
64
|
className: "o-forms-input__label o-forms-input__address-type__label",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@financial-times/n-conversion-forms",
|
|
3
|
-
"version": "27.0
|
|
3
|
+
"version": "27.1.0",
|
|
4
4
|
"description": "Containing jsx components and styles for forms included on Accounts and Acqusition apps (next-signup, next-profile, next-retention, etc).",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -105,6 +105,19 @@ const deliveryOptionMessages = [
|
|
|
105
105
|
description:
|
|
106
106
|
'Enjoy delivery of the newspaper daily to your home or office address. \nPlease note: Your FT Weekend will be delivered on Sunday or Monday.',
|
|
107
107
|
},
|
|
108
|
+
{
|
|
109
|
+
deliveryFrequency: [
|
|
110
|
+
FIVE_DAYS_WEEK_DELIVERY_FREQ,
|
|
111
|
+
SIX_DAYS_WEEK_DELIVERY_FREQ,
|
|
112
|
+
],
|
|
113
|
+
distributorType: HAND_DELIVERY,
|
|
114
|
+
deliveryOnPublicationDate: false,
|
|
115
|
+
flightMarket: true,
|
|
116
|
+
country: [printRegions.cemeaV1, printRegions.cemeaV2, printRegions.apac],
|
|
117
|
+
title: 'Hand Delivery',
|
|
118
|
+
description:
|
|
119
|
+
'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.',
|
|
120
|
+
},
|
|
108
121
|
{
|
|
109
122
|
deliveryFrequency: [
|
|
110
123
|
FIVE_DAYS_WEEK_DELIVERY_FREQ,
|
|
@@ -112,12 +125,24 @@ const deliveryOptionMessages = [
|
|
|
112
125
|
],
|
|
113
126
|
distributorType: HAND_DELIVERY,
|
|
114
127
|
deliveryOnPublicationDate: true,
|
|
115
|
-
flightMarket:
|
|
128
|
+
flightMarket: true,
|
|
116
129
|
country: [printRegions.cemeaV1, printRegions.cemeaV2, printRegions.apac],
|
|
117
|
-
title: 'Hand
|
|
130
|
+
title: 'Hand Delivery',
|
|
118
131
|
description:
|
|
119
132
|
'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.',
|
|
120
133
|
},
|
|
134
|
+
{
|
|
135
|
+
deliveryFrequency: [
|
|
136
|
+
FIVE_DAYS_WEEK_DELIVERY_FREQ,
|
|
137
|
+
SIX_DAYS_WEEK_DELIVERY_FREQ,
|
|
138
|
+
],
|
|
139
|
+
distributorType: MAIL,
|
|
140
|
+
country: [printRegions.cemeaV1, printRegions.cemeaV2, printRegions.apac],
|
|
141
|
+
title: 'Mail Delivery',
|
|
142
|
+
customId: 'ML',
|
|
143
|
+
description:
|
|
144
|
+
'We can only deliver the newspaper to your location by postal mail which means your delivery will arrive up to 3 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.',
|
|
145
|
+
},
|
|
121
146
|
{
|
|
122
147
|
deliveryFrequency: [
|
|
123
148
|
FIVE_DAYS_WEEK_DELIVERY_FREQ,
|
|
@@ -188,38 +213,38 @@ function includesDeliveryFrequency (productCode = '', item) {
|
|
|
188
213
|
});
|
|
189
214
|
}
|
|
190
215
|
|
|
191
|
-
function mailStrategy (productCode, option,
|
|
216
|
+
function mailStrategy (productCode, option, FTShippingZone, item) {
|
|
192
217
|
return (
|
|
193
218
|
includesDeliveryFrequency(productCode, item) &&
|
|
194
219
|
item.distributorType === MAIL &&
|
|
195
|
-
item.country.includes(
|
|
220
|
+
item.country.includes(FTShippingZone)
|
|
196
221
|
);
|
|
197
222
|
}
|
|
198
223
|
|
|
199
|
-
function handDeliveryStrategy (productCode, option,
|
|
224
|
+
function handDeliveryStrategy (productCode, option, FTShippingZone, item) {
|
|
200
225
|
return (
|
|
201
226
|
includesDeliveryFrequency(productCode, item) &&
|
|
202
227
|
item.distributorType === HAND_DELIVERY &&
|
|
203
228
|
item.deliveryOnPublicationDate === option.deliveryOnPublicationDate &&
|
|
204
229
|
item.flightMarket === option.flightMarket &&
|
|
205
|
-
item.country.includes(
|
|
230
|
+
item.country.includes(FTShippingZone)
|
|
206
231
|
);
|
|
207
232
|
}
|
|
208
233
|
|
|
209
234
|
/**
|
|
210
|
-
* Method to find a specific delivery option based on the delivery frequency,
|
|
235
|
+
* Method to find a specific delivery option based on the delivery frequency, FTShippingZone and option values.
|
|
211
236
|
* There are two different strategies, one for options with mailDelivery = true and other by the opposite.
|
|
212
237
|
* Both cases are represented by system option code 'HD', but differ on the mailDelivery property value.
|
|
213
238
|
* If no message matchs, then undefined is returned.
|
|
214
239
|
*/
|
|
215
|
-
function findCustomDeliveryOption (productCode, option,
|
|
240
|
+
function findCustomDeliveryOption (productCode, option, FTShippingZone) {
|
|
216
241
|
let deliveryOption;
|
|
217
242
|
|
|
218
243
|
if (option.value === HAND_DELIVERY) {
|
|
219
244
|
const filteredMessages = deliveryOptionMessages.filter((item) => {
|
|
220
245
|
return option.mailDelivery
|
|
221
|
-
? mailStrategy(productCode, option,
|
|
222
|
-
: handDeliveryStrategy(productCode, option,
|
|
246
|
+
? mailStrategy(productCode, option, FTShippingZone, item)
|
|
247
|
+
: handDeliveryStrategy(productCode, option, FTShippingZone, item);
|
|
223
248
|
});
|
|
224
249
|
|
|
225
250
|
if (filteredMessages.length) {
|
|
@@ -231,10 +256,10 @@ function findCustomDeliveryOption (productCode, option, country) {
|
|
|
231
256
|
return deliveryOption;
|
|
232
257
|
}
|
|
233
258
|
|
|
234
|
-
function getDeliveryOption (productCode, option,
|
|
235
|
-
return
|
|
259
|
+
function getDeliveryOption (productCode, option, FTShippingZone) {
|
|
260
|
+
return FTShippingZone === UK_COUNTRY_CODE
|
|
236
261
|
? UKDeliveryOptions[option.value]
|
|
237
|
-
: findCustomDeliveryOption(productCode, option,
|
|
262
|
+
: findCustomDeliveryOption(productCode, option, FTShippingZone);
|
|
238
263
|
}
|
|
239
264
|
|
|
240
265
|
module.exports = {
|
|
@@ -133,4 +133,45 @@ describe('Find Custom Delivery Option', () => {
|
|
|
133
133
|
expect(deliveryOption).toEqual(expected);
|
|
134
134
|
});
|
|
135
135
|
});
|
|
136
|
+
|
|
137
|
+
describe('Find CEMEA/APAC Delivery Option', () => {
|
|
138
|
+
|
|
139
|
+
it('returns CEMEA/APAC HD delivery option', () => {
|
|
140
|
+
stubOption.flightMarket = true;
|
|
141
|
+
stubOption.deliveryOnPublicationDate = false;
|
|
142
|
+
stubOption.mailDelivery = false;
|
|
143
|
+
const expected = {
|
|
144
|
+
title: 'Hand Delivery',
|
|
145
|
+
description:
|
|
146
|
+
'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.',
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
const deliveryOption = getDeliveryOption(
|
|
150
|
+
'N6D',
|
|
151
|
+
stubOption,
|
|
152
|
+
'CEMEA_V1'
|
|
153
|
+
);
|
|
154
|
+
|
|
155
|
+
expect(deliveryOption).toEqual(expected);
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
it('returns CEMEA/APAC ML delivery option', () => {
|
|
159
|
+
stubOption.mailDelivery = true;
|
|
160
|
+
|
|
161
|
+
const expected = {
|
|
162
|
+
title: 'Mail Delivery',
|
|
163
|
+
customId: 'ML',
|
|
164
|
+
description:
|
|
165
|
+
'We can only deliver the newspaper to your location by postal mail which means your delivery will arrive up to 3 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.',
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
const deliveryOption = getDeliveryOption(
|
|
169
|
+
'N6D',
|
|
170
|
+
stubOption,
|
|
171
|
+
'APAC'
|
|
172
|
+
);
|
|
173
|
+
|
|
174
|
+
expect(deliveryOption).toEqual(expected);
|
|
175
|
+
});
|
|
176
|
+
});
|
|
136
177
|
});
|