@financial-times/n-conversion-forms 28.9.0 → 29.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.
@@ -1,11 +1,11 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
- exports[`AcceptTerms renders appropriately if a isAuthFirstAccount 1`] = `
3
+ exports[`AcceptTerms renders a component matching snapshot when withPrivacyPolicyTerms is true 1`] = `
4
4
  <div id="acceptTermsField"
5
5
  class="o-forms-field o-layout-typography ncf__validation-error"
6
6
  data-validate="required,checked"
7
7
  >
8
- <div class="auth-first-step-terms">
8
+ <div class="privacy-policy-terms">
9
9
  <span class="consent-text--top">
10
10
  For more information about how we use your data, please refer to our
11
11
  <a class="ncf__link--external"
@@ -58,70 +58,6 @@ exports[`AcceptTerms renders appropriately if a isAuthFirstAccount 1`] = `
58
58
  </div>
59
59
  `;
60
60
 
61
- exports[`AcceptTerms renders appropriately if a isAuthFirstPayment 1`] = `
62
- <div id="acceptTermsField"
63
- class="o-forms-field o-layout-typography ncf__validation-error"
64
- data-validate="required,checked"
65
- >
66
- <ul class="o-typography-list ncf__accept-terms-list">
67
- </ul>
68
- <label class="o-forms-input o-forms-input--checkbox"
69
- for="termsAcceptance"
70
- >
71
- <input type="checkbox"
72
- id="termsAcceptance"
73
- name="termsAcceptance"
74
- value="true"
75
- data-trackable="field-terms"
76
- aria-required="true"
77
- required
78
- >
79
- <span class="o-forms-input__label">
80
- I agree to the above terms &amp; conditions.
81
- </span>
82
- <p class="o-forms-input__error">
83
- Please accept our terms &amp; conditions
84
- </p>
85
- </label>
86
- </div>
87
- `;
88
-
89
- exports[`AcceptTerms renders appropriately if a registration 1`] = `
90
- <div id="acceptTermsField"
91
- class="o-forms-field o-layout-typography ncf__validation-error"
92
- data-validate="required,checked"
93
- data-trackable="register-up-terms"
94
- >
95
- <label class="o-forms-input o-forms-input--checkbox"
96
- for="termsAcceptance"
97
- >
98
- <input type="checkbox"
99
- id="termsAcceptance"
100
- name="termsAcceptance"
101
- value="true"
102
- data-trackable="field-terms"
103
- aria-required="true"
104
- required
105
- >
106
- <span class="o-forms-input__label terms-register">
107
- I confirm I am 16 years or older and have read and agree to the
108
- <a class="ncf__link--external"
109
- href="http://help.ft.com/help/legal-privacy/terms-conditions/"
110
- target="_blank"
111
- rel="noopener noreferrer"
112
- data-trackable="terms-and-conditions"
113
- >
114
- Terms &amp; Conditions
115
- </a>
116
- .
117
- </span>
118
- <p class="o-forms-input__error">
119
- Please accept our terms &amp; conditions
120
- </p>
121
- </label>
122
- </div>
123
- `;
124
-
125
61
  exports[`AcceptTerms renders appropriately if a signup 1`] = `
126
62
  <div id="acceptTermsField"
127
63
  class="o-forms-field o-layout-typography ncf__validation-error"
@@ -196,85 +132,6 @@ exports[`AcceptTerms renders appropriately if a signup 1`] = `
196
132
  </div>
197
133
  `;
198
134
 
199
- exports[`AcceptTerms renders appropriately if a signup and has special terms 1`] = `
200
- <div id="acceptTermsField"
201
- class="o-forms-field o-layout-typography ncf__validation-error"
202
- data-validate="required,checked"
203
- data-trackable="sign-up-terms"
204
- >
205
- <ul class="o-typography-list ncf__accept-terms-list">
206
- <li>
207
- <span class="terms-default">
208
- I confirm I am 16 years or older and have read and agree to the
209
- <a class="ncf__link--external"
210
- href="http://help.ft.com/help/legal-privacy/terms-conditions/"
211
- target="_blank"
212
- rel="noopener noreferrer"
213
- data-trackable="terms-and-conditions"
214
- >
215
- Terms &amp; Conditions
216
- </a>
217
- .
218
- </span>
219
- </li>
220
- <li>
221
- <span class="terms-signup">
222
- I give consent for my chosen payment method to be charged automatically at the end of each subscription term until I cancel it by contacting
223
- <a class="ncf__link--external"
224
- href="https://help.ft.com/help/contact-us/"
225
- target="_blank"
226
- rel="noopener noreferrer"
227
- >
228
- customer care through chat, phone or email
229
- </a>
230
- .
231
- </span>
232
- </li>
233
- <li>
234
- <span class="terms-signup">
235
- By placing my order, my subscription will start immediately and I am aware and agree that I will therefore lose my statutory right to cancel my subscription within 14 days of acceptance of my order. Any notice of cancellation that I provide will only take effect at the end of my subscription period and previously paid amounts are non-refundable, except in the event that there is a fault in the provision of the services.
236
- </span>
237
- </li>
238
- <li>
239
- <span class="terms-signup">
240
- Find out more about our cancellation policy in our
241
- <a class="ncf__link--external"
242
- href="https://help.ft.com/legal-privacy/terms-and-conditions/"
243
- target="_blank"
244
- rel="noopener noreferrer"
245
- >
246
- Terms &amp; Conditions
247
- </a>
248
- .
249
- </span>
250
- </li>
251
- <li>
252
- <span class="terms-special">
253
- Special terms text
254
- </span>
255
- </li>
256
- </ul>
257
- <label class="o-forms-input o-forms-input--checkbox"
258
- for="termsAcceptance"
259
- >
260
- <input type="checkbox"
261
- id="termsAcceptance"
262
- name="termsAcceptance"
263
- value="true"
264
- data-trackable="field-terms"
265
- aria-required="true"
266
- required
267
- >
268
- <span class="o-forms-input__label">
269
- I agree to the above terms &amp; conditions.
270
- </span>
271
- <p class="o-forms-input__error">
272
- Please accept our terms &amp; conditions
273
- </p>
274
- </label>
275
- </div>
276
- `;
277
-
278
135
  exports[`AcceptTerms renders appropriately if a signup for the print product 1`] = `
279
136
  <div id="acceptTermsField"
280
137
  class="o-forms-field o-layout-typography ncf__validation-error"
@@ -0,0 +1,121 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import classNames from 'classnames';
4
+
5
+ export function AcceptTermsBusiness({
6
+ hasError = false,
7
+ isB2b = false,
8
+ isEmbedded = false,
9
+ isTrial = false,
10
+ }) {
11
+ const divProps = {
12
+ id: 'acceptTermsField',
13
+ className: 'o-forms-field o-layout-typography ncf__validation-error',
14
+ 'data-validate': 'required,checked',
15
+ };
16
+ const labelClassName = classNames([
17
+ 'o-forms-input',
18
+ 'o-forms-input--checkbox',
19
+ {
20
+ 'o-forms-input--invalid': hasError,
21
+ },
22
+ ]);
23
+
24
+ const inputProps = {
25
+ id: 'termsAcceptance',
26
+ type: 'checkbox',
27
+ name: 'termsAcceptance',
28
+ value: 'true',
29
+ 'data-trackable': 'field-terms',
30
+ 'aria-required': 'true',
31
+ required: true,
32
+ };
33
+
34
+ const b2bTerms = isB2b ? (
35
+ <li>
36
+ <span className="terms-b2b">
37
+ By submitting this form, you indicate your consent to also being
38
+ contacted by Financial Times by email, post, or phone about our other
39
+ products, services or special offers unless you untick this box.
40
+ </span>
41
+ </li>
42
+ ) : (
43
+ <li>
44
+ <span className="terms-default">
45
+ I confirm I am 16 years or older and have read and agree to the{' '}
46
+ <a
47
+ className="ncf__link--external"
48
+ href="http://help.ft.com/help/legal-privacy/terms-conditions/"
49
+ target={isEmbedded ? '_top' : '_blank'}
50
+ rel="noopener noreferrer"
51
+ data-trackable="terms-and-conditions"
52
+ >
53
+ Terms &amp; Conditions
54
+ </a>
55
+ .
56
+ </span>
57
+ </li>
58
+ );
59
+
60
+ const corpSignupTerms = (
61
+ <>
62
+ <li>
63
+ <span className="terms-corp-signup">
64
+ Your organisation’s administrator(s) may view basic usage and profile
65
+ data about your account and have the ability to set up myFT topic
66
+ follows on your behalf.
67
+ </span>
68
+ </li>
69
+ <li>
70
+ <span className="terms-corp-signup">
71
+ Basic usage and profile data about your account can include; for
72
+ example, your job title and profile information, the date you last
73
+ visited, volume of content consumed, etc.
74
+ </span>
75
+ </li>
76
+ <li>
77
+ <span className="terms-corp-signup">
78
+ myFT topics may be selected on your behalf by your company
79
+ administrator or FT representative for you to follow. You can unfollow
80
+ these topics or unsubscribe from the myFT digest through the Contact
81
+ preferences section on myFT.
82
+ </span>
83
+ </li>
84
+ {isTrial && (
85
+ <li>
86
+ <span className="terms-corp-signup">
87
+ This trial is to demonstrate the value of a group subscription and
88
+ we’ll contact you during your trial.
89
+ </span>
90
+ </li>
91
+ )}
92
+ </>
93
+ );
94
+
95
+ return (
96
+ <div {...divProps}>
97
+ <ul className="o-typography-list ncf__accept-terms-list">
98
+ {b2bTerms}
99
+ {corpSignupTerms}
100
+ </ul>
101
+
102
+ <label className={labelClassName} htmlFor="termsAcceptance">
103
+ <input {...inputProps} />
104
+ <span className="o-forms-input__label">
105
+ I agree to the above terms &amp; conditions.
106
+ </span>
107
+ <p className="o-forms-input__error">
108
+ Please accept our terms &amp; conditions
109
+ </p>
110
+ </label>
111
+ </div>
112
+ );
113
+ }
114
+
115
+ AcceptTermsBusiness.propTypes = {
116
+ hasError: PropTypes.bool,
117
+ isChecked: PropTypes.bool,
118
+ isB2b: PropTypes.bool,
119
+ isEmbedded: PropTypes.bool,
120
+ isTrial: PropTypes.bool,
121
+ };
@@ -0,0 +1,47 @@
1
+ import React from 'react';
2
+ import { mount } from 'enzyme';
3
+ import { AcceptTermsBusiness } from './index';
4
+
5
+ describe('AcceptTermsPrivacyPolicy', () => {
6
+ it('renders with "o-forms-input--invalid" class when hasError prop is true', () => {
7
+ const props = { hasError: true };
8
+
9
+ const component = mount(<AcceptTermsBusiness {...props} />);
10
+
11
+ const labelElement = component.find('label');
12
+ expect(labelElement.hasClass('o-forms-input--invalid')).toBe(true);
13
+ });
14
+
15
+ it('renders the B2B terms when isB2b prop is true', () => {
16
+ const props = {
17
+ isB2b: true,
18
+ };
19
+
20
+ const component = mount(<AcceptTermsBusiness {...props} />);
21
+
22
+ const b2bTerms = component.find('.terms-b2b');
23
+ expect(b2bTerms.exists()).toBe(true);
24
+ });
25
+
26
+ it('renders the external link with target="_blank" when isEmbedded prop is false', () => {
27
+ const props = {
28
+ isEmbedded: false,
29
+ };
30
+
31
+ const component = mount(<AcceptTermsBusiness {...props} />);
32
+
33
+ const externalLink = component.find('.ncf__link--external');
34
+ expect(externalLink.prop('target')).toBe('_blank');
35
+ });
36
+
37
+ it('renders the trial terms when isTrial prop is true', () => {
38
+ const props = {
39
+ isTrial: true,
40
+ };
41
+
42
+ const component = mount(<AcceptTermsBusiness {...props} />);
43
+
44
+ const trialTerms = component.find('.terms-corp-signup');
45
+ expect(trialTerms.exists()).toBe(true);
46
+ });
47
+ });
@@ -0,0 +1,32 @@
1
+ import React from 'react';
2
+ import { AcceptTermsBusiness } from './accept-terms-business';
3
+
4
+ export default {
5
+ title: 'Accept Terms Business',
6
+ component: AcceptTermsBusiness,
7
+ };
8
+
9
+ export const Basic = (args) => <AcceptTermsBusiness {...args} />;
10
+ Basic.args = {};
11
+
12
+ export const AcceptTermsBusinessB2b = (args) => (
13
+ <AcceptTermsBusiness {...args} />
14
+ );
15
+ AcceptTermsBusinessB2b.args = {
16
+ isB2b: true,
17
+ };
18
+
19
+ export const AcceptTermsBusinessTrial = (args) => (
20
+ <AcceptTermsBusiness {...args} />
21
+ );
22
+ AcceptTermsBusinessTrial.args = {
23
+ isTrial: true,
24
+ };
25
+
26
+ export const AcceptTermsBusinessTrialAndB2b = (args) => (
27
+ <AcceptTermsBusiness {...args} />
28
+ );
29
+ AcceptTermsBusinessTrialAndB2b.args = {
30
+ isTrial: true,
31
+ isB2b: true,
32
+ };
@@ -0,0 +1,93 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import classNames from 'classnames';
4
+
5
+ export function AcceptTermsPrivacyPolicy({
6
+ hasError = false,
7
+ isEmbedded = false,
8
+ children,
9
+ }) {
10
+ const divProps = {
11
+ id: 'acceptTermsField',
12
+ className: 'o-forms-field o-layout-typography ncf__validation-error',
13
+ 'data-validate': 'required,checked',
14
+ };
15
+
16
+ const labelClassName = classNames([
17
+ 'o-forms-input',
18
+ 'o-forms-input--checkbox',
19
+ {
20
+ 'o-forms-input--invalid': hasError,
21
+ },
22
+ ]);
23
+ const inputProps = {
24
+ id: 'termsAcceptance',
25
+ type: 'checkbox',
26
+ name: 'termsAcceptance',
27
+ value: 'true',
28
+ 'data-trackable': 'field-terms',
29
+ 'aria-required': 'true',
30
+ required: true,
31
+ };
32
+
33
+ return (
34
+ <div {...divProps}>
35
+ <div className="privacy-policy-terms">
36
+ <label className={labelClassName} htmlFor="termsAcceptance">
37
+ <input {...inputProps} />
38
+ <span className="o-forms-input__label">
39
+ I confirm that I am 16 years or older and agree to the full{' '}
40
+ <a
41
+ className="ncf__link--external"
42
+ href="http://help.ft.com/help/legal-privacy/terms-conditions/"
43
+ target={isEmbedded ? '_top' : '_blank'}
44
+ rel="noopener noreferrer"
45
+ data-trackable="terms-and-conditions"
46
+ >
47
+ Terms &amp; Conditions
48
+ </a>
49
+ .
50
+ </span>
51
+ <p className="o-forms-input__error">
52
+ Please accept our terms &amp; conditions
53
+ </p>
54
+ </label>
55
+
56
+ {children && <div className="children-container">{children}</div>}
57
+
58
+ <span className={`consent-text--bottom`}>
59
+ For more information about how we use your data, please refer to our{' '}
60
+ <a
61
+ className="ncf__link--external"
62
+ href="https://help.ft.com/legal-privacy/privacy-policy/"
63
+ target="_blank"
64
+ rel="noopener noreferrer"
65
+ data-trackable="privacy-policy-info"
66
+ >
67
+ privacy
68
+ </a>{' '}
69
+ and&nbsp;
70
+ <a
71
+ className="ncf__link--external"
72
+ href="https://help.ft.com/legal-privacy/cookies/"
73
+ target="_blank"
74
+ rel="noopener noreferrer"
75
+ data-trackable="cookies-info"
76
+ >
77
+ cookie
78
+ </a>{' '}
79
+ policies.
80
+ </span>
81
+ </div>
82
+ </div>
83
+ );
84
+ }
85
+
86
+ AcceptTermsPrivacyPolicy.propTypes = {
87
+ hasError: PropTypes.bool,
88
+ isEmbedded: PropTypes.bool,
89
+ children: PropTypes.oneOfType([
90
+ PropTypes.arrayOf(PropTypes.node),
91
+ PropTypes.node,
92
+ ]),
93
+ };
@@ -0,0 +1,37 @@
1
+ import React from 'react';
2
+ import { mount } from 'enzyme';
3
+ import { AcceptTermsPrivacyPolicy } from './index';
4
+
5
+ describe('AcceptTermsPrivacyPolicy', () => {
6
+ it('renders with "o-forms-input--invalid" class when hasError prop is true', () => {
7
+ const props = { hasError: true };
8
+
9
+ const component = mount(<AcceptTermsPrivacyPolicy {...props} />);
10
+
11
+ const labelElement = component.find('label');
12
+ expect(labelElement.hasClass('o-forms-input--invalid')).toBe(true);
13
+ });
14
+
15
+ it('renders the external link with target="_top" when isEmbedded prop is true', () => {
16
+ const props = {
17
+ isEmbedded: true,
18
+ };
19
+
20
+ const component = mount(<AcceptTermsPrivacyPolicy {...props} />);
21
+
22
+ const externalLink = component.find('.ncf__link--external').first();
23
+ expect(externalLink.prop('target')).toBe('_top');
24
+ });
25
+
26
+ it('renders children when children prop is provided', () => {
27
+ const props = {
28
+ children: <div className="child-component">Child Component</div>,
29
+ };
30
+
31
+ const component = mount(<AcceptTermsPrivacyPolicy {...props} />);
32
+
33
+ const childElement = component.find('.child-component');
34
+ expect(childElement.exists()).toBe(true);
35
+ expect(childElement.text()).toBe('Child Component');
36
+ });
37
+ });
@@ -0,0 +1,24 @@
1
+ import React from 'react';
2
+ import { AcceptTermsPrivacyPolicy } from './accept-terms-privacy-policy';
3
+ import { Submit } from './submit';
4
+
5
+ export default {
6
+ title: 'Accept Terms Privacy Policy',
7
+ component: AcceptTermsPrivacyPolicy,
8
+ };
9
+
10
+ export const Basic = (args) => <AcceptTermsPrivacyPolicy {...args} />;
11
+ Basic.args = {};
12
+
13
+ export const AcceptTermsError = (args) => (
14
+ <AcceptTermsPrivacyPolicy {...args} />
15
+ );
16
+ AcceptTermsError.args = {
17
+ hasError: true,
18
+ };
19
+
20
+ export const AcceptTermsWithChildren = (args) => (
21
+ <AcceptTermsPrivacyPolicy {...args}>
22
+ <Submit />
23
+ </AcceptTermsPrivacyPolicy>
24
+ );