@financial-times/n-conversion-forms 32.9.0 → 32.11.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/.toolkitstate/ci.json +2 -2
- package/components/payment-term.jsx +15 -2
- package/components/payment-term.spec.js +14 -1
- package/components/payment-term.stories.js +35 -0
- package/components/position.jsx +2 -6
- package/components/responsibility.jsx +2 -6
- package/components/responsibility.spec.js +0 -10
- package/dist/payment-term.jsx +19 -4
- package/dist/position.jsx +1 -6
- package/dist/responsibility.jsx +1 -6
- package/package.json +2 -2
package/.toolkitstate/ci.json
CHANGED
|
@@ -17,6 +17,8 @@ export function PaymentTerm({
|
|
|
17
17
|
billingCountry = '',
|
|
18
18
|
is7DayPassExperiment = false,
|
|
19
19
|
isTermedSubscriptionTermType = false,
|
|
20
|
+
isTrialOfferAsNonTrialOverride = false,
|
|
21
|
+
labelOverride = '', // this is a temporary hack for the February 2024 campaign
|
|
20
22
|
}) {
|
|
21
23
|
/**
|
|
22
24
|
* Compute monthly price for given term name
|
|
@@ -25,7 +27,7 @@ export function PaymentTerm({
|
|
|
25
27
|
* @param {string} period (expressed in IS0 8601 duration format): e.g. PxY (yearly) or PxM (montly) where x is the amount of years/months
|
|
26
28
|
* @returns {string}
|
|
27
29
|
*/
|
|
28
|
-
const
|
|
30
|
+
const getMonthlyPriceFromPeriod = (amount, currency, period) => {
|
|
29
31
|
const periodObj = new Period(period);
|
|
30
32
|
const monthlyPrice = periodObj.calculatePrice('P1M', amount);
|
|
31
33
|
return new Monthly({ value: monthlyPrice, currency }).getAmount('monthly');
|
|
@@ -268,7 +270,7 @@ export function PaymentTerm({
|
|
|
268
270
|
{nameMap['custom'].monthlyPrice(
|
|
269
271
|
option.monthlyPrice && option.monthlyPrice !== '0'
|
|
270
272
|
? Number(option.monthlyPrice)
|
|
271
|
-
:
|
|
273
|
+
: getMonthlyPriceFromPeriod(
|
|
272
274
|
option.amount,
|
|
273
275
|
option.currency,
|
|
274
276
|
option.value
|
|
@@ -298,6 +300,16 @@ export function PaymentTerm({
|
|
|
298
300
|
const showTrialCopyInTitle =
|
|
299
301
|
option.isTrial && !isPrintOrBundle && !isEpaper;
|
|
300
302
|
|
|
303
|
+
// https://financialtimes.atlassian.net/browse/ACQ-2592
|
|
304
|
+
// We need to have one specific trial offer to have terms displayed as non-trial.
|
|
305
|
+
// The offer is a trial offer and should use trial mechanics but should show as non-trial.
|
|
306
|
+
// There is nothing in the offer payload to identify when this should happen, we need to rely on the offer id.
|
|
307
|
+
// This is a TEMPORARY hack and will be removed once the campaign is over.
|
|
308
|
+
// A ticket as been raised already to deal with the clean up: https://financialtimes.atlassian.net/browse/ACQ-2593.
|
|
309
|
+
if (isTrialOfferAsNonTrialOverride && labelOverride) {
|
|
310
|
+
return labelOverride;
|
|
311
|
+
}
|
|
312
|
+
|
|
301
313
|
const defaultTitle = (() => {
|
|
302
314
|
if (is7DayPassExperiment) {
|
|
303
315
|
return '';
|
|
@@ -461,4 +473,5 @@ PaymentTerm.propTypes = {
|
|
|
461
473
|
largePrice: PropTypes.bool,
|
|
462
474
|
optionsInARow: PropTypes.bool,
|
|
463
475
|
billingCountry: PropTypes.string,
|
|
476
|
+
isTrialOfferAsNonTrialOverride: PropTypes.bool,
|
|
464
477
|
};
|
|
@@ -261,7 +261,7 @@ describe('PaymentTerm', () => {
|
|
|
261
261
|
);
|
|
262
262
|
});
|
|
263
263
|
});
|
|
264
|
-
describe('getDisplayName', () => {
|
|
264
|
+
describe('getDisplayName trial', () => {
|
|
265
265
|
const trialOptions = {
|
|
266
266
|
...baseOptions,
|
|
267
267
|
isTrial: true,
|
|
@@ -273,6 +273,19 @@ describe('PaymentTerm', () => {
|
|
|
273
273
|
/^Trial: Premium Digital - Monthly .*$/
|
|
274
274
|
);
|
|
275
275
|
});
|
|
276
|
+
it('handles trial to non-trial payment term display name', () => {
|
|
277
|
+
const options = [trialOptions];
|
|
278
|
+
const wrapper = shallow(
|
|
279
|
+
<PaymentTerm
|
|
280
|
+
options={options}
|
|
281
|
+
labelOverride={'some term label'}
|
|
282
|
+
isTrialOfferAsNonTrialOverride={true}
|
|
283
|
+
/>
|
|
284
|
+
);
|
|
285
|
+
expect(wrapper.find('.ncf__payment-term__label').text()).toMatch(
|
|
286
|
+
/^some term label.*$/
|
|
287
|
+
);
|
|
288
|
+
});
|
|
276
289
|
it('renders using displayName if available', () => {
|
|
277
290
|
const options = [
|
|
278
291
|
{
|
|
@@ -183,3 +183,38 @@ RenewOffers.args = {
|
|
|
183
183
|
],
|
|
184
184
|
optionsInARow: true,
|
|
185
185
|
};
|
|
186
|
+
|
|
187
|
+
// https://financialtimes.atlassian.net/browse/ACQ-2592
|
|
188
|
+
// We need to have one specific trial offer to have terms displayed as non-trial.
|
|
189
|
+
// The offer is a trial offer and should use trial mechanics but should show as non-trial.
|
|
190
|
+
// There is nothing in the offer payload to identify when this should happen, we need to rely on the offer id.
|
|
191
|
+
// This is a TEMPORARY hack and will be removed once the campaign is over.
|
|
192
|
+
// A ticket as been raised already to deal with the clean up: https://financialtimes.atlassian.net/browse/ACQ-2593.
|
|
193
|
+
export const PaymentTermLabelOverride = (args) => (
|
|
194
|
+
<div className="ncf">
|
|
195
|
+
<Fieldset>
|
|
196
|
+
<PaymentTerm {...args} />
|
|
197
|
+
</Fieldset>
|
|
198
|
+
</div>
|
|
199
|
+
);
|
|
200
|
+
|
|
201
|
+
PaymentTermLabelOverride.args = {
|
|
202
|
+
isTrialOfferAsNonTrialOverride: true,
|
|
203
|
+
labelOverride: 'some fancy payment term',
|
|
204
|
+
options: [
|
|
205
|
+
{
|
|
206
|
+
name: '6 monthly',
|
|
207
|
+
isTrial: false,
|
|
208
|
+
discount: '',
|
|
209
|
+
selected: false,
|
|
210
|
+
price: '$229.00',
|
|
211
|
+
trialPrice: '$0.00',
|
|
212
|
+
trialDuration: '',
|
|
213
|
+
monthlyPrice: '0',
|
|
214
|
+
amount: '229.00',
|
|
215
|
+
trialAmount: null,
|
|
216
|
+
value: 'P6M',
|
|
217
|
+
currency: 'USD',
|
|
218
|
+
},
|
|
219
|
+
],
|
|
220
|
+
};
|
package/components/position.jsx
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import classNames from 'classnames';
|
|
4
|
-
import {
|
|
5
|
-
const B2CPositions = demographics.positions.positions;
|
|
6
|
-
const B2BPositions = b2b.demographics.positions.positions;
|
|
4
|
+
import { demographics } from 'n-common-static-data';
|
|
7
5
|
|
|
8
6
|
export function Position({
|
|
9
7
|
value,
|
|
@@ -12,8 +10,7 @@ export function Position({
|
|
|
12
10
|
fieldId = 'positionField',
|
|
13
11
|
selectId = 'position',
|
|
14
12
|
selectName = 'position',
|
|
15
|
-
|
|
16
|
-
options = isB2B ? B2BPositions : B2CPositions,
|
|
13
|
+
options = demographics.positions.positions,
|
|
17
14
|
isRequired = true,
|
|
18
15
|
fieldLabel = 'What’s your job position?',
|
|
19
16
|
}) {
|
|
@@ -74,7 +71,6 @@ Position.propTypes = {
|
|
|
74
71
|
fieldId: PropTypes.string,
|
|
75
72
|
selectId: PropTypes.string,
|
|
76
73
|
selectName: PropTypes.string,
|
|
77
|
-
isB2B: PropTypes.bool,
|
|
78
74
|
options: PropTypes.arrayOf(
|
|
79
75
|
PropTypes.shape({
|
|
80
76
|
code: PropTypes.string,
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import classNames from 'classnames';
|
|
4
|
-
import {
|
|
5
|
-
const B2CResponsibilities = demographics.responsibilities.responsibilities;
|
|
6
|
-
const B2BResponsibilities = b2b.demographics.responsibilities.responsibilities;
|
|
4
|
+
import { demographics } from 'n-common-static-data';
|
|
7
5
|
|
|
8
6
|
export function Responsibility({
|
|
9
7
|
value,
|
|
@@ -13,8 +11,7 @@ export function Responsibility({
|
|
|
13
11
|
fieldId = 'responsibilityField',
|
|
14
12
|
selectId = 'responsibility',
|
|
15
13
|
selectName = 'responsibility',
|
|
16
|
-
|
|
17
|
-
options = isB2B ? B2BResponsibilities : B2CResponsibilities,
|
|
14
|
+
options = demographics.responsibilities.responsibilities,
|
|
18
15
|
fieldLabel = 'Which best describes your job responsibility?',
|
|
19
16
|
}) {
|
|
20
17
|
const inputWrapperClassName = classNames([
|
|
@@ -76,7 +73,6 @@ Responsibility.propTypes = {
|
|
|
76
73
|
fieldId: PropTypes.string,
|
|
77
74
|
selectId: PropTypes.string,
|
|
78
75
|
selectName: PropTypes.string,
|
|
79
|
-
isB2B: PropTypes.bool,
|
|
80
76
|
options: PropTypes.arrayOf(
|
|
81
77
|
PropTypes.shape({
|
|
82
78
|
code: PropTypes.string,
|
|
@@ -74,14 +74,4 @@ describe('Responsibility', () => {
|
|
|
74
74
|
component.find('.o-forms-title.o-forms-field--optional').length
|
|
75
75
|
).toEqual(1);
|
|
76
76
|
});
|
|
77
|
-
|
|
78
|
-
it('defaults to B2B options if isB2B is true', () => {
|
|
79
|
-
const props = { isB2B: true };
|
|
80
|
-
const component = mount(Responsibility(props));
|
|
81
|
-
|
|
82
|
-
// Look for an option which is only present in the default B2B data set and not in the B2C one.
|
|
83
|
-
const optionValue = component.find('option').at(1).instance().value;
|
|
84
|
-
|
|
85
|
-
expect(optionValue).toBe('ACC');
|
|
86
|
-
});
|
|
87
77
|
});
|
package/dist/payment-term.jsx
CHANGED
|
@@ -37,7 +37,11 @@ function PaymentTerm(_ref) {
|
|
|
37
37
|
_ref$is7DayPassExperi = _ref.is7DayPassExperiment,
|
|
38
38
|
is7DayPassExperiment = _ref$is7DayPassExperi === void 0 ? false : _ref$is7DayPassExperi,
|
|
39
39
|
_ref$isTermedSubscrip = _ref.isTermedSubscriptionTermType,
|
|
40
|
-
isTermedSubscriptionTermType = _ref$isTermedSubscrip === void 0 ? false : _ref$isTermedSubscrip
|
|
40
|
+
isTermedSubscriptionTermType = _ref$isTermedSubscrip === void 0 ? false : _ref$isTermedSubscrip,
|
|
41
|
+
_ref$isTrialOfferAsNo = _ref.isTrialOfferAsNonTrialOverride,
|
|
42
|
+
isTrialOfferAsNonTrialOverride = _ref$isTrialOfferAsNo === void 0 ? false : _ref$isTrialOfferAsNo,
|
|
43
|
+
_ref$labelOverride = _ref.labelOverride,
|
|
44
|
+
labelOverride = _ref$labelOverride === void 0 ? '' : _ref$labelOverride;
|
|
41
45
|
/**
|
|
42
46
|
* Compute monthly price for given term name
|
|
43
47
|
* @param {number} amount price in number format
|
|
@@ -45,7 +49,7 @@ function PaymentTerm(_ref) {
|
|
|
45
49
|
* @param {string} period (expressed in IS0 8601 duration format): e.g. PxY (yearly) or PxM (montly) where x is the amount of years/months
|
|
46
50
|
* @returns {string}
|
|
47
51
|
*/
|
|
48
|
-
var
|
|
52
|
+
var getMonthlyPriceFromPeriod = function getMonthlyPriceFromPeriod(amount, currency, period) {
|
|
49
53
|
var periodObj = new _nPricing.Period(period);
|
|
50
54
|
var monthlyPrice = periodObj.calculatePrice('P1M', amount);
|
|
51
55
|
return new _nPricing.Monthly({
|
|
@@ -222,7 +226,7 @@ function PaymentTerm(_ref) {
|
|
|
222
226
|
// for those containing period on option.value, render custom template, for the rest keep legacy render
|
|
223
227
|
isValidPeriod(option.value) ? /*#__PURE__*/_react["default"].createElement("div", {
|
|
224
228
|
className: "ncf__payment-term__description"
|
|
225
|
-
}, nameMap['custom'].price(option.price), nameMap['custom'].monthlyPrice(option.monthlyPrice && option.monthlyPrice !== '0' ? Number(option.monthlyPrice) :
|
|
229
|
+
}, nameMap['custom'].price(option.price), nameMap['custom'].monthlyPrice(option.monthlyPrice && option.monthlyPrice !== '0' ? Number(option.monthlyPrice) : getMonthlyPriceFromPeriod(option.amount, option.currency, option.value)), nameMap['custom'].renewsText(getTimeFromPeriod(option.value))) : /*#__PURE__*/_react["default"].createElement("div", null, /*#__PURE__*/_react["default"].createElement("span", {
|
|
226
230
|
className: largePrice ? 'ncf__payment-term__large-price' : ''
|
|
227
231
|
}, option.price), option.chargeOnText && /*#__PURE__*/_react["default"].createElement("p", {
|
|
228
232
|
className: "ncf__payment-term__charge-on-text"
|
|
@@ -230,6 +234,16 @@ function PaymentTerm(_ref) {
|
|
|
230
234
|
};
|
|
231
235
|
var getTermDisplayName = function getTermDisplayName() {
|
|
232
236
|
var showTrialCopyInTitle = option.isTrial && !isPrintOrBundle && !isEpaper;
|
|
237
|
+
|
|
238
|
+
// https://financialtimes.atlassian.net/browse/ACQ-2592
|
|
239
|
+
// We need to have one specific trial offer to have terms displayed as non-trial.
|
|
240
|
+
// The offer is a trial offer and should use trial mechanics but should show as non-trial.
|
|
241
|
+
// There is nothing in the offer payload to identify when this should happen, we need to rely on the offer id.
|
|
242
|
+
// This is a TEMPORARY hack and will be removed once the campaign is over.
|
|
243
|
+
// A ticket as been raised already to deal with the clean up: https://financialtimes.atlassian.net/browse/ACQ-2593.
|
|
244
|
+
if (isTrialOfferAsNonTrialOverride && labelOverride) {
|
|
245
|
+
return labelOverride;
|
|
246
|
+
}
|
|
233
247
|
var defaultTitle = function () {
|
|
234
248
|
if (is7DayPassExperiment) {
|
|
235
249
|
return '';
|
|
@@ -330,5 +344,6 @@ PaymentTerm.propTypes = {
|
|
|
330
344
|
showLegal: _propTypes["default"].bool,
|
|
331
345
|
largePrice: _propTypes["default"].bool,
|
|
332
346
|
optionsInARow: _propTypes["default"].bool,
|
|
333
|
-
billingCountry: _propTypes["default"].string
|
|
347
|
+
billingCountry: _propTypes["default"].string,
|
|
348
|
+
isTrialOfferAsNonTrialOverride: _propTypes["default"].bool
|
|
334
349
|
};
|
package/dist/position.jsx
CHANGED
|
@@ -9,8 +9,6 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
9
9
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
10
10
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
11
11
|
var _nCommonStaticData = require("n-common-static-data");
|
|
12
|
-
var B2CPositions = _nCommonStaticData.demographics.positions.positions;
|
|
13
|
-
var B2BPositions = _nCommonStaticData.b2b.demographics.positions.positions;
|
|
14
12
|
function Position(_ref) {
|
|
15
13
|
var value = _ref.value,
|
|
16
14
|
_ref$isDisabled = _ref.isDisabled,
|
|
@@ -23,10 +21,8 @@ function Position(_ref) {
|
|
|
23
21
|
selectId = _ref$selectId === void 0 ? 'position' : _ref$selectId,
|
|
24
22
|
_ref$selectName = _ref.selectName,
|
|
25
23
|
selectName = _ref$selectName === void 0 ? 'position' : _ref$selectName,
|
|
26
|
-
_ref$isB2B = _ref.isB2B,
|
|
27
|
-
isB2B = _ref$isB2B === void 0 ? false : _ref$isB2B,
|
|
28
24
|
_ref$options = _ref.options,
|
|
29
|
-
options = _ref$options === void 0 ?
|
|
25
|
+
options = _ref$options === void 0 ? _nCommonStaticData.demographics.positions.positions : _ref$options,
|
|
30
26
|
_ref$isRequired = _ref.isRequired,
|
|
31
27
|
isRequired = _ref$isRequired === void 0 ? true : _ref$isRequired,
|
|
32
28
|
_ref$fieldLabel = _ref.fieldLabel,
|
|
@@ -79,7 +75,6 @@ Position.propTypes = {
|
|
|
79
75
|
fieldId: _propTypes["default"].string,
|
|
80
76
|
selectId: _propTypes["default"].string,
|
|
81
77
|
selectName: _propTypes["default"].string,
|
|
82
|
-
isB2B: _propTypes["default"].bool,
|
|
83
78
|
options: _propTypes["default"].arrayOf(_propTypes["default"].shape({
|
|
84
79
|
code: _propTypes["default"].string,
|
|
85
80
|
description: _propTypes["default"].string
|
package/dist/responsibility.jsx
CHANGED
|
@@ -9,8 +9,6 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
9
9
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
10
10
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
11
11
|
var _nCommonStaticData = require("n-common-static-data");
|
|
12
|
-
var B2CResponsibilities = _nCommonStaticData.demographics.responsibilities.responsibilities;
|
|
13
|
-
var B2BResponsibilities = _nCommonStaticData.b2b.demographics.responsibilities.responsibilities;
|
|
14
12
|
function Responsibility(_ref) {
|
|
15
13
|
var value = _ref.value,
|
|
16
14
|
_ref$isDisabled = _ref.isDisabled,
|
|
@@ -25,10 +23,8 @@ function Responsibility(_ref) {
|
|
|
25
23
|
selectId = _ref$selectId === void 0 ? 'responsibility' : _ref$selectId,
|
|
26
24
|
_ref$selectName = _ref.selectName,
|
|
27
25
|
selectName = _ref$selectName === void 0 ? 'responsibility' : _ref$selectName,
|
|
28
|
-
_ref$isB2B = _ref.isB2B,
|
|
29
|
-
isB2B = _ref$isB2B === void 0 ? false : _ref$isB2B,
|
|
30
26
|
_ref$options = _ref.options,
|
|
31
|
-
options = _ref$options === void 0 ?
|
|
27
|
+
options = _ref$options === void 0 ? _nCommonStaticData.demographics.responsibilities.responsibilities : _ref$options,
|
|
32
28
|
_ref$fieldLabel = _ref.fieldLabel,
|
|
33
29
|
fieldLabel = _ref$fieldLabel === void 0 ? 'Which best describes your job responsibility?' : _ref$fieldLabel;
|
|
34
30
|
var inputWrapperClassName = (0, _classnames["default"])(['o-forms-input', 'o-forms-input--select', {
|
|
@@ -79,7 +75,6 @@ Responsibility.propTypes = {
|
|
|
79
75
|
fieldId: _propTypes["default"].string,
|
|
80
76
|
selectId: _propTypes["default"].string,
|
|
81
77
|
selectName: _propTypes["default"].string,
|
|
82
|
-
isB2B: _propTypes["default"].bool,
|
|
83
78
|
options: _propTypes["default"].arrayOf(_propTypes["default"].shape({
|
|
84
79
|
code: _propTypes["default"].string,
|
|
85
80
|
description: _propTypes["default"].string
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@financial-times/n-conversion-forms",
|
|
3
|
-
"version": "32.
|
|
3
|
+
"version": "32.11.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": {
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"classnames": "2.3.2",
|
|
31
31
|
"fetchres": "1.7.2",
|
|
32
32
|
"lodash.get": "4.4.2",
|
|
33
|
-
"n-common-static-data": "github:Financial-Times/n-common-static-data#v2.
|
|
33
|
+
"n-common-static-data": "github:Financial-Times/n-common-static-data#v2.4.0"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@babel/core": "^7.22.15",
|