@jetshop/core 5.8.4 → 5.11.1
Sign up to get free protection for your applications and to get access to all the features.
- package/ChannelHandler/ChannelHandler.d.ts +9 -13
- package/ChannelHandler/ChannelHandler.js +24 -66
- package/ChannelHandler/ChannelHandler.js.map +1 -1
- package/ChannelHandler/channelUtils.d.ts +13 -0
- package/ChannelHandler/channelUtils.js +26 -15
- package/ChannelHandler/channelUtils.js.map +1 -1
- package/ChannelHandler/redirectUtils.d.ts +3 -0
- package/ChannelHandler/redirectUtils.js +48 -0
- package/ChannelHandler/redirectUtils.js.map +1 -0
- package/ChannelHandler/redirectUtils.test.js +8 -0
- package/analytics/AnalyticsProvider.js +9 -2
- package/analytics/AnalyticsProvider.js.map +1 -1
- package/analytics/integrations/ga4.d.ts +2 -1
- package/analytics/integrations/ga4.js +15 -6
- package/analytics/integrations/ga4.js.map +1 -1
- package/analytics/integrations/gtag/gtag.d.ts +2 -1
- package/analytics/integrations/gtag/gtag.js +20 -10
- package/analytics/integrations/gtag/gtag.js.map +1 -1
- package/analytics/integrations/gtm/index.d.ts +10 -1
- package/analytics/integrations/gtm/index.js +175 -2
- package/analytics/integrations/gtm/index.js.map +1 -1
- package/boot/SharedTree.js +1 -1
- package/boot/SharedTree.js.map +1 -1
- package/boot/apollo.d.ts +5 -4
- package/boot/apollo.js +18 -18
- package/boot/apollo.js.map +1 -1
- package/boot/client/startClient.js +7 -16
- package/boot/client/startClient.js.map +1 -1
- package/boot/server/createRenderer.js +8 -7
- package/boot/server/createRenderer.js.map +1 -1
- package/boot/server/index.js +2 -2
- package/boot/server/index.js.map +1 -1
- package/boot/server/persistedQueries/__tests__/getPersistedQueriesForRequest.test.js +53 -39
- package/boot/server/persistedQueries/getPersistedQueriesForRequest.js +2 -2
- package/boot/server/persistedQueries/getPersistedQueriesForRequest.js.map +1 -1
- package/cart/useAddToCart.d.ts +2 -2
- package/cart/useAddToCart.js +13 -12
- package/cart/useAddToCart.js.map +1 -1
- package/components/Auth/CustomerUpdateForm.js +7 -7
- package/components/Auth/CustomerUpdateForm.js.map +1 -1
- package/components/AuthContext/LogOut.d.ts +1 -0
- package/components/ChannelContext/ChannelProvider.d.ts +1 -3
- package/components/ChannelContext/ChannelProvider.js +6 -13
- package/components/ChannelContext/ChannelProvider.js.map +1 -1
- package/components/ChannelContext/ChannelProvider.test.js +110 -0
- package/components/ConfigProvider.d.ts +1 -0
- package/components/ConfigProvider.js.map +1 -1
- package/components/DynamicRoute/ContentRoute.d.ts +1 -1
- package/components/DynamicRoute/ProductByArticlenumber.d.ts +1 -0
- package/components/DynamicRoute/ProductRoute.d.ts +1 -0
- package/components/DynamicRoute/ProductRoute.js +4 -2
- package/components/DynamicRoute/ProductRoute.js.map +1 -1
- package/components/DynamicRoute/RouteResolver.js +1 -1
- package/components/DynamicRoute/RouteResolver.js.map +1 -1
- package/components/Mutation/AddToCart/addToCartUtils.js +3 -2
- package/components/Mutation/AddToCart/addToCartUtils.js.map +1 -1
- package/components/Mutation/DecrementQuantity.d.ts +1 -0
- package/components/Mutation/IncrementQuantity.d.ts +1 -0
- package/components/Mutation/RemoveFromCart.d.ts +2 -1
- package/components/Mutation/SetQuantity.d.ts +1 -0
- package/components/Mutation/cartMutationUtils.js +7 -6
- package/components/Mutation/cartMutationUtils.js.map +1 -1
- package/components/OpenGraph/OpenGraph.test.js +32 -5
- package/components/OpenGraph/OpenGraphProductData.d.ts +6 -1
- package/components/OpenGraph/OpenGraphProductData.js +18 -12
- package/components/OpenGraph/OpenGraphProductData.js.map +1 -1
- package/components/Query/CartProvider.js +32 -22
- package/components/Query/CartProvider.js.map +1 -1
- package/components/StructuredData/SiteLinksSearchStructuredData.d.ts +1 -0
- package/components/StructuredData/StructuredBreadcrumbData.d.ts +1 -0
- package/components/StructuredData/StructuredBreadcrumbData.js +4 -3
- package/components/StructuredData/StructuredBreadcrumbData.js.map +1 -1
- package/data/fragments/ProductListsFragments.gql +94 -0
- package/data/mutations/productListMutations.gql +18 -0
- package/data/queries/ProductLists.gql +8 -0
- package/dependencies.d.ts +10 -1
- package/hooks/ProductList/ProductListContext.js +49 -14
- package/hooks/ProductList/ProductListContext.js.map +1 -1
- package/hooks/ProductList/ProductLists.gql +0 -0
- package/hooks/ProductList/action-creators.d.ts +20 -7
- package/hooks/ProductList/action-creators.js +138 -44
- package/hooks/ProductList/action-creators.js.map +1 -1
- package/hooks/ProductList/index.d.ts +34 -8
- package/hooks/ProductList/index.js +19 -0
- package/hooks/ProductList/index.js.map +1 -1
- package/hooks/ProductList/list-transforms.d.ts +3 -2
- package/hooks/ProductList/list-transforms.js +22 -22
- package/hooks/ProductList/list-transforms.js.map +1 -1
- package/hooks/ProductList/list-transforms.test.js +103 -100
- package/hooks/ProductList/product-list-reducer.d.ts +37 -14
- package/hooks/ProductList/product-list-reducer.js +106 -43
- package/hooks/ProductList/product-list-reducer.js.map +1 -1
- package/hooks/ProductList/product-list-reducer.test.js +144 -82
- package/hooks/ProductList/useProductList.d.ts +2 -2
- package/hooks/ProductList/useProductList.js +12 -5
- package/hooks/ProductList/useProductList.js.map +1 -1
- package/hooks/ProductList/useProductListItems.d.ts +1 -1
- package/hooks/ProductList/useProductListItems.js +8 -6
- package/hooks/ProductList/useProductListItems.js.map +1 -1
- package/hooks/useInfinitePagination.js +1 -1
- package/hooks/useInfinitePagination.js.map +1 -1
- package/hooks/useRoutePreload.js +2 -2
- package/hooks/useRoutePreload.js.map +1 -1
- package/package.json +5 -5
- package/resolvers/index.d.ts +3 -0
- package/resolvers/index.js +3 -0
- package/resolvers/index.js.map +1 -1
- package/sentry/client.js +9 -4
- package/sentry/client.js.map +1 -1
- package/sentry/common.d.ts +1 -0
- package/sentry/common.js +5 -0
- package/sentry/common.js.map +1 -0
- package/sentry/server.js +11 -2
- package/sentry/server.js.map +1 -1
- package/time.d.ts +1 -0
- package/time.js +6 -0
- package/time.js.map +1 -0
- package/types.d.ts +1 -0
@@ -1,14 +1,14 @@
|
|
1
1
|
import React, { useMemo } from 'react';
|
2
2
|
import ChannelContext from './ChannelContext';
|
3
|
-
const ChannelProvider = ({
|
3
|
+
const ChannelProvider = ({ channelHandler, children, config }) => {
|
4
4
|
const { channels, selectedChannel, recommendedChannel } = channelHandler;
|
5
5
|
const value = useMemo(() => {
|
6
6
|
const updateChannelSingleDomain = (newChannel) => {
|
7
|
-
channelHandler.updateChannel({ config,
|
7
|
+
channelHandler.updateChannel({ config, newChannel });
|
8
8
|
};
|
9
9
|
const channelsById = {};
|
10
|
-
|
11
|
-
|
10
|
+
channels &&
|
11
|
+
channels.forEach((channel) => {
|
12
12
|
channelsById[channel.id] = channel;
|
13
13
|
});
|
14
14
|
return {
|
@@ -17,16 +17,9 @@ const ChannelProvider = ({ client, channelHandler, children, config }) => {
|
|
17
17
|
channels,
|
18
18
|
selectedChannel,
|
19
19
|
channelsById,
|
20
|
-
basename: channelHandler.getChannelBasename()
|
20
|
+
basename: channelHandler.getChannelBasename() // TODO This isn't used anywhere?
|
21
21
|
};
|
22
|
-
}, [
|
23
|
-
channelHandler,
|
24
|
-
channels,
|
25
|
-
client,
|
26
|
-
config,
|
27
|
-
recommendedChannel,
|
28
|
-
selectedChannel
|
29
|
-
]);
|
22
|
+
}, [channelHandler, channels, config, recommendedChannel, selectedChannel]);
|
30
23
|
return (React.createElement(ChannelContext.Provider, { value: value }, children));
|
31
24
|
};
|
32
25
|
export default ChannelProvider;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ChannelProvider.js","sourceRoot":"","sources":["ChannelProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,cAAmC,MAAM,kBAAkB,CAAC;
|
1
|
+
{"version":3,"file":"ChannelProvider.js","sourceRoot":"","sources":["ChannelProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,cAAmC,MAAM,kBAAkB,CAAC;AAWnE,MAAM,eAAe,GAAG,CAAC,EACvB,cAAc,EACd,QAAQ,EACR,MAAM,EACe,EAAE,EAAE;IACzB,MAAM,EAAE,QAAQ,EAAE,eAAe,EAAE,kBAAkB,EAAE,GAAG,cAAc,CAAC;IACzE,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,EAAE;QACzB,MAAM,yBAAyB,GAAG,CAAC,UAA2B,EAAE,EAAE;YAChE,cAAc,CAAC,aAAa,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC,CAAC;QACvD,CAAC,CAAC;QAEF,MAAM,YAAY,GAA+B,EAAE,CAAC;QAEpD,QAAQ;YACN,QAAQ,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;gBAC3B,YAAY,CAAC,OAAO,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC;YACrC,CAAC,CAAC,CAAC;QAEL,OAAO;YACL,kBAAkB;YAClB,aAAa,EAAE,yBAAyB;YACxC,QAAQ;YACR,eAAe;YACf,YAAY;YACZ,QAAQ,EAAE,cAAc,CAAC,kBAAkB,EAAE,CAAC,iCAAiC;SAChF,CAAC;IACJ,CAAC,EAAE,CAAC,cAAc,EAAE,QAAQ,EAAE,MAAM,EAAE,kBAAkB,EAAE,eAAe,CAAC,CAAC,CAAC;IAE5E,OAAO,CACL,oBAAC,cAAc,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,IAAG,QAAQ,CAA2B,CAC5E,CAAC;AACJ,CAAC,CAAC;AACF,eAAe,eAAe,CAAC"}
|
@@ -0,0 +1,110 @@
|
|
1
|
+
import React, { useContext } from 'react';
|
2
|
+
import { render } from '@testing-library/react';
|
3
|
+
import ChannelContext, { ChannelProvider } from '../ChannelContext/';
|
4
|
+
import { ChannelHandler } from '../../ChannelHandler/ChannelHandler';
|
5
|
+
import { createSelectedChannel } from '../../ChannelHandler/channelUtils';
|
6
|
+
import { channels } from '@jetshop/core/test-utils/variables';
|
7
|
+
|
8
|
+
function SelectedChannel() {
|
9
|
+
const { selectedChannel } = useContext(ChannelContext);
|
10
|
+
return <div id="selected-channel">{selectedChannel.displayName}</div>;
|
11
|
+
}
|
12
|
+
|
13
|
+
describe('ChannelProvider', () => {
|
14
|
+
const selectedChannel = createSelectedChannel(channels[0]);
|
15
|
+
|
16
|
+
const oldWindowLocation = window.location;
|
17
|
+
let mockAssign = jest.fn();
|
18
|
+
|
19
|
+
beforeAll(() => {
|
20
|
+
// Mock the window.location object so we can test redirects
|
21
|
+
delete window.location;
|
22
|
+
window.location = Object.defineProperties(
|
23
|
+
{},
|
24
|
+
{
|
25
|
+
...Object.getOwnPropertyDescriptors(oldWindowLocation),
|
26
|
+
assign: {
|
27
|
+
configurable: true,
|
28
|
+
value: mockAssign
|
29
|
+
}
|
30
|
+
}
|
31
|
+
);
|
32
|
+
});
|
33
|
+
|
34
|
+
beforeEach(() => {
|
35
|
+
window.location.assign.mockReset();
|
36
|
+
});
|
37
|
+
|
38
|
+
afterAll(() => {
|
39
|
+
window.location = oldWindowLocation;
|
40
|
+
});
|
41
|
+
|
42
|
+
test('Selected channel should be available', () => {
|
43
|
+
const channelHandler = new ChannelHandler({
|
44
|
+
selectedChannel,
|
45
|
+
channels
|
46
|
+
});
|
47
|
+
|
48
|
+
render(
|
49
|
+
<ChannelProvider channelHandler={channelHandler}>
|
50
|
+
<SelectedChannel />
|
51
|
+
</ChannelProvider>
|
52
|
+
);
|
53
|
+
const selectedChannelElement = document.getElementById('selected-channel');
|
54
|
+
|
55
|
+
expect(selectedChannelElement.textContent).toBe(
|
56
|
+
selectedChannel.displayName
|
57
|
+
);
|
58
|
+
});
|
59
|
+
|
60
|
+
function sleep(ms) {
|
61
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
62
|
+
}
|
63
|
+
|
64
|
+
test('Updating a channel', async () => {
|
65
|
+
const newChannel = createSelectedChannel(channels[1]);
|
66
|
+
|
67
|
+
const channelHandler = new ChannelHandler({
|
68
|
+
selectedChannel,
|
69
|
+
channels,
|
70
|
+
getPrimaryRoutePath: (path) => Promise.resolve(path)
|
71
|
+
});
|
72
|
+
|
73
|
+
render(
|
74
|
+
<ChannelProvider
|
75
|
+
channelHandler={channelHandler}
|
76
|
+
config={{ preserveRedirect: true }}
|
77
|
+
>
|
78
|
+
<SelectedChannel />
|
79
|
+
</ChannelProvider>
|
80
|
+
);
|
81
|
+
channelHandler.updateChannel({
|
82
|
+
config: { preserveRedirect: true },
|
83
|
+
newChannel
|
84
|
+
});
|
85
|
+
const selectedChannelElement = document.getElementById('selected-channel');
|
86
|
+
|
87
|
+
expect(selectedChannelElement.textContent).not.toBe(newChannel.name);
|
88
|
+
|
89
|
+
expect(selectedChannelElement.textContent).toBe(
|
90
|
+
selectedChannel.displayName
|
91
|
+
);
|
92
|
+
|
93
|
+
// NOTE
|
94
|
+
// We need to sleep briefly here, otherwise the call to
|
95
|
+
// window.location.assign is not detected(!) in .toHaveBeenCalled()
|
96
|
+
await sleep(10);
|
97
|
+
|
98
|
+
// Updating a channel should trigger a redirect
|
99
|
+
expect(window.location.assign).toHaveBeenCalled();
|
100
|
+
|
101
|
+
const newUrl = new URL(window.location.assign.mock.calls[0][0]);
|
102
|
+
expect(newUrl.searchParams.get('channel')).toBe(newChannel.name);
|
103
|
+
expect(newUrl.searchParams.get('channelCountry')).toBe(
|
104
|
+
newChannel.country.code
|
105
|
+
);
|
106
|
+
expect(newUrl.searchParams.get('culture')).toBe(
|
107
|
+
newChannel.language.culture
|
108
|
+
);
|
109
|
+
});
|
110
|
+
});
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ConfigProvider.js","sourceRoot":"","sources":["ConfigProvider.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,EAAE,EAAE,aAAa,EAAgB,MAAM,OAAO,CAAC;AAM3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;
|
1
|
+
{"version":3,"file":"ConfigProvider.js","sourceRoot":"","sources":["ConfigProvider.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,EAAE,EAAE,aAAa,EAAgB,MAAM,OAAO,CAAC;AAM3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAmG5D,MAAM,CAAC,MAAM,iBAAiB,GAAG,aAAa,CAC5C,SAAS,CACV,CAAC;AAEF,MAAM,UAAU,cAAc,CAAC,EAO9B;QAP8B,EAC7B,MAAM,EAAE,UAAU,EAClB,QAAQ,OAKT,EAJI,IAAI,cAHsB,sBAI9B,CADQ;IAKP,MAAM,MAAM,GAAG,gBAAgB,CAAC,UAAU,CAAC,CAAC;IAC5C,OAAO,CACL,oBAAC,iBAAiB,CAAC,QAAQ,kBAAC,KAAK,EAAE,MAAM,IAAM,IAAI,GAChD,QAAQ,CACkB,CAC9B,CAAC;AACJ,CAAC"}
|
@@ -8,6 +8,7 @@ export interface ProductProps {
|
|
8
8
|
export interface ProductRouteProps {
|
9
9
|
component: ComponentType<ProductProps>;
|
10
10
|
result: QueryResult;
|
11
|
+
partialProduct?: Partial<Product>;
|
11
12
|
}
|
12
13
|
declare const ProductRoute: (props: ProductRouteProps) => JSX.Element;
|
13
14
|
export default ProductRoute;
|
@@ -19,8 +19,10 @@ import { StructuredProductData } from '../StructuredData';
|
|
19
19
|
import { OpenGraphProductData } from '../OpenGraph';
|
20
20
|
const ProductRoute = (props) => {
|
21
21
|
var _a, _b, _c;
|
22
|
-
const { component: ProductPage } = props, rest = __rest(props, ["component"]);
|
23
|
-
const product = ((_b = (_a = props.result.data) === null || _a === void 0 ? void 0 : _a.route) === null || _b === void 0 ? void 0 : _b.object) ||
|
22
|
+
const { component: ProductPage, partialProduct } = props, rest = __rest(props, ["component", "partialProduct"]);
|
23
|
+
const product = ((_b = (_a = props.result.data) === null || _a === void 0 ? void 0 : _a.route) === null || _b === void 0 ? void 0 : _b.object) ||
|
24
|
+
((_c = props.result.data) === null || _c === void 0 ? void 0 : _c.product) ||
|
25
|
+
partialProduct;
|
24
26
|
const { structuredData, openGraph } = useShopConfig();
|
25
27
|
const location = useLocation();
|
26
28
|
const track = useTracker();
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ProductRoute.js","sourceRoot":"","sources":["ProductRoute.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAErE,OAAO,KAAK,EAAE,EAAiB,SAAS,EAAE,MAAM,OAAO,CAAC;AAExD,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,4BAA4B,MAAM,8DAA8D,CAAC;AACxG,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;
|
1
|
+
{"version":3,"file":"ProductRoute.js","sourceRoot":"","sources":["ProductRoute.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAErE,OAAO,KAAK,EAAE,EAAiB,SAAS,EAAE,MAAM,OAAO,CAAC;AAExD,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,4BAA4B,MAAM,8DAA8D,CAAC;AACxG,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAYpD,MAAM,YAAY,GAAG,CAAC,KAAwB,EAAE,EAAE;;IAChD,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,cAAc,KAAc,KAAK,EAAd,IAAI,UAAK,KAAK,EAA3D,+BAAmD,CAAQ,CAAC;IAElE,MAAM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 +42,7 @@ const RouteResolver = ({ productPage, categoryPage, contentPage, notFoundPage: N
|
|
42
42
|
} })));
|
43
43
|
}
|
44
44
|
else if (isRouteType(state, result, 'Product')) {
|
45
|
-
return React.createElement(ProductRoute, { result: result, component: productPage });
|
45
|
+
return (React.createElement(ProductRoute, { result: result, partialProduct: state === null || state === void 0 ? void 0 : state.product, component: productPage }));
|
46
46
|
}
|
47
47
|
else if (isRouteType(state, result, 'Category')) {
|
48
48
|
return React.createElement(CategoryRoute, { result: result, component: categoryPage });
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"RouteResolver.js","sourceRoot":"","sources":["RouteResolver.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAwB,MAAM,OAAO,CAAC;AAC7C,OAAO,YAA8B,MAAM,gBAAgB,CAAC;AAC5D,OAAO,aAAgC,MAAM,iBAAiB,CAAC;AAC/D,OAAO,YAA8B,MAAM,gBAAgB,CAAC;AAE5D,OAAO,MAAM,MAAM,UAAU,CAAC;AAE9B,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AAEjE,MAAM,WAAW,GAAG,CAAC,KAAU,EAAE,MAAmB,EAAE,IAAY,EAAE,EAAE;;IACpE,IAAI,MAAM,CAAC,KAAK,EAAE;QAChB,OAAO,KAAK,CAAC;KACd;IACD,MAAM,SAAS,GAAG,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,IAAI,CAAC;IAC9B,MAAM,SAAS,GAAG,MAAA,MAAA,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,IAAI,0CAAE,KAAK,0CAAE,MAAM,0CAAE,UAAU,CAAC;IAC1D,MAAM,UAAU,GAAG,CAAC,MAAM,CAAC,OAAO,IAAI,CAAC,SAAS,CAAC;IACjD,IAAI,UAAU,EAAE;QACd,OAAO,KAAK,CAA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,SAAS,CAAC,CAAC,CAAC,CACX,oBAAC,SAAS,IAAC,KAAK,EAAE,MAAM,CAAC,KAAK,GAAI,CACnC,CAAC,CAAC,CAAC,CACF,oBAAC,YAAY,IAAC,KAAK,EAAE,MAAM,CAAC,KAAK,GAAI,CACtC,CACM,CACV,CAAC;KACH;AACH,CAAC,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
@@ -2,7 +2,8 @@ import { useTracker } from '@jetshop/core/analytics/Analytics';
|
|
2
2
|
import { useCallback } from 'react';
|
3
3
|
import { trackProductEvent } from '@jetshop/core/analytics/tracking';
|
4
4
|
export function getArticleNumber(product, selectedVariation) {
|
5
|
-
|
5
|
+
var _a, _b;
|
6
|
+
return ((_b = (_a = product === null || product === void 0 ? void 0 : product.variants) === null || _a === void 0 ? void 0 : _a.values) === null || _b === void 0 ? void 0 : _b.length) > 0
|
6
7
|
? selectedVariation === null || selectedVariation === void 0 ? void 0 : selectedVariation.articleNumber
|
7
8
|
: product === null || product === void 0 ? void 0 : product.articleNumber;
|
8
9
|
}
|
@@ -18,7 +19,7 @@ export function useTrackProductAdd(selectedVariation) {
|
|
18
19
|
}, [selectedVariation, track]);
|
19
20
|
}
|
20
21
|
export function getCommentsFromFormikValues(values) {
|
21
|
-
return Object.keys(values.comments).map(name => {
|
22
|
+
return Object.keys(values.comments).map((name) => {
|
22
23
|
return {
|
23
24
|
name,
|
24
25
|
value: values.comments[name]
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"addToCartUtils.js","sourceRoot":"","sources":["addToCartUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAC;AAE/D,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACpC,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAOrE,MAAM,UAAU,gBAAgB,CAC9B,OAAgB,EAChB,iBAAiC
|
1
|
+
{"version":3,"file":"addToCartUtils.js","sourceRoot":"","s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AAO,EAAE,EAAE;QACvB,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,KAAK,MAAM,EAAE;YAChD,IAAI,CAAC,SAAS,IAAI,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;SACrD;QACD,kBAAkB,IAAI,kBAAkB,CAAC,eAAe,CAAC,CAAC;IAC5D,CAAC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,EAC7B,gBAAgB,EAChB,eAAe,EAIhB;IACC,OAAO,CAAC,KAAU,EAAE,EAAE;QACpB,OAAO,CAAC,KAAK,CAAC,oBAAoB,EAAE,KAAK,CAAC,CAAC;QAC3C,IAAI,CAAC,gBAAgB,EAAE;YACrB,MAAM,KAAK,CAAC;SACb;QACD,gBAAgB,iCAAM,eAAe,KAAE,KAAK,IAAG,CAAC;IAClD,CAAC,CAAC;AACJ,CAAC"}
|
@@ -1,4 +1,5 @@
|
|
1
|
+
/// <reference types="react" />
|
1
2
|
import { CartMutationProps } from './cartMutationUtils';
|
2
|
-
declare type RemoveFromCartProps =
|
3
|
+
declare type RemoveFromCartProps = CartMutationProps;
|
3
4
|
declare const RemoveFromCart: ({ cartQuery, children }: RemoveFromCartProps) => JSX.Element;
|
4
5
|
export default RemoveFromCart;
|
@@ -2,6 +2,7 @@ import throwErrorInDev from '../../helpers/throwErrorInDev';
|
|
2
2
|
export const TEMP_CART_ID = 'TEMP_CART_ID';
|
3
3
|
export const getAddToCartOptimisticResponse = (product, quantity = 1, cartId, client, cartQuery) => {
|
4
4
|
const defaultOptimisticCart = {
|
5
|
+
__optimistic: true,
|
5
6
|
id: TEMP_CART_ID,
|
6
7
|
totalQuantity: quantity,
|
7
8
|
__typename: 'Cart',
|
@@ -38,7 +39,7 @@ export const getAddToCartOptimisticResponse = (product, quantity = 1, cartId, cl
|
|
38
39
|
const newTotalQuantity = cart.totalQuantity + quantity;
|
39
40
|
const newItemQuantity = cart.items[index].quantity + quantity;
|
40
41
|
// Already in cart, increase/decrease quantity
|
41
|
-
const optimisticCart = Object.assign(Object.assign({}, cart), { totalQuantity: newTotalQuantity, items: [
|
42
|
+
const optimisticCart = Object.assign(Object.assign({}, cart), { __optimistic: true, totalQuantity: newTotalQuantity, items: [
|
42
43
|
...cart.items.slice(0, index),
|
43
44
|
...(newItemQuantity > 0
|
44
45
|
? [
|
@@ -50,7 +51,7 @@ export const getAddToCartOptimisticResponse = (product, quantity = 1, cartId, cl
|
|
50
51
|
return optimisticCart;
|
51
52
|
}
|
52
53
|
else {
|
53
|
-
const optimisticCart = Object.assign(Object.assign({}, cart), { totalQuantity: cart.totalQuantity + quantity });
|
54
|
+
const optimisticCart = Object.assign(Object.assign({}, cart), { __optimistic: true, totalQuantity: cart.totalQuantity + quantity });
|
54
55
|
return optimisticCart;
|
55
56
|
}
|
56
57
|
}
|
@@ -69,7 +70,7 @@ export const getDecrementQuantityOptimisticResponse = ({ itemId, client, cartId,
|
|
69
70
|
variables: { cartId }
|
70
71
|
});
|
71
72
|
const items = cart.items.map((item) => item.id === itemId ? Object.assign(Object.assign({}, item), { quantity: item.quantity - 1 }) : item);
|
72
|
-
const optimisticCart = Object.assign(Object.assign({}, cart), { items });
|
73
|
+
const optimisticCart = Object.assign(Object.assign({}, cart), { items, __optimistic: true });
|
73
74
|
return optimisticCart;
|
74
75
|
};
|
75
76
|
export const getIncrementQuantityOptimisticResponse = ({ itemId, client, cartId, cartQuery }) => {
|
@@ -79,7 +80,7 @@ export const getIncrementQuantityOptimisticResponse = ({ itemId, client, cartId,
|
|
79
80
|
variables: { cartId }
|
80
81
|
});
|
81
82
|
const items = cart.items.map((item) => item.id === itemId ? Object.assign(Object.assign({}, item), { quantity: item.quantity + 1 }) : item);
|
82
|
-
const optimisticCart = Object.assign(Object.assign({}, cart), { items });
|
83
|
+
const optimisticCart = Object.assign(Object.assign({}, cart), { items, __optimistic: true });
|
83
84
|
return optimisticCart;
|
84
85
|
};
|
85
86
|
export const getRemoveFromCartOptimisticResponse = ({ itemId, client, cartId, setCartId, cartQuery }) => {
|
@@ -92,7 +93,7 @@ export const getRemoveFromCartOptimisticResponse = ({ itemId, client, cartId, se
|
|
92
93
|
if (items.length === 0) {
|
93
94
|
setCartId(null);
|
94
95
|
}
|
95
|
-
const optimisticCart = Object.assign(Object.assign({}, cart), { items });
|
96
|
+
const optimisticCart = Object.assign(Object.assign({}, cart), { items, __optimistic: true });
|
96
97
|
return optimisticCart;
|
97
98
|
};
|
98
99
|
export const getSetQuantityOptimisticResponse = ({ itemId, quantity, client, cartId, cartQuery }) => {
|
@@ -102,7 +103,7 @@ export const getSetQuantityOptimisticResponse = ({ itemId, quantity, client, car
|
|
102
103
|
variables: { cartId }
|
103
104
|
});
|
104
105
|
const items = cart.items.map((item) => item.id === itemId ? Object.assign(Object.assign({}, item), { quantity }) : item);
|
105
|
-
const optimisticCart = Object.assign(Object.assign({}, cart), { items });
|
106
|
+
const optimisticCart = Object.assign(Object.assign({}, cart), { items, __optimistic: true });
|
106
107
|
return optimisticCart;
|
107
108
|
};
|
108
109
|
//# sourceMappingURL=cartMutationUtils.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"cartMutationUtils.js","sourceRoot":"","sources":["cartMutationUtils.ts"],"names":[],"mappings":"AAKA,OAAO,eAAe,MAAM,+BAA+B,CAAC;AAS5D,MAAM,CAAC,MAAM,YAAY,GAAG,cAAc,CAAC;AAE3C,MAAM,CAAC,MAAM,8BAA8B,GAAG,CAC5C,OAAgB,EAChB,
|
1
|
+
{"version":3,"file":"cartMutationUtils.js","sourceRoot":"","sources":["cartMutationUtils.ts"],"names":[],"mappings":"AAKA,OAAO,eAAe,MAAM,+BAA+B,CAAC;AAS5D,MAAM,CAAC,MAAM,YAAY,GAAG,cAAc,CAAC;AAE3C,MAAM,CAAC,MAAM,8BAA8B,GAAG,CAC5C,OAAgB,EAChB,QAAQ,GAAG,CAAC,EACZ,MAAc,EACd,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M,cAAc,mCACf,IAAI,KACP,KAAK,EACL,YAAY,EAAE,IAAI,GACnB,CAAC;IACF,OAAO,cAAc,CAAC;AACxB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,gCAAgC,GAAG,CAAC,EAC/C,MAAM,EACN,QAAQ,EACR,MAAM,EACN,MAAM,EACN,SAAS,EACsC,EAAE,EAAE;IACnD,eAAe,CACb,CAAC,SAAS,EACV,oEAAoE,CACrE,CAAC;IAEF,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,CAAC,SAAS,CAAC;QAChC,KAAK,EAAE,SAAS;QAChB,SAAS,EAAE,EAAE,MAAM,EAAE;KACtB,CAAC,CAAC;IACH,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAc,EAAE,EAAE,CAC9C,IAAI,CAAC,EAAE,KAAK,MAAM,CAAC,CAAC,iCAAM,IAAI,KAAE,QAAQ,IAAG,CAAC,CAAC,IAAI,CAClD,CAAC;IACF,MAAM,cAAc,mCACf,IAAI,KACP,KAAK,EACL,YAAY,EAAE,IAAI,GACnB,CAAC;IACF,OAAO,cAAc,CAAC;AACxB,CAAC,CAAC"}
|
@@ -6,6 +6,8 @@ import { HelmetProvider } from 'react-helmet-async';
|
|
6
6
|
import { OpenGraphProductData, OpenGraphGeneralPageData } from './';
|
7
7
|
import { ChannelProvider } from '../ChannelContext';
|
8
8
|
import { ChannelHandler } from '../../ChannelHandler/ChannelHandler';
|
9
|
+
import { ConfigProvider } from '../ConfigProvider';
|
10
|
+
import mockShopConfig from '../../test-utils/mockShopConfig';
|
9
11
|
|
10
12
|
function getMetaProperty(propertyName) {
|
11
13
|
const metas = document.getElementsByTagName('meta');
|
@@ -27,11 +29,13 @@ function Providers({ children }) {
|
|
27
29
|
});
|
28
30
|
const context = {};
|
29
31
|
return (
|
30
|
-
<
|
31
|
-
<
|
32
|
-
{
|
33
|
-
|
34
|
-
|
32
|
+
<ConfigProvider config={mockShopConfig}>
|
33
|
+
<HelmetProvider context={context}>
|
34
|
+
<ChannelProvider channelHandler={channelHandler}>
|
35
|
+
{children}
|
36
|
+
</ChannelProvider>
|
37
|
+
</HelmetProvider>
|
38
|
+
</ConfigProvider>
|
35
39
|
);
|
36
40
|
}
|
37
41
|
|
@@ -150,4 +154,27 @@ describe('<OpenGraphProductData>', () => {
|
|
150
154
|
expect(getMetaProperty('custom-property')).toEqual('custom-value');
|
151
155
|
});
|
152
156
|
});
|
157
|
+
|
158
|
+
it('Overriding brandCustomField in shop config should work', async () => {
|
159
|
+
const product = {
|
160
|
+
...sampleProduct,
|
161
|
+
customFields: [
|
162
|
+
{
|
163
|
+
key: 'customBrandField',
|
164
|
+
stringValue: 'HyperBrand'
|
165
|
+
}
|
166
|
+
]
|
167
|
+
};
|
168
|
+
render(
|
169
|
+
<Providers>
|
170
|
+
<ConfigProvider config={{ brandCustomField: 'customBrandField' }}>
|
171
|
+
<OpenGraphProductData product={product} />
|
172
|
+
</ConfigProvider>
|
173
|
+
</Providers>
|
174
|
+
);
|
175
|
+
|
176
|
+
await wait(() => {
|
177
|
+
expect(getMetaProperty('product:brand')).toEqual('HyperBrand');
|
178
|
+
});
|
179
|
+
});
|
153
180
|
});
|
@@ -16,5 +16,10 @@ export interface OpenGraphProductDataProps {
|
|
16
16
|
*/
|
17
17
|
optionalFields?: OpenGraphDataTag[];
|
18
18
|
}
|
19
|
-
|
19
|
+
/**
|
20
|
+
* Get the brand field from a product's customFields.
|
21
|
+
*
|
22
|
+
* Usually you'd want to pass in the brand field from your shop config.
|
23
|
+
*/
|
24
|
+
export declare function getBrand(product: Product, brandField?: string): any;
|
20
25
|
export declare const OpenGraphProductData: React.FC<OpenGraphProductDataProps>;
|
@@ -1,38 +1,44 @@
|
|
1
1
|
import React from 'react';
|
2
2
|
import { useProductVariants } from '../../hooks/useProductVariants';
|
3
|
+
import { useShopConfig } from '@jetshop/core/hooks/useShopConfig';
|
3
4
|
import ChannelContext from '../ChannelContext';
|
4
5
|
import { Helmet } from 'react-helmet-async';
|
5
|
-
|
6
|
-
|
6
|
+
/**
|
7
|
+
* Get the brand field from a product's customFields.
|
8
|
+
*
|
9
|
+
* Usually you'd want to pass in the brand field from your shop config.
|
10
|
+
*/
|
11
|
+
export function getBrand(product, brandField = 'brand') {
|
7
12
|
var _a;
|
8
|
-
const field = (_a = product === null || product === void 0 ? void 0 : product.customFields) === null || _a === void 0 ? void 0 : _a.find(({ key }) => key ===
|
13
|
+
const field = (_a = product === null || product === void 0 ? void 0 : product.customFields) === null || _a === void 0 ? void 0 : _a.find(({ key }) => key === brandField);
|
9
14
|
if (field) {
|
10
15
|
return field === null || field === void 0 ? void 0 : field.stringValue;
|
11
16
|
}
|
12
17
|
}
|
13
|
-
export const OpenGraphProductData = ({ product, initialVariant, optionalFields = []
|
14
|
-
var _a, _b, _c;
|
15
|
-
const { selectedVariant: variant
|
16
|
-
initialVariant
|
18
|
+
export const OpenGraphProductData = ({ product, initialVariant, optionalFields = [] }) => {
|
19
|
+
var _a, _b, _c, _d;
|
20
|
+
const { selectedVariant: variant } = useProductVariants(product, {
|
21
|
+
initialVariant
|
17
22
|
});
|
18
23
|
const { selectedChannel } = React.useContext(ChannelContext);
|
24
|
+
const { brandCustomField } = useShopConfig();
|
19
25
|
const prod = variant || product;
|
20
|
-
const brand = getBrand(product);
|
26
|
+
const brand = getBrand(product, brandCustomField);
|
21
27
|
const overrides = optionalFields.map((tag) => tag.property);
|
22
28
|
// If these are updated, please also update the docs (OpenGraph.mdx)
|
23
29
|
const defaultTags = [
|
24
30
|
{
|
25
31
|
property: 'product:original_price:amount',
|
26
|
-
content: (_a = prod.previousPrice) === null || _a === void 0 ? void 0 : _a.incVat
|
32
|
+
content: (_a = prod.previousPrice) === null || _a === void 0 ? void 0 : _a.incVat
|
27
33
|
},
|
28
34
|
{ property: 'product:price:amount', content: (_b = prod.price) === null || _b === void 0 ? void 0 : _b.incVat },
|
29
35
|
{
|
30
36
|
property: 'og:price:currency',
|
31
|
-
content: selectedChannel.currency.format.code
|
37
|
+
content: selectedChannel.currency.format.code
|
32
38
|
},
|
33
|
-
{ property: 'product:availability', content: prod.stockStatus.buyable },
|
39
|
+
{ property: 'product:availability', content: (_c = prod.stockStatus) === null || _c === void 0 ? void 0 : _c.buyable },
|
34
40
|
{ property: 'product:brand', content: brand },
|
35
|
-
{ property: 'product:category', content: (
|
41
|
+
{ property: 'product:category', content: (_d = product.canonicalCategory) === null || _d === void 0 ? void 0 : _d.name }
|
36
42
|
].filter((tag) => !overrides.includes(tag.property));
|
37
43
|
return (React.createElement(Helmet, null,
|
38
44
|
defaultTags.map((tag) => {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"OpenGraphProductData.js","sourceRoot":"","sources":["OpenGraphProductData.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACpE,OAAO,cAAc,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAmB5C
|
1
|
+
{"version":3,"file":"OpenGraphProductData.js","sourceRoot":"","sources":["OpenGraphProductData.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAClE,OAAO,cAAc,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAmB5C;;;;GAIG;AACH,MAAM,UAAU,QAAQ,CAAC,OAAgB,EAAE,UAAU,GAAG,OAAO;;IAC7D,MAAM,KAAK,GAAQ,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,YAAY,0CAAE,IAAI,CAC5C,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,GAAG,KAAK,UAAU,CA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AAO,CAAC,iBAAiB,0CAAE,IAAI,EAAE;KAC3E,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,SAAS,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC;IAErD,OAAO,CACL,oBAAC,MAAM;QACJ,WAAW,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE;YACvB,OAAO,CACL,GAAG,CAAC,OAAO,IAAI,CACb,8BACE,GAAG,EAAE,UAAU,GAAG,CAAC,QAAQ,EAAE,EAC7B,QAAQ,EAAE,GAAG,CAAC,QAAQ,EACtB,OAAO,EAAE,GAAG,CAAC,OAAO,GACpB,CACH,CACF,CAAC;QACJ,CAAC,CAAC;QACD,cAAc,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAC3B,8BACE,GAAG,EAAE,UAAU,GAAG,CAAC,QAAQ,EAAE,EAC7B,QAAQ,EAAE,GAAG,CAAC,QAAQ,EACtB,OAAO,EAAE,GAAG,CAAC,OAAO,GACpB,CACH,CAAC,CACK,CACV,CAAC;AACJ,CAAC,CAAC"}
|
@@ -1,45 +1,55 @@
|
|
1
1
|
import { useQuery } from '@apollo/react-hooks';
|
2
|
-
import { useContext, useEffect } from 'react';
|
2
|
+
import { useContext, useEffect, useRef } from 'react';
|
3
3
|
import throwErrorInDev from '../../helpers/throwErrorInDev';
|
4
4
|
import { CartIdContext } from '../Cart/CartIdContext';
|
5
5
|
import debounce from 'lodash.debounce';
|
6
6
|
import { useTracker } from '../../analytics/Analytics';
|
7
7
|
import { trackCartEvent } from '../../analytics/tracking';
|
8
|
-
|
8
|
+
// We only want a single tracker to be attached even if we use `useCart` in multiple places in our app
|
9
|
+
let trackerAttached = false;
|
10
|
+
function useSingleCartTracker(result) {
|
9
11
|
var _a;
|
12
|
+
const track = useTracker();
|
13
|
+
useEffect(() => {
|
14
|
+
var _a, _b;
|
15
|
+
if (!trackerAttached) {
|
16
|
+
trackerAttached = true;
|
17
|
+
if (result.loading) {
|
18
|
+
}
|
19
|
+
else if ((_a = result.data) === null || _a === void 0 ? void 0 : _a.cart) {
|
20
|
+
if (result.data.cart.__optimistic) {
|
21
|
+
}
|
22
|
+
else {
|
23
|
+
track(trackCartEvent({ cart: (_b = result.data) === null || _b === void 0 ? void 0 : _b.cart }));
|
24
|
+
}
|
25
|
+
}
|
26
|
+
return () => {
|
27
|
+
trackerAttached = false;
|
28
|
+
};
|
29
|
+
}
|
30
|
+
}, [result.loading, (_a = result.data) === null || _a === void 0 ? void 0 : _a.cart, track]);
|
31
|
+
}
|
32
|
+
export function useCart(cartQuery) {
|
10
33
|
const { cartId } = useContext(CartIdContext);
|
11
34
|
const result = useQuery(cartQuery, {
|
12
35
|
variables: { cartId },
|
13
|
-
skip: __IN_SERVER__
|
36
|
+
skip: __IN_SERVER__
|
14
37
|
});
|
15
|
-
|
16
|
-
useEffect(() => {
|
17
|
-
var _a;
|
18
|
-
if (result.loading) {
|
19
|
-
return;
|
20
|
-
}
|
21
|
-
else {
|
22
|
-
track(trackCartEvent({
|
23
|
-
cart: (_a = result.data) === null || _a === void 0 ? void 0 : _a.cart,
|
24
|
-
}));
|
25
|
-
}
|
26
|
-
}, [(_a = result.data) === null || _a === void 0 ? void 0 : _a.cart, track]);
|
38
|
+
useSingleCartTracker(result);
|
27
39
|
return { result, cart: result.data && result.data.cart };
|
28
40
|
}
|
29
41
|
const useLocalStorageCart = (refetch) => {
|
30
|
-
|
42
|
+
const debounceRefetch = useRef(null);
|
31
43
|
useEffect(() => {
|
32
44
|
const listener = (e) => {
|
33
45
|
const localStorageCart = localStorage.getItem('cartChange');
|
34
46
|
if (e.storageArea === localStorage &&
|
35
47
|
e.key === 'cartChange' &&
|
36
48
|
localStorageCart) {
|
37
|
-
if (debounceRefetch)
|
38
|
-
debounceRefetch.cancel();
|
39
|
-
debounceRefetch = debounce(() =>
|
40
|
-
|
41
|
-
}, 1500);
|
42
|
-
debounceRefetch();
|
49
|
+
if (debounceRefetch.current)
|
50
|
+
debounceRefetch.current.cancel();
|
51
|
+
debounceRefetch.current = debounce(() => refetch(), 1500);
|
52
|
+
debounceRefetch.current();
|
43
53
|
localStorage.removeItem('cartChange');
|
44
54
|
}
|
45
55
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"CartProvider.js","sourceRoot":"","sources":["CartProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAE/C,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;
|
1
|
+
{"version":3,"file":"CartProvider.js","sourceRoot":"","sources":["CartProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAE/C,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAEtD,OAAO,eAAe,MAAM,+BAA+B,CAAC;AAE5D,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,QAAQ,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAiB1D,sGAAsG;AACtG,IAAI,eAAe,GAAG,KAAK,CAAC;AAC5B,SAAS,oBAAoB,CAAC,MAAyB;;IACrD,MAAM,KAAK,GAAG,UAAU,EAAE,CAAC;IAE3B,SAAS,CAAC,GAAG,EAAE;;QACb,IAAI,CAAC,eAAe,EAAE;YACpB,eAAe,GAAG,IAAI,CAAC;YAEvB,IAAI,MAAM,CAAC,OAAO,EAAE;aACnB;iBAAM,IAAI,MAAA,MAAM,CAAC,IAAI,0CAAE,IAAI,EAAE;gBAC5B,IAAK,MAAM,CAAC,IAAI,CAAC,IAAY,CAAC,YAAY,EAAE;iBAC3C;qBAAM;oBACL,KAAK,CAAC,cAAc,CAAC,EAAE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