@faststore/core 2.0.117-alpha.0 → 2.0.120-alpha.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/.turbo/turbo-build.log +38 -26
- package/CHANGELOG.md +10 -0
- package/cms/faststore/content-types.json +6 -0
- package/cms/faststore/sections.json +8 -0
- package/package.json +3 -3
- package/src/Layout.tsx +2 -24
- package/src/components/cms/GlobalSections.tsx +81 -0
- package/src/components/cms/RenderSections.tsx +39 -0
- package/src/components/common/Alert/Alert.tsx +7 -5
- package/src/components/common/Alert/index.ts +1 -0
- package/src/components/sections/Alert/Alert.tsx +28 -0
- package/src/pages/404.tsx +25 -3
- package/src/pages/500.tsx +25 -3
- package/src/pages/[...slug].tsx +85 -66
- package/src/pages/[slug]/p.tsx +16 -6
- package/src/pages/account.tsx +25 -3
- package/src/pages/checkout.tsx +25 -3
- package/src/pages/index.tsx +20 -10
- package/src/pages/login.tsx +25 -3
- package/src/pages/s.tsx +63 -39
- package/.next/BUILD_ID +0 -1
- package/.next/build-manifest.json +0 -99
- package/.next/cache/.tsbuildinfo +0 -1
- package/.next/cache/config.json +0 -7
- package/.next/cache/eslint/.cache_1gneedd +0 -1
- package/.next/cache/next-server.js.nft.json +0 -1
- 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/export-marker.json +0 -1
- package/.next/images-manifest.json +0 -1
- package/.next/next-server.js.nft.json +0 -1
- package/.next/package.json +0 -1
- package/.next/prerender-manifest.json +0 -1
- package/.next/react-loadable-manifest.json +0 -42
- package/.next/required-server-files.json +0 -1
- package/.next/routes-manifest.json +0 -1
- package/.next/server/chunks/120.js +0 -435
- package/.next/server/chunks/123.js +0 -58
- package/.next/server/chunks/1394.js +0 -3801
- package/.next/server/chunks/1597.js +0 -151
- package/.next/server/chunks/1608.js +0 -515
- package/.next/server/chunks/2154.js +0 -206
- package/.next/server/chunks/247.js +0 -61
- package/.next/server/chunks/2502.js +0 -584
- package/.next/server/chunks/2914.js +0 -95
- package/.next/server/chunks/2922.js +0 -7293
- package/.next/server/chunks/3264.js +0 -67
- package/.next/server/chunks/3431.js +0 -7241
- package/.next/server/chunks/350.js +0 -142
- package/.next/server/chunks/3746.js +0 -250
- package/.next/server/chunks/3898.js +0 -240
- package/.next/server/chunks/4312.js +0 -674
- package/.next/server/chunks/4371.js +0 -1424
- package/.next/server/chunks/5098.js +0 -124
- package/.next/server/chunks/5335.js +0 -544
- package/.next/server/chunks/5576.js +0 -79
- package/.next/server/chunks/6280.js +0 -322
- package/.next/server/chunks/6465.js +0 -91
- package/.next/server/chunks/676.js +0 -32
- package/.next/server/chunks/6859.js +0 -959
- package/.next/server/chunks/6881.js +0 -320
- package/.next/server/chunks/6898.js +0 -149
- package/.next/server/chunks/7104.js +0 -235
- package/.next/server/chunks/7181.js +0 -664
- package/.next/server/chunks/7183.js +0 -79
- package/.next/server/chunks/8098.js +0 -246
- package/.next/server/chunks/810.js +0 -432
- package/.next/server/chunks/8287.js +0 -58
- package/.next/server/chunks/9143.js +0 -106
- package/.next/server/chunks/9557.js +0 -119
- package/.next/server/chunks/9854.js +0 -72
- package/.next/server/chunks/font-manifest.json +0 -1
- package/.next/server/font-manifest.json +0 -1
- package/.next/server/middleware-build-manifest.js +0 -1
- package/.next/server/middleware-manifest.json +0 -6
- package/.next/server/middleware-react-loadable-manifest.js +0 -1
- package/.next/server/pages/404.js.nft.json +0 -1
- package/.next/server/pages/500.js.nft.json +0 -1
- package/.next/server/pages/[...slug].js +0 -666
- package/.next/server/pages/[...slug].js.nft.json +0 -1
- package/.next/server/pages/[slug]/p.js +0 -2327
- package/.next/server/pages/[slug]/p.js.nft.json +0 -1
- package/.next/server/pages/_app.js +0 -2454
- package/.next/server/pages/_app.js.nft.json +0 -1
- package/.next/server/pages/_document.js +0 -304
- package/.next/server/pages/_document.js.nft.json +0 -1
- package/.next/server/pages/_error.js +0 -164
- package/.next/server/pages/_error.js.nft.json +0 -1
- package/.next/server/pages/account.js.nft.json +0 -1
- package/.next/server/pages/api/graphql.js +0 -315
- package/.next/server/pages/api/graphql.js.nft.json +0 -1
- package/.next/server/pages/api/preview.js +0 -118
- package/.next/server/pages/api/preview.js.nft.json +0 -1
- package/.next/server/pages/checkout.js.nft.json +0 -1
- package/.next/server/pages/en-US/404.html +0 -81
- package/.next/server/pages/en-US/500.html +0 -81
- package/.next/server/pages/en-US/account.html +0 -81
- package/.next/server/pages/en-US/checkout.html +0 -81
- package/.next/server/pages/en-US/login.html +0 -81
- package/.next/server/pages/en-US/s.html +0 -81
- package/.next/server/pages/en-US.html +0 -81
- package/.next/server/pages/en-US.json +0 -1
- package/.next/server/pages/index.js +0 -475
- package/.next/server/pages/index.js.nft.json +0 -1
- package/.next/server/pages/login.js.nft.json +0 -1
- package/.next/server/pages/s.js.nft.json +0 -1
- package/.next/server/pages-manifest.json +0 -16
- package/.next/server/webpack-api-runtime.js +0 -229
- package/.next/server/webpack-runtime.js +0 -229
- package/.next/static/chunks/143.dd8a556e6957baa1.js +0 -1
- package/.next/static/chunks/170.79b2f8527e327bca.js +0 -1
- package/.next/static/chunks/264-5b07911df63b8601.js +0 -1
- package/.next/static/chunks/351-a4e28d64f48c5269.js +0 -1
- package/.next/static/chunks/54.e6562383f8a1dfe7.js +0 -1
- package/.next/static/chunks/597.fc79494903e8bb84.js +0 -1
- package/.next/static/chunks/608.59e69b83f35d9c44.js +0 -1
- package/.next/static/chunks/651.7142f31ce1e052b3.js +0 -1
- package/.next/static/chunks/741.52f7fb873418346f.js +0 -1
- package/.next/static/chunks/781-e1b538e051ff4c3e.js +0 -1
- package/.next/static/chunks/98.97381d2021f86cd9.js +0 -1
- package/.next/static/chunks/996.98e590872c51f815.js +0 -1
- package/.next/static/chunks/framework-dfd14d7ce6600b03.js +0 -1
- package/.next/static/chunks/main-9746772201fe3ac1.js +0 -1
- package/.next/static/chunks/pages/404-3637ef83b3359df7.js +0 -1
- package/.next/static/chunks/pages/500-910883c20541d9ce.js +0 -1
- package/.next/static/chunks/pages/[...slug]-29d3b81ee0953846.js +0 -1
- package/.next/static/chunks/pages/[slug]/p-9b24055cb30ee7a8.js +0 -1
- package/.next/static/chunks/pages/_app-4aeb21d72aeea9b7.js +0 -1
- package/.next/static/chunks/pages/_error-a7a0c1d9bfbb4f38.js +0 -1
- package/.next/static/chunks/pages/account-b8fc5222ffe89b60.js +0 -1
- package/.next/static/chunks/pages/checkout-f8cb7cb22225ef9d.js +0 -1
- package/.next/static/chunks/pages/index-d48285f48d2a66ea.js +0 -1
- package/.next/static/chunks/pages/login-45cc84352bac2408.js +0 -1
- package/.next/static/chunks/pages/s-ba2868e14fedb65b.js +0 -1
- package/.next/static/chunks/polyfills-c67a75d1b6f99dc8.js +0 -1
- package/.next/static/chunks/webpack-f725b61675603493.js +0 -1
- package/.next/static/css/1f987650dd4e39d0.css +0 -1
- package/.next/static/css/3a57acf6e411f24d.css +0 -1
- package/.next/static/css/4abccf9803c3c356.css +0 -1
- package/.next/static/css/502746c995f64cce.css +0 -1
- package/.next/static/css/6507cb48401e73a4.css +0 -1
- package/.next/static/css/6f4d3e91f1d161a8.css +0 -1
- package/.next/static/kFT8gMGQbscGgKaZLxG_K/_buildManifest.js +0 -1
- package/.next/static/kFT8gMGQbscGgKaZLxG_K/_ssgManifest.js +0 -1
- package/.next/static/media/brandless-neutral.76ddf63a.png +0 -0
- package/.next/trace +0 -64
- package/public/~partytown/debug/partytown-atomics.js +0 -556
- package/public/~partytown/debug/partytown-media.js +0 -374
- package/public/~partytown/debug/partytown-sandbox-sw.js +0 -543
- package/public/~partytown/debug/partytown-sw.js +0 -59
- package/public/~partytown/debug/partytown-ww-atomics.js +0 -1789
- package/public/~partytown/debug/partytown-ww-sw.js +0 -1781
- package/public/~partytown/debug/partytown.js +0 -72
- package/public/~partytown/partytown-atomics.js +0 -2
- package/public/~partytown/partytown-media.js +0 -2
- package/public/~partytown/partytown-sw.js +0 -2
- package/public/~partytown/partytown.js +0 -2
- package/src/components/cms/RenderPageSections.tsx +0 -37
package/.turbo/turbo-build.log
CHANGED
|
@@ -13,39 +13,51 @@ info - Disabled SWC as replacement for Babel because of custom Babel configurat
|
|
|
13
13
|
info - Using external babel configuration from /home/runner/work/faststore/faststore/packages/core/.babelrc
|
|
14
14
|
info - Compiled successfully
|
|
15
15
|
info - Collecting page data...
|
|
16
|
-
info - Generating static pages (0/
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
info - Generating static pages (
|
|
16
|
+
info - Generating static pages (0/7)
|
|
17
|
+
warn - Children not found. Add a new component for this section or remove it from the CMS
|
|
18
|
+
warn - Children not found. Add a new component for this section or remove it from the CMS
|
|
19
|
+
info - Generating static pages (1/7)
|
|
20
|
+
warn - Children not found. Add a new component for this section or remove it from the CMS
|
|
21
|
+
warn - Children not found. Add a new component for this section or remove it from the CMS
|
|
22
|
+
warn - Children not found. Add a new component for this section or remove it from the CMS
|
|
23
|
+
warn - Children not found. Add a new component for this section or remove it from the CMS
|
|
24
|
+
info - Generating static pages (3/7)
|
|
25
|
+
warn - Children not found. Add a new component for this section or remove it from the CMS
|
|
26
|
+
warn - Children not found. Add a new component for this section or remove it from the CMS
|
|
20
27
|
warn - CallToAction not found. Add a new component for this section or remove it from the CMS
|
|
21
28
|
warn - CallToAction not found. Add a new component for this section or remove it from the CMS
|
|
22
29
|
warn - CallToAction not found. Add a new component for this section or remove it from the CMS
|
|
23
|
-
|
|
30
|
+
warn - Children not found. Add a new component for this section or remove it from the CMS
|
|
31
|
+
warn - Children not found. Add a new component for this section or remove it from the CMS
|
|
32
|
+
info - Generating static pages (5/7)
|
|
33
|
+
warn - Children not found. Add a new component for this section or remove it from the CMS
|
|
34
|
+
warn - Children not found. Add a new component for this section or remove it from the CMS
|
|
35
|
+
info - Generating static pages (7/7)
|
|
24
36
|
info - Finalizing page optimization...
|
|
25
37
|
|
|
26
38
|
Route (pages) Size First Load JS
|
|
27
|
-
┌ ● /
|
|
28
|
-
├ └ css/
|
|
29
|
-
├ /_app 0 B
|
|
30
|
-
├ ● /[...slug]
|
|
31
|
-
├ └ css/
|
|
32
|
-
├ ● /[slug]/p
|
|
33
|
-
├ └ css/
|
|
34
|
-
├ ○ /404
|
|
35
|
-
├
|
|
36
|
-
├
|
|
37
|
-
├ λ /api/graphql 0 B
|
|
38
|
-
├ λ /api/preview 0 B
|
|
39
|
-
├
|
|
40
|
-
├
|
|
41
|
-
└
|
|
42
|
-
└ css/
|
|
43
|
-
+ First Load JS shared by all
|
|
39
|
+
┌ ● / 4.05 kB 122 kB
|
|
40
|
+
├ └ css/777fb0b5b1c2fa32.css 2.87 kB
|
|
41
|
+
├ /_app 0 B 77.8 kB
|
|
42
|
+
├ ● /[...slug] 2.29 kB 130 kB
|
|
43
|
+
├ └ css/c302d203b46499ff.css 2.52 kB
|
|
44
|
+
├ ● /[slug]/p 12.3 kB 130 kB
|
|
45
|
+
├ └ css/384a7a015bca80d6.css 3.01 kB
|
|
46
|
+
├ ○ /404 950 B 110 kB
|
|
47
|
+
├ ● /500 718 B 109 kB
|
|
48
|
+
├ ● /account 670 B 109 kB
|
|
49
|
+
├ λ /api/graphql 0 B 77.8 kB
|
|
50
|
+
├ λ /api/preview 0 B 77.8 kB
|
|
51
|
+
├ ● /checkout 659 B 109 kB
|
|
52
|
+
├ ● /login 870 B 110 kB
|
|
53
|
+
└ ● /s 2.77 kB 121 kB
|
|
54
|
+
└ css/57c1885d16efdc73.css 2.48 kB
|
|
55
|
+
+ First Load JS shared by all 100 kB
|
|
44
56
|
├ chunks/framework-dfd14d7ce6600b03.js 45.3 kB
|
|
45
|
-
├ chunks/main-
|
|
46
|
-
├ chunks/pages/_app-
|
|
47
|
-
├ chunks/webpack-
|
|
48
|
-
└ css/
|
|
57
|
+
├ chunks/main-bf297268d707456d.js 23.9 kB
|
|
58
|
+
├ chunks/pages/_app-3cf84159cce4c8ef.js 6.41 kB
|
|
59
|
+
├ chunks/webpack-e105e23dccb05796.js 2.2 kB
|
|
60
|
+
└ css/4e34a56a38b0d9d5.css 22.5 kB
|
|
49
61
|
|
|
50
62
|
λ (Server) server-side renders at runtime (uses getInitialProps or getServerSideProps)
|
|
51
63
|
○ (Static) automatically rendered as static HTML (uses no initial props)
|
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,16 @@
|
|
|
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
|
+
## [2.0.120-alpha.0](https://github.com/vtex/faststore/compare/v2.0.119-alpha.0...v2.0.120-alpha.0) (2023-04-27)
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
- Integrates Global Sections, with Alert component ([#1722](https://github.com/vtex/faststore/issues/1722)) ([da38b2a](https://github.com/vtex/faststore/commit/da38b2af3db5bd6abd57707d11d67d7463d5fa12))
|
|
11
|
+
|
|
12
|
+
## [2.0.118-alpha.0](https://github.com/vtex/faststore/compare/v2.0.117-alpha.0...v2.0.118-alpha.0) (2023-04-26)
|
|
13
|
+
|
|
14
|
+
**Note:** Version bump only for package @faststore/core
|
|
15
|
+
|
|
6
16
|
## [2.0.117-alpha.0](https://github.com/vtex/faststore/compare/v2.0.116-alpha.0...v2.0.117-alpha.0) (2023-04-26)
|
|
7
17
|
|
|
8
18
|
### Features
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@faststore/core",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.120-alpha.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"browserslist": "supports es6-module and not dead",
|
|
6
6
|
"scripts": {
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"@envelop/graphql-jit": "^1.1.1",
|
|
30
30
|
"@envelop/parser-cache": "^2.2.0",
|
|
31
31
|
"@envelop/validation-cache": "^2.2.0",
|
|
32
|
-
"@faststore/api": "^2.0.
|
|
32
|
+
"@faststore/api": "^2.0.118-alpha.0",
|
|
33
33
|
"@faststore/components": "^2.0.117-alpha.0",
|
|
34
34
|
"@faststore/graphql-utils": "^2.0.3-alpha.0",
|
|
35
35
|
"@faststore/sdk": "^2.0.3-alpha.0",
|
|
@@ -108,5 +108,5 @@
|
|
|
108
108
|
"msw": {
|
|
109
109
|
"workerDirectory": "public"
|
|
110
110
|
},
|
|
111
|
-
"gitHead": "
|
|
111
|
+
"gitHead": "7c7da070b4a307b9c158fef70b22234831a97756"
|
|
112
112
|
}
|
package/src/Layout.tsx
CHANGED
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
import type { PropsWithChildren } from 'react'
|
|
2
2
|
import { lazy, Suspense } from 'react'
|
|
3
3
|
|
|
4
|
-
import {
|
|
5
|
-
import Alert from 'src/components/common/Alert'
|
|
6
|
-
import Footer from 'src/components/common/Footer'
|
|
7
|
-
import Navbar from 'src/components/navigation/Navbar'
|
|
8
|
-
import Toast from 'src/components/common/Toast'
|
|
9
|
-
import RegionBar from 'src/components/region/RegionBar'
|
|
4
|
+
import { useUI } from '@faststore/ui'
|
|
10
5
|
|
|
11
6
|
const CartSidebar = lazy(() => import('src/components/cart/CartSidebar'))
|
|
12
7
|
const RegionModal = lazy(() => import('src/components/region/RegionModal'))
|
|
@@ -16,24 +11,7 @@ function Layout({ children }: PropsWithChildren) {
|
|
|
16
11
|
|
|
17
12
|
return (
|
|
18
13
|
<>
|
|
19
|
-
|
|
20
|
-
icon={<Icon name="Bell" />}
|
|
21
|
-
link={{ children: 'Buy now', href: '/office', target: '_self' }}
|
|
22
|
-
dismissible
|
|
23
|
-
>
|
|
24
|
-
Get 10% off today: <span>NEW10</span>
|
|
25
|
-
</Alert>
|
|
26
|
-
|
|
27
|
-
<Navbar />
|
|
28
|
-
|
|
29
|
-
<Toast />
|
|
30
|
-
|
|
31
|
-
<main>
|
|
32
|
-
<RegionBar className="display-mobile" />
|
|
33
|
-
{children}
|
|
34
|
-
</main>
|
|
35
|
-
|
|
36
|
-
<Footer />
|
|
14
|
+
{children}
|
|
37
15
|
|
|
38
16
|
{displayCart && (
|
|
39
17
|
<Suspense fallback={null}>
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { PropsWithChildren, useMemo } from 'react'
|
|
2
|
+
|
|
3
|
+
import { Locator, Section } from '@vtex/client-cms'
|
|
4
|
+
import { PageContentType, getPage } from 'src/server/cms'
|
|
5
|
+
import CUSTOM_COMPONENTS from 'src/customizations/components'
|
|
6
|
+
import type { ComponentType } from 'react'
|
|
7
|
+
|
|
8
|
+
import RenderSections from './RenderSections'
|
|
9
|
+
import { RegionBar } from '@faststore/components'
|
|
10
|
+
import Alert from 'src/components/sections/Alert/Alert'
|
|
11
|
+
import Navbar from 'src/components/navigation/Navbar'
|
|
12
|
+
import Footer from 'src/components/common/Footer'
|
|
13
|
+
import Toast from 'src/components/common/Toast'
|
|
14
|
+
|
|
15
|
+
// TODO: When the CMS is finished, switch to using 'globalSections'.
|
|
16
|
+
export const GLOBAL_SECTIONS_CONTENT_TYPE = 'globalAlert'
|
|
17
|
+
|
|
18
|
+
export type GlobalSectionsData = {
|
|
19
|
+
sections: Section[]
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/* A list of components that can be used in the CMS. */
|
|
23
|
+
const COMPONENTS: Record<string, ComponentType<any>> = {
|
|
24
|
+
Alert,
|
|
25
|
+
...CUSTOM_COMPONENTS,
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const useDividedSections = (sections: Section[]) => {
|
|
29
|
+
return useMemo(() => {
|
|
30
|
+
const indexChildren = sections.findIndex(({ name }) => name === 'Children')
|
|
31
|
+
const hasChildren = indexChildren > -1
|
|
32
|
+
|
|
33
|
+
return {
|
|
34
|
+
hasChildren,
|
|
35
|
+
firstSections: hasChildren ? sections.slice(0, indexChildren) : sections,
|
|
36
|
+
...(hasChildren && { lastSections: sections.slice(indexChildren + 1) }),
|
|
37
|
+
}
|
|
38
|
+
}, [sections])
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function GlobalSections({
|
|
42
|
+
children,
|
|
43
|
+
sections,
|
|
44
|
+
}: PropsWithChildren<GlobalSectionsData>) {
|
|
45
|
+
const { hasChildren, firstSections, lastSections } =
|
|
46
|
+
useDividedSections(sections)
|
|
47
|
+
|
|
48
|
+
return (
|
|
49
|
+
<>
|
|
50
|
+
<RenderSections sections={firstSections} components={COMPONENTS} />
|
|
51
|
+
<Navbar />
|
|
52
|
+
|
|
53
|
+
<Toast />
|
|
54
|
+
|
|
55
|
+
<main>
|
|
56
|
+
<RegionBar className="display-mobile" />
|
|
57
|
+
{children}
|
|
58
|
+
</main>
|
|
59
|
+
|
|
60
|
+
<Footer />
|
|
61
|
+
{hasChildren && (
|
|
62
|
+
<RenderSections sections={lastSections} components={COMPONENTS} />
|
|
63
|
+
)}
|
|
64
|
+
</>
|
|
65
|
+
)
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export default GlobalSections
|
|
69
|
+
|
|
70
|
+
export const getGlobalSectionsData = async (
|
|
71
|
+
previewData: Locator
|
|
72
|
+
): Promise<GlobalSectionsData> => {
|
|
73
|
+
const { sections } = await getPage<PageContentType>({
|
|
74
|
+
...(previewData?.contentType === GLOBAL_SECTIONS_CONTENT_TYPE
|
|
75
|
+
? previewData
|
|
76
|
+
: { filters: { 'settings.seo.slug': '/' } }),
|
|
77
|
+
contentType: GLOBAL_SECTIONS_CONTENT_TYPE,
|
|
78
|
+
})
|
|
79
|
+
|
|
80
|
+
return { sections }
|
|
81
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import chalk from 'chalk'
|
|
2
|
+
import { ComponentType, PropsWithChildren, ReactNode, useMemo } from 'react'
|
|
3
|
+
|
|
4
|
+
import SectionBoundary from './SectionBoundary'
|
|
5
|
+
|
|
6
|
+
interface Props {
|
|
7
|
+
components: Record<string, ComponentType<any>>
|
|
8
|
+
sections: Array<{ name: string; data: any }>
|
|
9
|
+
context?: unknown
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const RenderSections = ({ sections = [], context, components }: Props) => {
|
|
13
|
+
return (
|
|
14
|
+
<>
|
|
15
|
+
{sections.map(({ name, data }, index) => {
|
|
16
|
+
const Component = components[name]
|
|
17
|
+
|
|
18
|
+
if (!Component) {
|
|
19
|
+
// TODO: add a documentation link to help to do this
|
|
20
|
+
console.info(
|
|
21
|
+
`${chalk.yellow(
|
|
22
|
+
'warn'
|
|
23
|
+
)} - ${name} not found. Add a new component for this section or remove it from the CMS`
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
return null
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<SectionBoundary key={`cms-section-${index}`} name={name}>
|
|
31
|
+
<Component {...data} context={context} />
|
|
32
|
+
</SectionBoundary>
|
|
33
|
+
)
|
|
34
|
+
})}
|
|
35
|
+
</>
|
|
36
|
+
)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export default RenderSections
|
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
import type { PropsWithChildren, ReactNode } from 'react'
|
|
2
2
|
import { useCallback, useState } from 'react'
|
|
3
3
|
|
|
4
|
-
import { Alert as UIAlert, AlertProps } from '@faststore/ui'
|
|
4
|
+
import { Alert as UIAlert, AlertProps as UIAlertProps } from '@faststore/ui'
|
|
5
5
|
import { mark } from 'src/sdk/tests/mark'
|
|
6
6
|
|
|
7
|
-
interface
|
|
7
|
+
export interface AlertProps extends UIAlertProps {
|
|
8
8
|
/**
|
|
9
9
|
* For CMS integration purposes, should be used to pass content through it
|
|
10
10
|
* instead pass through children
|
|
11
11
|
*/
|
|
12
12
|
content?: ReactNode
|
|
13
13
|
}
|
|
14
|
-
function Alert(
|
|
14
|
+
function Alert({
|
|
15
|
+
content,
|
|
16
|
+
children,
|
|
17
|
+
...otherProps
|
|
18
|
+
}: PropsWithChildren<AlertProps>) {
|
|
15
19
|
const [displayAlert, setDisplayAlert] = useState(true)
|
|
16
20
|
|
|
17
21
|
const onAlertClose = useCallback(
|
|
@@ -23,8 +27,6 @@ function Alert(args: PropsWithChildren<Props>) {
|
|
|
23
27
|
return null
|
|
24
28
|
}
|
|
25
29
|
|
|
26
|
-
const { content, children, ...otherProps } = args
|
|
27
|
-
|
|
28
30
|
return (
|
|
29
31
|
<UIAlert onClose={onAlertClose} {...otherProps}>
|
|
30
32
|
{content ?? children}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Icon as UIIcon } from '@faststore/ui'
|
|
2
|
+
import Section from '../Section'
|
|
3
|
+
import UIAlert from 'src/components/common/Alert'
|
|
4
|
+
|
|
5
|
+
export interface AlertProps {
|
|
6
|
+
icon: string
|
|
7
|
+
content: string
|
|
8
|
+
link: {
|
|
9
|
+
text: string
|
|
10
|
+
to: string
|
|
11
|
+
}
|
|
12
|
+
dismissible: boolean
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// TODO: Change actionPath and actionLabel with Link
|
|
16
|
+
function Alert({ icon, content, link, dismissible }: AlertProps) {
|
|
17
|
+
return (
|
|
18
|
+
<UIAlert
|
|
19
|
+
icon={<UIIcon name={icon} />}
|
|
20
|
+
link={{ children: link?.text, href: link?.to, target: '_self' }}
|
|
21
|
+
dismissible={dismissible}
|
|
22
|
+
>
|
|
23
|
+
{content}
|
|
24
|
+
</UIAlert>
|
|
25
|
+
)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export default Alert
|
package/src/pages/404.tsx
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { NextSeo } from 'next-seo'
|
|
2
2
|
import { useRouter } from 'next/router'
|
|
3
3
|
import { EmptyState as UIEmptyState, Icon as UIIcon } from '@faststore/ui'
|
|
4
|
+
import GlobalSections, {
|
|
5
|
+
GlobalSectionsData,
|
|
6
|
+
getGlobalSectionsData,
|
|
7
|
+
} from 'src/components/cms/GlobalSections'
|
|
8
|
+
import { GetStaticProps } from 'next'
|
|
9
|
+
import { Locator } from '@vtex/client-cms'
|
|
4
10
|
|
|
5
11
|
const useErrorState = () => {
|
|
6
12
|
const router = useRouter()
|
|
@@ -12,11 +18,15 @@ const useErrorState = () => {
|
|
|
12
18
|
}
|
|
13
19
|
}
|
|
14
20
|
|
|
15
|
-
|
|
21
|
+
type Props = {
|
|
22
|
+
globalSections: GlobalSectionsData
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function Page({ globalSections }: Props) {
|
|
16
26
|
const { fromUrl } = useErrorState()
|
|
17
27
|
|
|
18
28
|
return (
|
|
19
|
-
|
|
29
|
+
<GlobalSections {...globalSections}>
|
|
20
30
|
<NextSeo noindex nofollow />
|
|
21
31
|
|
|
22
32
|
<UIEmptyState
|
|
@@ -33,8 +43,20 @@ function Page() {
|
|
|
33
43
|
>
|
|
34
44
|
<p>This app could not find url {fromUrl}</p>
|
|
35
45
|
</UIEmptyState>
|
|
36
|
-
|
|
46
|
+
</GlobalSections>
|
|
37
47
|
)
|
|
38
48
|
}
|
|
39
49
|
|
|
50
|
+
export const getStaticProps: GetStaticProps<
|
|
51
|
+
Props,
|
|
52
|
+
Record<string, string>,
|
|
53
|
+
Locator
|
|
54
|
+
> = async ({ previewData }) => {
|
|
55
|
+
const globalSections = await getGlobalSectionsData(previewData)
|
|
56
|
+
|
|
57
|
+
return {
|
|
58
|
+
props: { globalSections },
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
40
62
|
export default Page
|
package/src/pages/500.tsx
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
|
+
import { Locator } from '@vtex/client-cms'
|
|
2
|
+
import { GetStaticProps } from 'next'
|
|
1
3
|
import { NextSeo } from 'next-seo'
|
|
2
4
|
import { useRouter } from 'next/router'
|
|
5
|
+
import GlobalSections, {
|
|
6
|
+
GlobalSectionsData,
|
|
7
|
+
getGlobalSectionsData,
|
|
8
|
+
} from 'src/components/cms/GlobalSections'
|
|
9
|
+
|
|
10
|
+
type Props = {
|
|
11
|
+
globalSections: GlobalSectionsData
|
|
12
|
+
}
|
|
3
13
|
|
|
4
14
|
const useErrorState = () => {
|
|
5
15
|
const router = useRouter()
|
|
@@ -11,11 +21,11 @@ const useErrorState = () => {
|
|
|
11
21
|
}
|
|
12
22
|
}
|
|
13
23
|
|
|
14
|
-
function Page() {
|
|
24
|
+
function Page({ globalSections }: Props) {
|
|
15
25
|
const { errorId, fromUrl } = useErrorState()
|
|
16
26
|
|
|
17
27
|
return (
|
|
18
|
-
|
|
28
|
+
<GlobalSections {...globalSections}>
|
|
19
29
|
<NextSeo noindex nofollow />
|
|
20
30
|
|
|
21
31
|
<h1>500</h1>
|
|
@@ -24,8 +34,20 @@ function Page() {
|
|
|
24
34
|
<div>
|
|
25
35
|
The server errored with id {errorId} when visiting page {fromUrl}
|
|
26
36
|
</div>
|
|
27
|
-
|
|
37
|
+
</GlobalSections>
|
|
28
38
|
)
|
|
29
39
|
}
|
|
30
40
|
|
|
41
|
+
export const getStaticProps: GetStaticProps<
|
|
42
|
+
Props,
|
|
43
|
+
Record<string, string>,
|
|
44
|
+
Locator
|
|
45
|
+
> = async ({ previewData }) => {
|
|
46
|
+
const globalSections = await getGlobalSectionsData(previewData)
|
|
47
|
+
|
|
48
|
+
return {
|
|
49
|
+
props: { globalSections },
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
31
53
|
export default Page
|
package/src/pages/[...slug].tsx
CHANGED
|
@@ -27,10 +27,19 @@ import { mark } from 'src/sdk/tests/mark'
|
|
|
27
27
|
import { execute } from 'src/server'
|
|
28
28
|
|
|
29
29
|
import storeConfig from '../../faststore.config'
|
|
30
|
+
import GlobalSections, {
|
|
31
|
+
getGlobalSectionsData,
|
|
32
|
+
GlobalSectionsData,
|
|
33
|
+
} from 'src/components/cms/GlobalSections'
|
|
34
|
+
import { Locator } from '@vtex/client-cms'
|
|
35
|
+
|
|
36
|
+
type Props = ServerCollectionPageQueryQuery & {
|
|
37
|
+
globalSections: GlobalSectionsData
|
|
38
|
+
}
|
|
30
39
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
40
|
+
const useSearchParams = ({
|
|
41
|
+
collection,
|
|
42
|
+
}: ServerCollectionPageQueryQuery): SearchState => {
|
|
34
43
|
const selectedFacets = collection?.meta.selectedFacets
|
|
35
44
|
const { asPath } = useRouter()
|
|
36
45
|
|
|
@@ -48,7 +57,7 @@ const useSearchParams = ({ collection }: Props): SearchState => {
|
|
|
48
57
|
return useMemo(() => parseSearchState(new URL(hrefState)), [hrefState])
|
|
49
58
|
}
|
|
50
59
|
|
|
51
|
-
function Page(props: Props) {
|
|
60
|
+
function Page({ globalSections, ...props }: Props) {
|
|
52
61
|
const { collection } = props
|
|
53
62
|
const router = useRouter()
|
|
54
63
|
const applySearchState = useApplySearchState()
|
|
@@ -62,64 +71,66 @@ function Page(props: Props) {
|
|
|
62
71
|
const canonical = `${storeConfig.storeUrl}${pathname}${pageQuery}`
|
|
63
72
|
|
|
64
73
|
return (
|
|
65
|
-
<
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
74
|
+
<GlobalSections {...globalSections}>
|
|
75
|
+
<SearchProvider
|
|
76
|
+
onChange={applySearchState}
|
|
77
|
+
itemsPerPage={ITEMS_PER_PAGE}
|
|
78
|
+
{...searchParams}
|
|
79
|
+
>
|
|
80
|
+
{/* SEO */}
|
|
81
|
+
<NextSeo
|
|
82
|
+
title={title}
|
|
83
|
+
description={description}
|
|
84
|
+
titleTemplate={storeConfig.seo.titleTemplate}
|
|
85
|
+
canonical={canonical}
|
|
86
|
+
openGraph={{
|
|
87
|
+
type: 'website',
|
|
88
|
+
title,
|
|
89
|
+
description,
|
|
90
|
+
}}
|
|
91
|
+
/>
|
|
92
|
+
<BreadcrumbJsonLd
|
|
93
|
+
itemListElements={collection?.breadcrumbList.itemListElement ?? []}
|
|
94
|
+
/>
|
|
95
|
+
|
|
96
|
+
{/*
|
|
97
|
+
WARNING: Do not import or render components from any
|
|
98
|
+
other folder than '../components/sections' in here.
|
|
99
|
+
|
|
100
|
+
This is necessary to keep the integration with the CMS
|
|
101
|
+
easy and consistent, enabling the change and reorder
|
|
102
|
+
of elements on this page.
|
|
103
|
+
|
|
104
|
+
If needed, wrap your component in a <Section /> component
|
|
105
|
+
(not the HTML tag) before rendering it here.
|
|
106
|
+
*/}
|
|
107
|
+
<Breadcrumb
|
|
108
|
+
breadcrumbList={collection?.breadcrumbList.itemListElement}
|
|
109
|
+
name={title}
|
|
110
|
+
/>
|
|
111
|
+
|
|
112
|
+
<Hero
|
|
113
|
+
variant="secondary"
|
|
114
|
+
title={title}
|
|
115
|
+
subtitle={`All the amazing ${title} from the brands we partner with.`}
|
|
116
|
+
image={{
|
|
117
|
+
src: 'https://storeframework.vtexassets.com/arquivos/ids/190897/Photo.jpg',
|
|
118
|
+
alt: 'Quest 2 Controller on a table',
|
|
119
|
+
}}
|
|
120
|
+
/>
|
|
121
|
+
|
|
122
|
+
<ProductGallery title={title} />
|
|
123
|
+
|
|
124
|
+
<ProductShelf
|
|
125
|
+
first={ITEMS_PER_SECTION}
|
|
126
|
+
sort="score_desc"
|
|
127
|
+
title="You might also like"
|
|
128
|
+
withDivisor
|
|
129
|
+
/>
|
|
130
|
+
|
|
131
|
+
<ScrollToTopButton />
|
|
132
|
+
</SearchProvider>
|
|
133
|
+
</GlobalSections>
|
|
123
134
|
)
|
|
124
135
|
}
|
|
125
136
|
|
|
@@ -148,9 +159,12 @@ const query = gql`
|
|
|
148
159
|
`
|
|
149
160
|
|
|
150
161
|
export const getStaticProps: GetStaticProps<
|
|
151
|
-
|
|
152
|
-
{ slug: string[] }
|
|
153
|
-
|
|
162
|
+
Props,
|
|
163
|
+
{ slug: string[] },
|
|
164
|
+
Locator
|
|
165
|
+
> = async (context) => {
|
|
166
|
+
const { params } = context
|
|
167
|
+
|
|
154
168
|
const { data, errors = [] } = await execute<
|
|
155
169
|
ServerCollectionPageQueryQueryVariables,
|
|
156
170
|
ServerCollectionPageQueryQuery
|
|
@@ -171,8 +185,13 @@ export const getStaticProps: GetStaticProps<
|
|
|
171
185
|
throw errors[0]
|
|
172
186
|
}
|
|
173
187
|
|
|
188
|
+
const globalSections = await getGlobalSectionsData(context.previewData)
|
|
189
|
+
|
|
174
190
|
return {
|
|
175
|
-
props:
|
|
191
|
+
props: {
|
|
192
|
+
...data,
|
|
193
|
+
globalSections,
|
|
194
|
+
},
|
|
176
195
|
}
|
|
177
196
|
}
|
|
178
197
|
|