@faststore/core 3.52.1 → 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.
Files changed (82) hide show
  1. package/.next/BUILD_ID +1 -1
  2. package/.next/build-manifest.json +28 -28
  3. package/.next/cache/.tsbuildinfo +1 -1
  4. package/.next/cache/config.json +3 -3
  5. package/.next/cache/webpack/client-production/0.pack +0 -0
  6. package/.next/cache/webpack/client-production/index.pack +0 -0
  7. package/.next/cache/webpack/server-production/0.pack +0 -0
  8. package/.next/cache/webpack/server-production/index.pack +0 -0
  9. package/.next/prerender-manifest.js +1 -1
  10. package/.next/prerender-manifest.json +1 -1
  11. package/.next/react-loadable-manifest.json +1 -1
  12. package/.next/routes-manifest.json +1 -1
  13. package/.next/server/chunks/6011.js +2 -2
  14. package/.next/server/chunks/6886.js +1 -1
  15. package/.next/server/chunks/9563.js +2 -2
  16. package/.next/server/middleware-build-manifest.js +1 -1
  17. package/.next/server/middleware-react-loadable-manifest.js +1 -1
  18. package/.next/server/pages/[...slug].js +1 -1
  19. package/.next/server/pages/[slug]/p.js +1 -1
  20. package/.next/server/pages/account/403.js +1 -1
  21. package/.next/server/pages/account/403.js.nft.json +1 -1
  22. package/.next/server/pages/account/404.js +1 -1
  23. package/.next/server/pages/account/404.js.nft.json +1 -1
  24. package/.next/server/pages/account/orders/[id].js +1 -1
  25. package/.next/server/pages/account/orders.js +1 -1
  26. package/.next/server/pages/account/profile.js +1 -1
  27. package/.next/server/pages/account/profile.js.nft.json +1 -1
  28. package/.next/server/pages/account/security.js +1 -1
  29. package/.next/server/pages/account/security.js.nft.json +1 -1
  30. package/.next/server/pages/account/user-details.js +1 -1
  31. package/.next/server/pages/account/user-details.js.nft.json +1 -1
  32. package/.next/server/pages/api/graphql.js +1 -1
  33. package/.next/server/pages/en-US/404.html +2 -2
  34. package/.next/server/pages/en-US/500.html +2 -2
  35. package/.next/server/pages/en-US/checkout.html +2 -2
  36. package/.next/server/pages/en-US/login.html +2 -2
  37. package/.next/server/pages/en-US/s.html +2 -2
  38. package/.next/server/pages/en-US.html +2 -2
  39. package/.next/server/pages-manifest.json +1 -1
  40. package/.next/static/{tpAEjQ5nDxLrA2DooSVfx → GZVLqXVuC34d47BGkDWsx}/_buildManifest.js +1 -1
  41. package/.next/static/GZVLqXVuC34d47BGkDWsx/_ssgManifest.js +1 -0
  42. package/.next/static/chunks/{1552.2705dd1ff3aee879.js → 1552.8751332da83cadc5.js} +1 -1
  43. package/.next/static/chunks/pages/account/403-6f4addf9a9d54a1c.js +1 -0
  44. package/.next/static/chunks/pages/account/404-9e8ca6ee5f981dae.js +1 -0
  45. package/.next/static/chunks/pages/account/orders/[id]-15f404dbf08bc5df.js +1 -0
  46. package/.next/static/chunks/pages/account/orders-e879939373942f27.js +1 -0
  47. package/.next/static/chunks/pages/account/profile-adfe3518bdab5463.js +1 -0
  48. package/.next/static/chunks/pages/account/security-ea5c8811b3e6e415.js +1 -0
  49. package/.next/static/chunks/pages/account/user-details-9309d14f4e59f398.js +1 -0
  50. package/.next/static/chunks/{webpack-b2d921b9d06db874.js → webpack-215661b94a325396.js} +1 -1
  51. package/.next/trace +128 -129
  52. package/.turbo/turbo-build.log +15 -15
  53. package/.turbo/turbo-test.log +5 -5
  54. package/@generated/gql.ts +36 -4
  55. package/@generated/graphql.ts +62 -2
  56. package/@generated/persisted-documents.json +6 -2
  57. package/@generated/schema.graphql +2 -0
  58. package/CHANGELOG.md +6 -0
  59. package/package.json +3 -3
  60. package/src/components/account/MyAccountLayout/MyAccountLayout.tsx +5 -8
  61. package/src/components/account/MyAccountMenu/MyAccountMenu.tsx +1 -1
  62. package/src/experimental/myAccountSeverSideProps.ts +31 -5
  63. package/src/pages/account/403.tsx +43 -17
  64. package/src/pages/account/404.tsx +47 -18
  65. package/src/pages/account/orders/[id].tsx +4 -1
  66. package/src/pages/account/orders/index.tsx +4 -1
  67. package/src/pages/account/profile.tsx +44 -16
  68. package/src/pages/account/security.tsx +48 -16
  69. package/src/pages/account/user-details.tsx +56 -23
  70. package/test/server/index.test.ts +1 -0
  71. package/.next/server/pages/en-US/account/403.html +0 -28
  72. package/.next/server/pages/en-US/account/403.json +0 -1
  73. package/.next/server/pages/en-US/account/404.html +0 -28
  74. package/.next/server/pages/en-US/account/404.json +0 -1
  75. package/.next/static/chunks/pages/account/403-5037929d6d9f6ae3.js +0 -1
  76. package/.next/static/chunks/pages/account/404-1deb28189263c93c.js +0 -1
  77. package/.next/static/chunks/pages/account/orders/[id]-82dc3dda9809ea0d.js +0 -1
  78. package/.next/static/chunks/pages/account/orders-d4751ce0296dd64c.js +0 -1
  79. package/.next/static/chunks/pages/account/profile-294f44b0ab99b7e3.js +0 -1
  80. package/.next/static/chunks/pages/account/security-d38403ae57b09a68.js +0 -1
  81. package/.next/static/chunks/pages/account/user-details-106d6064b64410d3.js +0 -1
  82. package/.next/static/tpAEjQ5nDxLrA2DooSVfx/_ssgManifest.js +0 -1
@@ -1,5 +1,5 @@
1
1
  import type { Locator } from '@vtex/client-cms'
2
- import type { GetStaticProps } from 'next'
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
- export const getStaticProps: GetStaticProps<
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 ({ previewData }) => {
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 [page, globalSections, globalSectionsHeader, globalSectionsFooter] =
74
- await Promise.all([
75
- getPage<PageContentType>({
76
- ...(previewData?.contentType === '404' && previewData),
77
- contentType: '404',
78
- }),
79
- globalSectionsPromise,
80
- globalSectionsHeaderPromise,
81
- globalSectionsFooterPromise,
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: { page, globalSections: globalSectionsResult },
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({ globalSections }: MyAccountProps) {
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 ({ previewData, query }) => {
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
- // TODO handle 404 when profile request is made
75
- // if (profile.errors) {
76
- // return {
77
- // redirect: {
78
- // destination: '/account/404',
79
- // permanent: false,
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: { globalSections: globalSectionsResult },
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
- export default function Page({ globalSections }: MyAccountProps) {
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 ({ previewData, query }) => {
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
- // TODO handle 404 when security request is made
76
- // if (security.errors) {
77
- // return {
78
- // redirect: {
79
- // destination: '/account/404',
80
- // permanent: false,
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: { globalSections: globalSectionsResult },
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 Page({ globalSections }: MyAccountProps) {
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 ({ previewData, query }) => {
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 [globalSections, globalSectionsHeader, globalSectionsFooter] =
69
- await Promise.all([
70
- globalSectionsPromise,
71
- globalSectionsHeaderPromise,
72
- globalSectionsFooterPromise,
73
- ])
74
-
75
- // TODO handle 404 when userDetails request is made
76
- // if (userDetails.errors) {
77
- // return {
78
- // redirect: {
79
- // destination: '/account/404',
80
- // permanent: false,
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: { globalSections: globalSectionsResult },
122
+ props: {
123
+ globalSections: globalSectionsResult,
124
+ accountName: userDetails.data.accountName,
125
+ },
93
126
  }
94
127
  }
@@ -76,6 +76,7 @@ const QUERIES = [
76
76
  'productCount',
77
77
  'userOrder',
78
78
  'listUserOrders',
79
+ 'accountName',
79
80
  ]
80
81
 
81
82
  const MUTATIONS = [
@@ -1,28 +0,0 @@
1
- <!DOCTYPE html><html lang="en-US"><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width"/><meta name="generated-at" content="2025-06-16T13:32:46.368Z"/><meta name="robots" content="noindex,nofollow"/><meta name="next-head-count" content="4"/><link rel="preconnect" href="https://storeframework.vtexassets.com"/><link rel="dns-prefetch" href="https://storeframework.vtexassets.com"/><meta name="storefront" content="fast_store"/><script>var partytown={forward:[...["sendrc"],!window.location.search.includes('gtm_debug=')&&true?'dataLayer.push':null].filter(Boolean)}</script><script type="text/partytown">!window.location.search.includes('gtm_debug=')&&
2
- (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
3
- new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
4
- j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
5
- 'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
6
- })(window,document,'script',"dataLayer","GTM-PGHZ95N");</script><script type="text/javascript">window.location.search.includes('gtm_debug=')&&
7
- (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
8
- new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
9
- j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
10
- 'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
11
- })(window,document,'script',"dataLayer","GTM-PGHZ95N");</script><script type="text/partytown">
12
- window.VTEX_METADATA = {account:'storeframework', renderer: 'faststore'};
13
- window.sendrc=function(en,ed){window.NavigationCapture&&window.NavigationCapture.sendEvent(en,ed)};
14
- </script><script type="text/partytown" async="" src="https://io.vtex.com.br/rc/rc.js"></script><script type="text/javascript">
15
- (function(v,t,e,x,a,f,s){
16
- f=v.vtexaf=v.vtexaf||function(){(f.q=f.q||[]).push(arguments)}
17
- ;f.l=+new Date;s=t.createElement(e);s.async=!0;
18
- s.src=x;a=t.getElementsByTagName(e)[0];
19
- a.parentNode.insertBefore(s,a)
20
- })(window,document,'script','https://activity-flow.vtex.com/af/af.js');
21
- </script><script type="text/javascript">
22
- window.vtexaf('init', {
23
- account: 'storeframework',
24
- env: 'vtexcommercestable',
25
- workspace: 'master'
26
- });
27
- </script><script>!(function(w,p,f,c){c=w[p]=w[p]||{};c[f]=(c[f]||[])})(window,'partytown','forward');/* Partytown 0.6.4 - MIT builder.io */
28
- !function(t,e,n,i,r,o,a,d,s,c,p,l){function u(){l||(l=1,"/"==(a=(o.lib||"/~partytown/")+(o.debug?"debug/":""))[0]&&(s=e.querySelectorAll('script[type="text/partytown"]'),i!=t?i.dispatchEvent(new CustomEvent("pt1",{detail:t})):(d=setTimeout(w,1e4),e.addEventListener("pt0",f),r?h(1):n.serviceWorker?n.serviceWorker.register(a+(o.swPath||"partytown-sw.js"),{scope:a}).then((function(t){t.active?h():t.installing&&t.installing.addEventListener("statechange",(function(t){"activated"==t.target.state&&h()}))}),console.error):w())))}function h(t){c=e.createElement(t?"script":"iframe"),t||(c.setAttribute("style","display:block;width:0;height:0;border:0;visibility:hidden"),c.setAttribute("aria-hidden",!0)),c.src=a+"partytown-"+(t?"atomics.js?v=0.6.4":"sandbox-sw.html?"+Date.now()),e.body.appendChild(c)}function w(t,n){for(f(),t=0;t<s.length;t++)(n=e.createElement("script")).innerHTML=s[t].innerHTML,e.head.appendChild(n);c&&c.parentNode.removeChild(c)}function f(){clearTimeout(d)}o=t.partytown||{},i==t&&(o.forward||[]).map((function(e){p=t,e.split(".").map((function(e,n,i){p=p[i[n]]=n+1<i.length?"push"==i[n+1]?[]:p[i[n]]||{}:function(){(t._ptf=t._ptf||[]).push(i,arguments)}}))})),"complete"==e.readyState?u():(t.addEventListener("DOMContentLoaded",u),t.addEventListener("load",u))}(window,document,navigator,top,window.crossOriginIsolated);document.currentScript.dataset.partytown="";</script><link rel="preload" href="/_next/static/css/0a57ee6c7a57788c.css" as="style" crossorigin=""/><link rel="stylesheet" href="/_next/static/css/0a57ee6c7a57788c.css" crossorigin="" data-n-g=""/><link rel="preload" href="/_next/static/css/1fef663a0519dddf.css" as="style" crossorigin=""/><link rel="stylesheet" href="/_next/static/css/1fef663a0519dddf.css" crossorigin="" data-n-p=""/><link rel="preload" href="/_next/static/css/b7bba8fce075688b.css" as="style" crossorigin=""/><link rel="stylesheet" href="/_next/static/css/b7bba8fce075688b.css" crossorigin="" data-n-p=""/><noscript data-n-css=""></noscript><script defer="" crossorigin="" nomodule="" src="/_next/static/chunks/polyfills-c67a75d1b6f99dc8.js"></script><script src="/_next/static/chunks/webpack-b2d921b9d06db874.js" defer="" crossorigin=""></script><script src="/_next/static/chunks/framework-807b0f81cbc129f0.js" defer="" crossorigin=""></script><script src="/_next/static/chunks/main-f658704b53a96ab1.js" defer="" crossorigin=""></script><script src="/_next/static/chunks/pages/_app-eb6edb0ba4b4be67.js" defer="" crossorigin=""></script><script src="/_next/static/chunks/6031-18797e7ebff417ab.js" defer="" crossorigin=""></script><script src="/_next/static/chunks/9173-f1dbeccc6eaecda7.js" defer="" crossorigin=""></script><script src="/_next/static/chunks/pages/account/403-5037929d6d9f6ae3.js" defer="" crossorigin=""></script><script src="/_next/static/tpAEjQ5nDxLrA2DooSVfx/_buildManifest.js" defer="" crossorigin=""></script><script src="/_next/static/tpAEjQ5nDxLrA2DooSVfx/_ssgManifest.js" defer="" crossorigin=""></script></head><body class="theme"><div id="__next"><div data-store-section-name="Alert" style="height:823px;width:100%"></div><div data-store-section-name="Navbar" style="height:823px;width:100%"></div><div data-store-section-name="RegionBar" style="height:823px;width:100%"></div><div class="section_layout__QJ4xs"><div class="section_menu__WKZdl"><ul class="section_nav__Jjee8"><li class="section_navItem__yr27R" data-is-selected="false"><a data-fs-link="true" data-fs-link-variant="default" data-fs-link-size="regular" data-testid="fs-link" href="/account/orders" tabindex="0">Orders</a></li></ul></div><section><section class="section section_section__KG_b8 section-empty-state"><section data-fs-empty-state="true" data-fs-empty-state-variant="default" data-fs-empty-state-bkg-color="light" data-fs-content="empty-state" data-testid="fs-empty-state"><header data-fs-empty-state-title="true"><svg data-fs-icon="true" data-testid="fs-icon" width="56" height="56" stroke-width="8" aria-label="Shopping Cart"><use href="/icons.svg#ShoppingCart"></use></svg><p>Unauthorized Access</p></header><h2>You don&#x27;t have permission to access this page.</h2><a data-fs-button="true" data-fs-link-button="true" data-fs-button-size="regular" data-fs-button-variant="secondary" data-testid="fs-link-button" href="/account"><div data-fs-button-wrapper="true"><span>Back to Account</span></div></a></section></section></section></div><div data-store-section-name="Toast" style="height:823px;width:100%"></div><div data-store-section-name="Footer" style="height:823px;width:100%"></div></div><script id="__NEXT_DATA__" type="application/json" crossorigin="">{"props":{"pageProps":{"globalSections":{"id":"55379be7-488b-11f0-b37f-dbace3a56cb2","name":"Global Sections","type":"globalSections","status":"published","versionId":"57421dd3-488b-11f0-b37f-f0aeb8f72ca4","versionStatus":"published","sections":[{"id":"c1e438e3-48c6-4a8a-bb22-12d9ea08eeb4","name":"Alert","data":{"link":{"text":"Buy now","to":"/office"},"dismissible":true,"icon":"BellRinging","content":"Get 15% off today: NEW15!"}},{"id":"a2e7db96-e3a4-4ed3-b061-1984bf0adc95","name":"Navbar","data":{"logo":{"link":{"url":"/","title":"Go To Home"},"src":"https://storeframework.vtexassets.com/assets/vtex.file-manager-graphql/images/ab9997f4-8fd6-46f5-99d2-9d5af3ef5e34___6d75a203771d7408d8f0d1c660a076dd.png","alt":"Store logo"},"searchInput":{"sort":"score_desc"},"signInButton":{"icon":{"icon":"User","alt":"User"},"label":"Sign In","myAccountLabel":"My Account"},"cartIcon":{"icon":"ShoppingCart","alt":"Shopping Cart"},"navigation":{"regionalization":{"enabled":true,"icon":{"icon":"MapPin","alt":"MapPin"},"label":"Set Your Location"},"pageLinks":[{"text":"Office","url":"/office"},{"text":"Technology","url":"/technology"}],"menu":{"icon":{"icon":"List","alt":"List"}},"home":{"label":"Go to Home"}}}},{"id":"73158fb8-069e-4562-9515-2352eae5c700","name":"RegionBar","data":{"icon":{"icon":"MapPin","alt":"Map Pin icon"},"label":"Set your location","editLabel":"Edit","buttonIcon":{"icon":"CaretRight","alt":"Caret Right icon"}}},{"id":"3124e4b7-f017-451f-861f-6f2f6b054bd5","name":"CartSidebar","data":{"title":"Your Cart","alert":{"icon":{"icon":"Truck","alt":"Arrow Right icon"},"text":"Free shipping starts at $300"},"checkoutButton":{"label":"Checkout","loadingLabel":"Loading...","icon":{"icon":"ArrowRight","alt":"Arrow Right icon"}}}},{"id":"a0a95f54-0fbb-46b8-9f22-2b40a714df45","name":"RegionModal","data":{"title":"Set your location","description":"Prices, offers and availability may vary according to your location.","closeButtonAriaLabel":"Close Region Modal","inputField":{"label":"Postal Code","errorMessage":"You entered an invalid Postal Code"},"idkPostalCodeLink":{"text":"I don't know my Postal Code","icon":{"icon":"ArrowSquareOut","alt":"Arrow Square Out icon"}}}},{"id":"624924c3-d9b2-4d0a-b4ae-6c50e0017691","name":"Children","data":{}},{"id":"d9daaf4f-458c-4a39-b313-0268bc14e640","name":"Footer","data":{"incentives":[{"title":" ","firstLineText":"Trusted","icon":"ShieldCheck","secondLineText":"by Safecon"},{"title":" ","firstLineText":"Free","icon":"Calendar","secondLineText":"Return"},{"title":" ","firstLineText":"Pickup","icon":"Storefront","secondLineText":"Options"},{"firstLineText":"Free","secondLineText":"Shipping","title":" ","icon":"Truck"}],"footerLinks":[{"items":[{"text":"About Us","url":"https://starter.vtex.app"},{"text":"Our Blog","url":"https://starter.vtex.app"},{"text":"Stores","url":"https://starter.vtex.app"},{"text":"Work With Us","url":"https://starter.vtex.app"}],"sectionTitle":"Our company"},{"items":[{"text":"Returns and Exchanges","url":"/"},{"text":"Product Recall","url":"/"},{"text":"Gift Cards","url":"/"}],"sectionTitle":"Orders and Purchases"},{"items":[{"text":"Support Center","url":"/"},{"text":"Support \u0026 Services","url":"/"},{"text":"Contact Us","url":"/"}],"sectionTitle":"Support \u0026 Services"},{"items":[{"text":"Affiliate Program","url":"/"},{"text":"Marketplace","url":"/"}],"sectionTitle":"Partnerships"}],"footerSocial":{"title":"Follow Us","socialLinks":[{"icon":{"icon":"Facebook"},"alt":"Facebook","url":"https://www.facebook.com"},{"icon":{"icon":"Instagram"},"alt":"Instagram","url":"https://www.instagram.com"},{"icon":{"icon":"Pinterest"},"alt":"Pinterest","url":"https://www.pinterest.com"},{"icon":{"icon":"Twitter"},"alt":"Twitter","url":"https://www.twitter.com"}]},"logo":{"link":{"title":"FastStore Starter","url":"https://starter.vtex.app/"},"src":"https://storeframework.vtexassets.com/assets/vtex.file-manager-graphql/images/ec191c4a-32d8-41a9-9255-f319819bc98c___c24a66e2bef2c3f2bea07571a3636804.png","alt":"Store Logo"},"acceptedPaymentMethods":{"showPaymentMethods":true,"title":"Payment Methods","paymentMethods":[{"icon":{"icon":"Diners"},"alt":"Diners Club"},{"icon":{"icon":"Visa"},"alt":"Visa"},{"icon":{"icon":"Mastercard"},"alt":"Mastercard"},{"icon":{"icon":"EloCard"},"alt":"Elo Card"},{"icon":{"icon":"PayPal"},"alt":"PayPal"},{"icon":{"icon":"GooglePay"},"alt":"GooglePay"},{"icon":{"icon":"ApplePay"},"alt":"Apple Pay"}]},"copyrightInfo":"This website uses VTEX technology. In-store price may vary. Prices and offers are subject to change. 2023 Brandless Store. All rights reserved. Store is a trademark of Store and its affiliated companies. Mount St, 000, New York / NY - 00000."}}]}},"__N_SSG":true},"page":"/account/403","query":{},"buildId":"tpAEjQ5nDxLrA2DooSVfx","isFallback":false,"gsp":true,"locale":"en-US","locales":["en-US"],"defaultLocale":"en-US","scriptLoader":[]}</script></body></html>
@@ -1 +0,0 @@
1
- {"pageProps":{"globalSections":{"id":"55379be7-488b-11f0-b37f-dbace3a56cb2","name":"Global Sections","type":"globalSections","status":"published","versionId":"57421dd3-488b-11f0-b37f-f0aeb8f72ca4","versionStatus":"published","sections":[{"id":"c1e438e3-48c6-4a8a-bb22-12d9ea08eeb4","name":"Alert","data":{"link":{"text":"Buy now","to":"/office"},"dismissible":true,"icon":"BellRinging","content":"Get 15% off today: NEW15!"}},{"id":"a2e7db96-e3a4-4ed3-b061-1984bf0adc95","name":"Navbar","data":{"logo":{"link":{"url":"/","title":"Go To Home"},"src":"https://storeframework.vtexassets.com/assets/vtex.file-manager-graphql/images/ab9997f4-8fd6-46f5-99d2-9d5af3ef5e34___6d75a203771d7408d8f0d1c660a076dd.png","alt":"Store logo"},"searchInput":{"sort":"score_desc"},"signInButton":{"icon":{"icon":"User","alt":"User"},"label":"Sign In","myAccountLabel":"My Account"},"cartIcon":{"icon":"ShoppingCart","alt":"Shopping Cart"},"navigation":{"regionalization":{"enabled":true,"icon":{"icon":"MapPin","alt":"MapPin"},"label":"Set Your Location"},"pageLinks":[{"text":"Office","url":"/office"},{"text":"Technology","url":"/technology"}],"menu":{"icon":{"icon":"List","alt":"List"}},"home":{"label":"Go to Home"}}}},{"id":"73158fb8-069e-4562-9515-2352eae5c700","name":"RegionBar","data":{"icon":{"icon":"MapPin","alt":"Map Pin icon"},"label":"Set your location","editLabel":"Edit","buttonIcon":{"icon":"CaretRight","alt":"Caret Right icon"}}},{"id":"3124e4b7-f017-451f-861f-6f2f6b054bd5","name":"CartSidebar","data":{"title":"Your Cart","alert":{"icon":{"icon":"Truck","alt":"Arrow Right icon"},"text":"Free shipping starts at $300"},"checkoutButton":{"label":"Checkout","loadingLabel":"Loading...","icon":{"icon":"ArrowRight","alt":"Arrow Right icon"}}}},{"id":"a0a95f54-0fbb-46b8-9f22-2b40a714df45","name":"RegionModal","data":{"title":"Set your location","description":"Prices, offers and availability may vary according to your location.","closeButtonAriaLabel":"Close Region Modal","inputField":{"label":"Postal Code","errorMessage":"You entered an invalid Postal Code"},"idkPostalCodeLink":{"text":"I don't know my Postal Code","icon":{"icon":"ArrowSquareOut","alt":"Arrow Square Out icon"}}}},{"id":"624924c3-d9b2-4d0a-b4ae-6c50e0017691","name":"Children","data":{}},{"id":"d9daaf4f-458c-4a39-b313-0268bc14e640","name":"Footer","data":{"incentives":[{"title":" ","firstLineText":"Trusted","icon":"ShieldCheck","secondLineText":"by Safecon"},{"title":" ","firstLineText":"Free","icon":"Calendar","secondLineText":"Return"},{"title":" ","firstLineText":"Pickup","icon":"Storefront","secondLineText":"Options"},{"firstLineText":"Free","secondLineText":"Shipping","title":" ","icon":"Truck"}],"footerLinks":[{"items":[{"text":"About Us","url":"https://starter.vtex.app"},{"text":"Our Blog","url":"https://starter.vtex.app"},{"text":"Stores","url":"https://starter.vtex.app"},{"text":"Work With Us","url":"https://starter.vtex.app"}],"sectionTitle":"Our company"},{"items":[{"text":"Returns and Exchanges","url":"/"},{"text":"Product Recall","url":"/"},{"text":"Gift Cards","url":"/"}],"sectionTitle":"Orders and Purchases"},{"items":[{"text":"Support Center","url":"/"},{"text":"Support & Services","url":"/"},{"text":"Contact Us","url":"/"}],"sectionTitle":"Support & Services"},{"items":[{"text":"Affiliate Program","url":"/"},{"text":"Marketplace","url":"/"}],"sectionTitle":"Partnerships"}],"footerSocial":{"title":"Follow Us","socialLinks":[{"icon":{"icon":"Facebook"},"alt":"Facebook","url":"https://www.facebook.com"},{"icon":{"icon":"Instagram"},"alt":"Instagram","url":"https://www.instagram.com"},{"icon":{"icon":"Pinterest"},"alt":"Pinterest","url":"https://www.pinterest.com"},{"icon":{"icon":"Twitter"},"alt":"Twitter","url":"https://www.twitter.com"}]},"logo":{"link":{"title":"FastStore Starter","url":"https://starter.vtex.app/"},"src":"https://storeframework.vtexassets.com/assets/vtex.file-manager-graphql/images/ec191c4a-32d8-41a9-9255-f319819bc98c___c24a66e2bef2c3f2bea07571a3636804.png","alt":"Store Logo"},"acceptedPaymentMethods":{"showPaymentMethods":true,"title":"Payment Methods","paymentMethods":[{"icon":{"icon":"Diners"},"alt":"Diners Club"},{"icon":{"icon":"Visa"},"alt":"Visa"},{"icon":{"icon":"Mastercard"},"alt":"Mastercard"},{"icon":{"icon":"EloCard"},"alt":"Elo Card"},{"icon":{"icon":"PayPal"},"alt":"PayPal"},{"icon":{"icon":"GooglePay"},"alt":"GooglePay"},{"icon":{"icon":"ApplePay"},"alt":"Apple Pay"}]},"copyrightInfo":"This website uses VTEX technology. In-store price may vary. Prices and offers are subject to change. 2023 Brandless Store. All rights reserved. Store is a trademark of Store and its affiliated companies. Mount St, 000, New York / NY - 00000."}}]}},"__N_SSG":true}