@newskit-render/core 1.29.4 → 1.32.1

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/CHANGELOG.md CHANGED
@@ -3,6 +3,58 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [1.32.1](https://github.com/newscorp-ghfb/ncu-newskit-render/compare/@newskit-render/core@1.32.0...@newskit-render/core@1.32.1) (2022-03-09)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **PPDSR-633:** update temp header ([#622](https://github.com/newscorp-ghfb/ncu-newskit-render/issues/622)) ([dc77a3a](https://github.com/newscorp-ghfb/ncu-newskit-render/commit/dc77a3ae4e946523817a67a210516c88fc43f768))
12
+
13
+
14
+
15
+
16
+
17
+ # [1.32.0](https://github.com/newscorp-ghfb/ncu-newskit-render/compare/@newskit-render/core@1.31.0...@newskit-render/core@1.32.0) (2022-03-09)
18
+
19
+
20
+ ### Features
21
+
22
+ * **PPDSR-633:** Update payment failure to MAIN ([#618](https://github.com/newscorp-ghfb/ncu-newskit-render/issues/618)) ([3de75ac](https://github.com/newscorp-ghfb/ncu-newskit-render/commit/3de75acaed7fbd2e994d36f2c070fced6c2ea123))
23
+
24
+
25
+
26
+
27
+
28
+ # [1.31.0](https://github.com/newscorp-ghfb/ncu-newskit-render/compare/@newskit-render/core@1.30.0...@newskit-render/core@1.31.0) (2022-03-09)
29
+
30
+
31
+ ### Features
32
+
33
+ * **PPDSR-678:** add feed package ([#620](https://github.com/newscorp-ghfb/ncu-newskit-render/issues/620)) ([903cbdf](https://github.com/newscorp-ghfb/ncu-newskit-render/commit/903cbdf24e0ed0a1dea301a03f9d78cf7357187e))
34
+
35
+
36
+
37
+
38
+
39
+ # [1.30.0](https://github.com/newscorp-ghfb/ncu-newskit-render/compare/@newskit-render/core@1.29.5...@newskit-render/core@1.30.0) (2022-03-07)
40
+
41
+
42
+ ### Features
43
+
44
+ * **PPDSR-627:** update-account-cancellation ([#593](https://github.com/newscorp-ghfb/ncu-newskit-render/issues/593)) ([9b70d1c](https://github.com/newscorp-ghfb/ncu-newskit-render/commit/9b70d1c8c670541b3d084073f372274951006ade))
45
+
46
+
47
+
48
+
49
+
50
+ ## [1.29.5](https://github.com/newscorp-ghfb/ncu-newskit-render/compare/@newskit-render/core@1.29.4...@newskit-render/core@1.29.5) (2022-03-03)
51
+
52
+ **Note:** Version bump only for package @newskit-render/core
53
+
54
+
55
+
56
+
57
+
6
58
  ## [1.29.4](https://github.com/newscorp-ghfb/ncu-newskit-render/compare/@newskit-render/core@1.29.3...@newskit-render/core@1.29.4) (2022-03-02)
7
59
 
8
60
 
@@ -5,7 +5,7 @@ import Article, {
5
5
  } from '../../pages/[section]/[articleId]/[articleSlug]'
6
6
  import { renderWithQuery } from '../../helpers/test-utils'
7
7
  import { getUniversalArticleMock } from '../../helpers/mocks'
8
- import { URL, Slug, UserData } from '../../helpers/global-types'
8
+ import { URL, Slug } from '../../helpers/global-types'
9
9
 
10
10
  const props: ArticleSlug = {
11
11
  universalArticle: {
@@ -59,25 +59,18 @@ const props: ArticleSlug = {
59
59
  gscId: '4320982',
60
60
  }
61
61
 
62
- const userMock = {
63
- vxInstances: [
64
- {
65
- interactions: [
66
- {
67
- pastDue: {
68
- isPastDue: false,
69
- since: new Date(),
70
- },
71
- },
72
- ],
73
- },
74
- ],
75
- } as UserData
62
+ const user = {
63
+ paymentFailure: {
64
+ active: false,
65
+ startDate: null,
66
+ },
67
+ subscriptions: [{ endDate: null }],
68
+ }
76
69
 
77
70
  jest.mock('cross-fetch', () =>
78
71
  jest.fn().mockImplementation(() =>
79
72
  Promise.resolve({
80
- json: () => Promise.resolve(userMock),
73
+ json: () => Promise.resolve(user),
81
74
  })
82
75
  )
83
76
  )
@@ -93,13 +86,12 @@ jest.mock('@newskit-render/api', () => ({
93
86
  }),
94
87
  })
95
88
  }),
96
- getMainSession: jest.fn(),
89
+ getAcsCookie: jest.fn().mockReturnValue({ Cookie: 'something' }),
97
90
  }))
98
91
 
99
92
  jest.mock('@newskit-render/my-account', () => {
100
93
  return {
101
94
  PastDueBannerExternal: 'PastDueBannerExternal',
102
- getMainSession: jest.fn(),
103
95
  }
104
96
  })
105
97
 
@@ -138,7 +130,7 @@ describe('Article', () => {
138
130
  req: { headers: { cookie: 'some-cookie' } },
139
131
  res: { setHeader: setHeaderMock },
140
132
  })
141
- expect(response).toEqual({ props: { ...props, showAds: true } })
133
+ expect(response).toEqual({ props: { ...props, showAds: true, user } })
142
134
  expect(setHeaderMock).toHaveBeenCalledWith(
143
135
  'Cache-Control',
144
136
  'public, s-maxage=10, stale-while-revalidate=59'
@@ -573,10 +573,6 @@ exports[`getServerSideProps Homepage 1`] = `
573
573
  </div>
574
574
  </div>
575
575
  </div>
576
- <pastduebannerexternal
577
- pastduebanner="[object Object]"
578
- wrapper="NO_COMPONENT_SELECTOR"
579
- />
580
576
  @media screen {
581
577
  .emotion-0 {
582
578
  background-color: #FFFFFF;
@@ -7,6 +7,14 @@ jest.mock('../../helpers/getYear', () => ({
7
7
  getYear: jest.fn().mockReturnValue('YYYY'),
8
8
  }))
9
9
 
10
+ const user = {
11
+ paymentFailure: {
12
+ active: false,
13
+ startDate: null,
14
+ },
15
+ subscriptions: [{ endDate: null }],
16
+ }
17
+
10
18
  jest.mock('@newskit-render/api', () => ({
11
19
  ClientTypes: { nkapi: 'nkapi' },
12
20
  createApolloClient: jest.fn().mockImplementation(() => {
@@ -23,16 +31,13 @@ jest.mock('@newskit-render/api', () => ({
23
31
  }),
24
32
  })
25
33
  }),
26
- getMainSession: jest.fn(),
34
+ getAcsCookie: jest.fn().mockReturnValue({ Cookie: 'something' }),
27
35
  }))
28
36
 
29
37
  jest.mock('cross-fetch', () =>
30
38
  jest.fn().mockImplementation(() =>
31
39
  Promise.resolve({
32
- json: () =>
33
- Promise.resolve({
34
- vxInstances: null,
35
- }),
40
+ json: () => Promise.resolve(user),
36
41
  })
37
42
  )
38
43
  )
@@ -66,6 +71,7 @@ describe('getServerSideProps', () => {
66
71
  },
67
72
  },
68
73
  showAds: true,
74
+ user,
69
75
  },
70
76
  })
71
77
  )
@@ -573,10 +573,6 @@ exports[`Article should render tile and sub title 1`] = `
573
573
  </div>
574
574
  </div>
575
575
  </div>
576
- <pastduebannerexternal
577
- pastduebanner="[object Object]"
578
- wrapper="NO_COMPONENT_SELECTOR"
579
- />
580
576
  @media screen {
581
577
  .emotion-0 {
582
578
  background-color: #FFFFFF;
@@ -14,6 +14,7 @@ import {
14
14
  Divider,
15
15
  } from 'newskit'
16
16
  import { SEOComponent } from '@newskit-render/shared-components'
17
+ import { UserData } from '@newskit-render/my-account'
17
18
  import MetaBoxComponent from './MetaBox'
18
19
  import Ad from '../ad'
19
20
  import Highlights from './Highlights'
@@ -27,7 +28,6 @@ import {
27
28
  Topic,
28
29
  Byline,
29
30
  ParagraphBlock,
30
- UserData,
31
31
  } from '../../helpers/global-types'
32
32
  import ShareButton from '../common/ShareButton'
33
33
  import Layout from '../layout'
@@ -2,8 +2,10 @@ import { fireEvent } from '@testing-library/react'
2
2
  import { renderWithTheme } from '../../helpers/test-utils'
3
3
  import Header from '.'
4
4
 
5
- jest.mock('@newskit-render/my-account', () => {
5
+ jest.mock('@newskit-render/shared-components', () => {
6
6
  return {
7
+ // @ts-ignore
8
+ ...jest.requireActual('@newskit-render/shared-components'),
7
9
  PastDueBannerExternal: 'PastDueBannerExternal',
8
10
  }
9
11
  })
@@ -12,13 +12,14 @@ import {
12
12
  IconFilledMenu,
13
13
  Image,
14
14
  } from 'newskit'
15
- import { PastDueBannerExternal } from '@newskit-render/my-account'
15
+ import { UserData } from '@newskit-render/my-account'
16
16
  import {
17
17
  NextLink,
18
18
  theSunTheme,
19
19
  timesTheme,
20
20
  virginRadioTheme,
21
21
  ThemeDropdown,
22
+ PastDueBannerExternal,
22
23
  } from '@newskit-render/shared-components'
23
24
  import {
24
25
  renderCustomLightTheme as LightTheme,
@@ -30,7 +31,6 @@ import NewsKitLogoShort from '../common/NewskitLogoShort'
30
31
  import NavLink from '../common/NavLink'
31
32
  import { AppContext } from '../../app-context/AppContext'
32
33
  import { handleEnterKeyPress } from '../../helpers/a11y'
33
- import { UserData, VxInstance } from '../../helpers/global-types'
34
34
 
35
35
  export const headerSize = 'sizing090'
36
36
 
@@ -80,6 +80,12 @@ const pastDueBanner = {
80
80
  text:
81
81
  'You’ll no longer have access to subscription benefits. To re-activate call 0800 555 1234.',
82
82
  },
83
+ toBeCancelled: {
84
+ title: 'Your subscription will end soon.',
85
+ phoneNumber: '0800 555 1234',
86
+ text:
87
+ 'You have cacelled your subscription and will lose access to all benefits on ##DATE##. To re-activate your subcsription call ##PHONE_NUMBER##.',
88
+ },
83
89
  treshold: {
84
90
  firstNotice: 26,
85
91
  secondNotice: 30,
@@ -280,7 +286,7 @@ const Header: React.FC<{ user: UserData }> = ({ user }) => {
280
286
  </StyledHeader>
281
287
  <PastDueBannerExternal
282
288
  pastDueBanner={pastDueBanner}
283
- vxInstances={user?.vxInstances as VxInstance[]}
289
+ user={user}
284
290
  wrapper={BannerContainer}
285
291
  />
286
292
  </>
@@ -1,10 +1,10 @@
1
1
  import React from 'react'
2
+ import { UserData } from '@newskit-render/my-account'
2
3
  import Header from '../header'
3
4
  import Footer from '../footer'
4
5
  import { Gutter } from './Gutter'
5
6
  import { LayoutProps } from './layoutTypes'
6
7
  import { MainGrid } from './MainGrid'
7
- import { UserData } from '../../helpers/global-types'
8
8
 
9
9
  const LayoutTemplate: React.FC<LayoutProps> = ({
10
10
  children,
@@ -1,6 +1,6 @@
1
1
  import React from 'react'
2
2
  import { GridProps } from 'newskit'
3
- import { UserData } from '../../helpers/global-types'
3
+ import { UserData } from '@newskit-render/my-account'
4
4
 
5
5
  export type LayoutProps = {
6
6
  children: React.ReactNode
@@ -1,7 +1,7 @@
1
1
  import React from 'react'
2
2
  import { Cell } from 'newskit'
3
-
4
- import { Page, UserData } from '../../helpers/global-types'
3
+ import { UserData } from '@newskit-render/my-account'
4
+ import { Page } from '../../helpers/global-types'
5
5
  import Layout from '../layout'
6
6
  import pageBlock from './pageBlock'
7
7
  import SectionTitleBar from '../common/SectionTitleBar'
@@ -13,7 +13,10 @@ describe('getUser function', () => {
13
13
  it("should call console.error with 'Bad response from server' when Response.status >= 400", async () => {
14
14
  jest.spyOn(console, 'error')
15
15
  fetchMock.mockImplementation(() => Promise.resolve({ status: 500 }))
16
- await fetchUser('', 'http://localhost:3000/api/account/query')
16
+ await fetchUser(
17
+ { Cookie: 'test' },
18
+ 'http://localhost:3000/api/account/query'
19
+ )
17
20
  expect(console.error).toHaveBeenCalledWith('Bad response from server')
18
21
  })
19
22
 
@@ -22,7 +25,22 @@ describe('getUser function', () => {
22
25
  fetchMock.mockImplementation(() =>
23
26
  Promise.resolve({ status: 200, json: mockJson })
24
27
  )
25
- await fetchUser('', 'http://localhost:3000/api/account/query')
28
+ await fetchUser(
29
+ { Cookie: 'test' },
30
+ 'http://localhost:3000/api/account/query'
31
+ )
26
32
  expect(mockJson).toHaveBeenCalled()
27
33
  })
34
+
35
+ it('should return null if no cookie', async () => {
36
+ const mockJson = jest.fn()
37
+ fetchMock.mockImplementation(() =>
38
+ Promise.resolve({ status: 200, json: mockJson })
39
+ )
40
+ await fetchUser(
41
+ "I'm not a cookie",
42
+ 'http://localhost:3000/api/account/query'
43
+ )
44
+ expect(mockJson).not.toHaveBeenCalled()
45
+ })
28
46
  })
@@ -1,5 +1,6 @@
1
1
  import fetch from 'cross-fetch'
2
- import { UserData } from './global-types'
2
+ import { UserData } from '@newskit-render/my-account'
3
+ import { MainAcsCookie } from '@newskit-render/api'
3
4
 
4
5
  interface UserHeaders {
5
6
  [key: string]: string
@@ -10,23 +11,26 @@ interface UserConfig {
10
11
  body: string
11
12
  }
12
13
 
13
- const userConfig = (session: string): UserConfig => ({
14
+ const userConfig = (acsCookie: { Cookie: string }): UserConfig => ({
14
15
  method: 'POST',
15
16
  headers: {
16
17
  'Content-Type': 'application/json',
17
- 'X-MAIN-SESSION': session,
18
+ ...acsCookie,
18
19
  },
19
- body: JSON.stringify({ queryFragment: 'UserPaymentInstance' }),
20
+ body: JSON.stringify({ queryFragment: 'UserPaymentInfo' }),
20
21
  })
21
22
 
22
23
  export const fetchUser = async (
23
- session: string,
24
+ acsCookie: MainAcsCookie,
24
25
  url: string
25
26
  ): Promise<UserData | null> => {
26
- const response = await fetch(url, userConfig(session))
27
- if (response.status >= 400) {
28
- console.error('Bad response from server')
29
- return null
27
+ if (typeof acsCookie === 'object') {
28
+ const response = await fetch(url, userConfig(acsCookie))
29
+ if (response.status >= 400) {
30
+ console.error('Bad response from server')
31
+ return null
32
+ }
33
+ return (await response.json()) as UserData
30
34
  }
31
- return (await response.json()) as UserData
35
+ return null
32
36
  }
@@ -3,35 +3,6 @@ export enum ContentType {
3
3
  post,
4
4
  }
5
5
 
6
- export interface UserData {
7
- firstName?: string
8
- lastName?: string
9
- cpn?: string
10
- email?: string
11
- hash?: string
12
- customData?: string
13
- displayName?: string
14
- vxInstances?: VxInstance[]
15
- }
16
-
17
- export interface VxInstance {
18
- spec?: {
19
- description: string
20
- id: string
21
- isActive: string
22
- name: string
23
- }
24
- interactions: [SubscriptionPaymentInstance]
25
- }
26
-
27
- export interface PastDue {
28
- isPastDue: boolean
29
- since: Date
30
- }
31
- export interface SubscriptionPaymentInstance {
32
- pastDue: PastDue
33
- }
34
-
35
6
  export type RadioPost = {
36
7
  id: number
37
8
  type: ContentType
@@ -240,7 +240,6 @@ orbs:
240
240
  echo 'export HELM_OPT_SET="$HELM_OPT_SET --set secret.items.NEW_RELIC_LICENSE_KEY=${NEW_RELIC_LICENSE_KEY}"' >> $BASH_ENV
241
241
  echo 'export HELM_OPT_SET="$HELM_OPT_SET --set secret.items.MAIN_GRAPHQL_URL=${MAIN_GRAPHQL_URL}"' >> $BASH_ENV
242
242
  echo 'export HELM_OPT_SET="$HELM_OPT_SET --set secret.items.MAIN_COOKIE_NAME=${MAIN_COOKIE_NAME}"' >> $BASH_ENV
243
- echo 'export HELM_OPT_SET="$HELM_OPT_SET --set secret.items.MAIN_USER_ID=${MAIN_USER_ID}"' >> $BASH_ENV
244
243
  echo 'export HELM_OPT_SET="$HELM_OPT_SET --set secret.items.MAIN_AUDIENCE=${MAIN_AUDIENCE}"' >> $BASH_ENV
245
244
  echo 'export HELM_OPT_SET="$HELM_OPT_SET --set secret.items.MAIN_OAUTH_TOKEN=${MAIN_OAUTH_TOKEN}"' >> $BASH_ENV
246
245
  echo 'export HELM_OPT_SET="$HELM_OPT_SET --set secret.items.MAIN_CLIENT_ID=${MAIN_CLIENT_ID}"' >> $BASH_ENV
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@newskit-render/core",
3
- "version": "1.29.4",
3
+ "version": "1.32.1",
4
4
  "description": "Newskit Render - Core package",
5
5
  "author": "",
6
6
  "license": "UNLICENSED",
@@ -35,12 +35,12 @@
35
35
  "@apollo/client": "3.4.16",
36
36
  "@newskit-render/api": "^0.15.0",
37
37
  "@newskit-render/auth": "^0.29.0",
38
- "@newskit-render/checkout": "^0.24.2",
38
+ "@newskit-render/checkout": "^0.24.3",
39
39
  "@newskit-render/feature-flags": "^0.11.0",
40
- "@newskit-render/my-account": "^0.142.3",
41
- "@newskit-render/shared-components": "^0.37.2",
40
+ "@newskit-render/my-account": "^0.144.0",
41
+ "@newskit-render/shared-components": "^0.38.0",
42
42
  "@newskit-render/sitemap": "^0.35.0",
43
- "@newskit-render/validation": "^0.36.0",
43
+ "@newskit-render/validation": "^0.37.0",
44
44
  "cross-fetch": "3.1.5",
45
45
  "graphql": "15.6.0",
46
46
  "newrelic": "7.1.0",
@@ -1,12 +1,16 @@
1
1
  import React from 'react'
2
2
  import newrelic from 'newrelic'
3
- import { createApolloClient, ClientTypes } from '@newskit-render/api'
3
+ import {
4
+ createApolloClient,
5
+ ClientTypes,
6
+ getAcsCookie,
7
+ } from '@newskit-render/api'
8
+ import { UserData } from '@newskit-render/my-account'
4
9
  import { GET_UNIVERSAL_ARTICLE } from '../../../queries'
5
10
  import ArticlePage, { UniversalArticle } from '../../../components/article'
6
11
  import { highlights, relatedArticles } from '../../../helpers/mocks/articleMock'
7
- import { UserData } from '../../../helpers/global-types'
8
- // import { fetchUser } from '../../../helpers/getUser'
9
- // import { ACCOUNT_QUERY_URL } from '../../../constants'
12
+ import { fetchUser } from '../../../helpers/getUser'
13
+ import { ACCOUNT_QUERY_URL } from '../../../constants'
10
14
  import { addCacheHeaders } from '../../../helpers/addCacheHeaders'
11
15
 
12
16
  export type ArticleSlug = {
@@ -41,7 +45,9 @@ const Article: React.FC<ArticleSlug> = ({
41
45
 
42
46
  export async function getServerSideProps(context) {
43
47
  const apolloClient = await createApolloClient(ClientTypes.nkapi)
44
- // const mainSession = getMainSession(context.req.headers.cookie)
48
+ const acsCookie = context.req.headers.cookie
49
+ ? getAcsCookie(ClientTypes.main, context.req.headers.cookie)
50
+ : ''
45
51
 
46
52
  const {
47
53
  params: { articleId, section, articleSlug },
@@ -51,15 +57,12 @@ export async function getServerSideProps(context) {
51
57
  `Article: /${section}/${articleId}/${articleSlug}`
52
58
  )
53
59
 
54
- const [
55
- { data },
56
- // user
57
- ] = await Promise.all([
60
+ const [{ data }, user] = await Promise.all([
58
61
  apolloClient.query({
59
62
  query: GET_UNIVERSAL_ARTICLE,
60
63
  variables: { publisher: 'DEMO', id: articleId },
61
64
  }),
62
- // await fetchUser(mainSession, ACCOUNT_QUERY_URL),
65
+ await fetchUser(acsCookie, ACCOUNT_QUERY_URL),
63
66
  ])
64
67
 
65
68
  addCacheHeaders(context.res)
@@ -71,7 +74,7 @@ export async function getServerSideProps(context) {
71
74
  siteHost: process.env.SITE_HOST || '',
72
75
  gscId: process.env.GSC_ID || '',
73
76
  showAds: true,
74
- // user,
77
+ user,
75
78
  },
76
79
  }
77
80
  }
@@ -1,13 +1,13 @@
1
1
  import newrelic from 'newrelic'
2
2
  import {
3
3
  createApolloClient,
4
- // getMainSession,
4
+ getAcsCookie,
5
5
  ClientTypes,
6
6
  } from '@newskit-render/api'
7
7
  import { GET_PAGE } from '../../queries'
8
8
  import SectionPage from '../../components/section'
9
- // import { fetchUser } from '../../helpers/getUser'
10
- // import { ACCOUNT_QUERY_URL } from '../../constants'
9
+ import { fetchUser } from '../../helpers/getUser'
10
+ import { ACCOUNT_QUERY_URL } from '../../constants'
11
11
  import { addCacheHeaders } from '../../helpers/addCacheHeaders'
12
12
 
13
13
  export async function getServerSideProps(context) {
@@ -17,20 +17,17 @@ export async function getServerSideProps(context) {
17
17
  params: { section },
18
18
  } = context
19
19
 
20
- // const mainSession = getMainSession(context.req.headers.cookie)
20
+ const acsCookie = context.req.headers.cookie
21
+ ? getAcsCookie(ClientTypes.main, context.req.headers.cookie)
22
+ : ''
21
23
 
22
24
  newrelic.setTransactionName(`Section: ${section}`)
23
- const [
24
- { data },
25
- // user
26
- ] = await Promise.all([
25
+ const [{ data }, user] = await Promise.all([
27
26
  apolloClient.query({
28
27
  query: GET_PAGE,
29
28
  variables: { channel: section, publisher: 'DEMO' },
30
29
  }),
31
-
32
- // TODO: Enable once Main add Subscriptions
33
- // await fetchUser(mainSession, ACCOUNT_QUERY_URL),
30
+ await fetchUser(acsCookie, ACCOUNT_QUERY_URL),
34
31
  ])
35
32
 
36
33
  addCacheHeaders(context.res)
@@ -39,7 +36,7 @@ export async function getServerSideProps(context) {
39
36
  page: data.page,
40
37
  isIndexPage: true,
41
38
  showAds: true,
42
- // user,
39
+ user,
43
40
  },
44
41
  }
45
42
  }
package/pages/index.tsx CHANGED
@@ -1,13 +1,13 @@
1
1
  import newrelic from 'newrelic'
2
2
  import {
3
3
  createApolloClient,
4
- // getMainSession,
4
+ getAcsCookie,
5
5
  ClientTypes,
6
6
  } from '@newskit-render/api'
7
7
  import { GET_PAGE } from '../queries'
8
8
  import SectionPage from '../components/section'
9
- // import { fetchUser } from '../helpers/getUser'
10
- // import { ACCOUNT_QUERY_URL } from '../constants'
9
+ import { fetchUser } from '../helpers/getUser'
10
+ import { ACCOUNT_QUERY_URL } from '../constants'
11
11
  import { addCacheHeaders } from '../helpers/addCacheHeaders'
12
12
 
13
13
  export async function getServerSideProps(context) {
@@ -16,18 +16,16 @@ export async function getServerSideProps(context) {
16
16
  console.warn(context.req && context.req.headers)
17
17
 
18
18
  const apolloClient = await createApolloClient(ClientTypes.nkapi)
19
- // const mainSession = getMainSession(context.req.headers.cookie)
19
+ const acsCookie = context.req.headers.cookie
20
+ ? getAcsCookie(ClientTypes.main, context.req.headers.cookie)
21
+ : ''
20
22
 
21
- const [
22
- { data },
23
- // user
24
- ] = await Promise.all([
23
+ const [{ data }, user] = await Promise.all([
25
24
  apolloClient.query({
26
25
  query: GET_PAGE,
27
26
  variables: { channel: 'homepage', publisher: 'DEMO' },
28
27
  }),
29
- // TODO: Enable once Main add Subscriptions
30
- // await fetchUser(mainSession, ACCOUNT_QUERY_URL),
28
+ await fetchUser(acsCookie, ACCOUNT_QUERY_URL),
31
29
  ])
32
30
 
33
31
  addCacheHeaders(context.res)
@@ -36,10 +34,9 @@ export async function getServerSideProps(context) {
36
34
  props: {
37
35
  page,
38
36
  showAds: true,
39
- // user: (user || null),
37
+ user,
40
38
  },
41
39
  }
42
40
  }
43
41
 
44
- // TEST RELEASE_CLI
45
42
  export default SectionPage
package/temp/header.tsx CHANGED
@@ -11,14 +11,13 @@ import {
11
11
  Block,
12
12
  IconFilledMenu,
13
13
  } from 'newskit'
14
- import { NextLink } from '@newskit-render/shared-components'
15
- import { PastDueBannerExternal } from '@newskit-render/my-account'
14
+ import { UserData } from '@newskit-render/my-account'
15
+ import { NextLink, PastDueBannerExternal } from '@newskit-render/shared-components'
16
16
  import { MainGrid } from '../layout/MainGrid'
17
17
  import NewsKitLogoFull from '../common/NewskitLogo'
18
18
  import NewsKitLogoShort from '../common/NewskitLogoShort'
19
19
  import NavLink from '../common/NavLink'
20
20
  import { handleEnterKeyPress } from '../../helpers/a11y'
21
- import { UserData } from '../../helpers/global-types'
22
21
 
23
22
  export const headerSize = 'sizing090'
24
23
 
@@ -89,21 +88,31 @@ const Navigation = styled.div`
89
88
  const pastDueBanner = {
90
89
  firstNotice: {
91
90
  title: "We haven't been able to take payment",
92
- text: 'You may need to update your payment details to keep your subscription.',
91
+ text:
92
+ 'You may need to update your payment details to keep your subscription.',
93
93
  button: 'Update payment details',
94
94
  },
95
95
  secondNotice: {
96
96
  title: 'Act now to keep your subscription',
97
- text: 'We’ve tried several times, but haven’t been able to take payment. Please update your payment details to keep your subscription.',
97
+ text:
98
+ 'We’ve tried several times, but haven’t been able to take payment. Please update your payment details to keep your subscription.',
98
99
  button: 'Update payment details',
99
100
  },
100
101
  terminated: {
101
102
  title: 'Your subscription has been terminated',
102
- text: 'We didn’t receive payment for your subscription. To reactivate it, please call 0800 018 5177.',
103
+ text:
104
+ 'We didn’t receive payment for your subscription. To reactivate it, please call 0800 018 5177.',
103
105
  },
104
106
  cancelled: {
105
107
  title: 'Your subscription has been cancelled.',
106
- text: 'You’ll no longer have access to subscription benefits. To re-activate call 0800 555 1234.',
108
+ text:
109
+ 'You’ll no longer have access to subscription benefits. To re-activate call 0800 555 1234.',
110
+ },
111
+ toBeCancelled: {
112
+ title: 'Your subscription will end soon.',
113
+ phoneNumber: '0800 555 1234',
114
+ text:
115
+ 'You have cacelled your subscription and will lose access to all benefits on ##DATE##. To re-activate your subcsription call ##PHONE_NUMBER##.',
107
116
  },
108
117
  treshold: {
109
118
  firstNotice: 26,
@@ -229,7 +238,7 @@ const Header: React.FC<{ user: UserData }> = ({ user }) => {
229
238
  </StyledHeader>
230
239
  <PastDueBannerExternal
231
240
  pastDueBanner={pastDueBanner}
232
- vxInstances={user?.vxInstances}
241
+ user={user}
233
242
  wrapper={BannerContainer}
234
243
  />
235
244
  </>