@newskit-render/core 0.0.0-caeaa514b → 0.0.0-cc45b00ad

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.
Files changed (34) hide show
  1. package/CHANGELOG.md +840 -0
  2. package/Dockerfile.withNewRelic +1 -2
  3. package/__tests__/pages/__snapshots__/home.test.tsx.snap +0 -3
  4. package/components/article/__tests__/__snapshots__/index.test.tsx.snap +0 -3
  5. package/components/header/banner-messages.ts +4 -0
  6. package/cypress/e2e/account/holiday-stops.cy.js +4 -4
  7. package/cypress/e2e/account/newsletters-page.cy.js +30 -9
  8. package/cypress/e2e/account/subscription-and-billing.cy.js +10 -41
  9. package/cypress/support/commands.js +1 -1
  10. package/cypress/support/users.js +6 -2
  11. package/helpers/getProviderPropsUtil.ts +20 -0
  12. package/next.config.js +55 -57
  13. package/package.json +12 -13
  14. package/pages/account/add/[field].tsx +13 -56
  15. package/pages/account/{family → bonus-accounts}/index.tsx +9 -4
  16. package/pages/account/cancellation/index.tsx +3 -2
  17. package/pages/account/delete/confirm/index.tsx +3 -5
  18. package/pages/account/delete/error/index.tsx +3 -5
  19. package/pages/account/delete/index.tsx +3 -5
  20. package/pages/account/delete/success/index.tsx +3 -5
  21. package/pages/account/dream-team/index.tsx +3 -2
  22. package/pages/account/edit/[field].tsx +17 -5
  23. package/pages/account/holiday-stop/index.tsx +3 -6
  24. package/pages/account/holiday-stop/previous-holiday-stops.tsx +3 -6
  25. package/pages/account/holiday-stop/upcoming-holiday-stops.tsx +3 -6
  26. package/pages/account/index.tsx +3 -6
  27. package/pages/account/newsletters/index.tsx +3 -2
  28. package/pages/account/newsletters-and-alerts/index.tsx +3 -6
  29. package/pages/account/payment/[paymentMethod].tsx +2 -3
  30. package/pages/account/payment/index.tsx +3 -2
  31. package/pages/account/payment-methods/index.tsx +3 -6
  32. package/pages/account/subscription-and-billing/index.tsx +13 -6
  33. package/pages/account/user-hub/index.tsx +4 -6
  34. package/temp/_document.tsx +1 -0
@@ -4,7 +4,6 @@ WORKDIR /app
4
4
 
5
5
  ENV NEXT_TELEMETRY_DISABLED 1
6
6
 
7
- RUN npm install @newrelic/next
8
7
  COPY .next/standalone ./standalone
9
8
  COPY public ./standalone/public
10
9
  COPY .next/static ./standalone/.next/static
@@ -12,4 +11,4 @@ COPY .next/static ./standalone/.next/static
12
11
  EXPOSE 3000
13
12
  ENV PORT 3000
14
13
 
15
- CMD ["node", "-r", "@newrelic/next", "./standalone/server.js"]
14
+ CMD ["node", "./standalone/server.js"]
@@ -102,7 +102,6 @@ exports[`getServerSideProps Homepage 1`] = `
102
102
  aria-label="Section One Link"
103
103
  class="css-1ulbpfm"
104
104
  href="/section-one"
105
- type="standalone"
106
105
  >
107
106
  <span
108
107
  class="css-1xnclyu"
@@ -126,7 +125,6 @@ exports[`getServerSideProps Homepage 1`] = `
126
125
  aria-label="Section Two Link"
127
126
  class="css-1ulbpfm"
128
127
  href="/section-two"
129
- type="standalone"
130
128
  >
131
129
  <span
132
130
  class="css-1xnclyu"
@@ -150,7 +148,6 @@ exports[`getServerSideProps Homepage 1`] = `
150
148
  aria-label="Section Three Link"
151
149
  class="css-1ulbpfm"
152
150
  href="/section-three"
153
- type="standalone"
154
151
  >
155
152
  <span
156
153
  class="css-1xnclyu"
@@ -102,7 +102,6 @@ exports[`Article should render tile and sub title 1`] = `
102
102
  aria-label="Section One Link"
103
103
  class="css-1ulbpfm"
104
104
  href="/section-one"
105
- type="standalone"
106
105
  >
107
106
  <span
108
107
  class="css-1xnclyu"
@@ -126,7 +125,6 @@ exports[`Article should render tile and sub title 1`] = `
126
125
  aria-label="Section Two Link"
127
126
  class="css-1ulbpfm"
128
127
  href="/section-two"
129
- type="standalone"
130
128
  >
131
129
  <span
132
130
  class="css-1xnclyu"
@@ -150,7 +148,6 @@ exports[`Article should render tile and sub title 1`] = `
150
148
  aria-label="Section Three Link"
151
149
  class="css-1ulbpfm"
152
150
  href="/section-three"
153
- type="standalone"
154
151
  >
155
152
  <span
156
153
  class="css-1xnclyu"
@@ -32,6 +32,10 @@ export const pastDueBanner = {
32
32
  text: 'We have successfully cancelled your subscription and will be processing your refund shortly. If you have any question please call ##PHONE_NUMBER##.',
33
33
  dismissDays: 7,
34
34
  },
35
+ paymentFailure: {
36
+ title: 'We haven’t been able to take payment',
37
+ text: 'Your latest payment has failed. Please update your payment details as soon as possible to keep your membership.',
38
+ },
35
39
  treshold: {
36
40
  firstNotice: 26,
37
41
  secondNotice: 30,
@@ -1,6 +1,6 @@
1
1
  import { getTestDates } from '../../fixtures/testDates'
2
2
 
3
- describe('Book a Holiday Stop', () => {
3
+ describe.skip('Book a Holiday Stop', () => {
4
4
  beforeEach(() => {
5
5
  cy.GetTnlAcsSession('tnl')
6
6
  cy.mockConsentAndVisit('/account/holiday-stop')
@@ -13,7 +13,7 @@ describe('Book a Holiday Stop', () => {
13
13
  })
14
14
  })
15
15
 
16
- describe('Add a Holiday Stop', () => {
16
+ describe.skip('Add a Holiday Stop', () => {
17
17
  beforeEach(() => {
18
18
  cy.GetTnlAcsSession('tnl')
19
19
  cy.mockConsentAndVisit('/account/add/holiday-stop')
@@ -52,7 +52,7 @@ describe('Add a Holiday Stop', () => {
52
52
  })
53
53
  })
54
54
 
55
- describe('Upcoming Holiday Stops - edit button', () => {
55
+ describe.skip('Upcoming Holiday Stops - edit button', () => {
56
56
  beforeEach(() => {
57
57
  cy.GetTnlAcsSession('tnl')
58
58
  cy.mockConsentAndVisit('/account/holiday-stop')
@@ -86,7 +86,7 @@ describe('Upcoming Holiday Stops - edit button', () => {
86
86
  })
87
87
  })
88
88
 
89
- describe('Cancel Holiday Stop', () => {
89
+ describe.skip('Cancel Holiday Stop', () => {
90
90
  beforeEach(() => {
91
91
  cy.GetTnlAcsSession('tnl')
92
92
  cy.mockConsentAndVisit('/account/holiday-stop')
@@ -1,33 +1,53 @@
1
1
  describe('Newsletters page', () => {
2
2
  beforeEach(() => {
3
3
  cy.GetTnlAcsSession()
4
+ cy.mockConsent()
5
+ })
6
+
7
+ // will be fixed in TMR-2284
8
+ it.skip('Should display all the newsletters on the newsletters page when user has a subscription', () => {
4
9
  cy.mockConsentAndVisit('/account/newsletters')
10
+ cy.contains('Newsletters')
11
+ cy.contains(
12
+ 'Exclusive content and a curated selection of our top stories straight to your inbox.'
13
+ )
14
+ cy.get('[data-testid="newsletters-grid"] > div > div').should(
15
+ 'have.length',
16
+ 23
17
+ )
5
18
  })
6
19
 
7
- it('Should display the newsletters page', () => {
20
+ it('Should only display selected newsletters on the newsletters page when user is registered', () => {
21
+ cy.GetTnlAcsSession('tnlNoSubscription')
22
+ cy.mockConsentAndVisit('/account/newsletters')
8
23
  cy.contains('Newsletters')
9
24
  cy.contains(
10
25
  'Exclusive content and a curated selection of our top stories straight to your inbox.'
11
26
  )
12
- cy.get('[data-testid="newsletters-grid"] > div').should('have.length', 20)
27
+ cy.get('[data-testid="newsletters-grid"] > div > div').should(
28
+ 'have.length',
29
+ 6
30
+ )
13
31
  })
14
32
 
15
33
  it('Should display all required newsletter text in the first grid card', () => {
16
- cy.get('[data-testid="newsletters-grid"]').then(($parentDiv) => {
34
+ cy.mockConsentAndVisit('/account/newsletters')
35
+ cy.get('[data-testid="newsletters-grid-featured"]').then(($parentDiv) => {
17
36
  const firstNewsletter = $parentDiv.find('div:first-child')
18
37
 
19
- cy.wrap(firstNewsletter).contains('Business').should('be.visible')
38
+ cy.wrap(firstNewsletter).contains('Daily Briefing').should('be.visible')
20
39
  cy.wrap(firstNewsletter).contains('Daily').should('be.visible')
21
40
  cy.wrap(firstNewsletter)
22
41
  .contains(
23
- "The business editor's exclusive analysis of all the latest financial and economic news."
42
+ 'Our flagship newsletter with our top stories and exclusive analysis every morning.'
24
43
  )
25
44
  .should('be.visible')
26
45
  })
27
46
  })
28
47
 
29
48
  it('Should successfully subscribe to a newsletter', () => {
30
- cy.get('[data-testid="newsletters-grid"]').then(($parentDiv) => {
49
+ cy.mockConsentAndVisit('/account/newsletters')
50
+ cy.get('[data-testid="newsletters-grid-featured"]').then(($parentDiv) => {
31
51
  cy.intercept('POST', '/api/account/mutate', { statusCode: 200, ok: true })
32
52
 
33
53
  const firstNewsletter = $parentDiv.find('div:first-child')
@@ -40,13 +60,14 @@ describe('Newsletters page', () => {
40
60
 
41
61
  cy.contains(
42
62
  '[data-testid="toast-container"]',
43
- 'Thank you, you are now signed up to the Business newsletter'
63
+ 'Thank you, you are now signed up to the Daily Briefing newsletter'
44
64
  )
45
65
  })
46
66
  })
47
67
 
48
68
  it('Should show the error toast on server error', () => {
49
- cy.get('[data-testid="newsletters-grid"]').then(($parentDiv) => {
69
+ cy.mockConsentAndVisit('/account/newsletters')
70
+ cy.get('[data-testid="newsletters-grid-featured"]').then(($parentDiv) => {
50
71
  cy.intercept('POST', '/api/account/mutate', {
51
72
  statusCode: 500,
52
73
  ok: false,
@@ -62,7 +83,7 @@ describe('Newsletters page', () => {
62
83
 
63
84
  cy.contains(
64
85
  '[data-testid="toast-container"]',
65
- 'Sorry we were unable to sign you up to the Business newsletter, please try again'
86
+ 'Sorry we were unable to sign you up to the Daily Briefing newsletter, please try again'
66
87
  )
67
88
  })
68
89
  })
@@ -134,18 +134,18 @@ describe('Subscription and billing details for Digital user', () => {
134
134
  cy.contains('[data-testid="ContentListIntroduction"]', 'Billing details')
135
135
  cy.contains('Payment method')
136
136
  cy.get('[data-testid="visa-icon"]').should('exist')
137
- cy.contains('************1111')
138
- cy.contains('expiry date 03/30')
137
+ cy.contains('************4242')
138
+ cy.contains('expiry date 02/27')
139
139
  })
140
140
 
141
- it('Should display Invoice history section', () => {
142
- cy.contains('[data-testid="ContentListIntroduction"]', 'Invoice history')
143
- cy.contains('Digital pack')
144
- cy.contains('20 Sept 2022')
145
- cy.contains('Paid')
146
- cy.get('a[data-testid="download-button"]')
147
- .should('have.attr', 'href', '#')
148
- .contains('View')
141
+ // Section no longer displayed when Invoice history is empty due to graphql change
142
+ // Invoices are no longer fetched if older than 1 year
143
+ // This test would periodically fail as it depends on changing user data
144
+ it('Should not display empty Invoice history section', () => {
145
+ cy.get('[data-testid="ContentListIntroduction"]').should(
146
+ 'not.contain',
147
+ 'Invoice history'
148
+ )
149
149
  })
150
150
 
151
151
  it('Should NOT display Your deliveries section', () => {
@@ -226,16 +226,6 @@ describe('Subscription and billing details for Print user', () => {
226
226
  )
227
227
  })
228
228
 
229
- it('Should display Invoice history section', () => {
230
- cy.contains('[data-testid="ContentListIntroduction"]', 'Invoice history')
231
- cy.contains('Print pack')
232
- cy.contains('24 Apr 2023')
233
- cy.contains('Paid')
234
- cy.get('a[data-testid="download-button"]')
235
- .should('have.attr', 'href', '#')
236
- .contains('View')
237
- })
238
-
239
229
  it('Should display Your deliveries section for users with vouchers', () => {
240
230
  cy.GetTnlAcsSession('printVouchers')
241
231
  cy.mockConsentAndVisit('/account/subscription-and-billing')
@@ -243,8 +233,6 @@ describe('Subscription and billing details for Print user', () => {
243
233
  cy.contains('[data-testid="ContentListIntroduction"]', 'Your deliveries')
244
234
  cy.contains('Address')
245
235
  cy.contains('2 Tuke House, Cromwell Road, York, YO1 6DJ, North Yorkshire')
246
- cy.contains('Delivery instructions')
247
- cy.contains('On my doorstep')
248
236
  cy.contains('Holiday Stops')
249
237
  cy.contains(
250
238
  'You can pause your print delivery at any time by adding a Holiday Stop to your account. Holiday Stops need to be booked before 16:00 GMT the day before you want to pause delivery.'
@@ -277,16 +265,6 @@ describe('Subscription and billing details for Digi-Print user', () => {
277
265
  cy.contains('Digi-Print')
278
266
  //...rest is same as Print user
279
267
  })
280
-
281
- it('Should display Invoice history section', () => {
282
- cy.contains('[data-testid="ContentListIntroduction"]', 'Invoice history')
283
- cy.contains('Digi-Print pack')
284
- cy.contains('12 Nov 2023')
285
- cy.contains('Paid')
286
- cy.get('a[data-testid="download-button"]')
287
- .should('have.attr', 'href', '#')
288
- .contains('View')
289
- })
290
268
  })
291
269
 
292
270
  describe('Subscription and billing details for Paypal user', () => {
@@ -302,15 +280,6 @@ describe('Subscription and billing details for Paypal user', () => {
302
280
  cy.get('[data-testid="paypal-icon"]').should('exist')
303
281
  cy.contains('cmp.paypal.user.verified.test@news.co.uk')
304
282
  })
305
-
306
- it('Should show inline banner for Paypal subscription', () => {
307
- cy.get('a[href="/account/payment"]').should('be.visible').click()
308
- cy.contains(
309
- '[data-testid="Zuora-inline"]',
310
- 'To update your Paypal credentials, please speak to one of our advisors on xxxx-xxx-xxxx or add a new payment method via credit/debit card using the form below.',
311
- { timeout: 15000 }
312
- )
313
- })
314
283
  })
315
284
 
316
285
  describe('Subscription and billing edit pages', () => {
@@ -1,4 +1,4 @@
1
- //Note: Check periodically if these consent cookie values exprire
1
+ //Note: Check periodically if these consent cookie values expire
2
2
  import _ from 'lodash'
3
3
  import {
4
4
  consentUUIDValue,
@@ -54,5 +54,9 @@ export const userMap = {
54
54
  username: 'digi-print-card-15-11-22@yopmail.com',
55
55
  password: 'Password123Testing123$',
56
56
  },
57
- }
58
-
57
+ tnlNoSubscription: {
58
+ //registered user with no subscription, tests the number of newsletters displayed
59
+ username: 'tm-test+staging-registered-user@news.co.uk',
60
+ password: 'Growth123',
61
+ },
62
+ }
@@ -0,0 +1,20 @@
1
+ import {
2
+ getProviderProps,
3
+ getProviderPropsTimes,
4
+ } from '@newskit-render/my-account'
5
+ import { publisher } from '../config'
6
+
7
+ export const getProviderPropsUtil = (context, options?) => {
8
+ if (process.env.NODE_ENV === 'development' && publisher === 'TIMES') {
9
+ return getProviderPropsTimes({
10
+ context,
11
+ options: {
12
+ ...options,
13
+ },
14
+ })
15
+ }
16
+
17
+ return getProviderProps(context, {
18
+ ...options,
19
+ })
20
+ }
package/next.config.js CHANGED
@@ -29,67 +29,65 @@ module.exports = (phase) => {
29
29
  }
30
30
 
31
31
  const path = require('path')
32
- const withTM = require('next-transpile-modules')([
33
- '@newskit-render/auth',
34
- '@newskit-render/my-account',
35
- '@newskit-render/validation',
36
- ])
37
32
  const withBundleAnalyzer = require('@next/bundle-analyzer')({
38
33
  enabled: process.env.ANALYZE === 'true',
39
34
  })
40
35
 
41
- return withBundleAnalyzer(
42
- withTM({
43
- webpack: (config, options) => {
44
- if (options.isServer) {
45
- config.externals = ['react', ...config.externals]
46
- }
36
+ return withBundleAnalyzer({
37
+ transpilePackages: [
38
+ '@newskit-render/auth',
39
+ '@newskit-render/my-account',
40
+ '@newskit-render/validation',
41
+ ],
42
+ webpack: (config, options) => {
43
+ if (options.isServer) {
44
+ config.externals = ['react', ...config.externals]
45
+ }
47
46
 
48
- config.resolve.alias.newskit = path.resolve(
49
- __dirname,
50
- '.',
51
- 'node_modules',
52
- 'newskit'
53
- )
54
- config.resolve.alias.react = path.resolve(
55
- __dirname,
56
- '.',
57
- 'node_modules',
58
- 'react'
59
- )
47
+ config.resolve.alias.newskit = path.resolve(
48
+ __dirname,
49
+ '.',
50
+ 'node_modules',
51
+ 'newskit'
52
+ )
53
+ config.resolve.alias.react = path.resolve(
54
+ __dirname,
55
+ '.',
56
+ 'node_modules',
57
+ 'react'
58
+ )
60
59
 
61
- return config
62
- },
63
- images,
64
- output: 'standalone',
65
- async rewrites() {
66
- return [
67
- {
68
- source: '/sitemap.xml',
69
- destination: '/api/sitemap',
70
- },
71
- {
72
- source: '/pages-sitemap.xml',
73
- destination: '/api/pages-sitemap',
74
- },
75
- {
76
- source: '/competitions-sitemap.xml',
77
- destination: '/api/competitions-sitemap',
78
- },
79
- {
80
- source: '/news-sitemap.xml',
81
- destination: '/api/news-sitemap',
82
- },
83
- {
84
- source: '/feed',
85
- destination: '/api/feed',
86
- },
87
- {
88
- source: '/robots.txt',
89
- destination: '/api/robots',
90
- },
91
- ]
92
- },
93
- })
94
- )
60
+ return config
61
+ },
62
+ images,
63
+ output: 'standalone',
64
+ async rewrites() {
65
+ return [
66
+ {
67
+ source: '/sitemap.xml',
68
+ destination: '/api/sitemap',
69
+ },
70
+ {
71
+ source: '/pages-sitemap.xml',
72
+ destination: '/api/pages-sitemap',
73
+ },
74
+ {
75
+ source: '/competitions-sitemap.xml',
76
+ destination: '/api/competitions-sitemap',
77
+ },
78
+ {
79
+ source: '/news-sitemap.xml',
80
+ destination: '/api/news-sitemap',
81
+ },
82
+ {
83
+ source: '/feed',
84
+ destination: '/api/feed',
85
+ },
86
+ {
87
+ source: '/robots.txt',
88
+ destination: '/api/robots',
89
+ },
90
+ ]
91
+ },
92
+ })
95
93
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@newskit-render/core",
3
- "version": "0.0.0-caeaa514b",
3
+ "version": "0.0.0-cc45b00ad",
4
4
  "description": "Newskit Render - Core package",
5
5
  "author": "",
6
6
  "license": "UNLICENSED",
@@ -42,21 +42,21 @@
42
42
  "@emotion/styled": "11.9.3",
43
43
  "@newrelic/next": "0.5.2",
44
44
  "@newrelic/winston-enricher": "4.0.1",
45
- "@newskit-render/api": "^1.12.2",
46
- "@newskit-render/auth": "^1.8.1",
47
- "@newskit-render/checkout": "^3.10.10",
48
- "@newskit-render/feature-flags": "^1.10.0",
49
- "@newskit-render/feed": "^1.8.10",
50
- "@newskit-render/my-account": "^7.64.1",
51
- "@newskit-render/shared-components": "^4.31.4",
52
- "@newskit-render/standalone-components": "^3.21.10",
53
- "@newskit-render/validation": "^1.17.1",
45
+ "@newskit-render/api": "^1.16.13",
46
+ "@newskit-render/auth": "^1.8.32",
47
+ "@newskit-render/checkout": "^3.10.69",
48
+ "@newskit-render/feature-flags": "^1.11.29",
49
+ "@newskit-render/feed": "^1.8.48",
50
+ "@newskit-render/my-account": "^7.110.8",
51
+ "@newskit-render/shared-components": "^4.47.22",
52
+ "@newskit-render/standalone-components": "^3.25.39",
53
+ "@newskit-render/validation": "^1.19.29",
54
54
  "cross-fetch": "3.1.5",
55
55
  "graphql": "16.6.0",
56
56
  "lodash.get": "4.4.2",
57
57
  "newrelic": "10.6.1",
58
58
  "newskit": "7.7.0",
59
- "next": "13.4.4",
59
+ "next": "13.5.10",
60
60
  "react": "18.2.0",
61
61
  "react-dom": "18.2.0",
62
62
  "react-helmet": "6.1.0",
@@ -100,11 +100,10 @@
100
100
  "jest-junit": "15.0.0",
101
101
  "jest-watch-typeahead": "2.2.1",
102
102
  "lint-staged": "13.1.0",
103
- "next-transpile-modules": "10.0.0",
104
103
  "prettier": "2.8.3",
105
104
  "prettier-eslint": "15.0.1",
106
105
  "prettier-eslint-cli": "7.1.0",
107
- "typescript": "4.9.4",
106
+ "typescript": "5.6.3",
108
107
  "wait-on": "7.0.1"
109
108
  },
110
109
  "precommit": [
@@ -1,13 +1,10 @@
1
1
  import React from 'react'
2
2
  import { replaceConsoleAndSetTransactionName } from '../../../helpers/logger'
3
- import {
4
- AddField,
5
- addComponentMap,
6
- getProviderPropsTimes,
7
- // getProviderProps,
8
- } from '@newskit-render/my-account'
3
+ import { AddField, addComponentMap } from '@newskit-render/my-account'
9
4
  import validation from '../../../validation'
10
5
  import { DynamicPage } from '@newskit-render/my-account'
6
+ import { getAllFeatureFlags } from '@newskit-render/feature-flags' /* cra-effected */
7
+ import { getProviderPropsUtil } from '../../../helpers/getProviderPropsUtil'
11
8
 
12
9
  const AccountAddField = (props) => (
13
10
  <DynamicPage
@@ -20,67 +17,27 @@ const AccountAddField = (props) => (
20
17
  )
21
18
 
22
19
  export default AccountAddField
23
- // export const getServerSideProps = async (context) => {
24
- // const {
25
- // params: { field },
26
- // } = context
27
- // const doesAddpageExist = Object.keys(addComponentMap).includes(field)
28
- // replaceConsoleAndSetTransactionName(`Account: add ${field}`)
29
-
30
- // if (!doesAddpageExist) {
31
- // context.res.statusCode = 404
32
- // // Logging the error for being captured by New Relic
33
- // console.error(`An error ${context.res.statusCode} occurred on server`)
34
- // }
35
-
36
- // return {
37
- // props: { data: { type: field } },
38
- // }
39
- // }
40
-
41
20
  export const getServerSideProps = async (context) => {
42
- // const featureFlags = await getAllFeatureFlags(
43
- // getUserAttributes(context?.req?.headers)
44
- // )
45
-
46
21
  const {
47
22
  params: { field },
48
23
  } = context
49
- const doesAddPageExist = Object.keys(addComponentMap).includes(field)
50
-
24
+ const doesAddpageExist = Object.keys(addComponentMap).includes(field)
51
25
  replaceConsoleAndSetTransactionName(`Account: add ${field}`)
52
26
 
53
- const defaultPageResponse = {
54
- props: { data: { type: field }, requestHeaders: context.req.headers },
55
- }
56
-
57
- const getProviderPropsResponse = (await getProviderPropsTimes({
58
- ...context,
59
- provider: 'AddField',
60
- })) as unknown as { props: unknown }
61
- console.log('getProviderPropsResponse', getProviderPropsResponse)
62
-
63
- if (!doesAddPageExist) {
27
+ if (!doesAddpageExist) {
64
28
  context.res.statusCode = 404
65
29
  // Logging the error for being captured by New Relic
66
30
  console.error(`An error ${context.res.statusCode} occurred on server`)
67
-
68
- // The 404 logic for non-existent [add] components is added in the DynamicPage
69
- return defaultPageResponse
70
31
  }
71
32
 
72
- const { isUserFamilyAccountPrimary } =
73
- // @ts-ignore
74
- getProviderPropsResponse.props.user
33
+ const featureFlags = await getAllFeatureFlags()
34
+ const providerProps = (await getProviderPropsUtil(
35
+ { ...context, provider: 'AddField' },
36
+ { featureFlags } /* cra-effected */
37
+ )) as unknown as { props: { data: { type: string } } }
75
38
 
76
- if (field === 'family' && !isUserFamilyAccountPrimary) {
77
- return {
78
- redirect: {
79
- permanent: false,
80
- destination: '/404',
81
- },
82
- }
39
+ if (providerProps?.props) {
40
+ providerProps.props = { ...providerProps.props, data: { type: field } }
83
41
  }
84
-
85
- return defaultPageResponse
42
+ return providerProps
86
43
  }
@@ -1,19 +1,24 @@
1
1
  import React from 'react'
2
- import { Family, getProviderPropsTimes } from '@newskit-render/my-account'
2
+ import { Family } from '@newskit-render/my-account'
3
3
  import { replaceConsoleAndSetTransactionName } from '../../../helpers/logger'
4
4
  import { getAllFeatureFlags } from '@newskit-render/feature-flags' /* cra-effected */
5
+ import { getProviderPropsUtil } from '../../../helpers/getProviderPropsUtil'
5
6
 
6
7
  const AccountFamily = (props) => <Family {...props} />
7
8
 
8
9
  export default AccountFamily
9
10
 
10
11
  export const getServerSideProps = async (context) => {
11
- replaceConsoleAndSetTransactionName('Account: Family')
12
+ replaceConsoleAndSetTransactionName('Account: Bonus Accounts')
12
13
  /* start cra-effected */
13
14
  const featureFlags = await getAllFeatureFlags()
15
+
14
16
  /* end cra-effected */
15
- return getProviderPropsTimes(
16
- { ...context, provider: 'GroupAccounts' },
17
+ return getProviderPropsUtil(
18
+ {
19
+ ...context,
20
+ provider: 'GroupAccountsV2',
21
+ },
17
22
  { featureFlags } /* cra-effected */
18
23
  )
19
24
  }
@@ -1,8 +1,9 @@
1
1
  import React from 'react'
2
- import { Cancellation, getProviderProps } from '@newskit-render/my-account'
2
+ import { Cancellation } from '@newskit-render/my-account'
3
3
  import { replaceConsoleAndSetTransactionName } from '../../../helpers/logger'
4
4
  import { getAllFeatureFlags } from '@newskit-render/feature-flags' /* cra-effected */
5
5
  import validation from '../../../validation'
6
+ import { getProviderPropsUtil } from '../../../helpers/getProviderPropsUtil'
6
7
 
7
8
  const AccountCancellation = (props) => (
8
9
  <Cancellation {...props} validation={validation} />
@@ -15,7 +16,7 @@ export const getServerSideProps = async (context) => {
15
16
  /* start cra-effected */
16
17
  const featureFlags = await getAllFeatureFlags()
17
18
  /* end cra-effected */
18
- return getProviderProps(
19
+ return getProviderPropsUtil(
19
20
  { ...context, provider: 'Cancellation' },
20
21
  { featureFlags } /* cra-effected */
21
22
  )