@faststore/core 3.35.0 → 3.36.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 (73) hide show
  1. package/.next/BUILD_ID +1 -1
  2. package/.next/build-manifest.json +25 -15
  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 +2 -2
  12. package/.next/routes-manifest.json +1 -1
  13. package/.next/server/chunks/1506.js +1 -1
  14. package/.next/server/chunks/3117.js +1 -1
  15. package/.next/server/chunks/8646.js +1 -1
  16. package/.next/server/functions-config-manifest.json +1 -1
  17. package/.next/server/middleware-build-manifest.js +1 -1
  18. package/.next/server/middleware-react-loadable-manifest.js +1 -1
  19. package/.next/server/pages/account/profile.js +1 -0
  20. package/.next/server/pages/account/profile.js.nft.json +1 -0
  21. package/.next/server/pages/account.js +1 -1
  22. package/.next/server/pages/api/graphql.js +1 -1
  23. package/.next/server/pages/en-US/404.html +2 -2
  24. package/.next/server/pages/en-US/404.json +1 -1
  25. package/.next/server/pages/en-US/500.html +2 -2
  26. package/.next/server/pages/en-US/500.json +1 -1
  27. package/.next/server/pages/en-US/checkout.html +2 -2
  28. package/.next/server/pages/en-US/checkout.json +1 -1
  29. package/.next/server/pages/en-US/login.html +2 -2
  30. package/.next/server/pages/en-US/login.json +1 -1
  31. package/.next/server/pages/en-US/s.html +2 -2
  32. package/.next/server/pages/en-US/s.json +1 -1
  33. package/.next/server/pages/en-US.html +2 -2
  34. package/.next/server/pages/en-US.json +1 -1
  35. package/.next/server/pages-manifest.json +1 -1
  36. package/.next/static/chunks/{1552.b5a073e7ac834965.js → 1552.e7cece605fc2e1cd.js} +1 -1
  37. package/.next/static/chunks/CartSidebar.26d3e39bf93a368f.js +1 -0
  38. package/.next/static/chunks/pages/{_app-836e2ad874a5b36e.js → _app-012e51403727ae6a.js} +1 -1
  39. package/.next/static/chunks/pages/account/profile-1fdb500de8f12b3a.js +1 -0
  40. package/.next/static/chunks/pages/account-32bc9db3fea9b0c4.js +1 -0
  41. package/.next/static/chunks/webpack-1cd1c4aa7f418483.js +1 -0
  42. package/.next/static/css/249b9deaabc0d32d.css +1 -0
  43. package/.next/static/go585duKn6vmUmdZiKusb/_buildManifest.js +1 -0
  44. package/.next/static/go585duKn6vmUmdZiKusb/_ssgManifest.js +1 -0
  45. package/.next/trace +124 -122
  46. package/.turbo/turbo-build.log +18 -16
  47. package/.turbo/turbo-test.log +5 -5
  48. package/CHANGELOG.md +12 -0
  49. package/discovery.config.default.js +1 -0
  50. package/index.ts +1 -0
  51. package/package.json +2 -2
  52. package/src/components/account/MyAccountLayout/MyAccountLayout.tsx +25 -0
  53. package/src/components/account/MyAccountLayout/index.ts +1 -0
  54. package/src/components/account/MyAccountLayout/styles.scss +17 -0
  55. package/src/components/account/MyAccountMenu/MyAccountMenu.tsx +74 -0
  56. package/src/components/account/MyAccountMenu/index.ts +1 -0
  57. package/src/components/account/MyAccountMenu/styles.scss +124 -0
  58. package/src/components/account/index.ts +2 -0
  59. package/src/components/account/section.module.scss +3 -0
  60. package/src/components/cart/CartSidebar/CartSidebar.tsx +7 -2
  61. package/src/customizations/src/myAccount/navigation.ts +3 -0
  62. package/src/experimental/myAccountSeverSideProps.ts +42 -0
  63. package/src/pages/account/index.tsx +44 -0
  64. package/src/pages/account/profile.tsx +48 -0
  65. package/src/sdk/account/getMyAccountRoutes.ts +34 -0
  66. package/.next/server/pages/en-US/account.html +0 -28
  67. package/.next/server/pages/en-US/account.json +0 -1
  68. package/.next/static/Mhu8_zB9OvbEDLsJZoDbf/_buildManifest.js +0 -1
  69. package/.next/static/Mhu8_zB9OvbEDLsJZoDbf/_ssgManifest.js +0 -1
  70. package/.next/static/chunks/CartSidebar.11e73132b1647eec.js +0 -1
  71. package/.next/static/chunks/pages/account-2123c229c3e93039.js +0 -1
  72. package/.next/static/chunks/webpack-c5394865bff5422b.js +0 -1
  73. package/src/pages/account.tsx +0 -72
@@ -1,23 +1,23 @@
1
1
 
2
- > @faststore/core@3.34.0 prebuild /home/runner/work/faststore/faststore/packages/core
2
+ > @faststore/core@3.35.1 prebuild /home/runner/work/faststore/faststore/packages/core
3
3
  > na run partytown && na run generate
4
4
 
5
5
 
6
- > @faststore/core@3.34.0 partytown /home/runner/work/faststore/faststore/packages/core
6
+ > @faststore/core@3.35.1 partytown /home/runner/work/faststore/faststore/packages/core
7
7
  > partytown copylib ./public/~partytown
8
8
 
9
9
  Partytown lib copied to: /home/runner/work/faststore/faststore/packages/core/public/~partytown
10
10
 
11
- > @faststore/core@3.34.0 generate /home/runner/work/faststore/faststore/packages/core
11
+ > @faststore/core@3.35.1 generate /home/runner/work/faststore/faststore/packages/core
12
12
  > na run generate:schema && na run generate:codegen && na run format:generated
13
13
 
14
14
 
15
- > @faststore/core@3.34.0 generate:schema /home/runner/work/faststore/faststore/packages/core
15
+ > @faststore/core@3.35.1 generate:schema /home/runner/work/faststore/faststore/packages/core
16
16
  > tsx src/server/generator/generateGraphQLSchemaFile.ts
17
17
 
18
18
  Schema GraphQL file generated successfully
19
19
 
20
- > @faststore/core@3.34.0 generate:codegen /home/runner/work/faststore/faststore/packages/core
20
+ > @faststore/core@3.35.1 generate:codegen /home/runner/work/faststore/faststore/packages/core
21
21
  > graphql-codegen
22
22
 
23
23
  [STARTED] Parse Configuration
@@ -37,11 +37,11 @@ Running lifecycle hook "afterStart" scripts...
37
37
  [CLI] Loading Documents
38
38
  [CLI] Generating output
39
39
 
40
- > @faststore/core@3.34.0 format:generated /home/runner/work/faststore/faststore/packages/core
40
+ > @faststore/core@3.35.1 format:generated /home/runner/work/faststore/faststore/packages/core
41
41
  > prettier --write "@generated/**/*.{ts,js,tsx,jsx,json}" --loglevel error
42
42
 
43
43
 
44
- > @faststore/core@3.34.0 build /home/runner/work/faststore/faststore/packages/core
44
+ > @faststore/core@3.35.1 build /home/runner/work/faststore/faststore/packages/core
45
45
  > next build
46
46
 
47
47
  ⚠ No build cache found. Please configure build caching for faster rebuilds. Read more: https://nextjs.org/docs/messages/no-cache
@@ -57,12 +57,12 @@ https://nextjs.org/telemetry
57
57
  Using external babel configuration from /home/runner/work/faststore/faststore/packages/core/.babelrc.js
58
58
  ✓ Compiled successfully
59
59
  Collecting page data ...
60
- Generating static pages (0/7) ...
61
-
62
60
  Generating static pages (1/7)
61
+ Generating static pages (0/6) ...
62
+
63
63
  Generating static pages (1/6)
64
64
  Warning: Dynamic Content not found for the page: home. Refer to the Dynamic Content documentation at https://developers.vtex.com/docs/guides/faststore/dynamic-content-overview for mapping the page and the corresponding data-fetching function.
65
-
66
65
  Generating static pages (3/7)
67
-
68
66
  Generating static pages (5/7)
69
-
70
67
  ✓ Generating static pages (7/7)
68
+
71
69
  Generating static pages (2/6)
70
+
72
71
  Generating static pages (4/6)
72
+
73
73
  ✓ Generating static pages (6/6)
74
74
  Finalizing page optimization ...
75
75
  Collecting build traces ...
76
76
 
@@ -77,7 +77,9 @@ Route (pages) Size First Load JS
77
77
  ├ └ css/b5bf49598c8f8b66.css 16.1 kB
78
78
  ├ ○ /404 1.48 kB 122 kB
79
79
  ├ ● /500 1.48 kB 122 kB
80
- /account 712 B 121 kB
80
+ λ /account 767 B 121 kB
81
+ ├ λ /account/profile 1.34 kB 122 kB
82
+ ├ └ css/249b9deaabc0d32d.css 2.51 kB
81
83
  ├ λ /api/graphql 0 B 92.4 kB
82
84
  ├ λ /api/health/live 0 B 92.4 kB
83
85
  ├ λ /api/health/ready 0 B 92.4 kB
@@ -85,11 +87,11 @@ Route (pages) Size First Load JS
85
87
  ├ ● /checkout 694 B 121 kB
86
88
  ├ ● /login 1.59 kB 122 kB
87
89
  └ ● /s 3.18 kB 134 kB
88
- + First Load JS shared by all 95.8 kB
90
+ + First Load JS shared by all 95.9 kB
89
91
  ├ chunks/framework-807b0f81cbc129f0.js 45.4 kB
90
92
  ├ chunks/main-5569625b3fdd6741.js 33.1 kB
91
- ├ chunks/pages/_app-836e2ad874a5b36e.js 10.3 kB
92
- ├ chunks/webpack-c5394865bff5422b.js 3.58 kB
93
+ ├ chunks/pages/_app-012e51403727ae6a.js 10.4 kB
94
+ ├ chunks/webpack-1cd1c4aa7f418483.js 3.59 kB
93
95
  └ css/0a57ee6c7a57788c.css 3.49 kB
94
96
 
95
97
  λ (Server) server-side renders at runtime (uses getInitialProps or getServerSideProps)
@@ -1,14 +1,14 @@
1
1
 
2
- > @faststore/core@3.34.0 test /home/runner/work/faststore/faststore/packages/core
2
+ > @faststore/core@3.35.1 test /home/runner/work/faststore/faststore/packages/core
3
3
  > jest
4
4
 
5
- PASS test/server/cms/global.test.ts (25.214 s)
6
- PASS test/utils/multipleTemplates.test.ts (26.454 s)
5
+ PASS test/utils/multipleTemplates.test.ts (22.915 s)
6
+ PASS test/server/cms/global.test.ts (23.944 s)
7
7
  PASS test/server/cms/index.test.ts
8
- PASS test/server/index.test.ts (32.955 s)
8
+ PASS test/server/index.test.ts (29.285 s)
9
9
 
10
10
  Test Suites: 4 passed, 4 total
11
11
  Tests: 22 passed, 22 total
12
12
  Snapshots: 0 total
13
- Time: 34.128 s
13
+ Time: 30.513 s
14
14
  Ran all test suites.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,18 @@
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
+ # [3.36.0](https://github.com/vtex/faststore/compare/v3.35.1...v3.36.0) (2025-04-09)
7
+
8
+ ### Features
9
+
10
+ - My Account Menu and Extensibility ([#2761](https://github.com/vtex/faststore/issues/2761)) ([0daf07a](https://github.com/vtex/faststore/commit/0daf07a7fdf524992472d9f9b4a013885aa175a2)), closes [#2729](https://github.com/vtex/faststore/issues/2729) [#2720](https://github.com/vtex/faststore/issues/2720) [#2738](https://github.com/vtex/faststore/issues/2738) [#2752](https://github.com/vtex/faststore/issues/2752)
11
+
12
+ ## [3.35.1](https://github.com/vtex/faststore/compare/v3.35.0...v3.35.1) (2025-04-08)
13
+
14
+ ### Bug Fixes
15
+
16
+ - multiple view_cart events ([#2770](https://github.com/vtex/faststore/issues/2770)) ([9e8234b](https://github.com/vtex/faststore/commit/9e8234b0e097b7c4a749584e491c556cbdab4a31))
17
+
6
18
  # [3.35.0](https://github.com/vtex/faststore/compare/v3.34.0...v3.35.0) (2025-04-08)
7
19
 
8
20
  ### Features
@@ -130,6 +130,7 @@ module.exports = {
130
130
  preact: false,
131
131
  enableRedirects: false,
132
132
  enableSearchSSR: false,
133
+ enableFaststoreMyAccount: false,
133
134
  enableVtexAssetsLoader: false,
134
135
  graphqlCacheControl: {
135
136
  maxAge: 0, // 0 disables cache, 5 * 60 enable cache control maxAge 5 minutes
package/index.ts CHANGED
@@ -10,6 +10,7 @@ export { useProductsQuery } from './src/sdk/product/useProductsQuery'
10
10
 
11
11
  export * from './src/typings/overrides'
12
12
  export { getOverriddenSection } from './src/sdk/overrides/getOverriddenSection'
13
+ export { getMyAccountRoutes } from './src/sdk/account/getMyAccountRoutes'
13
14
 
14
15
  // Overridable Sections
15
16
  export { default as AlertSection } from './src/components/sections/Alert'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@faststore/core",
3
- "version": "3.35.0",
3
+ "version": "3.36.0",
4
4
  "license": "MIT",
5
5
  "repository": "vtex/faststore",
6
6
  "browserslist": "supports es6-module and not dead",
@@ -105,5 +105,5 @@
105
105
  "ts-jest": "29.1.1",
106
106
  "typescript": "5.3.2"
107
107
  },
108
- "gitHead": "d7888ccc4f9e5511cc18a483d5d0014fdf15f6ab"
108
+ "gitHead": "02b2a2e2ef528893276e4ae88d0ef5fda96c4bf7"
109
109
  }
@@ -0,0 +1,25 @@
1
+ import type { PropsWithChildren } from 'react'
2
+ import MyAccountMenu from '../MyAccountMenu'
3
+ import menuRoutes from 'src/customizations/src/myAccount/navigation'
4
+ import styles from '../section.module.scss'
5
+
6
+ export type MyAccountLayoutProps = {}
7
+
8
+ /* ######################################### */
9
+ /* Mocked Data until development is finished */
10
+ const mockedUserName = 'Mocked Username'
11
+
12
+ /* ######################################### */
13
+
14
+ const MyAccountLayout = ({
15
+ children,
16
+ }: PropsWithChildren<MyAccountLayoutProps>) => {
17
+ return (
18
+ <div className={styles.layout}>
19
+ <MyAccountMenu accountName={mockedUserName} items={menuRoutes} />
20
+ {children}
21
+ </div>
22
+ )
23
+ }
24
+
25
+ export default MyAccountLayout
@@ -0,0 +1 @@
1
+ export { default } from './MyAccountLayout'
@@ -0,0 +1,17 @@
1
+ .layout {
2
+ @import "@faststore/ui/src/components/atoms/Button/styles.scss";
3
+ @import "../MyAccountMenu/styles.scss";
4
+
5
+ display: grid;
6
+ grid-template-rows: auto 1fr;
7
+ min-height: calc(100vh - 18rem);
8
+
9
+ @include media(">=notebook") {
10
+ grid-template-rows: none;
11
+ grid-template-columns: max(300px) auto;
12
+ gap: var(--fs-spacing-8);
13
+ max-width: var(--fs-grid-max-width);
14
+ padding: 0;
15
+ margin: 0 auto;
16
+ }
17
+ }
@@ -0,0 +1,74 @@
1
+ import { Button, Link } from '@faststore/ui'
2
+ import { useRouter } from 'next/router'
3
+
4
+ import styles from '../section.module.scss'
5
+
6
+ import useScreenResize from 'src/sdk/ui/useScreenResize'
7
+
8
+ interface NavItem {
9
+ title: string
10
+ route: string
11
+ }
12
+
13
+ export interface MyAccountMenuProps
14
+ extends React.HTMLAttributes<HTMLDivElement> {
15
+ avatarImageUrl?: string
16
+ accountName: string
17
+ items: NavItem[]
18
+ }
19
+
20
+ const Nav = ({ items }: Pick<MyAccountMenuProps, 'items'>) => {
21
+ const router = useRouter()
22
+ const currentRoute = router.pathname
23
+
24
+ return (
25
+ <ul className={styles.nav}>
26
+ {items.map(({ route, title }) => (
27
+ <li
28
+ className={styles.navItem}
29
+ data-is-selected={currentRoute === route}
30
+ key={route}
31
+ >
32
+ <Link href={route} tabIndex={0}>
33
+ {title}
34
+ </Link>
35
+ </li>
36
+ ))}
37
+ </ul>
38
+ )
39
+ }
40
+
41
+ const MyAccountMenu = ({
42
+ avatarImageUrl,
43
+ accountName,
44
+ items,
45
+ }: MyAccountMenuProps) => {
46
+ const { isDesktop } = useScreenResize()
47
+
48
+ return (
49
+ <div className={styles.menu}>
50
+ {isDesktop ? (
51
+ <div className={styles.account}>
52
+ <div className={styles.avatarContainer}>
53
+ {avatarImageUrl ? (
54
+ <img className={styles.avatar} src={avatarImageUrl} />
55
+ ) : (
56
+ <span className={styles.avatar}>{accountName[0]}</span>
57
+ )}
58
+ <h2>{accountName}</h2>
59
+ </div>
60
+ <Button
61
+ className={styles.switchButton}
62
+ variant="secondary"
63
+ size="small"
64
+ >
65
+ Switch
66
+ </Button>
67
+ </div>
68
+ ) : null}
69
+ <Nav items={items} />
70
+ </div>
71
+ )
72
+ }
73
+
74
+ export default MyAccountMenu
@@ -0,0 +1 @@
1
+ export { default } from './MyAccountMenu'
@@ -0,0 +1,124 @@
1
+ .menu {
2
+ display: flex;
3
+ flex-direction: column;
4
+ max-height: inherit;
5
+ padding: var(--fs-spacing-3);
6
+ overflow: scroll;
7
+ scrollbar-width: none;
8
+ -ms-overflow-style: none;
9
+ }
10
+
11
+ .account {
12
+ display: flex;
13
+ align-items: flex-end;
14
+ justify-content: space-between;
15
+ width: 100%;
16
+ padding-bottom: var(--fs-spacing-5);
17
+ }
18
+
19
+ .avatarContainer {
20
+ display: grid;
21
+ grid-template-rows: auto;
22
+ gap: var(--fs-spacing-2);
23
+ align-items: center;
24
+ padding-bottom: var(--fs-spacing-1);
25
+
26
+ h2 {
27
+ font-size: var(--fs-text-size-3);
28
+ font-weight: var(--fs-text-weight-semibold);
29
+ line-height: var(--fs-text-size-5);
30
+ }
31
+ }
32
+
33
+ .switchButton {
34
+ display: none; /* While it's use case is not implemented */
35
+ max-width: fit-content;
36
+ height: 1.5rem;
37
+ }
38
+
39
+ .nav {
40
+ display: flex;
41
+ gap: var(--fs-spacing-1);
42
+ }
43
+
44
+ .navItem {
45
+ align-content: center;
46
+ height: var(--fs-spacing-6);
47
+ font-size: var(--fs-text-size-1);
48
+ font-weight: var(--fs-text-weight-medium);
49
+ background-color: var(--fs-color-tertiary-bkg);
50
+ border-radius: var(--fs-border-radius-pill);
51
+
52
+ &:hover,
53
+ &[data-is-selected="true"] {
54
+ background-color: var(--fs-color-tertiary-bkg-hover);
55
+ }
56
+
57
+ &:active {
58
+ background-color: var(--fs-color-tertiary-bkg-active);
59
+ outline: none;
60
+ }
61
+
62
+ &:disabled {
63
+ color: var(--fs-color-disabled-text);
64
+ cursor: not-allowed;
65
+ background-color: var(--fs-color-tertiary-bkg-disabled);
66
+ }
67
+
68
+ >a,
69
+ a:link,
70
+ a:visited {
71
+ display: inline-block;
72
+ align-content: center;
73
+ width: max-content;
74
+ width: 100%;
75
+ height: 100%;
76
+ padding: 0 var(--fs-spacing-3);
77
+ color: var(--fs-color-text);
78
+ text-decoration: none;
79
+ background-color: transparent;
80
+ border-radius: var(--fs-border-radius-pill);
81
+
82
+ &:focus-visible {
83
+ outline: 3px solid var(--fs-color-focus-ring);
84
+ box-shadow: none;
85
+ }
86
+ }
87
+ }
88
+
89
+ @include media(">=notebook") {
90
+ grid-template-rows: none;
91
+ grid-template-columns: max(300px) 80%;
92
+ gap: var(--fs-spacing-8);
93
+ padding: 0 var(--fs-spacing-8);
94
+
95
+ .menu {
96
+ padding: 0;
97
+ padding-top: var(--fs-spacing-6);
98
+ overflow: visible;
99
+ }
100
+
101
+ .nav {
102
+ flex-direction: column;
103
+ gap: 0;
104
+ }
105
+
106
+ .navItem {
107
+ margin-left: -16px;
108
+ }
109
+
110
+ .avatar {
111
+ display: flex;
112
+ align-items: center;
113
+ justify-content: center;
114
+ width: var(--fs-spacing-8);
115
+ height: var(--fs-spacing-8);
116
+ font-size: var(--fs-text-size-4);
117
+ font-weight: var(--fs-text-weight-semibold);
118
+ color: var(--fs-color-main-2);
119
+ text-align: center;
120
+ background-color: var(--fs-color-accent-0);
121
+ border: var(--spacing-1) solid var(--fs-color-neutral-0);
122
+ border-radius: var(--fs-border-radius-circle);
123
+ }
124
+ }
@@ -0,0 +1,2 @@
1
+ export { default as MyAccountLayout } from './MyAccountLayout'
2
+ export { default as MyAccountMenu } from './MyAccountMenu'
@@ -0,0 +1,3 @@
1
+ @layer components {
2
+ @import "./MyAccountLayout/styles.scss";
3
+ }
@@ -65,7 +65,12 @@ function useViewCartEvent() {
65
65
  const {
66
66
  currency: { code },
67
67
  } = useSession()
68
- const { items, gifts, total } = useCart()
68
+ const { items: itemsFromCart, gifts: giftsFromCart, total } = useCart()
69
+
70
+ // We need to stringify the items and gifts to avoid circular references
71
+ // when sending the event to the analytics
72
+ const gifts = JSON.stringify(giftsFromCart)
73
+ const items = JSON.stringify(itemsFromCart)
69
74
 
70
75
  const sendViewCartEvent = useCallback(() => {
71
76
  import('@faststore/sdk').then(({ sendAnalyticsEvent }) => {
@@ -74,7 +79,7 @@ function useViewCartEvent() {
74
79
  params: {
75
80
  currency: code as CurrencyCode,
76
81
  value: total,
77
- items: items.concat(gifts).map((item) => ({
82
+ items: itemsFromCart.concat(giftsFromCart).map((item) => ({
78
83
  item_id: item.itemOffered.isVariantOf.productGroupID,
79
84
  item_name: item.itemOffered.isVariantOf.name,
80
85
  item_brand: item.itemOffered.brand.name,
@@ -0,0 +1,3 @@
1
+ import { getMyAccountRoutes } from 'src/sdk/account/getMyAccountRoutes'
2
+
3
+ export default getMyAccountRoutes({ routes: [] })
@@ -0,0 +1,42 @@
1
+ import type { Locator } from '@vtex/client-cms'
2
+ import type { GetServerSideProps } from 'next'
3
+
4
+ import {
5
+ type GlobalSectionsData,
6
+ getGlobalSectionsData,
7
+ } from 'src/components/cms/GlobalSections'
8
+
9
+ import { injectGlobalSections } from 'src/server/cms/global'
10
+
11
+ export type MyAccountProps = {
12
+ globalSections: GlobalSectionsData
13
+ }
14
+
15
+ export const getServerSideProps: GetServerSideProps<
16
+ MyAccountProps,
17
+ Record<string, string>,
18
+ Locator
19
+ > = async ({ previewData }) => {
20
+ const [
21
+ globalSectionsPromise,
22
+ globalSectionsHeaderPromise,
23
+ globalSectionsFooterPromise,
24
+ ] = getGlobalSectionsData(previewData)
25
+
26
+ const [globalSections, globalSectionsHeader, globalSectionsFooter] =
27
+ await Promise.all([
28
+ globalSectionsPromise,
29
+ globalSectionsHeaderPromise,
30
+ globalSectionsFooterPromise,
31
+ ])
32
+
33
+ const globalSectionsResult = injectGlobalSections({
34
+ globalSections,
35
+ globalSectionsHeader,
36
+ globalSectionsFooter,
37
+ })
38
+
39
+ return {
40
+ props: { globalSections: globalSectionsResult },
41
+ }
42
+ }
@@ -0,0 +1,44 @@
1
+ import { NextSeo } from 'next-seo'
2
+ import type { ComponentType } from 'react'
3
+ import { useEffect } from 'react'
4
+ import RenderSections from 'src/components/cms/RenderSections'
5
+ import { default as GLOBAL_COMPONENTS } from 'src/components/cms/global/Components'
6
+ import CUSTOM_COMPONENTS from 'src/customizations/src/components'
7
+ import storeConfig from 'discovery.config'
8
+ import {
9
+ getServerSideProps,
10
+ type MyAccountProps,
11
+ } from 'src/experimental/myAccountSeverSideProps'
12
+ import { useRouter } from 'next/router'
13
+
14
+ /* A list of components that can be used in the CMS. */
15
+ const COMPONENTS: Record<string, ComponentType<any>> = {
16
+ ...GLOBAL_COMPONENTS,
17
+ ...CUSTOM_COMPONENTS,
18
+ }
19
+
20
+ function Page({ globalSections }: MyAccountProps) {
21
+ const router = useRouter()
22
+ useEffect(() => {
23
+ if (storeConfig.experimental.enableFaststoreMyAccount) {
24
+ router.push('/account/profile') // current default path in my account
25
+ } else {
26
+ window.location.href = `${storeConfig.accountUrl}${window.location.search}`
27
+ }
28
+ }, [])
29
+
30
+ return (
31
+ <RenderSections
32
+ globalSections={globalSections.sections}
33
+ components={COMPONENTS}
34
+ >
35
+ <NextSeo noindex nofollow />
36
+
37
+ <div>loading...</div>
38
+ </RenderSections>
39
+ )
40
+ }
41
+
42
+ export { getServerSideProps }
43
+
44
+ export default Page
@@ -0,0 +1,48 @@
1
+ /* ######################################### */
2
+ /* Mocked Page until development is finished, it will be removed after */
3
+
4
+ import { NextSeo } from 'next-seo'
5
+ import type { ComponentType } from 'react'
6
+ import { MyAccountLayout } from 'src/components/account'
7
+ import RenderSections from 'src/components/cms/RenderSections'
8
+ import { default as GLOBAL_COMPONENTS } from 'src/components/cms/global/Components'
9
+ import CUSTOM_COMPONENTS from 'src/customizations/src/components'
10
+ import {
11
+ getServerSideProps,
12
+ type MyAccountProps,
13
+ } from 'src/experimental/myAccountSeverSideProps'
14
+
15
+ /* A list of components that can be used in the CMS. */
16
+ const COMPONENTS: Record<string, ComponentType<any>> = {
17
+ ...GLOBAL_COMPONENTS,
18
+ ...CUSTOM_COMPONENTS,
19
+ }
20
+
21
+ const style = {
22
+ alignContent: 'center',
23
+ justifyContent: 'center',
24
+ alignItems: 'center',
25
+ display: 'flex',
26
+ h1: {
27
+ fontSize: '100px',
28
+ },
29
+ }
30
+
31
+ export default function Profile({ globalSections }: MyAccountProps) {
32
+ return (
33
+ <RenderSections
34
+ globalSections={globalSections.sections}
35
+ components={COMPONENTS}
36
+ >
37
+ <NextSeo noindex nofollow />
38
+
39
+ <MyAccountLayout>
40
+ <div style={style}>
41
+ <h1 style={style.h1}>Profile</h1>
42
+ </div>
43
+ </MyAccountLayout>
44
+ </RenderSections>
45
+ )
46
+ }
47
+
48
+ export { getServerSideProps }
@@ -0,0 +1,34 @@
1
+ interface Route {
2
+ /* Page name, displayed in the sidebar */
3
+ title: string
4
+ /* Accessible path within My Account */
5
+ route: string
6
+ }
7
+
8
+ interface GetMyAccountRouteParams {
9
+ /* Route list */
10
+ routes: Route[]
11
+ }
12
+
13
+ const DEFAULT_ROUTES: Route[] = [
14
+ {
15
+ title: 'Profile',
16
+ route: '/account/profile',
17
+ },
18
+ {
19
+ title: 'Orders',
20
+ route: '/account/orders',
21
+ },
22
+ {
23
+ title: 'User Details',
24
+ route: '/account/user-details',
25
+ },
26
+ {
27
+ title: 'Security',
28
+ route: '/account/security',
29
+ },
30
+ ]
31
+
32
+ export function getMyAccountRoutes({ routes }: GetMyAccountRouteParams) {
33
+ return [...DEFAULT_ROUTES, ...routes]
34
+ }