@financial-times/n-conversion-forms 24.2.0 → 25.0.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.
@@ -11,12 +11,6 @@ exports[`Confirmation renders appropriately if is B2C Partnership 1`] = `
11
11
  <h1 class="ncf__header ncf__header--confirmation">
12
12
  </h1>
13
13
  </div>
14
- <p class="ncf__paragraph">
15
- We’ve sent confirmation to your email. Make sure you check your spam folder if you don’t receive it.
16
- </p>
17
- <p>
18
- We&#x27;ve also sent you an email to start your 90-day All Access Digital subscription with The Washington Post.
19
- </p>
20
14
  <p class="ncf__paragraph">
21
15
  Here’s a summary of your subscription:
22
16
  </p>
@@ -7,6 +7,7 @@ export function Confirmation ({
7
7
  // isTrial prop is needed for the floodlight pixel tracking.
8
8
  isTrial = false,
9
9
  isB2cPartnership = false,
10
+ b2cPartnershipCopy = [],
10
11
  offer = '',
11
12
  email = EMAIL_DEFAULT_TEXT,
12
13
  details = null,
@@ -63,15 +64,18 @@ export function Confirmation ({
63
64
  </div>
64
65
 
65
66
  {nextActionTop}
67
+ {!isB2cPartnership && (
68
+ <p className="ncf__paragraph">
69
+ We’ve sent confirmation to {email}. Make sure you check your spam folder
70
+ if you don’t receive it.
71
+ </p>
72
+ )}
66
73
 
67
- <p className="ncf__paragraph">
68
- We’ve sent confirmation to {email}. Make sure you check your spam folder
69
- if you don’t receive it.
70
- </p>
71
- {isB2cPartnership ? (
72
- <p>
73
- We&apos;ve also sent you an email to start your 90-day All Access
74
- Digital subscription with The Washington Post.
74
+ {isB2cPartnership && b2cPartnershipCopy.length > 0 ? (
75
+ <p className="ncf__paragraph">
76
+ {b2cPartnershipCopy[0]}
77
+ <span className="ncf__legend">{` ${email}. `}</span>
78
+ {b2cPartnershipCopy[1]}
75
79
  </p>
76
80
  ) : (
77
81
  ''
@@ -126,6 +130,7 @@ export function Confirmation ({
126
130
  Confirmation.propTypes = {
127
131
  isTrial: PropTypes.bool,
128
132
  isB2cPartnership: PropTypes.bool,
133
+ b2cPartnershipCopy: PropTypes.array,
129
134
  offer: PropTypes.string.isRequired,
130
135
  email: PropTypes.string,
131
136
  details: PropTypes.arrayOf(
@@ -21,7 +21,7 @@ describe('Confirmation', () => {
21
21
  });
22
22
 
23
23
  it('renders appropriately if is B2C Partnership', () => {
24
- const props = { isB2cPartnership: true };
24
+ const props = { isB2cPartnership: true, b2cDiscountCopy: ['Send email'] };
25
25
 
26
26
  expect(Confirmation).toRenderCorrectly(props);
27
27
  });
@@ -1,6 +1,5 @@
1
1
  export { AcceptTerms } from './accept-terms';
2
2
  export { AppBanner } from './app-banner';
3
- export { B2cPartnershipPaymentTerm } from './b2c-partnership-payment-term';
4
3
  export { BillingCity } from './billing-city';
5
4
  export { BillingCountry } from './billing-country';
6
5
  export { BillingPostcode } from './billing-postcode';
@@ -54,3 +53,4 @@ export { EducationJobTitle } from './education-job-title';
54
53
  export { GraduationDate } from './graduation-date';
55
54
  export { LiteSubConfirmation } from './lite-sub-confirmation';
56
55
  export { GoogleSignIn } from './google-sign-in';
56
+ export { TextInput } from './text-input';
@@ -192,6 +192,15 @@ export function PaymentTerm ({
192
192
  );
193
193
  };
194
194
 
195
+ const createB2cDiscountCopy = () => {
196
+ return (
197
+ option.b2cPartnership && option.b2cDiscountCopy && (
198
+ <span className="ncf__payment-term__discount">
199
+ {option.b2cDiscountCopy}
200
+ </span>
201
+ )
202
+ );
203
+ };
195
204
  const createDescription = () => {
196
205
  return option.isTrial ? (
197
206
  <div className="ncf__payment-term__description">
@@ -285,6 +294,7 @@ export function PaymentTerm ({
285
294
  className="o-forms-input__label ncf__payment-term__label"
286
295
  >
287
296
  {createDiscount()}
297
+ {createB2cDiscountCopy()}
288
298
 
289
299
  <span
290
300
  className={classNames([
@@ -365,6 +375,8 @@ PaymentTerm.propTypes = {
365
375
  isEpaper: PropTypes.bool,
366
376
  options: PropTypes.arrayOf(
367
377
  PropTypes.shape({
378
+ b2cDiscountCopy: PropTypes.string,
379
+ isB2cPartnership: PropTypes.bool,
368
380
  discount: PropTypes.string,
369
381
  isTrial: PropTypes.bool,
370
382
  name: PropTypes.string.isRequired,
@@ -0,0 +1,73 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import classNames from 'classnames';
4
+
5
+ export function TextInput ({
6
+ dataTrackable,
7
+ errorText = 'Please enter a value',
8
+ fieldId,
9
+ hasError = false,
10
+ inputId,
11
+ inputName,
12
+ isDisabled = false,
13
+ isRequired = false,
14
+ label = '',
15
+ placeHolder = '',
16
+ value = '',
17
+ description,
18
+ }) {
19
+ // Use inputId if inputName is not explicitly passed.
20
+ inputName = inputName || inputId;
21
+
22
+ const inputWrapperClassNames = classNames([
23
+ 'o-forms-input',
24
+ 'o-forms-input--text',
25
+ { 'o-forms-input--invalid': hasError },
26
+ { 'o-forms-field--optional': !isRequired },
27
+ ]);
28
+
29
+ return (
30
+ <label
31
+ id={fieldId}
32
+ className="o-forms-field ncf__validation-error"
33
+ data-validate="required"
34
+ htmlFor={inputId}
35
+ >
36
+ <span className="o-forms-title">
37
+ <span className="o-forms-title__main">{label}</span>
38
+ {description ? (
39
+ <span className="o-forms-title__prompt">{description}</span>
40
+ ) : null}
41
+ </span>
42
+ <span className={inputWrapperClassNames}>
43
+ <input
44
+ type="text"
45
+ id={inputId}
46
+ name={inputName}
47
+ placeholder={placeHolder}
48
+ data-trackable={dataTrackable}
49
+ aria-required={isRequired}
50
+ required={isRequired}
51
+ disabled={isDisabled}
52
+ defaultValue={value}
53
+ />
54
+ <span className="o-forms-input__error">{errorText}</span>
55
+ </span>
56
+ </label>
57
+ );
58
+ }
59
+
60
+ TextInput.propTypes = {
61
+ dataTrackable: PropTypes.string,
62
+ errorText: PropTypes.string,
63
+ fieldId: PropTypes.string,
64
+ hasError: PropTypes.bool,
65
+ inputId: PropTypes.string,
66
+ inputName: PropTypes.string,
67
+ isDisabled: PropTypes.bool,
68
+ isRequired: PropTypes.bool,
69
+ label: PropTypes.string,
70
+ placeHolder: PropTypes.string,
71
+ value: PropTypes.string,
72
+ description: PropTypes.string,
73
+ };
@@ -0,0 +1,118 @@
1
+ import { TextInput } from './index';
2
+
3
+ import Enzyme, { mount } from 'enzyme';
4
+ import Adapter from 'enzyme-adapter-react-16';
5
+ Enzyme.configure({ adapter: new Adapter() });
6
+
7
+ describe('Text Input', () => {
8
+ it('renders with default props', () => {
9
+ const props = {};
10
+
11
+ const component = mount(TextInput(props));
12
+ const element = component.find('input');
13
+
14
+ expect(element.exists()).toBe(true);
15
+ });
16
+
17
+ it('renders a field with custom field id', () => {
18
+ const props = { fieldId: 'customFieldId' };
19
+
20
+ const component = mount(TextInput(props));
21
+ const element = component.find('#customFieldId');
22
+
23
+ expect(element.exists()).toBe(true);
24
+ });
25
+
26
+ it('renders with an error', () => {
27
+ const props = { hasError: true, errorText: 'Invalid value' };
28
+
29
+ const component = mount(TextInput(props));
30
+ const element = component.find('.o-forms-input--invalid');
31
+ const errorMsg = component.find('.o-forms-input__error');
32
+
33
+ expect(element.exists()).toBe(true);
34
+ expect(errorMsg.text()).toEqual('Invalid value');
35
+ });
36
+
37
+ it('renders a field with custom input id', () => {
38
+ const props = { inputId: 'customInputId' };
39
+
40
+ const component = mount(TextInput(props));
41
+ const element = component.find('input#customInputId');
42
+
43
+ expect(element.exists()).toBe(true);
44
+ });
45
+
46
+ it('renders a field with custom input name', () => {
47
+ const CUSTOM_INPUT_NAME = 'customInputName';
48
+ const props = { inputName: CUSTOM_INPUT_NAME };
49
+
50
+ const component = mount(TextInput(props));
51
+ const element = component.find('input');
52
+
53
+ expect(element.prop('name')).toBe(CUSTOM_INPUT_NAME);
54
+ });
55
+
56
+ it('renders with a custom value', () => {
57
+ const props = { value: 'foobar' };
58
+
59
+ const component = mount(TextInput(props));
60
+ const element = component.find('input');
61
+
62
+ expect(element.prop('defaultValue')).toEqual('foobar');
63
+ });
64
+
65
+ it('renders with disabled input', () => {
66
+ const props = { isDisabled: true };
67
+
68
+ const component = mount(TextInput(props));
69
+ const element = component.find('input[disabled=true]');
70
+
71
+ expect(element.exists()).toBe(true);
72
+ });
73
+
74
+ it('renders with default label wording', () => {
75
+ const props = {};
76
+
77
+ const component = mount(TextInput(props));
78
+ const label = component.find('.o-forms-title__main');
79
+
80
+ expect(label.text()).toEqual('');
81
+ });
82
+
83
+ it('renders with custom label wording', () => {
84
+ const props = { label: 'Code' };
85
+
86
+ const component = mount(TextInput(props));
87
+ const label = component.find('.o-forms-title__main');
88
+
89
+ expect(label.text()).toEqual('Code');
90
+ });
91
+
92
+ it('renders with custom description wording', () => {
93
+ const props = { description: 'Description text' };
94
+
95
+ const component = mount(TextInput(props));
96
+ const description = component.find('.o-forms-title__prompt');
97
+
98
+ expect(description.text()).toEqual('Description text');
99
+ });
100
+
101
+ it('renders as required field', () => {
102
+ const props = { isRequired: true };
103
+
104
+ const component = mount(TextInput(props));
105
+ const element = component.find('input[required=true]');
106
+
107
+ expect(element.exists()).toBe(true);
108
+ });
109
+
110
+ it('renders as optional field', () => {
111
+ const props = { isRequired: false };
112
+
113
+ const component = mount(TextInput(props));
114
+ const element = component.find('input[required=true]');
115
+
116
+ expect(element.exists()).toBe(false);
117
+ });
118
+ });
@@ -0,0 +1,31 @@
1
+ import React from 'react';
2
+ import { TextInput } from './text-input';
3
+
4
+ export default {
5
+ title: 'Text Input',
6
+ component: TextInput,
7
+ };
8
+
9
+ export const Basic = (args) => <TextInput {...args} />;
10
+ Basic.args = {
11
+ label: 'Text Input',
12
+ };
13
+
14
+ export const VerificationCode = (args) => <TextInput {...args} />;
15
+ VerificationCode.args = {
16
+ dataTrackable: 'verification-code',
17
+ errorText: 'This verification code is incorrect, please try again',
18
+ fieldId: 'verificationCodeField',
19
+ inputId: 'verificationCode',
20
+ isRequired: true,
21
+ placeHolder: 'Enter code',
22
+ description:
23
+ 'An email with a link and verification code has been sent to your email. Enter the code below or follow the link in the email to continue.',
24
+ hasError: true,
25
+ };
26
+
27
+ export const Comments = (args) => <TextInput {...args} />;
28
+ Comments.args = {
29
+ label: 'Comments',
30
+ placeHolder: 'Please enter your comments',
31
+ };
@@ -24,6 +24,8 @@ function Confirmation(_ref) {
24
24
  isTrial = _ref$isTrial === void 0 ? false : _ref$isTrial,
25
25
  _ref$isB2cPartnership = _ref.isB2cPartnership,
26
26
  isB2cPartnership = _ref$isB2cPartnership === void 0 ? false : _ref$isB2cPartnership,
27
+ _ref$b2cPartnershipCo = _ref.b2cPartnershipCopy,
28
+ b2cPartnershipCopy = _ref$b2cPartnershipCo === void 0 ? [] : _ref$b2cPartnershipCo,
27
29
  _ref$offer = _ref.offer,
28
30
  offer = _ref$offer === void 0 ? '' : _ref$offer,
29
31
  _ref$email = _ref.email,
@@ -77,9 +79,13 @@ function Confirmation(_ref) {
77
79
  className: "ncf__paragraph--reduced-padding ncf__paragraph--subscription-confirmation"
78
80
  }, "You are now subscribed to:"), /*#__PURE__*/_react["default"].createElement("h1", {
79
81
  className: "ncf__header ncf__header--confirmation"
80
- }, offer)), nextActionTop, /*#__PURE__*/_react["default"].createElement("p", {
82
+ }, offer)), nextActionTop, !isB2cPartnership && /*#__PURE__*/_react["default"].createElement("p", {
81
83
  className: "ncf__paragraph"
82
- }, "We\u2019ve sent confirmation to ", email, ". Make sure you check your spam folder if you don\u2019t receive it."), isB2cPartnership ? /*#__PURE__*/_react["default"].createElement("p", null, "We've also sent you an email to start your 90-day All Access Digital subscription with The Washington Post.") : '', /*#__PURE__*/_react["default"].createElement("p", {
84
+ }, "We\u2019ve sent confirmation to ", email, ". Make sure you check your spam folder if you don\u2019t receive it."), isB2cPartnership && b2cPartnershipCopy.length > 0 ? /*#__PURE__*/_react["default"].createElement("p", {
85
+ className: "ncf__paragraph"
86
+ }, b2cPartnershipCopy[0], /*#__PURE__*/_react["default"].createElement("span", {
87
+ className: "ncf__legend"
88
+ }, " ".concat(email, ". ")), b2cPartnershipCopy[1]) : '', /*#__PURE__*/_react["default"].createElement("p", {
83
89
  className: "ncf__paragraph"
84
90
  }, "Here\u2019s a summary of your ", offer, " subscription:"), detailElements, directDebitMandateUrlElement, /*#__PURE__*/_react["default"].createElement("div", {
85
91
  className: "ncf__headed-paragraph"
@@ -109,6 +115,7 @@ function Confirmation(_ref) {
109
115
  Confirmation.propTypes = {
110
116
  isTrial: _propTypes["default"].bool,
111
117
  isB2cPartnership: _propTypes["default"].bool,
118
+ b2cPartnershipCopy: _propTypes["default"].array,
112
119
  offer: _propTypes["default"].string.isRequired,
113
120
  email: _propTypes["default"].string,
114
121
  details: _propTypes["default"].arrayOf(_propTypes["default"].shape({
package/dist/index.js CHANGED
@@ -21,12 +21,6 @@ Object.defineProperty(exports, "B2CPartnershipConfirmation", {
21
21
  return _b2cPartnershipConfirmation.B2CPartnershipConfirmation;
22
22
  }
23
23
  });
24
- Object.defineProperty(exports, "B2cPartnershipPaymentTerm", {
25
- enumerable: true,
26
- get: function get() {
27
- return _b2cPartnershipPaymentTerm.B2cPartnershipPaymentTerm;
28
- }
29
- });
30
24
  Object.defineProperty(exports, "BillingCity", {
31
25
  enumerable: true,
32
26
  get: function get() {
@@ -333,6 +327,12 @@ Object.defineProperty(exports, "Submit", {
333
327
  return _submit.Submit;
334
328
  }
335
329
  });
330
+ Object.defineProperty(exports, "TextInput", {
331
+ enumerable: true,
332
+ get: function get() {
333
+ return _textInput.TextInput;
334
+ }
335
+ });
336
336
  Object.defineProperty(exports, "TrialBanner", {
337
337
  enumerable: true,
338
338
  get: function get() {
@@ -344,8 +344,6 @@ var _acceptTerms = require("./accept-terms");
344
344
 
345
345
  var _appBanner = require("./app-banner");
346
346
 
347
- var _b2cPartnershipPaymentTerm = require("./b2c-partnership-payment-term");
348
-
349
347
  var _billingCity = require("./billing-city");
350
348
 
351
349
  var _billingCountry = require("./billing-country");
@@ -450,4 +448,6 @@ var _graduationDate = require("./graduation-date");
450
448
 
451
449
  var _liteSubConfirmation = require("./lite-sub-confirmation");
452
450
 
453
- var _googleSignIn = require("./google-sign-in");
451
+ var _googleSignIn = require("./google-sign-in");
452
+
453
+ var _textInput = require("./text-input");
@@ -195,6 +195,12 @@ function PaymentTerm(_ref) {
195
195
  }, option.bestOffer ? 'Best offer' : "Save ".concat(option.discount, " off RRP"));
196
196
  };
197
197
 
198
+ var createB2cDiscountCopy = function createB2cDiscountCopy() {
199
+ return option.b2cPartnership && option.b2cDiscountCopy && /*#__PURE__*/_react["default"].createElement("span", {
200
+ className: "ncf__payment-term__discount"
201
+ }, option.b2cDiscountCopy);
202
+ };
203
+
198
204
  var createDescription = function createDescription() {
199
205
  return option.isTrial ? /*#__PURE__*/_react["default"].createElement("div", {
200
206
  className: "ncf__payment-term__description"
@@ -250,7 +256,7 @@ function PaymentTerm(_ref) {
250
256
  }, /*#__PURE__*/_react["default"].createElement("input", props), /*#__PURE__*/_react["default"].createElement("label", {
251
257
  htmlFor: option.value,
252
258
  className: "o-forms-input__label ncf__payment-term__label"
253
- }, createDiscount(), /*#__PURE__*/_react["default"].createElement("span", {
259
+ }, createDiscount(), createB2cDiscountCopy(), /*#__PURE__*/_react["default"].createElement("span", {
254
260
  className: (0, _classnames["default"])(['ncf__payment-term__title', {
255
261
  'ncf__payment-term__title--large-price': largePrice
256
262
  }])
@@ -289,6 +295,8 @@ PaymentTerm.propTypes = {
289
295
  isPrintOrBundle: _propTypes["default"].bool,
290
296
  isEpaper: _propTypes["default"].bool,
291
297
  options: _propTypes["default"].arrayOf(_propTypes["default"].shape({
298
+ b2cDiscountCopy: _propTypes["default"].string,
299
+ isB2cPartnership: _propTypes["default"].bool,
292
300
  discount: _propTypes["default"].string,
293
301
  isTrial: _propTypes["default"].bool,
294
302
  name: _propTypes["default"].string.isRequired,
@@ -0,0 +1,84 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.TextInput = TextInput;
9
+
10
+ var _react = _interopRequireDefault(require("react"));
11
+
12
+ var _propTypes = _interopRequireDefault(require("prop-types"));
13
+
14
+ var _classnames = _interopRequireDefault(require("classnames"));
15
+
16
+ function TextInput(_ref) {
17
+ var dataTrackable = _ref.dataTrackable,
18
+ _ref$errorText = _ref.errorText,
19
+ errorText = _ref$errorText === void 0 ? 'Please enter a value' : _ref$errorText,
20
+ fieldId = _ref.fieldId,
21
+ _ref$hasError = _ref.hasError,
22
+ hasError = _ref$hasError === void 0 ? false : _ref$hasError,
23
+ inputId = _ref.inputId,
24
+ inputName = _ref.inputName,
25
+ _ref$isDisabled = _ref.isDisabled,
26
+ isDisabled = _ref$isDisabled === void 0 ? false : _ref$isDisabled,
27
+ _ref$isRequired = _ref.isRequired,
28
+ isRequired = _ref$isRequired === void 0 ? false : _ref$isRequired,
29
+ _ref$label = _ref.label,
30
+ label = _ref$label === void 0 ? '' : _ref$label,
31
+ _ref$placeHolder = _ref.placeHolder,
32
+ placeHolder = _ref$placeHolder === void 0 ? '' : _ref$placeHolder,
33
+ _ref$value = _ref.value,
34
+ value = _ref$value === void 0 ? '' : _ref$value,
35
+ description = _ref.description;
36
+ // Use inputId if inputName is not explicitly passed.
37
+ inputName = inputName || inputId;
38
+ var inputWrapperClassNames = (0, _classnames["default"])(['o-forms-input', 'o-forms-input--text', {
39
+ 'o-forms-input--invalid': hasError
40
+ }, {
41
+ 'o-forms-field--optional': !isRequired
42
+ }]);
43
+ return /*#__PURE__*/_react["default"].createElement("label", {
44
+ id: fieldId,
45
+ className: "o-forms-field ncf__validation-error",
46
+ "data-validate": "required",
47
+ htmlFor: inputId
48
+ }, /*#__PURE__*/_react["default"].createElement("span", {
49
+ className: "o-forms-title"
50
+ }, /*#__PURE__*/_react["default"].createElement("span", {
51
+ className: "o-forms-title__main"
52
+ }, label), description ? /*#__PURE__*/_react["default"].createElement("span", {
53
+ className: "o-forms-title__prompt"
54
+ }, description) : null), /*#__PURE__*/_react["default"].createElement("span", {
55
+ className: inputWrapperClassNames
56
+ }, /*#__PURE__*/_react["default"].createElement("input", {
57
+ type: "text",
58
+ id: inputId,
59
+ name: inputName,
60
+ placeholder: placeHolder,
61
+ "data-trackable": dataTrackable,
62
+ "aria-required": isRequired,
63
+ required: isRequired,
64
+ disabled: isDisabled,
65
+ defaultValue: value
66
+ }), /*#__PURE__*/_react["default"].createElement("span", {
67
+ className: "o-forms-input__error"
68
+ }, errorText)));
69
+ }
70
+
71
+ TextInput.propTypes = {
72
+ dataTrackable: _propTypes["default"].string,
73
+ errorText: _propTypes["default"].string,
74
+ fieldId: _propTypes["default"].string,
75
+ hasError: _propTypes["default"].bool,
76
+ inputId: _propTypes["default"].string,
77
+ inputName: _propTypes["default"].string,
78
+ isDisabled: _propTypes["default"].bool,
79
+ isRequired: _propTypes["default"].bool,
80
+ label: _propTypes["default"].string,
81
+ placeHolder: _propTypes["default"].string,
82
+ value: _propTypes["default"].string,
83
+ description: _propTypes["default"].string
84
+ };
package/main.scss CHANGED
@@ -10,7 +10,6 @@
10
10
  @import '@financial-times/o-fonts/main';
11
11
  @import './styles/package-change';
12
12
  @import './styles/payment-term';
13
- @import './styles/b2c-partnership-payment-term';
14
13
  @import './styles/payment-type';
15
14
  @import './styles/loader';
16
15
  @import './styles/accept-terms';
@@ -436,7 +435,6 @@
436
435
  @include ncfMessage();
437
436
  @include ncfPackageChange();
438
437
  @include ncfPaymentTerm();
439
- @include ncfB2cPartnershipPaymentTerm();
440
438
  @include ncfPaymentType();
441
439
  @include ncfLoader();
442
440
  @include ncfContinueReading();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@financial-times/n-conversion-forms",
3
- "version": "24.2.0",
3
+ "version": "25.0.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": {
@@ -1,193 +0,0 @@
1
- // Jest Snapshot v1, https://goo.gl/fbAQLP
2
-
3
- exports[`B2cPartnershipPaymentTerm render with minimum props required 1`] = `
4
- <div id="paymentTermField"
5
- class="o-forms__group ncf__payment-term ncf__b2c-partnership-payment-term"
6
- >
7
- <div class="ncf__payment-term__item o-forms-input--radio-round">
8
- <input type="radio"
9
- id="299.99"
10
- name="paymentTerm"
11
- value="299.99"
12
- checked
13
- >
14
- <label for="299.99"
15
- class="o-forms-input__label ncf__payment-term__label"
16
- >
17
- <span class="ncf__payment-term__title">
18
- £299.99 - Digital FT + The Washington Post
19
- </span>
20
- <div class="ncf__b2c-partnership-payment-term__description">
21
- <p>
22
- Includes:
23
- <br>
24
- 1 year Digital subscription to the Financial Times
25
- <br>
26
- 90-day All-Access Digital subscription to The Washington Post
27
- </p>
28
- </div>
29
- </label>
30
- </div>
31
- <div class="ncf__payment-term__legal">
32
- <p>
33
- We will automatically renew your subscription using the payment method provided unless you cancel before your renewal date.
34
- </p>
35
- <p>
36
- We will notify you at least 14 days in advance of any changes to the price in your subscription that would apply upon next renewal. Find out more about our cancellation policy in our
37
- <a class="ncf__link--external"
38
- href="https://help.ft.com/help/legal-privacy/terms-conditions/"
39
- title="FT Legal Terms and Conditions help page"
40
- target="_blank"
41
- rel="noopener noreferrer"
42
- >
43
- Terms &amp; Conditions
44
- </a>
45
- .
46
- </p>
47
- </div>
48
- </div>
49
- `;
50
-
51
- exports[`B2cPartnershipPaymentTerm renders with annual option 1`] = `
52
- <div id="paymentTermField"
53
- class="o-forms__group ncf__payment-term ncf__b2c-partnership-payment-term"
54
- >
55
- <div class="ncf__payment-term__item o-forms-input--radio-round">
56
- <input type="radio"
57
- id="annual"
58
- name="paymentTerm"
59
- value="annual"
60
- checked
61
- >
62
- <label for="annual"
63
- class="o-forms-input__label ncf__payment-term__label"
64
- >
65
- <span class="ncf__payment-term__title">
66
- £20.00 - Digital FT + The Washington Post
67
- </span>
68
- <div class="ncf__b2c-partnership-payment-term__description">
69
- <p>
70
- Includes:
71
- <br>
72
- 1 year Digital subscription to the Financial Times
73
- <br>
74
- 90-day All-Access Digital subscription to The Washington Post
75
- </p>
76
- </div>
77
- </label>
78
- </div>
79
- <div class="ncf__payment-term__legal">
80
- <p>
81
- We will automatically renew your subscription using the payment method provided unless you cancel before your renewal date.
82
- </p>
83
- <p>
84
- We will notify you at least 14 days in advance of any changes to the price in your subscription that would apply upon next renewal. Find out more about our cancellation policy in our
85
- <a class="ncf__link--external"
86
- href="https://help.ft.com/help/legal-privacy/terms-conditions/"
87
- title="FT Legal Terms and Conditions help page"
88
- target="_blank"
89
- rel="noopener noreferrer"
90
- >
91
- Terms &amp; Conditions
92
- </a>
93
- .
94
- </p>
95
- </div>
96
- </div>
97
- `;
98
-
99
- exports[`B2cPartnershipPaymentTerm renders with monthly option 1`] = `
100
- <div id="paymentTermField"
101
- class="o-forms__group ncf__payment-term ncf__b2c-partnership-payment-term"
102
- >
103
- <div class="ncf__payment-term__item o-forms-input--radio-round">
104
- <input type="radio"
105
- id="monthly"
106
- name="paymentTerm"
107
- value="monthly"
108
- checked
109
- >
110
- <label for="monthly"
111
- class="o-forms-input__label ncf__payment-term__label"
112
- >
113
- <span class="ncf__payment-term__title">
114
- £20.00 - Digital FT + The Washington Post
115
- </span>
116
- <div class="ncf__b2c-partnership-payment-term__description">
117
- <p>
118
- Includes:
119
- <br>
120
- 1 month Digital subscription to the Financial Times
121
- <br>
122
- 90-day All-Access Digital subscription to The Washington Post
123
- </p>
124
- </div>
125
- </label>
126
- </div>
127
- <div class="ncf__payment-term__legal">
128
- <p>
129
- We will automatically renew your subscription using the payment method provided unless you cancel before your renewal date.
130
- </p>
131
- <p>
132
- We will notify you at least 14 days in advance of any changes to the price in your subscription that would apply upon next renewal. Find out more about our cancellation policy in our
133
- <a class="ncf__link--external"
134
- href="https://help.ft.com/help/legal-privacy/terms-conditions/"
135
- title="FT Legal Terms and Conditions help page"
136
- target="_blank"
137
- rel="noopener noreferrer"
138
- >
139
- Terms &amp; Conditions
140
- </a>
141
- .
142
- </p>
143
- </div>
144
- </div>
145
- `;
146
-
147
- exports[`B2cPartnershipPaymentTerm renders with quarterly option 1`] = `
148
- <div id="paymentTermField"
149
- class="o-forms__group ncf__payment-term ncf__b2c-partnership-payment-term"
150
- >
151
- <div class="ncf__payment-term__item o-forms-input--radio-round">
152
- <input type="radio"
153
- id="quarterly"
154
- name="paymentTerm"
155
- value="quarterly"
156
- checked
157
- >
158
- <label for="quarterly"
159
- class="o-forms-input__label ncf__payment-term__label"
160
- >
161
- <span class="ncf__payment-term__title">
162
- £20.00 - Digital FT + The Washington Post
163
- </span>
164
- <div class="ncf__b2c-partnership-payment-term__description">
165
- <p>
166
- Includes:
167
- <br>
168
- 3 month Digital subscription to the Financial Times
169
- <br>
170
- 90-day All-Access Digital subscription to The Washington Post
171
- </p>
172
- </div>
173
- </label>
174
- </div>
175
- <div class="ncf__payment-term__legal">
176
- <p>
177
- We will automatically renew your subscription using the payment method provided unless you cancel before your renewal date.
178
- </p>
179
- <p>
180
- We will notify you at least 14 days in advance of any changes to the price in your subscription that would apply upon next renewal. Find out more about our cancellation policy in our
181
- <a class="ncf__link--external"
182
- href="https://help.ft.com/help/legal-privacy/terms-conditions/"
183
- title="FT Legal Terms and Conditions help page"
184
- target="_blank"
185
- rel="noopener noreferrer"
186
- >
187
- Terms &amp; Conditions
188
- </a>
189
- .
190
- </p>
191
- </div>
192
- </div>
193
- `;
@@ -1,126 +0,0 @@
1
- import React from 'react';
2
- import PropTypes from 'prop-types';
3
-
4
- export function B2cPartnershipPaymentTerm ({
5
- fieldId = 'paymentTermField',
6
- inputName = 'paymentTerm',
7
- options = [],
8
- displayName,
9
- offerType,
10
- partnerOffer,
11
- conditions = [],
12
- }) {
13
- const durations = {
14
- annual: '1 year',
15
- quarterly: '3 month',
16
- monthly: '1 month',
17
- };
18
-
19
- // convert to Title Case
20
- offerType = offerType
21
- .split('')
22
- .map((letter, i) => (i !== 0 ? letter.toLowerCase() : letter.toUpperCase()))
23
- .join('');
24
-
25
- return (
26
- <div
27
- id={fieldId}
28
- className="o-forms__group ncf__payment-term ncf__b2c-partnership-payment-term"
29
- >
30
- {options.map(
31
- (option) =>
32
- option.selected && (
33
- <div
34
- className="ncf__payment-term__item o-forms-input--radio-round"
35
- key={option.value}
36
- >
37
- <input
38
- type="radio"
39
- id={option.value}
40
- name={inputName}
41
- value={option.value}
42
- defaultChecked={true}
43
- />
44
- <label
45
- htmlFor={option.value}
46
- className="o-forms-input__label ncf__payment-term__label"
47
- >
48
- <span className="ncf__payment-term__title">
49
- {option.price} - {displayName}
50
- </span>
51
- <div className="ncf__b2c-partnership-payment-term__description">
52
- <p>
53
- Includes:
54
- <br />
55
- {durations[option.name]} {offerType} subscription to the
56
- Financial Times
57
- <br />
58
- {partnerOffer.duration} {partnerOffer.name} subscription to{' '}
59
- {partnerOffer.vendor}
60
- </p>
61
- {conditions.length > 0 && (
62
- <p>
63
- {conditions.map((line) => (
64
- <>
65
- {line}
66
- <br />
67
- </>
68
- ))}
69
- </p>
70
- )}
71
- </div>
72
- </label>
73
- </div>
74
- )
75
- )}
76
-
77
- <div className="ncf__payment-term__legal">
78
- <p>
79
- We will automatically renew your subscription using the payment method
80
- provided unless you cancel before your renewal date.
81
- </p>
82
- <p>
83
- We will notify you at least 14 days in advance of any changes to the
84
- price in your subscription that would apply upon next renewal. Find
85
- out more about our cancellation policy in our{' '}
86
- <a
87
- className="ncf__link--external"
88
- href="https://help.ft.com/help/legal-privacy/terms-conditions/"
89
- title="FT Legal Terms and Conditions help page"
90
- target="_blank"
91
- rel="noopener noreferrer"
92
- >
93
- Terms &amp; Conditions
94
- </a>
95
- .
96
- </p>
97
- </div>
98
- </div>
99
- );
100
- }
101
-
102
- B2cPartnershipPaymentTerm.propTypes = {
103
- fieldId: PropTypes.string,
104
- inputName: PropTypes.string,
105
- options: PropTypes.arrayOf(
106
- PropTypes.shape({
107
- discount: PropTypes.string,
108
- isTrial: PropTypes.bool,
109
- name: PropTypes.string.isRequired,
110
- price: PropTypes.string.isRequired,
111
- selected: PropTypes.bool,
112
- trialDuration: PropTypes.string,
113
- trialPrice: PropTypes.string,
114
- value: PropTypes.string.isRequired,
115
- monthlyPrice: PropTypes.string,
116
- })
117
- ).isRequired,
118
- displayName: PropTypes.string.isRequired,
119
- partnerOffer: PropTypes.shape({
120
- duration: PropTypes.string.isRequired,
121
- name: PropTypes.string.isRequired,
122
- vendor: PropTypes.string.isRequired,
123
- }).isRequired,
124
- conditions: PropTypes.arrayOf(PropTypes.string),
125
- offerType: PropTypes.string.isRequired,
126
- };
@@ -1,52 +0,0 @@
1
- import { B2cPartnershipPaymentTerm } from './index';
2
- import { expectToRenderCorrectly } from '../test-jest/helpers/expect-to-render-correctly';
3
-
4
- expect.extend(expectToRenderCorrectly);
5
-
6
- const defaultProps = {
7
- displayName: 'Digital FT + The Washington Post',
8
- partnerOffer: {
9
- duration: '90-day',
10
- name: 'All-Access Digital',
11
- vendor: 'The Washington Post',
12
- },
13
- offerType: 'DIGITAL',
14
- options: [
15
- {
16
- name: 'annual',
17
- price: '£299.99',
18
- value: 299.99,
19
- isTrial: false,
20
- discount: null,
21
- selected: true,
22
- },
23
- ],
24
- };
25
-
26
- describe('B2cPartnershipPaymentTerm', () => {
27
- it('render with minimum props required', () => {
28
- const props = {
29
- ...defaultProps,
30
- };
31
-
32
- expect(B2cPartnershipPaymentTerm).toRenderCorrectly(props);
33
- });
34
-
35
- ['annual', 'quarterly', 'monthly'].forEach((type) => {
36
- it(`renders with ${type} option`, () => {
37
- const props = {
38
- ...defaultProps,
39
- options: [
40
- {
41
- name: type,
42
- value: type,
43
- price: '£20.00',
44
- selected: true,
45
- },
46
- ],
47
- };
48
-
49
- expect(B2cPartnershipPaymentTerm).toRenderCorrectly(props);
50
- });
51
- });
52
- });
@@ -1,44 +0,0 @@
1
- import React from 'react';
2
- import { Fieldset } from './fieldset';
3
- import { B2cPartnershipPaymentTerm } from './b2c-partnership-payment-term';
4
-
5
- export default {
6
- title: 'B2C Partnership Payment Term',
7
- component: B2cPartnershipPaymentTerm,
8
- };
9
-
10
- export const Basic = (args) => (
11
- <Fieldset>
12
- <B2cPartnershipPaymentTerm {...args} />
13
- </Fieldset>
14
- );
15
- Basic.args = {
16
- displayName: 'Digital FT + The Washington Post',
17
- partnerOffer: {
18
- duration: '90-day',
19
- name: 'All-Access Digital',
20
- vendor: 'The Washington Post',
21
- },
22
- conditions: [
23
- '90-day Washington Post subscription must be redeemed by 31 March 2021.',
24
- ],
25
- offerType: 'DIGITAL',
26
- options: [
27
- {
28
- name: 'monthly',
29
- price: '£49.99',
30
- value: 49.99,
31
- isTrial: false,
32
- discount: '33%',
33
- selected: false,
34
- },
35
- {
36
- name: 'annual',
37
- price: '£299.99',
38
- value: 299.99,
39
- isTrial: false,
40
- discount: null,
41
- selected: true,
42
- },
43
- ],
44
- };
@@ -1,91 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.B2cPartnershipPaymentTerm = B2cPartnershipPaymentTerm;
9
-
10
- var _react = _interopRequireDefault(require("react"));
11
-
12
- var _propTypes = _interopRequireDefault(require("prop-types"));
13
-
14
- function B2cPartnershipPaymentTerm(_ref) {
15
- var _ref$fieldId = _ref.fieldId,
16
- fieldId = _ref$fieldId === void 0 ? 'paymentTermField' : _ref$fieldId,
17
- _ref$inputName = _ref.inputName,
18
- inputName = _ref$inputName === void 0 ? 'paymentTerm' : _ref$inputName,
19
- _ref$options = _ref.options,
20
- options = _ref$options === void 0 ? [] : _ref$options,
21
- displayName = _ref.displayName,
22
- offerType = _ref.offerType,
23
- partnerOffer = _ref.partnerOffer,
24
- _ref$conditions = _ref.conditions,
25
- conditions = _ref$conditions === void 0 ? [] : _ref$conditions;
26
- var durations = {
27
- annual: '1 year',
28
- quarterly: '3 month',
29
- monthly: '1 month'
30
- }; // convert to Title Case
31
-
32
- offerType = offerType.split('').map(function (letter, i) {
33
- return i !== 0 ? letter.toLowerCase() : letter.toUpperCase();
34
- }).join('');
35
- return /*#__PURE__*/_react["default"].createElement("div", {
36
- id: fieldId,
37
- className: "o-forms__group ncf__payment-term ncf__b2c-partnership-payment-term"
38
- }, options.map(function (option) {
39
- return option.selected && /*#__PURE__*/_react["default"].createElement("div", {
40
- className: "ncf__payment-term__item o-forms-input--radio-round",
41
- key: option.value
42
- }, /*#__PURE__*/_react["default"].createElement("input", {
43
- type: "radio",
44
- id: option.value,
45
- name: inputName,
46
- value: option.value,
47
- defaultChecked: true
48
- }), /*#__PURE__*/_react["default"].createElement("label", {
49
- htmlFor: option.value,
50
- className: "o-forms-input__label ncf__payment-term__label"
51
- }, /*#__PURE__*/_react["default"].createElement("span", {
52
- className: "ncf__payment-term__title"
53
- }, option.price, " - ", displayName), /*#__PURE__*/_react["default"].createElement("div", {
54
- className: "ncf__b2c-partnership-payment-term__description"
55
- }, /*#__PURE__*/_react["default"].createElement("p", null, "Includes:", /*#__PURE__*/_react["default"].createElement("br", null), durations[option.name], " ", offerType, " subscription to the Financial Times", /*#__PURE__*/_react["default"].createElement("br", null), partnerOffer.duration, " ", partnerOffer.name, " subscription to", ' ', partnerOffer.vendor), conditions.length > 0 && /*#__PURE__*/_react["default"].createElement("p", null, conditions.map(function (line) {
56
- return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, line, /*#__PURE__*/_react["default"].createElement("br", null));
57
- })))));
58
- }), /*#__PURE__*/_react["default"].createElement("div", {
59
- className: "ncf__payment-term__legal"
60
- }, /*#__PURE__*/_react["default"].createElement("p", null, "We will automatically renew your subscription using the payment method provided unless you cancel before your renewal date."), /*#__PURE__*/_react["default"].createElement("p", null, "We will notify you at least 14 days in advance of any changes to the price in your subscription that would apply upon next renewal. Find out more about our cancellation policy in our", ' ', /*#__PURE__*/_react["default"].createElement("a", {
61
- className: "ncf__link--external",
62
- href: "https://help.ft.com/help/legal-privacy/terms-conditions/",
63
- title: "FT Legal Terms and Conditions help page",
64
- target: "_blank",
65
- rel: "noopener noreferrer"
66
- }, "Terms & Conditions"), ".")));
67
- }
68
-
69
- B2cPartnershipPaymentTerm.propTypes = {
70
- fieldId: _propTypes["default"].string,
71
- inputName: _propTypes["default"].string,
72
- options: _propTypes["default"].arrayOf(_propTypes["default"].shape({
73
- discount: _propTypes["default"].string,
74
- isTrial: _propTypes["default"].bool,
75
- name: _propTypes["default"].string.isRequired,
76
- price: _propTypes["default"].string.isRequired,
77
- selected: _propTypes["default"].bool,
78
- trialDuration: _propTypes["default"].string,
79
- trialPrice: _propTypes["default"].string,
80
- value: _propTypes["default"].string.isRequired,
81
- monthlyPrice: _propTypes["default"].string
82
- })).isRequired,
83
- displayName: _propTypes["default"].string.isRequired,
84
- partnerOffer: _propTypes["default"].shape({
85
- duration: _propTypes["default"].string.isRequired,
86
- name: _propTypes["default"].string.isRequired,
87
- vendor: _propTypes["default"].string.isRequired
88
- }).isRequired,
89
- conditions: _propTypes["default"].arrayOf(_propTypes["default"].string),
90
- offerType: _propTypes["default"].string.isRequired
91
- };
@@ -1,20 +0,0 @@
1
- @mixin ncfB2cPartnershipPaymentTerm() {
2
- &__b2c-partnership-payment-term {
3
- &__description {
4
- font-size: 15px;
5
-
6
- p:first-child {
7
- margin-top: 0;
8
- }
9
- p:last-child {
10
- margin-bottom: 0;
11
- }
12
- }
13
-
14
- // hide radio button
15
- .o-forms-input--radio-round .o-forms-input__label:after,
16
- .o-forms-input--radio-round .o-forms-input__label:before {
17
- content: none;
18
- }
19
- }
20
- }