@salesforce/retail-react-app 6.0.0 → 6.1.0-dev
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/app/components/_app/index.jsx +13 -2
- package/app/components/_app/index.test.js +73 -29
- package/app/components/breadcrumb/index.jsx +2 -2
- package/app/components/links-list/index.test.js +0 -2
- package/app/components/product-view-modal/bundle.test.js +6 -1
- package/app/components/recommended-products/index.jsx +9 -0
- package/app/components/store-locator-modal/store-locator-content.test.jsx +0 -1
- package/app/hooks/use-datacloud.js +481 -0
- package/app/hooks/use-datacloud.test.js +164 -0
- package/app/mocks/datacloud-mock-data.js +404 -0
- package/app/pages/account/index.jsx +3 -0
- package/app/pages/account/index.test.js +36 -36
- package/app/pages/home/index.jsx +3 -0
- package/app/pages/login/index.jsx +3 -0
- package/app/pages/product-detail/index.jsx +16 -2
- package/app/pages/product-list/index.jsx +15 -1
- package/app/pages/registration/index.jsx +3 -0
- package/app/pages/reset-password/index.jsx +3 -0
- package/app/ssr.js +3 -1
- package/config/default.js +4 -0
- package/config/mocks/default.js +4 -0
- package/jest-setup.js +10 -0
- package/jest.config.js +5 -1
- package/package.json +15 -9
|
@@ -72,6 +72,7 @@ import {
|
|
|
72
72
|
} from '@salesforce/retail-react-app/app/hooks'
|
|
73
73
|
import {useToast} from '@salesforce/retail-react-app/app/hooks/use-toast'
|
|
74
74
|
import useEinstein from '@salesforce/retail-react-app/app/hooks/use-einstein'
|
|
75
|
+
import useDataCloud from '@salesforce/retail-react-app/app/hooks/use-datacloud'
|
|
75
76
|
import useActiveData from '@salesforce/retail-react-app/app/hooks/use-active-data'
|
|
76
77
|
|
|
77
78
|
// Others
|
|
@@ -117,6 +118,7 @@ const ProductList = (props) => {
|
|
|
117
118
|
const location = useLocation()
|
|
118
119
|
const toast = useToast()
|
|
119
120
|
const einstein = useEinstein()
|
|
121
|
+
const dataCloud = useDataCloud()
|
|
120
122
|
const activeData = useActiveData()
|
|
121
123
|
const {res} = useServerContext()
|
|
122
124
|
const customerId = useCustomerId()
|
|
@@ -159,7 +161,14 @@ const ProductList = (props) => {
|
|
|
159
161
|
perPricebook: true,
|
|
160
162
|
allVariationProperties: true,
|
|
161
163
|
allImages: true,
|
|
162
|
-
expand: [
|
|
164
|
+
expand: [
|
|
165
|
+
'promotions',
|
|
166
|
+
'variations',
|
|
167
|
+
'prices',
|
|
168
|
+
'images',
|
|
169
|
+
'page_meta_tags',
|
|
170
|
+
'custom_properties'
|
|
171
|
+
],
|
|
163
172
|
refine: _refine
|
|
164
173
|
}
|
|
165
174
|
},
|
|
@@ -384,6 +393,7 @@ const ProductList = (props) => {
|
|
|
384
393
|
additionalProperties: {error: err, searchQuery}
|
|
385
394
|
})
|
|
386
395
|
}
|
|
396
|
+
dataCloud.sendViewSearchResults(searchParams, productSearchResult)
|
|
387
397
|
activeData.sendViewSearch(searchParams, productSearchResult)
|
|
388
398
|
} else {
|
|
389
399
|
try {
|
|
@@ -394,6 +404,7 @@ const ProductList = (props) => {
|
|
|
394
404
|
additionalProperties: {error: err, category}
|
|
395
405
|
})
|
|
396
406
|
}
|
|
407
|
+
dataCloud.sendViewCategory(searchParams, category, productSearchResult)
|
|
397
408
|
activeData.sendViewCategory(searchParams, category, productSearchResult)
|
|
398
409
|
}
|
|
399
410
|
}
|
|
@@ -411,6 +422,9 @@ const ProductList = (props) => {
|
|
|
411
422
|
<title>{category?.pageTitle ?? searchQuery}</title>
|
|
412
423
|
<meta name="description" content={category?.pageDescription ?? searchQuery} />
|
|
413
424
|
<meta name="keywords" content={category?.pageKeywords} />
|
|
425
|
+
{productSearchResult?.pageMetaTags?.map(({id, value}) => {
|
|
426
|
+
return <meta name={id} content={value} key={id} />
|
|
427
|
+
})}
|
|
414
428
|
</Helmet>
|
|
415
429
|
{showNoResults ? (
|
|
416
430
|
<EmptySearchResults searchQuery={searchQuery} category={category} />
|
|
@@ -16,6 +16,7 @@ import Seo from '@salesforce/retail-react-app/app/components/seo'
|
|
|
16
16
|
import RegisterForm from '@salesforce/retail-react-app/app/components/register'
|
|
17
17
|
import useNavigation from '@salesforce/retail-react-app/app/hooks/use-navigation'
|
|
18
18
|
import useEinstein from '@salesforce/retail-react-app/app/hooks/use-einstein'
|
|
19
|
+
import useDataCloud from '@salesforce/retail-react-app/app/hooks/use-datacloud'
|
|
19
20
|
import {API_ERROR_MESSAGE} from '@salesforce/retail-react-app/app/constants'
|
|
20
21
|
|
|
21
22
|
const Registration = () => {
|
|
@@ -24,6 +25,7 @@ const Registration = () => {
|
|
|
24
25
|
const {isRegistered} = useCustomerType()
|
|
25
26
|
const form = useForm()
|
|
26
27
|
const einstein = useEinstein()
|
|
28
|
+
const dataCloud = useDataCloud()
|
|
27
29
|
const {pathname} = useLocation()
|
|
28
30
|
const register = useAuthHelper(AuthHelpers.Register)
|
|
29
31
|
|
|
@@ -54,6 +56,7 @@ const Registration = () => {
|
|
|
54
56
|
/**************** Einstein ****************/
|
|
55
57
|
useEffect(() => {
|
|
56
58
|
einstein.sendViewPage(pathname)
|
|
59
|
+
dataCloud.sendViewPage(pathname)
|
|
57
60
|
}, [])
|
|
58
61
|
|
|
59
62
|
return (
|
|
@@ -15,6 +15,7 @@ import ResetPasswordForm from '@salesforce/retail-react-app/app/components/reset
|
|
|
15
15
|
import ResetPasswordLanding from '@salesforce/retail-react-app/app/pages/reset-password/reset-password-landing'
|
|
16
16
|
import useNavigation from '@salesforce/retail-react-app/app/hooks/use-navigation'
|
|
17
17
|
import useEinstein from '@salesforce/retail-react-app/app/hooks/use-einstein'
|
|
18
|
+
import useDataCloud from '@salesforce/retail-react-app/app/hooks/use-datacloud'
|
|
18
19
|
import {useLocation} from 'react-router-dom'
|
|
19
20
|
import {useRouteMatch} from 'react-router'
|
|
20
21
|
import {usePasswordReset} from '@salesforce/retail-react-app/app/hooks/use-password-reset'
|
|
@@ -29,6 +30,7 @@ const ResetPassword = () => {
|
|
|
29
30
|
const form = useForm()
|
|
30
31
|
const navigate = useNavigation()
|
|
31
32
|
const einstein = useEinstein()
|
|
33
|
+
const dataCloud = useDataCloud()
|
|
32
34
|
const {pathname} = useLocation()
|
|
33
35
|
const {path} = useRouteMatch()
|
|
34
36
|
const {getPasswordResetToken} = usePasswordReset()
|
|
@@ -48,6 +50,7 @@ const ResetPassword = () => {
|
|
|
48
50
|
/**************** Einstein ****************/
|
|
49
51
|
useEffect(() => {
|
|
50
52
|
einstein.sendViewPage(pathname)
|
|
53
|
+
dataCloud.sendViewPage(pathname)
|
|
51
54
|
}, [])
|
|
52
55
|
|
|
53
56
|
return (
|
package/app/ssr.js
CHANGED
|
@@ -313,7 +313,9 @@ const {handler} = runtime.createHandler(options, (app) => {
|
|
|
313
313
|
],
|
|
314
314
|
'connect-src': [
|
|
315
315
|
// Connect to Einstein APIs
|
|
316
|
-
'api.cquotient.com'
|
|
316
|
+
'api.cquotient.com',
|
|
317
|
+
// Connect to DataCloud APIs
|
|
318
|
+
'*.c360a.salesforce.com'
|
|
317
319
|
]
|
|
318
320
|
}
|
|
319
321
|
}
|
package/config/default.js
CHANGED
|
@@ -53,6 +53,10 @@ module.exports = {
|
|
|
53
53
|
// This differs from the siteId in commerceAPIConfig for testing purposes
|
|
54
54
|
siteId: 'aaij-MobileFirst',
|
|
55
55
|
isProduction: false
|
|
56
|
+
},
|
|
57
|
+
dataCloudAPI: {
|
|
58
|
+
appSourceId: 'fb81edab-24c6-4b40-8684-b67334dfdf32',
|
|
59
|
+
tenantId: 'mmyw8zrxhfsg09lfmzrd1zjqmg'
|
|
56
60
|
}
|
|
57
61
|
},
|
|
58
62
|
externals: [],
|
package/config/mocks/default.js
CHANGED
|
@@ -95,6 +95,10 @@ module.exports = {
|
|
|
95
95
|
// This is temporary and is meant as a placeholder until there is a mechanism for reading
|
|
96
96
|
// the is_production property from an MRT target
|
|
97
97
|
isProduction: false
|
|
98
|
+
},
|
|
99
|
+
dataCloudAPI: {
|
|
100
|
+
appSourceId: '23df7335-2e9d-4fbc-bc34-7e93649e69b7',
|
|
101
|
+
tenantId: '5zqheixqu9vji7spdkzxwh4hpz'
|
|
98
102
|
}
|
|
99
103
|
},
|
|
100
104
|
// This list contains server-side only libraries that you don't want to be compiled by webpack
|
package/jest-setup.js
CHANGED
|
@@ -50,6 +50,12 @@ export const setupMockServer = () => {
|
|
|
50
50
|
rest.get('*/customers/:customerId/baskets', (req, res, ctx) =>
|
|
51
51
|
res(ctx.delay(0), ctx.status(200), ctx.json(mockCustomerBaskets))
|
|
52
52
|
),
|
|
53
|
+
rest.get('*/shopper-context/:usid', (req, res, ctx) =>
|
|
54
|
+
res(ctx.delay(0), ctx.status(200), ctx.json({}))
|
|
55
|
+
),
|
|
56
|
+
rest.get('*/shopper-experience/*', (req, res, ctx) =>
|
|
57
|
+
res(ctx.delay(0), ctx.status(200), ctx.json({}))
|
|
58
|
+
),
|
|
53
59
|
rest.post('*/sessions', (req, res, ctx) => res(ctx.delay(0), ctx.status(200))),
|
|
54
60
|
rest.post('*/oauth2/token', (req, res, ctx) =>
|
|
55
61
|
res(
|
|
@@ -86,6 +92,10 @@ export const setupMockServer = () => {
|
|
|
86
92
|
}),
|
|
87
93
|
rest.post('*/v3/personalization/recs/EinsteinTestSite/*', (req, res, ctx) => {
|
|
88
94
|
return res(ctx.delay(0), ctx.status(200), ctx.json({}))
|
|
95
|
+
}),
|
|
96
|
+
// Mock Data Cloud API
|
|
97
|
+
rest.post('*.pc-rnd.c360a.salesforce.com/web/events/*', (req, res, ctx) => {
|
|
98
|
+
return res(ctx.delay(0), ctx.status(204), ctx.json({}))
|
|
89
99
|
})
|
|
90
100
|
)
|
|
91
101
|
}
|
package/jest.config.js
CHANGED
|
@@ -18,8 +18,12 @@ module.exports = {
|
|
|
18
18
|
'^@tanstack/react-query$':
|
|
19
19
|
'<rootDir>/node_modules/@tanstack/react-query/build/lib/index.js',
|
|
20
20
|
'^is-what$': '<rootDir>/node_modules/is-what/dist/cjs/index.cjs',
|
|
21
|
-
'^copy-anything$': '<rootDir>/node_modules/copy-anything/dist/cjs/index.cjs'
|
|
21
|
+
'^copy-anything$': '<rootDir>/node_modules/copy-anything/dist/cjs/index.cjs',
|
|
22
|
+
"^@salesforce/cc-datacloud-typescript$": "<rootDir>/node_modules/@salesforce/cc-datacloud-typescript/dist/index.js"
|
|
22
23
|
},
|
|
24
|
+
transformIgnorePatterns: [
|
|
25
|
+
"/node_modules/(?!@salesforce/cc-datacloud-typescript)"
|
|
26
|
+
],
|
|
23
27
|
setupFilesAfterEnv: [path.join(__dirname, 'jest-setup.js')],
|
|
24
28
|
collectCoverageFrom: [
|
|
25
29
|
'app/**/*.{js,jsx}',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforce/retail-react-app",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.1.0-dev",
|
|
4
4
|
"license": "See license in LICENSE",
|
|
5
5
|
"author": "cc-pwa-kit@salesforce.com",
|
|
6
6
|
"ccExtensibility": {
|
|
@@ -45,10 +45,11 @@
|
|
|
45
45
|
"@lhci/cli": "^0.11.0",
|
|
46
46
|
"@loadable/component": "^5.15.3",
|
|
47
47
|
"@peculiar/webcrypto": "^1.4.2",
|
|
48
|
-
"@salesforce/
|
|
49
|
-
"@salesforce/
|
|
50
|
-
"@salesforce/pwa-kit-
|
|
51
|
-
"@salesforce/pwa-kit-
|
|
48
|
+
"@salesforce/cc-datacloud-typescript": "^1.0.10",
|
|
49
|
+
"@salesforce/commerce-sdk-react": "3.3.0-dev",
|
|
50
|
+
"@salesforce/pwa-kit-dev": "3.10.0-dev",
|
|
51
|
+
"@salesforce/pwa-kit-react-sdk": "3.10.0-dev",
|
|
52
|
+
"@salesforce/pwa-kit-runtime": "3.10.0-dev",
|
|
52
53
|
"@tanstack/react-query": "^4.28.0",
|
|
53
54
|
"@tanstack/react-query-devtools": "^4.29.1",
|
|
54
55
|
"@testing-library/dom": "^9.0.1",
|
|
@@ -57,7 +58,7 @@
|
|
|
57
58
|
"@testing-library/user-event": "^14.4.3",
|
|
58
59
|
"babel-plugin-module-resolver": "5.0.2",
|
|
59
60
|
"base64-arraybuffer": "^0.2.0",
|
|
60
|
-
"bundlesize2": "^0.0.
|
|
61
|
+
"bundlesize2": "^0.0.35",
|
|
61
62
|
"card-validator": "^8.1.1",
|
|
62
63
|
"cross-env": "^5.2.1",
|
|
63
64
|
"cross-fetch": "^3.1.4",
|
|
@@ -72,7 +73,7 @@
|
|
|
72
73
|
"jwt-decode": "^4.0.0",
|
|
73
74
|
"lodash": "^4.17.21",
|
|
74
75
|
"msw": "^1.2.1",
|
|
75
|
-
"nanoid": "^3.3.
|
|
76
|
+
"nanoid": "^3.3.8",
|
|
76
77
|
"prop-types": "^15.8.1",
|
|
77
78
|
"query-string": "^7.1.3",
|
|
78
79
|
"raf": "^3.4.1",
|
|
@@ -87,6 +88,11 @@
|
|
|
87
88
|
"devDependencies": {
|
|
88
89
|
"cross-env": "^5.2.1"
|
|
89
90
|
},
|
|
91
|
+
"overrides": {
|
|
92
|
+
"react-router": {
|
|
93
|
+
"path-to-regexp": "^1.9.0"
|
|
94
|
+
}
|
|
95
|
+
},
|
|
90
96
|
"engines": {
|
|
91
97
|
"node": "^16.11.0 || ^18.0.0 || ^20.0.0 || ^22.0.0",
|
|
92
98
|
"npm": "^8.0.0 || ^9.0.0 || ^10.0.0 || ^11.0.0"
|
|
@@ -98,8 +104,8 @@
|
|
|
98
104
|
},
|
|
99
105
|
{
|
|
100
106
|
"path": "build/vendor.js",
|
|
101
|
-
"maxSize": "
|
|
107
|
+
"maxSize": "328 kB"
|
|
102
108
|
}
|
|
103
109
|
],
|
|
104
|
-
"gitHead": "
|
|
110
|
+
"gitHead": "d86dc7bea3fe03a0f475ecf1a0ab878374f07026"
|
|
105
111
|
}
|