@newskit-render/core 1.30.0 → 1.33.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 +52 -0
- package/__tests__/pages/[articleSlug].test.tsx +10 -5
- package/__tests__/pages/__snapshots__/home.test.tsx.snap +0 -4
- package/__tests__/pages/home.test.tsx +11 -5
- package/components/article/__tests__/__snapshots__/index.test.tsx.snap +0 -4
- package/components/header/index.test.tsx +3 -1
- package/components/header/index.tsx +2 -1
- package/cypress/e2e/account/main-api.spec.js +1 -1
- package/helpers/__tests__/getUser.test.ts +20 -2
- package/helpers/getUser.ts +13 -9
- package/package.json +6 -6
- package/pages/[section]/[articleId]/[articleSlug].tsx +13 -10
- package/pages/[section]/index.tsx +9 -12
- package/pages/api/news-sitemap.ts +1 -1
- package/pages/api/sitemap.ts +1 -1
- package/pages/index.tsx +9 -12
- package/temp/header.tsx +17 -8
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.33.1](https://github.com/newscorp-ghfb/ncu-newskit-render/compare/@newskit-render/core@1.33.0...@newskit-render/core@1.33.1) (2022-03-14)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @newskit-render/core
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
# [1.33.0](https://github.com/newscorp-ghfb/ncu-newskit-render/compare/@newskit-render/core@1.32.1...@newskit-render/core@1.33.0) (2022-03-14)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Features
|
|
18
|
+
|
|
19
|
+
* **PPDSR-678:** Update Readme & core package ([#623](https://github.com/newscorp-ghfb/ncu-newskit-render/issues/623)) ([5f04661](https://github.com/newscorp-ghfb/ncu-newskit-render/commit/5f046614f765b5bb8a155e2258ca29c3a389bf1c))
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
## [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)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
### Bug Fixes
|
|
29
|
+
|
|
30
|
+
* **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))
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
# [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)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
### Features
|
|
40
|
+
|
|
41
|
+
* **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))
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
# [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)
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
### Features
|
|
51
|
+
|
|
52
|
+
* **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))
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
6
58
|
# [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)
|
|
7
59
|
|
|
8
60
|
|
|
@@ -59,12 +59,18 @@ const props: ArticleSlug = {
|
|
|
59
59
|
gscId: '4320982',
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
const
|
|
62
|
+
const user = {
|
|
63
|
+
paymentFailure: {
|
|
64
|
+
active: false,
|
|
65
|
+
startDate: null,
|
|
66
|
+
},
|
|
67
|
+
subscriptions: [{ endDate: null }],
|
|
68
|
+
}
|
|
63
69
|
|
|
64
70
|
jest.mock('cross-fetch', () =>
|
|
65
71
|
jest.fn().mockImplementation(() =>
|
|
66
72
|
Promise.resolve({
|
|
67
|
-
json: () => Promise.resolve(
|
|
73
|
+
json: () => Promise.resolve(user),
|
|
68
74
|
})
|
|
69
75
|
)
|
|
70
76
|
)
|
|
@@ -80,13 +86,12 @@ jest.mock('@newskit-render/api', () => ({
|
|
|
80
86
|
}),
|
|
81
87
|
})
|
|
82
88
|
}),
|
|
83
|
-
|
|
89
|
+
getAcsCookie: jest.fn().mockReturnValue({ Cookie: 'something' }),
|
|
84
90
|
}))
|
|
85
91
|
|
|
86
92
|
jest.mock('@newskit-render/my-account', () => {
|
|
87
93
|
return {
|
|
88
94
|
PastDueBannerExternal: 'PastDueBannerExternal',
|
|
89
|
-
getMainSession: jest.fn(),
|
|
90
95
|
}
|
|
91
96
|
})
|
|
92
97
|
|
|
@@ -125,7 +130,7 @@ describe('Article', () => {
|
|
|
125
130
|
req: { headers: { cookie: 'some-cookie' } },
|
|
126
131
|
res: { setHeader: setHeaderMock },
|
|
127
132
|
})
|
|
128
|
-
expect(response).toEqual({ props: { ...props, showAds: true } })
|
|
133
|
+
expect(response).toEqual({ props: { ...props, showAds: true, user } })
|
|
129
134
|
expect(setHeaderMock).toHaveBeenCalledWith(
|
|
130
135
|
'Cache-Control',
|
|
131
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
|
-
|
|
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;
|
|
@@ -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/
|
|
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 {
|
|
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,
|
|
@@ -85,7 +85,7 @@ describe('MAIN API', () => {
|
|
|
85
85
|
}).as('userSubscription')
|
|
86
86
|
cy.get('@userSubscription').then((response) => {
|
|
87
87
|
expect(response.status).to.eq(200)
|
|
88
|
-
expect(response.body.cpn).to.eq('
|
|
88
|
+
expect(response.body.cpn).to.eq('4AAA038732032')
|
|
89
89
|
assert.isArray(response.body.subscriptions)
|
|
90
90
|
})
|
|
91
91
|
})
|
|
@@ -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(
|
|
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(
|
|
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
|
})
|
package/helpers/getUser.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import fetch from 'cross-fetch'
|
|
2
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 = (
|
|
14
|
+
const userConfig = (acsCookie: { Cookie: string }): UserConfig => ({
|
|
14
15
|
method: 'POST',
|
|
15
16
|
headers: {
|
|
16
17
|
'Content-Type': 'application/json',
|
|
17
|
-
|
|
18
|
+
...acsCookie,
|
|
18
19
|
},
|
|
19
|
-
body: JSON.stringify({ queryFragment: '
|
|
20
|
+
body: JSON.stringify({ queryFragment: 'UserPaymentInfo' }),
|
|
20
21
|
})
|
|
21
22
|
|
|
22
23
|
export const fetchUser = async (
|
|
23
|
-
|
|
24
|
+
acsCookie: MainAcsCookie,
|
|
24
25
|
url: string
|
|
25
26
|
): Promise<UserData | null> => {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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
|
|
35
|
+
return null
|
|
32
36
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@newskit-render/core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.33.1",
|
|
4
4
|
"description": "Newskit Render - Core package",
|
|
5
5
|
"author": "",
|
|
6
6
|
"license": "UNLICENSED",
|
|
@@ -33,13 +33,13 @@
|
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@apollo/client": "3.4.16",
|
|
36
|
-
"@newskit-render/api": "^0.
|
|
36
|
+
"@newskit-render/api": "^0.16.0",
|
|
37
37
|
"@newskit-render/auth": "^0.29.0",
|
|
38
|
-
"@newskit-render/checkout": "^0.24.
|
|
38
|
+
"@newskit-render/checkout": "^0.24.3",
|
|
39
39
|
"@newskit-render/feature-flags": "^0.11.0",
|
|
40
|
-
"@newskit-render/
|
|
41
|
-
"@newskit-render/
|
|
42
|
-
"@newskit-render/
|
|
40
|
+
"@newskit-render/feed": "^0.3.1",
|
|
41
|
+
"@newskit-render/my-account": "^0.144.1",
|
|
42
|
+
"@newskit-render/shared-components": "^0.38.0",
|
|
43
43
|
"@newskit-render/validation": "^0.37.0",
|
|
44
44
|
"cross-fetch": "3.1.5",
|
|
45
45
|
"graphql": "15.6.0",
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
2
|
import newrelic from 'newrelic'
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
createApolloClient,
|
|
5
|
+
ClientTypes,
|
|
6
|
+
getAcsCookie,
|
|
7
|
+
} from '@newskit-render/api'
|
|
4
8
|
import { UserData } from '@newskit-render/my-account'
|
|
5
9
|
import { GET_UNIVERSAL_ARTICLE } from '../../../queries'
|
|
6
10
|
import ArticlePage, { UniversalArticle } from '../../../components/article'
|
|
7
11
|
import { highlights, relatedArticles } from '../../../helpers/mocks/articleMock'
|
|
8
|
-
|
|
9
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
10
|
-
|
|
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
|
-
|
|
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
|
-
|
|
39
|
+
user,
|
|
43
40
|
},
|
|
44
41
|
}
|
|
45
42
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { NextApiRequest, NextApiResponse } from 'next'
|
|
2
|
-
import { newsSitemap, PublisherGroup } from '@newskit-render/
|
|
2
|
+
import { newsSitemap, PublisherGroup } from '@newskit-render/feed'
|
|
3
3
|
|
|
4
4
|
const handler = async (req: NextApiRequest, res: NextApiResponse) =>
|
|
5
5
|
newsSitemap({
|
package/pages/api/sitemap.ts
CHANGED
package/pages/index.tsx
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import newrelic from 'newrelic'
|
|
2
2
|
import {
|
|
3
3
|
createApolloClient,
|
|
4
|
-
|
|
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
|
-
|
|
10
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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 {
|
|
15
|
-
import { PastDueBannerExternal } from '@newskit-render/
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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
|
-
|
|
241
|
+
user={user}
|
|
233
242
|
wrapper={BannerContainer}
|
|
234
243
|
/>
|
|
235
244
|
</>
|