@faststore/core 3.52.0 → 3.53.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.
- package/.next/BUILD_ID +1 -1
- package/.next/build-manifest.json +43 -43
- package/.next/cache/.tsbuildinfo +1 -1
- package/.next/cache/config.json +3 -3
- package/.next/cache/webpack/client-production/0.pack +0 -0
- package/.next/cache/webpack/client-production/index.pack +0 -0
- package/.next/cache/webpack/server-production/0.pack +0 -0
- package/.next/cache/webpack/server-production/index.pack +0 -0
- package/.next/prerender-manifest.js +1 -1
- package/.next/prerender-manifest.json +1 -1
- package/.next/react-loadable-manifest.json +1 -1
- package/.next/routes-manifest.json +1 -1
- package/.next/server/chunks/6011.js +2 -2
- package/.next/server/chunks/6886.js +1 -1
- package/.next/server/chunks/7178.js +1 -1
- package/.next/server/chunks/948.js +1 -1
- package/.next/server/chunks/9563.js +2 -2
- package/.next/server/functions-config-manifest.json +1 -1
- package/.next/server/middleware-build-manifest.js +1 -1
- package/.next/server/middleware-react-loadable-manifest.js +1 -1
- package/.next/server/pages/[...slug].js +1 -1
- package/.next/server/pages/[slug]/p.js +1 -1
- package/.next/server/pages/account/403.js +1 -1
- package/.next/server/pages/account/403.js.nft.json +1 -1
- package/.next/server/pages/account/404.js +1 -1
- package/.next/server/pages/account/404.js.nft.json +1 -1
- package/.next/server/pages/account/orders/[id].js +1 -1
- package/.next/server/pages/account/orders.js +1 -1
- package/.next/server/pages/account/profile.js +1 -1
- package/.next/server/pages/account/profile.js.nft.json +1 -1
- package/.next/server/pages/account/security.js +1 -1
- package/.next/server/pages/account/security.js.nft.json +1 -1
- package/.next/server/pages/account/user-details.js +1 -1
- package/.next/server/pages/account/user-details.js.nft.json +1 -1
- package/.next/server/pages/api/graphql.js +1 -1
- package/.next/server/pages/en-US/404.html +2 -2
- package/.next/server/pages/en-US/404.json +1 -1
- package/.next/server/pages/en-US/500.html +2 -2
- package/.next/server/pages/en-US/500.json +1 -1
- package/.next/server/pages/en-US/checkout.html +2 -2
- package/.next/server/pages/en-US/checkout.json +1 -1
- package/.next/server/pages/en-US/login.html +2 -2
- package/.next/server/pages/en-US/login.json +1 -1
- package/.next/server/pages/en-US/s.html +2 -2
- package/.next/server/pages/en-US/s.json +1 -1
- package/.next/server/pages/en-US.html +2 -2
- package/.next/server/pages/en-US.json +1 -1
- package/.next/server/pages-manifest.json +1 -1
- package/.next/static/{fmlJseOxpqR3A9KoHn42L → GZVLqXVuC34d47BGkDWsx}/_buildManifest.js +1 -1
- package/.next/static/GZVLqXVuC34d47BGkDWsx/_ssgManifest.js +1 -0
- package/.next/static/chunks/2284.abe693ea8fc2cb2d.js +1 -0
- package/.next/static/chunks/9173-f1dbeccc6eaecda7.js +1 -0
- package/.next/static/chunks/pages/account/403-6f4addf9a9d54a1c.js +1 -0
- package/.next/static/chunks/pages/account/404-9e8ca6ee5f981dae.js +1 -0
- package/.next/static/chunks/pages/account/orders/[id]-15f404dbf08bc5df.js +1 -0
- package/.next/static/chunks/pages/account/orders-e879939373942f27.js +1 -0
- package/.next/static/chunks/pages/account/profile-adfe3518bdab5463.js +1 -0
- package/.next/static/chunks/pages/account/security-ea5c8811b3e6e415.js +1 -0
- package/.next/static/chunks/pages/account/user-details-9309d14f4e59f398.js +1 -0
- package/.next/static/chunks/{webpack-100cd28c010132c0.js → webpack-215661b94a325396.js} +1 -1
- package/.next/trace +128 -129
- package/.turbo/turbo-build.log +15 -15
- package/.turbo/turbo-test.log +5 -5
- package/@generated/gql.ts +36 -4
- package/@generated/graphql.ts +62 -2
- package/@generated/persisted-documents.json +6 -2
- package/@generated/schema.graphql +2 -0
- package/CHANGELOG.md +12 -0
- package/package.json +3 -3
- package/src/components/account/MyAccountLayout/MyAccountLayout.tsx +5 -8
- package/src/components/account/MyAccountMenu/MyAccountMenu.tsx +1 -1
- package/src/components/search/SearchDropdown/SearchDropdown.tsx +6 -6
- package/src/components/search/SearchInput/SearchInput.tsx +0 -1
- package/src/components/search/SearchProductItem/SearchProductItem.tsx +7 -7
- package/src/experimental/myAccountSeverSideProps.ts +31 -5
- package/src/pages/account/403.tsx +43 -17
- package/src/pages/account/404.tsx +47 -18
- package/src/pages/account/orders/[id].tsx +4 -1
- package/src/pages/account/orders/index.tsx +4 -1
- package/src/pages/account/profile.tsx +44 -16
- package/src/pages/account/security.tsx +48 -16
- package/src/pages/account/user-details.tsx +56 -23
- package/test/server/index.test.ts +1 -0
- package/.next/server/pages/en-US/account/403.html +0 -28
- package/.next/server/pages/en-US/account/403.json +0 -1
- package/.next/server/pages/en-US/account/404.html +0 -28
- package/.next/server/pages/en-US/account/404.json +0 -1
- package/.next/static/chunks/2284.6539f77c530719e0.js +0 -1
- package/.next/static/chunks/9173-b67cd7510d59f099.js +0 -1
- package/.next/static/chunks/pages/account/403-5037929d6d9f6ae3.js +0 -1
- package/.next/static/chunks/pages/account/404-1deb28189263c93c.js +0 -1
- package/.next/static/chunks/pages/account/orders/[id]-82dc3dda9809ea0d.js +0 -1
- package/.next/static/chunks/pages/account/orders-d4751ce0296dd64c.js +0 -1
- package/.next/static/chunks/pages/account/profile-294f44b0ab99b7e3.js +0 -1
- package/.next/static/chunks/pages/account/security-d38403ae57b09a68.js +0 -1
- package/.next/static/chunks/pages/account/user-details-106d6064b64410d3.js +0 -1
- package/.next/static/fmlJseOxpqR3A9KoHn42L/_ssgManifest.js +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Locator } from '@vtex/client-cms'
|
|
2
|
-
import type {
|
|
2
|
+
import type { GetServerSideProps } from 'next'
|
|
3
3
|
import { NextSeo } from 'next-seo'
|
|
4
4
|
import type { ComponentType } from 'react'
|
|
5
5
|
import {
|
|
@@ -17,6 +17,12 @@ import PLUGINS_COMPONENTS from 'src/plugins'
|
|
|
17
17
|
import { type PageContentType, getPage } from 'src/server/cms'
|
|
18
18
|
import { injectGlobalSections } from 'src/server/cms/global'
|
|
19
19
|
import { getMyAccountRedirect } from 'src/utils/myAccountRedirect'
|
|
20
|
+
import { gql } from '@generated/gql'
|
|
21
|
+
import { execute } from 'src/server'
|
|
22
|
+
import type {
|
|
23
|
+
ServerAccountPageQueryQuery,
|
|
24
|
+
ServerAccountPageQueryQueryVariables,
|
|
25
|
+
} from '@generated/graphql'
|
|
20
26
|
|
|
21
27
|
/* A list of components that can be used in the CMS. */
|
|
22
28
|
const COMPONENTS: Record<string, ComponentType<any>> = {
|
|
@@ -27,9 +33,10 @@ const COMPONENTS: Record<string, ComponentType<any>> = {
|
|
|
27
33
|
|
|
28
34
|
type Props = {
|
|
29
35
|
globalSections: GlobalSectionsData
|
|
36
|
+
accountName: ServerAccountPageQueryQuery['accountName']
|
|
30
37
|
}
|
|
31
38
|
|
|
32
|
-
function Page({ globalSections }: Props) {
|
|
39
|
+
function Page({ globalSections, accountName }: Props) {
|
|
33
40
|
return (
|
|
34
41
|
<RenderSections
|
|
35
42
|
globalSections={globalSections.sections}
|
|
@@ -37,7 +44,7 @@ function Page({ globalSections }: Props) {
|
|
|
37
44
|
>
|
|
38
45
|
<NextSeo noindex nofollow />
|
|
39
46
|
|
|
40
|
-
<MyAccountLayout>
|
|
47
|
+
<MyAccountLayout accountName={accountName}>
|
|
41
48
|
<EmptyState
|
|
42
49
|
title="Unauthorized Access"
|
|
43
50
|
titleIcon={{ icon: 'ShoppingCart', alt: 'Shopping Cart' }}
|
|
@@ -53,15 +60,21 @@ function Page({ globalSections }: Props) {
|
|
|
53
60
|
)
|
|
54
61
|
}
|
|
55
62
|
|
|
56
|
-
|
|
63
|
+
const query = gql(`
|
|
64
|
+
query ServerAccountPageQuery {
|
|
65
|
+
accountName
|
|
66
|
+
}
|
|
67
|
+
`)
|
|
68
|
+
|
|
69
|
+
export const getServerSideProps: GetServerSideProps<
|
|
57
70
|
Props,
|
|
58
71
|
Record<string, string>,
|
|
59
72
|
Locator
|
|
60
|
-
> = async (
|
|
73
|
+
> = async (context) => {
|
|
61
74
|
// TODO validate permissions here
|
|
62
75
|
|
|
63
76
|
const { isFaststoreMyAccountEnabled, redirect } = getMyAccountRedirect({
|
|
64
|
-
query:
|
|
77
|
+
query: context.query,
|
|
65
78
|
})
|
|
66
79
|
|
|
67
80
|
if (!isFaststoreMyAccountEnabled) {
|
|
@@ -72,18 +85,30 @@ export const getStaticProps: GetStaticProps<
|
|
|
72
85
|
globalSectionsPromise,
|
|
73
86
|
globalSectionsHeaderPromise,
|
|
74
87
|
globalSectionsFooterPromise,
|
|
75
|
-
] = getGlobalSectionsData(previewData)
|
|
88
|
+
] = getGlobalSectionsData(context.previewData)
|
|
76
89
|
|
|
77
|
-
const [
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
90
|
+
const [
|
|
91
|
+
page,
|
|
92
|
+
account,
|
|
93
|
+
globalSections,
|
|
94
|
+
globalSectionsHeader,
|
|
95
|
+
globalSectionsFooter,
|
|
96
|
+
] = await Promise.all([
|
|
97
|
+
getPage<PageContentType>({
|
|
98
|
+
...(context.previewData?.contentType === '403' && context.previewData),
|
|
99
|
+
contentType: '403',
|
|
100
|
+
}),
|
|
101
|
+
execute<ServerAccountPageQueryQueryVariables, ServerAccountPageQueryQuery>(
|
|
102
|
+
{
|
|
103
|
+
variables: {},
|
|
104
|
+
operation: query,
|
|
105
|
+
},
|
|
106
|
+
{ headers: { ...context.req.headers } }
|
|
107
|
+
),
|
|
108
|
+
globalSectionsPromise,
|
|
109
|
+
globalSectionsHeaderPromise,
|
|
110
|
+
globalSectionsFooterPromise,
|
|
111
|
+
])
|
|
87
112
|
|
|
88
113
|
const globalSectionsResult = injectGlobalSections({
|
|
89
114
|
globalSections,
|
|
@@ -96,6 +121,7 @@ export const getStaticProps: GetStaticProps<
|
|
|
96
121
|
// The sections from the CMS page are not utilized here for the My Account page.
|
|
97
122
|
// page,
|
|
98
123
|
globalSections: globalSectionsResult,
|
|
124
|
+
accountName: account.data.accountName,
|
|
99
125
|
},
|
|
100
126
|
}
|
|
101
127
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Locator } from '@vtex/client-cms'
|
|
2
|
-
import type {
|
|
2
|
+
import type { GetServerSideProps } from 'next'
|
|
3
3
|
import { NextSeo } from 'next-seo'
|
|
4
4
|
import type { ComponentType } from 'react'
|
|
5
5
|
import {
|
|
@@ -18,6 +18,12 @@ import PLUGINS_COMPONENTS from 'src/plugins'
|
|
|
18
18
|
import { type PageContentType, getPage } from 'src/server/cms'
|
|
19
19
|
import { injectGlobalSections } from 'src/server/cms/global'
|
|
20
20
|
import { getMyAccountRedirect } from 'src/utils/myAccountRedirect'
|
|
21
|
+
import { gql } from '@generated/gql'
|
|
22
|
+
import { execute } from 'src/server'
|
|
23
|
+
import type {
|
|
24
|
+
ServerAccountPageQueryQuery,
|
|
25
|
+
ServerAccountPageQueryQueryVariables,
|
|
26
|
+
} from '@generated/graphql'
|
|
21
27
|
|
|
22
28
|
/* A list of components that can be used in the CMS. */
|
|
23
29
|
const COMPONENTS: Record<string, ComponentType<any>> = {
|
|
@@ -30,9 +36,10 @@ const COMPONENTS: Record<string, ComponentType<any>> = {
|
|
|
30
36
|
type Props = {
|
|
31
37
|
page: PageContentType
|
|
32
38
|
globalSections: GlobalSectionsData
|
|
39
|
+
accountName: ServerAccountPageQueryQuery['accountName']
|
|
33
40
|
}
|
|
34
41
|
|
|
35
|
-
function Page({ page: { sections }, globalSections }: Props) {
|
|
42
|
+
function Page({ page: { sections }, globalSections, accountName }: Props) {
|
|
36
43
|
return (
|
|
37
44
|
<RenderSections
|
|
38
45
|
globalSections={globalSections.sections}
|
|
@@ -40,7 +47,7 @@ function Page({ page: { sections }, globalSections }: Props) {
|
|
|
40
47
|
>
|
|
41
48
|
<NextSeo noindex nofollow />
|
|
42
49
|
|
|
43
|
-
<MyAccountLayout>
|
|
50
|
+
<MyAccountLayout accountName={accountName}>
|
|
44
51
|
{sections && sections.length > 0 && (
|
|
45
52
|
<RenderSectionsBase sections={sections} components={COMPONENTS} />
|
|
46
53
|
)}
|
|
@@ -49,15 +56,21 @@ function Page({ page: { sections }, globalSections }: Props) {
|
|
|
49
56
|
)
|
|
50
57
|
}
|
|
51
58
|
|
|
52
|
-
|
|
59
|
+
const query = gql(`
|
|
60
|
+
query ServerAccountPageQuery {
|
|
61
|
+
accountName
|
|
62
|
+
}
|
|
63
|
+
`)
|
|
64
|
+
|
|
65
|
+
export const getServerSideProps: GetServerSideProps<
|
|
53
66
|
Props,
|
|
54
67
|
Record<string, string>,
|
|
55
68
|
Locator
|
|
56
|
-
> = async (
|
|
69
|
+
> = async (context) => {
|
|
57
70
|
// TODO validate permissions here
|
|
58
71
|
|
|
59
72
|
const { isFaststoreMyAccountEnabled, redirect } = getMyAccountRedirect({
|
|
60
|
-
query:
|
|
73
|
+
query: context.query,
|
|
61
74
|
})
|
|
62
75
|
|
|
63
76
|
if (!isFaststoreMyAccountEnabled) {
|
|
@@ -68,18 +81,30 @@ export const getStaticProps: GetStaticProps<
|
|
|
68
81
|
globalSectionsPromise,
|
|
69
82
|
globalSectionsHeaderPromise,
|
|
70
83
|
globalSectionsFooterPromise,
|
|
71
|
-
] = getGlobalSectionsData(previewData)
|
|
84
|
+
] = getGlobalSectionsData(context.previewData)
|
|
72
85
|
|
|
73
|
-
const [
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
86
|
+
const [
|
|
87
|
+
page,
|
|
88
|
+
account,
|
|
89
|
+
globalSections,
|
|
90
|
+
globalSectionsHeader,
|
|
91
|
+
globalSectionsFooter,
|
|
92
|
+
] = await Promise.all([
|
|
93
|
+
getPage<PageContentType>({
|
|
94
|
+
...(context.previewData?.contentType === '404' && context.previewData),
|
|
95
|
+
contentType: '404',
|
|
96
|
+
}),
|
|
97
|
+
execute<ServerAccountPageQueryQueryVariables, ServerAccountPageQueryQuery>(
|
|
98
|
+
{
|
|
99
|
+
variables: {},
|
|
100
|
+
operation: query,
|
|
101
|
+
},
|
|
102
|
+
{ headers: { ...context.req.headers } }
|
|
103
|
+
),
|
|
104
|
+
globalSectionsPromise,
|
|
105
|
+
globalSectionsHeaderPromise,
|
|
106
|
+
globalSectionsFooterPromise,
|
|
107
|
+
])
|
|
83
108
|
|
|
84
109
|
const globalSectionsResult = injectGlobalSections({
|
|
85
110
|
globalSections,
|
|
@@ -88,7 +113,11 @@ export const getStaticProps: GetStaticProps<
|
|
|
88
113
|
})
|
|
89
114
|
|
|
90
115
|
return {
|
|
91
|
-
props: {
|
|
116
|
+
props: {
|
|
117
|
+
page,
|
|
118
|
+
globalSections: globalSectionsResult,
|
|
119
|
+
accountName: account.data.accountName,
|
|
120
|
+
},
|
|
92
121
|
}
|
|
93
122
|
}
|
|
94
123
|
|
|
@@ -33,6 +33,7 @@ type OrderDetailsPageProps = {
|
|
|
33
33
|
export default function OrderDetailsPage({
|
|
34
34
|
globalSections,
|
|
35
35
|
order,
|
|
36
|
+
accountName,
|
|
36
37
|
}: OrderDetailsPageProps) {
|
|
37
38
|
return (
|
|
38
39
|
<RenderSections
|
|
@@ -41,7 +42,7 @@ export default function OrderDetailsPage({
|
|
|
41
42
|
>
|
|
42
43
|
<NextSeo noindex nofollow />
|
|
43
44
|
|
|
44
|
-
<MyAccountLayout>
|
|
45
|
+
<MyAccountLayout accountName={accountName}>
|
|
45
46
|
<BeforeSection />
|
|
46
47
|
<MyAccountOrderDetails order={order} />
|
|
47
48
|
<AfterSection />
|
|
@@ -193,6 +194,7 @@ const query = gql(`
|
|
|
193
194
|
value
|
|
194
195
|
}
|
|
195
196
|
}
|
|
197
|
+
accountName
|
|
196
198
|
}
|
|
197
199
|
`)
|
|
198
200
|
|
|
@@ -266,6 +268,7 @@ export const getServerSideProps: GetServerSideProps<
|
|
|
266
268
|
props: {
|
|
267
269
|
globalSections: globalSectionsResult,
|
|
268
270
|
order: orderDetails.data.userOrder,
|
|
271
|
+
accountName: orderDetails.data.accountName,
|
|
269
272
|
},
|
|
270
273
|
}
|
|
271
274
|
}
|
|
@@ -46,6 +46,7 @@ type ListOrdersPageProps = {
|
|
|
46
46
|
|
|
47
47
|
export default function ListOrdersPage({
|
|
48
48
|
globalSections,
|
|
49
|
+
accountName,
|
|
49
50
|
listOrders,
|
|
50
51
|
total,
|
|
51
52
|
perPage,
|
|
@@ -58,7 +59,7 @@ export default function ListOrdersPage({
|
|
|
58
59
|
>
|
|
59
60
|
<NextSeo noindex nofollow />
|
|
60
61
|
|
|
61
|
-
<MyAccountLayout>
|
|
62
|
+
<MyAccountLayout accountName={accountName}>
|
|
62
63
|
<BeforeSection />
|
|
63
64
|
<MyAccountListOrders
|
|
64
65
|
listOrders={listOrders}
|
|
@@ -107,6 +108,7 @@ const query = gql(`
|
|
|
107
108
|
perPage
|
|
108
109
|
}
|
|
109
110
|
}
|
|
111
|
+
accountName
|
|
110
112
|
}
|
|
111
113
|
`)
|
|
112
114
|
|
|
@@ -205,6 +207,7 @@ export const getServerSideProps: GetServerSideProps<
|
|
|
205
207
|
return {
|
|
206
208
|
props: {
|
|
207
209
|
globalSections: globalSectionsResult,
|
|
210
|
+
accountName: listOrders.data.accountName,
|
|
208
211
|
listOrders: listOrders.data.listUserOrders,
|
|
209
212
|
total: listOrders.data.listUserOrders.paging.total,
|
|
210
213
|
perPage: listOrders.data.listUserOrders.paging.perPage,
|
|
@@ -17,6 +17,12 @@ import { default as BeforeSection } from 'src/customizations/src/myAccount/exten
|
|
|
17
17
|
import type { MyAccountProps } from 'src/experimental/myAccountSeverSideProps'
|
|
18
18
|
import { injectGlobalSections } from 'src/server/cms/global'
|
|
19
19
|
import { getMyAccountRedirect } from 'src/utils/myAccountRedirect'
|
|
20
|
+
import { gql } from '@generated/gql'
|
|
21
|
+
import { execute } from 'src/server'
|
|
22
|
+
import type {
|
|
23
|
+
ServerProfileQueryQuery,
|
|
24
|
+
ServerProfileQueryQueryVariables,
|
|
25
|
+
} from '@generated/graphql'
|
|
20
26
|
|
|
21
27
|
/* A list of components that can be used in the CMS. */
|
|
22
28
|
const COMPONENTS: Record<string, ComponentType<any>> = {
|
|
@@ -24,7 +30,10 @@ const COMPONENTS: Record<string, ComponentType<any>> = {
|
|
|
24
30
|
...CUSTOM_COMPONENTS,
|
|
25
31
|
}
|
|
26
32
|
|
|
27
|
-
export default function Profile({
|
|
33
|
+
export default function Profile({
|
|
34
|
+
globalSections,
|
|
35
|
+
accountName,
|
|
36
|
+
}: MyAccountProps) {
|
|
28
37
|
return (
|
|
29
38
|
<RenderSections
|
|
30
39
|
globalSections={globalSections.sections}
|
|
@@ -32,7 +41,7 @@ export default function Profile({ globalSections }: MyAccountProps) {
|
|
|
32
41
|
>
|
|
33
42
|
<NextSeo noindex nofollow />
|
|
34
43
|
|
|
35
|
-
<MyAccountLayout>
|
|
44
|
+
<MyAccountLayout accountName={accountName}>
|
|
36
45
|
<BeforeSection />
|
|
37
46
|
<div>
|
|
38
47
|
<h1>Profile</h1>
|
|
@@ -43,15 +52,21 @@ export default function Profile({ globalSections }: MyAccountProps) {
|
|
|
43
52
|
)
|
|
44
53
|
}
|
|
45
54
|
|
|
55
|
+
const query = gql(`
|
|
56
|
+
query ServerProfileQuery {
|
|
57
|
+
accountName
|
|
58
|
+
}
|
|
59
|
+
`)
|
|
60
|
+
|
|
46
61
|
export const getServerSideProps: GetServerSideProps<
|
|
47
62
|
MyAccountProps,
|
|
48
63
|
Record<string, string>,
|
|
49
64
|
Locator
|
|
50
|
-
> = async (
|
|
65
|
+
> = async (context) => {
|
|
51
66
|
// TODO validate permissions here
|
|
52
67
|
|
|
53
68
|
const { isFaststoreMyAccountEnabled, redirect } = getMyAccountRedirect({
|
|
54
|
-
query,
|
|
69
|
+
query: context.query,
|
|
55
70
|
})
|
|
56
71
|
|
|
57
72
|
if (!isFaststoreMyAccountEnabled) {
|
|
@@ -62,24 +77,34 @@ export const getServerSideProps: GetServerSideProps<
|
|
|
62
77
|
globalSectionsPromise,
|
|
63
78
|
globalSectionsHeaderPromise,
|
|
64
79
|
globalSectionsFooterPromise,
|
|
65
|
-
] = getGlobalSectionsData(previewData)
|
|
80
|
+
] = getGlobalSectionsData(context.previewData)
|
|
66
81
|
|
|
67
|
-
const [globalSections, globalSectionsHeader, globalSectionsFooter] =
|
|
82
|
+
const [profile, globalSections, globalSectionsHeader, globalSectionsFooter] =
|
|
68
83
|
await Promise.all([
|
|
84
|
+
execute<ServerProfileQueryQueryVariables, ServerProfileQueryQuery>(
|
|
85
|
+
{
|
|
86
|
+
variables: {},
|
|
87
|
+
operation: query,
|
|
88
|
+
},
|
|
89
|
+
{ headers: { ...context.req.headers } }
|
|
90
|
+
),
|
|
69
91
|
globalSectionsPromise,
|
|
70
92
|
globalSectionsHeaderPromise,
|
|
71
93
|
globalSectionsFooterPromise,
|
|
72
94
|
])
|
|
73
95
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
96
|
+
if (profile.errors) {
|
|
97
|
+
const statusCode: number = (profile.errors[0] as any)?.extensions?.status
|
|
98
|
+
const destination: string =
|
|
99
|
+
statusCode === 403 ? '/account/403' : '/account/404'
|
|
100
|
+
|
|
101
|
+
return {
|
|
102
|
+
redirect: {
|
|
103
|
+
destination,
|
|
104
|
+
permanent: false,
|
|
105
|
+
},
|
|
106
|
+
}
|
|
107
|
+
}
|
|
83
108
|
|
|
84
109
|
const globalSectionsResult = injectGlobalSections({
|
|
85
110
|
globalSections,
|
|
@@ -88,6 +113,9 @@ export const getServerSideProps: GetServerSideProps<
|
|
|
88
113
|
})
|
|
89
114
|
|
|
90
115
|
return {
|
|
91
|
-
props: {
|
|
116
|
+
props: {
|
|
117
|
+
globalSections: globalSectionsResult,
|
|
118
|
+
accountName: profile.data.accountName,
|
|
119
|
+
},
|
|
92
120
|
}
|
|
93
121
|
}
|
|
@@ -18,6 +18,12 @@ import { default as BeforeSection } from 'src/customizations/src/myAccount/exten
|
|
|
18
18
|
import type { MyAccountProps } from 'src/experimental/myAccountSeverSideProps'
|
|
19
19
|
import { injectGlobalSections } from 'src/server/cms/global'
|
|
20
20
|
import { getMyAccountRedirect } from 'src/utils/myAccountRedirect'
|
|
21
|
+
import { execute } from 'src/server'
|
|
22
|
+
import { gql } from '@generated/gql'
|
|
23
|
+
import type {
|
|
24
|
+
ServerSecurityQueryQuery,
|
|
25
|
+
ServerSecurityQueryQueryVariables,
|
|
26
|
+
} from '@generated/graphql'
|
|
21
27
|
|
|
22
28
|
/* A list of components that can be used in the CMS. */
|
|
23
29
|
const COMPONENTS: Record<string, ComponentType<any>> = {
|
|
@@ -25,7 +31,14 @@ const COMPONENTS: Record<string, ComponentType<any>> = {
|
|
|
25
31
|
...CUSTOM_COMPONENTS,
|
|
26
32
|
}
|
|
27
33
|
|
|
28
|
-
|
|
34
|
+
type SecurityPageProps = {
|
|
35
|
+
accountName: string
|
|
36
|
+
} & MyAccountProps
|
|
37
|
+
|
|
38
|
+
export default function Page({
|
|
39
|
+
globalSections,
|
|
40
|
+
accountName,
|
|
41
|
+
}: SecurityPageProps) {
|
|
29
42
|
return (
|
|
30
43
|
<RenderSections
|
|
31
44
|
globalSections={globalSections.sections}
|
|
@@ -33,7 +46,7 @@ export default function Page({ globalSections }: MyAccountProps) {
|
|
|
33
46
|
>
|
|
34
47
|
<NextSeo noindex nofollow />
|
|
35
48
|
|
|
36
|
-
<MyAccountLayout>
|
|
49
|
+
<MyAccountLayout accountName={accountName}>
|
|
37
50
|
<BeforeSection />
|
|
38
51
|
<div>
|
|
39
52
|
<h1>Security</h1>
|
|
@@ -44,15 +57,21 @@ export default function Page({ globalSections }: MyAccountProps) {
|
|
|
44
57
|
)
|
|
45
58
|
}
|
|
46
59
|
|
|
60
|
+
const query = gql(`
|
|
61
|
+
query ServerSecurityQuery {
|
|
62
|
+
accountName
|
|
63
|
+
}
|
|
64
|
+
`)
|
|
65
|
+
|
|
47
66
|
export const getServerSideProps: GetServerSideProps<
|
|
48
67
|
MyAccountProps,
|
|
49
68
|
Record<string, string>,
|
|
50
69
|
Locator
|
|
51
|
-
> = async (
|
|
70
|
+
> = async (context) => {
|
|
52
71
|
// TODO validate permissions here
|
|
53
72
|
|
|
54
73
|
const { isFaststoreMyAccountEnabled, redirect } = getMyAccountRedirect({
|
|
55
|
-
query,
|
|
74
|
+
query: context.query,
|
|
56
75
|
})
|
|
57
76
|
|
|
58
77
|
if (!isFaststoreMyAccountEnabled) {
|
|
@@ -63,24 +82,34 @@ export const getServerSideProps: GetServerSideProps<
|
|
|
63
82
|
globalSectionsPromise,
|
|
64
83
|
globalSectionsHeaderPromise,
|
|
65
84
|
globalSectionsFooterPromise,
|
|
66
|
-
] = getGlobalSectionsData(previewData)
|
|
85
|
+
] = getGlobalSectionsData(context.previewData)
|
|
67
86
|
|
|
68
|
-
const [globalSections, globalSectionsHeader, globalSectionsFooter] =
|
|
87
|
+
const [security, globalSections, globalSectionsHeader, globalSectionsFooter] =
|
|
69
88
|
await Promise.all([
|
|
89
|
+
execute<ServerSecurityQueryQueryVariables, ServerSecurityQueryQuery>(
|
|
90
|
+
{
|
|
91
|
+
variables: {},
|
|
92
|
+
operation: query,
|
|
93
|
+
},
|
|
94
|
+
{ headers: { ...context.req.headers } }
|
|
95
|
+
),
|
|
70
96
|
globalSectionsPromise,
|
|
71
97
|
globalSectionsHeaderPromise,
|
|
72
98
|
globalSectionsFooterPromise,
|
|
73
99
|
])
|
|
74
100
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
101
|
+
if (security.errors) {
|
|
102
|
+
const statusCode: number = (security.errors[0] as any)?.extensions?.status
|
|
103
|
+
const destination: string =
|
|
104
|
+
statusCode === 403 ? '/account/403' : '/account/404'
|
|
105
|
+
|
|
106
|
+
return {
|
|
107
|
+
redirect: {
|
|
108
|
+
destination,
|
|
109
|
+
permanent: false,
|
|
110
|
+
},
|
|
111
|
+
}
|
|
112
|
+
}
|
|
84
113
|
|
|
85
114
|
const globalSectionsResult = injectGlobalSections({
|
|
86
115
|
globalSections,
|
|
@@ -89,6 +118,9 @@ export const getServerSideProps: GetServerSideProps<
|
|
|
89
118
|
})
|
|
90
119
|
|
|
91
120
|
return {
|
|
92
|
-
props: {
|
|
121
|
+
props: {
|
|
122
|
+
globalSections: globalSectionsResult,
|
|
123
|
+
accountName: security.data.accountName,
|
|
124
|
+
},
|
|
93
125
|
}
|
|
94
126
|
}
|
|
@@ -18,6 +18,12 @@ import { default as BeforeSection } from 'src/customizations/src/myAccount/exten
|
|
|
18
18
|
import type { MyAccountProps } from 'src/experimental/myAccountSeverSideProps'
|
|
19
19
|
import { injectGlobalSections } from 'src/server/cms/global'
|
|
20
20
|
import { getMyAccountRedirect } from 'src/utils/myAccountRedirect'
|
|
21
|
+
import { gql } from '@generated/gql'
|
|
22
|
+
import { execute } from 'src/server'
|
|
23
|
+
import type {
|
|
24
|
+
ServerUserDetailsQueryQuery,
|
|
25
|
+
ServerUserDetailsQueryQueryVariables,
|
|
26
|
+
} from '@generated/graphql'
|
|
21
27
|
|
|
22
28
|
/* A list of components that can be used in the CMS. */
|
|
23
29
|
const COMPONENTS: Record<string, ComponentType<any>> = {
|
|
@@ -25,7 +31,10 @@ const COMPONENTS: Record<string, ComponentType<any>> = {
|
|
|
25
31
|
...CUSTOM_COMPONENTS,
|
|
26
32
|
}
|
|
27
33
|
|
|
28
|
-
export default function
|
|
34
|
+
export default function UserDetails({
|
|
35
|
+
globalSections,
|
|
36
|
+
accountName,
|
|
37
|
+
}: MyAccountProps) {
|
|
29
38
|
return (
|
|
30
39
|
<RenderSections
|
|
31
40
|
globalSections={globalSections.sections}
|
|
@@ -33,7 +42,7 @@ export default function Page({ globalSections }: MyAccountProps) {
|
|
|
33
42
|
>
|
|
34
43
|
<NextSeo noindex nofollow />
|
|
35
44
|
|
|
36
|
-
<MyAccountLayout>
|
|
45
|
+
<MyAccountLayout accountName={accountName}>
|
|
37
46
|
<BeforeSection />
|
|
38
47
|
<div>
|
|
39
48
|
<h1>User Details</h1>
|
|
@@ -44,15 +53,21 @@ export default function Page({ globalSections }: MyAccountProps) {
|
|
|
44
53
|
)
|
|
45
54
|
}
|
|
46
55
|
|
|
56
|
+
const query = gql(`
|
|
57
|
+
query ServerUserDetailsQuery {
|
|
58
|
+
accountName
|
|
59
|
+
}
|
|
60
|
+
`)
|
|
61
|
+
|
|
47
62
|
export const getServerSideProps: GetServerSideProps<
|
|
48
63
|
MyAccountProps,
|
|
49
64
|
Record<string, string>,
|
|
50
65
|
Locator
|
|
51
|
-
> = async (
|
|
66
|
+
> = async (context) => {
|
|
52
67
|
// TODO validate permissions here
|
|
53
68
|
|
|
54
69
|
const { isFaststoreMyAccountEnabled, redirect } = getMyAccountRedirect({
|
|
55
|
-
query,
|
|
70
|
+
query: context.query,
|
|
56
71
|
})
|
|
57
72
|
|
|
58
73
|
if (!isFaststoreMyAccountEnabled) {
|
|
@@ -63,24 +78,39 @@ export const getServerSideProps: GetServerSideProps<
|
|
|
63
78
|
globalSectionsPromise,
|
|
64
79
|
globalSectionsHeaderPromise,
|
|
65
80
|
globalSectionsFooterPromise,
|
|
66
|
-
] = getGlobalSectionsData(previewData)
|
|
67
|
-
|
|
68
|
-
const [
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
81
|
+
] = getGlobalSectionsData(context.previewData)
|
|
82
|
+
|
|
83
|
+
const [
|
|
84
|
+
userDetails,
|
|
85
|
+
globalSections,
|
|
86
|
+
globalSectionsHeader,
|
|
87
|
+
globalSectionsFooter,
|
|
88
|
+
] = await Promise.all([
|
|
89
|
+
execute<ServerUserDetailsQueryQueryVariables, ServerUserDetailsQueryQuery>(
|
|
90
|
+
{
|
|
91
|
+
variables: {},
|
|
92
|
+
operation: query,
|
|
93
|
+
},
|
|
94
|
+
{ headers: { ...context.req.headers } }
|
|
95
|
+
),
|
|
96
|
+
globalSectionsPromise,
|
|
97
|
+
globalSectionsHeaderPromise,
|
|
98
|
+
globalSectionsFooterPromise,
|
|
99
|
+
])
|
|
100
|
+
|
|
101
|
+
if (userDetails.errors) {
|
|
102
|
+
const statusCode: number = (userDetails.errors[0] as any)?.extensions
|
|
103
|
+
?.status
|
|
104
|
+
const destination: string =
|
|
105
|
+
statusCode === 403 ? '/account/403' : '/account/404'
|
|
106
|
+
|
|
107
|
+
return {
|
|
108
|
+
redirect: {
|
|
109
|
+
destination,
|
|
110
|
+
permanent: false,
|
|
111
|
+
},
|
|
112
|
+
}
|
|
113
|
+
}
|
|
84
114
|
|
|
85
115
|
const globalSectionsResult = injectGlobalSections({
|
|
86
116
|
globalSections,
|
|
@@ -89,6 +119,9 @@ export const getServerSideProps: GetServerSideProps<
|
|
|
89
119
|
})
|
|
90
120
|
|
|
91
121
|
return {
|
|
92
|
-
props: {
|
|
122
|
+
props: {
|
|
123
|
+
globalSections: globalSectionsResult,
|
|
124
|
+
accountName: userDetails.data.accountName,
|
|
125
|
+
},
|
|
93
126
|
}
|
|
94
127
|
}
|