@faststore/core 2.1.95 → 2.1.96
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.next/BUILD_ID +1 -1
- package/.next/build-manifest.json +14 -14
- package/.next/cache/.tsbuildinfo +1 -1
- package/.next/cache/config.json +3 -3
- package/.next/cache/eslint/.cache_1gneedd +1 -1
- package/.next/cache/next-server.js.nft.json +1 -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/next-server.js.nft.json +1 -1
- package/.next/prerender-manifest.json +1 -1
- package/.next/react-loadable-manifest.json +1 -1
- package/.next/routes-manifest.json +1 -1
- package/.next/server/chunks/183.js +1 -0
- package/.next/server/chunks/530.js +58 -36
- package/.next/server/chunks/576.js +1 -0
- package/.next/server/middleware-build-manifest.js +1 -1
- package/.next/server/middleware-react-loadable-manifest.js +1 -1
- package/.next/server/pages/404.js.nft.json +1 -1
- package/.next/server/pages/500.js.nft.json +1 -1
- package/.next/server/pages/[...slug].js.nft.json +1 -1
- package/.next/server/pages/[slug]/p.js.nft.json +1 -1
- package/.next/server/pages/_app.js.nft.json +1 -1
- package/.next/server/pages/account.js.nft.json +1 -1
- package/.next/server/pages/checkout.js.nft.json +1 -1
- package/.next/server/pages/en-US/404.html +2 -2
- package/.next/server/pages/en-US/500.html +2 -2
- package/.next/server/pages/en-US/account.html +2 -2
- package/.next/server/pages/en-US/checkout.html +2 -2
- package/.next/server/pages/en-US/login.html +2 -2
- package/.next/server/pages/en-US/s.html +2 -2
- package/.next/server/pages/en-US.html +2 -2
- package/.next/server/pages/index.js.nft.json +1 -1
- package/.next/server/pages/login.js.nft.json +1 -1
- package/.next/server/pages/s.js.nft.json +1 -1
- package/.next/server/pages-manifest.json +4 -4
- package/.next/static/chunks/{530.848b014622932b93.js → 530.da3ec94477af00a4.js} +1 -1
- package/.next/static/chunks/pages/{_app-6d0e6ab9a4dd8106.js → _app-40cff0982559d0b8.js} +1 -1
- package/.next/static/chunks/{webpack-6580be4a27ecdd75.js → webpack-fac5a4eeea429971.js} +1 -1
- package/.next/trace +80 -80
- package/.turbo/turbo-build.log +2 -2
- package/README.md +3 -3
- package/cypress/global.js +8 -0
- package/cypress/integration/a11y.test.js +7 -24
- package/cypress/integration/analytics.test.js +78 -87
- package/cypress/integration/cart.test.js +4 -4
- package/cypress/integration/plp.test.js +6 -6
- package/cypress/integration/search.test.js +1 -1
- package/cypress/integration/seo.test.js +14 -14
- package/cypress.config.ts +19 -0
- package/faststore.config.js +1 -0
- package/package.json +8 -8
- package/src/components/cart/CartSidebar/CartSidebar.tsx +41 -27
- package/cypress.json +0 -9
- /package/.next/static/{ziUh67NXJKKH4lkHTrbrJ → 8EkJazrZDz4rsTIa4IP5R}/_buildManifest.js +0 -0
- /package/.next/static/{ziUh67NXJKKH4lkHTrbrJ → 8EkJazrZDz4rsTIa4IP5R}/_ssgManifest.js +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@faststore/core",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.96",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"browserslist": "supports es6-module and not dead",
|
|
6
6
|
"scripts": {
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"typescript": "4.7.3"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
|
-
"@cypress/code-coverage": "^3.
|
|
63
|
+
"@cypress/code-coverage": "^3.12.1",
|
|
64
64
|
"@faststore/eslint-config": "^2.1.82",
|
|
65
65
|
"@faststore/lighthouse": "^1.12.32",
|
|
66
66
|
"@graphql-codegen/cli": "^2.6.2",
|
|
@@ -74,13 +74,13 @@
|
|
|
74
74
|
"@storybook/builder-webpack5": "^6.5.9",
|
|
75
75
|
"@storybook/manager-webpack5": "^6.5.9",
|
|
76
76
|
"@storybook/react": "^6.5.9",
|
|
77
|
-
"@testing-library/cypress": "^
|
|
77
|
+
"@testing-library/cypress": "^10.0.1",
|
|
78
78
|
"@types/cypress": "^1.1.3",
|
|
79
79
|
"@vtex/prettier-config": "1.0.0",
|
|
80
|
-
"axe-core": "^4.
|
|
81
|
-
"cypress": "
|
|
82
|
-
"cypress-axe": "^
|
|
83
|
-
"cypress-wait-until": "^
|
|
80
|
+
"axe-core": "^4.8.1",
|
|
81
|
+
"cypress": "12.17.4",
|
|
82
|
+
"cypress-axe": "^1.5.0",
|
|
83
|
+
"cypress-wait-until": "^2.0.1",
|
|
84
84
|
"dotenv": "^8.2.0",
|
|
85
85
|
"eslint": "^7.32.0",
|
|
86
86
|
"husky": "^5.2.0",
|
|
@@ -110,5 +110,5 @@
|
|
|
110
110
|
"msw": {
|
|
111
111
|
"workerDirectory": "public"
|
|
112
112
|
},
|
|
113
|
-
"gitHead": "
|
|
113
|
+
"gitHead": "7a9d3f22a02b6c882cda586da99a7b073a458ee9"
|
|
114
114
|
}
|
|
@@ -10,7 +10,7 @@ import type { CartSidebarProps as UICartSidebarProps } from '@faststore/ui'
|
|
|
10
10
|
|
|
11
11
|
import type { CurrencyCode, ViewCartEvent } from '@faststore/sdk'
|
|
12
12
|
import { Icon, useFadeEffect, useUI } from '@faststore/ui'
|
|
13
|
-
import { Suspense, useEffect } from 'react'
|
|
13
|
+
import { Suspense, useCallback, useEffect, useMemo } from 'react'
|
|
14
14
|
import { useCart } from 'src/sdk/cart'
|
|
15
15
|
import { useCheckoutButton } from 'src/sdk/cart/useCheckoutButton'
|
|
16
16
|
import { useSession } from 'src/sdk/session'
|
|
@@ -21,6 +21,37 @@ import EmptyCart from '../EmptyCart'
|
|
|
21
21
|
import OrderSummary from '../OrderSummary'
|
|
22
22
|
import styles from './section.module.scss'
|
|
23
23
|
|
|
24
|
+
function useViewCartEvent() {
|
|
25
|
+
const {
|
|
26
|
+
currency: { code },
|
|
27
|
+
} = useSession()
|
|
28
|
+
const { items, gifts, total } = useCart()
|
|
29
|
+
|
|
30
|
+
const sendViewCartEvent = useCallback(() => {
|
|
31
|
+
return sendAnalyticsEvent<ViewCartEvent>({
|
|
32
|
+
name: 'view_cart',
|
|
33
|
+
params: {
|
|
34
|
+
currency: code as CurrencyCode,
|
|
35
|
+
value: total,
|
|
36
|
+
items: items.concat(gifts).map((item) => ({
|
|
37
|
+
item_id: item.itemOffered.isVariantOf.productGroupID,
|
|
38
|
+
item_name: item.itemOffered.isVariantOf.name,
|
|
39
|
+
item_brand: item.itemOffered.brand.name,
|
|
40
|
+
item_variant: item.itemOffered.sku,
|
|
41
|
+
quantity: item.quantity,
|
|
42
|
+
price: item.price,
|
|
43
|
+
discount: item.listPrice - item.price,
|
|
44
|
+
currency: code as CurrencyCode,
|
|
45
|
+
item_variant_name: item.itemOffered.name,
|
|
46
|
+
product_reference_id: item.itemOffered.gtin,
|
|
47
|
+
})),
|
|
48
|
+
},
|
|
49
|
+
})
|
|
50
|
+
}, [code, gifts, items, total])
|
|
51
|
+
|
|
52
|
+
return useMemo(() => ({ sendViewCartEvent }), [sendViewCartEvent])
|
|
53
|
+
}
|
|
54
|
+
|
|
24
55
|
export interface CartSidebarProps {
|
|
25
56
|
title: UICartSidebarProps['title']
|
|
26
57
|
alert?: {
|
|
@@ -52,38 +83,21 @@ function CartSidebar({
|
|
|
52
83
|
icon: { icon: checkoutButtonIcon, alt: checkoutButtonIconAlt },
|
|
53
84
|
},
|
|
54
85
|
}: CartSidebarProps) {
|
|
55
|
-
const { currency } = useSession()
|
|
56
86
|
const btnProps = useCheckoutButton()
|
|
57
|
-
const
|
|
87
|
+
const { items, gifts, totalItems, isValidating, subTotal, total } = useCart()
|
|
58
88
|
const { cart: displayCart, closeCart } = useUI()
|
|
59
89
|
const { fadeOut } = useFadeEffect()
|
|
90
|
+
const { sendViewCartEvent } = useViewCartEvent()
|
|
60
91
|
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
const isEmpty = items.length === 0
|
|
92
|
+
const isEmpty = useMemo(() => items.length === 0, [items])
|
|
64
93
|
|
|
65
94
|
useEffect(() => {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
item_id: item.itemOffered.isVariantOf.productGroupID,
|
|
73
|
-
item_name: item.itemOffered.isVariantOf.name,
|
|
74
|
-
item_brand: item.itemOffered.brand.name,
|
|
75
|
-
item_variant: item.itemOffered.sku,
|
|
76
|
-
quantity: item.quantity,
|
|
77
|
-
price: item.price,
|
|
78
|
-
discount: item.listPrice - item.price,
|
|
79
|
-
currency: currency.code as CurrencyCode,
|
|
80
|
-
item_variant_name: item.itemOffered.name,
|
|
81
|
-
product_reference_id: item.itemOffered.gtin,
|
|
82
|
-
})),
|
|
83
|
-
},
|
|
84
|
-
})
|
|
85
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
86
|
-
}, [])
|
|
95
|
+
if (!displayCart) {
|
|
96
|
+
return
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
sendViewCartEvent()
|
|
100
|
+
}, [displayCart, sendViewCartEvent])
|
|
87
101
|
|
|
88
102
|
return (
|
|
89
103
|
<>
|
package/cypress.json
DELETED
|
File without changes
|
|
File without changes
|