@sonic-equipment/ui 0.0.34 → 0.0.36
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/dist/algolia/algolia-provider.d.ts +2 -2
- package/dist/breadcrumbs/breadcrumb.d.ts +1 -2
- package/dist/breadcrumbs/breadcrumb.stories.d.ts +0 -4
- package/dist/buttons/link-button/link-button.d.ts +4 -1
- package/dist/cards/product-card/product-card.d.ts +2 -6
- package/dist/cards/product-card/product-card.stories.d.ts +0 -1
- package/dist/config.d.ts +3 -0
- package/dist/index.d.ts +3481 -90
- package/dist/index.js +433 -246
- package/dist/media/image/image.d.ts +1 -1
- package/dist/pages/page/page.d.ts +3 -1
- package/dist/pages/page/page.stories.d.ts +4 -0
- package/dist/pages/product-listing-page/product-listing-page-data-types.d.ts +1 -0
- package/dist/{pages/product-listing-page/use-fetch-product-listing-page → shared/api/bff/hooks}/use-fetch-product-listing-page-data.d.ts +4 -0
- package/dist/{pages/product-listing-page/use-fetch-product-listing-page/product-listing-page-data-response.d.ts → shared/api/bff/model/bff.model.d.ts} +1 -0
- package/dist/shared/api/shop/hooks/cart/cart.stories.d.ts +15 -0
- package/dist/shared/api/shop/hooks/cart/use-add-product-to-current-cart.d.ts +11 -0
- package/dist/shared/api/shop/hooks/cart/use-delete-cart-line-by-id.d.ts +5 -0
- package/dist/shared/api/shop/hooks/cart/use-fetch-current-cart-lines.d.ts +6 -0
- package/dist/shared/api/shop/hooks/cart/use-update-cart-line-by-id.d.ts +10 -0
- package/dist/shared/api/shop/model/shop.model.d.ts +2942 -0
- package/dist/shared/fetch/ResponseError.d.ts +1 -1
- package/dist/shared/providers/cart-provider.d.ts +8 -31
- package/dist/shared/routing/route-button.d.ts +9 -0
- package/dist/shared/routing/route-link.d.ts +8 -0
- package/dist/shared/routing/route-provider.d.ts +12 -0
- package/dist/shared/routing/route-provider.stories.d.ts +15 -0
- package/dist/shared/types/cart.d.ts +152 -4
- package/dist/shared/types/image.d.ts +18 -8
- package/dist/shared/utils/wait.d.ts +1 -0
- package/dist/styles.css +3 -1
- package/package.json +23 -19
- package/dist/breadcrumbs/connected-breadcrumb.d.ts +0 -1
- package/dist/pages/product-listing-page/product-listing-page-provider/use-breadcrumb.d.ts +0 -4
- /package/dist/{pages/product-listing-page/use-fetch-product-listing-page → shared/api/bff/hooks}/use-fetch-product-listing-page-data.stories.d.ts +0 -0
package/dist/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
+
import { useQuery, useQueryClient, useMutation } from '@tanstack/react-query';
|
|
1
2
|
import React, { useState, useCallback, useEffect, useRef, createContext, useContext, forwardRef, useLayoutEffect, Children, cloneElement, createElement as createElement$1, useMemo, Fragment as Fragment$1 } from 'react';
|
|
2
|
-
import { jsx,
|
|
3
|
-
import {
|
|
3
|
+
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
4
|
+
import { Link, Button as Button$1, Breadcrumbs, Breadcrumb as Breadcrumb$1, FieldError as FieldError$1, useContextProps, InputContext, Input as Input$1, Label as Label$1, NumberField as NumberField$1, Checkbox as Checkbox$1, Select as Select$1, SelectValue, Popover, ListBox, Section, Header, ListBoxItem, TextAreaContext, TextArea as TextArea$1, TextField as TextField$1 } from 'react-aria-components';
|
|
4
5
|
import clsx from 'clsx';
|
|
5
6
|
import { useCurrentRefinements, useClearRefinements, useRefinementList, useHits, useDynamicWidgets, usePagination, InstantSearch, Configure, useSortBy } from 'react-instantsearch';
|
|
6
7
|
import { history } from 'instantsearch.js/es/lib/routers/index.js';
|
|
7
8
|
import { simple } from 'instantsearch.js/es/lib/stateMappings/index.js';
|
|
8
|
-
import { useQuery } from '@tanstack/react-query';
|
|
9
9
|
import ReactDOM from 'react-dom';
|
|
10
10
|
import { TransitionGroup, Transition } from 'react-transition-group';
|
|
11
11
|
import { createAutocomplete } from '@algolia/autocomplete-core';
|
|
@@ -13,6 +13,282 @@ import { getAlgoliaResults, getAlgoliaFacets, parseAlgoliaHitHighlight } from '@
|
|
|
13
13
|
import { createQuerySuggestionsPlugin } from '@algolia/autocomplete-plugin-query-suggestions';
|
|
14
14
|
import { createLocalStorageRecentSearchesPlugin, search } from '@algolia/autocomplete-plugin-recent-searches';
|
|
15
15
|
|
|
16
|
+
class ResponseError extends Error {
|
|
17
|
+
constructor(response, message) {
|
|
18
|
+
super(response.statusText);
|
|
19
|
+
Object.defineProperty(this, "response", {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
configurable: true,
|
|
22
|
+
writable: true,
|
|
23
|
+
value: void 0
|
|
24
|
+
});
|
|
25
|
+
Object.defineProperty(this, "status", {
|
|
26
|
+
enumerable: true,
|
|
27
|
+
configurable: true,
|
|
28
|
+
writable: true,
|
|
29
|
+
value: void 0
|
|
30
|
+
});
|
|
31
|
+
Object.defineProperty(this, "statusText", {
|
|
32
|
+
enumerable: true,
|
|
33
|
+
configurable: true,
|
|
34
|
+
writable: true,
|
|
35
|
+
value: void 0
|
|
36
|
+
});
|
|
37
|
+
Object.defineProperty(this, "type", {
|
|
38
|
+
enumerable: true,
|
|
39
|
+
configurable: true,
|
|
40
|
+
writable: true,
|
|
41
|
+
value: void 0
|
|
42
|
+
});
|
|
43
|
+
Object.defineProperty(this, "url", {
|
|
44
|
+
enumerable: true,
|
|
45
|
+
configurable: true,
|
|
46
|
+
writable: true,
|
|
47
|
+
value: void 0
|
|
48
|
+
});
|
|
49
|
+
this.message = message || response.statusText;
|
|
50
|
+
this.name = 'ResponseError';
|
|
51
|
+
this.response = response;
|
|
52
|
+
this.status = response.status;
|
|
53
|
+
this.statusText = response.statusText;
|
|
54
|
+
this.type = response.type;
|
|
55
|
+
this.url = response.url;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
function isResponseError(error) {
|
|
59
|
+
return error instanceof ResponseError;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
class FetchProductListingPageDataError extends ResponseError {
|
|
63
|
+
constructor(response, message) {
|
|
64
|
+
super(response, message);
|
|
65
|
+
this.name = 'FetchProductListingPageDataError';
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
function useFetchProductListingPageData(bffUrl, { languageCode, pageUrl }) {
|
|
69
|
+
return useQuery({
|
|
70
|
+
gcTime: 1000 * 60 * 60 * 24,
|
|
71
|
+
queryFn: async () => {
|
|
72
|
+
const res = await fetch(`${bffUrl}/api/v1/plp/?pageUrl=${pageUrl}`, {
|
|
73
|
+
headers: { 'Current-Language-Id': languageCode },
|
|
74
|
+
});
|
|
75
|
+
if (!res.ok)
|
|
76
|
+
throw new FetchProductListingPageDataError(res);
|
|
77
|
+
return (await res.json());
|
|
78
|
+
},
|
|
79
|
+
queryKey: [bffUrl, 'product-listing-page-data', pageUrl, languageCode],
|
|
80
|
+
retry: false,
|
|
81
|
+
select: (data) => {
|
|
82
|
+
return {
|
|
83
|
+
banner: data.banner,
|
|
84
|
+
breadCrumb: data.breadCrumb.map(breadCrumb => ({
|
|
85
|
+
href: breadCrumb.url,
|
|
86
|
+
label: breadCrumb.text,
|
|
87
|
+
})),
|
|
88
|
+
category: {
|
|
89
|
+
href: data.categories.path,
|
|
90
|
+
image: {
|
|
91
|
+
alt: data.categories.imageAltText,
|
|
92
|
+
src: data.categories.smallImagePath,
|
|
93
|
+
title: data.categories.shortDescription,
|
|
94
|
+
},
|
|
95
|
+
title: data.categories.shortDescription,
|
|
96
|
+
},
|
|
97
|
+
categoryPages: data.categoryPages,
|
|
98
|
+
subcategories: data.categories.subCategories?.map(subcategory => ({
|
|
99
|
+
href: subcategory.path,
|
|
100
|
+
image: {
|
|
101
|
+
alt: subcategory.imageAltText,
|
|
102
|
+
src: subcategory.smallImagePath,
|
|
103
|
+
title: subcategory.shortDescription,
|
|
104
|
+
},
|
|
105
|
+
title: subcategory.shortDescription,
|
|
106
|
+
})),
|
|
107
|
+
};
|
|
108
|
+
},
|
|
109
|
+
staleTime: 1000 * 60 * 60 * 24,
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
var CurrencyPositioningType;
|
|
114
|
+
(function (CurrencyPositioningType) {
|
|
115
|
+
CurrencyPositioningType["Left"] = "Left";
|
|
116
|
+
CurrencyPositioningType["Right"] = "Right";
|
|
117
|
+
})(CurrencyPositioningType || (CurrencyPositioningType = {}));
|
|
118
|
+
var AvailabilityMessageType;
|
|
119
|
+
(function (AvailabilityMessageType) {
|
|
120
|
+
AvailabilityMessageType[AvailabilityMessageType["NoMessage"] = 0] = "NoMessage";
|
|
121
|
+
AvailabilityMessageType[AvailabilityMessageType["Available"] = 1] = "Available";
|
|
122
|
+
AvailabilityMessageType[AvailabilityMessageType["OutOfStock"] = 2] = "OutOfStock";
|
|
123
|
+
AvailabilityMessageType[AvailabilityMessageType["LowStock"] = 3] = "LowStock";
|
|
124
|
+
})(AvailabilityMessageType || (AvailabilityMessageType = {}));
|
|
125
|
+
var VariantDisplayTypeValues;
|
|
126
|
+
(function (VariantDisplayTypeValues) {
|
|
127
|
+
VariantDisplayTypeValues["Button"] = "Button";
|
|
128
|
+
VariantDisplayTypeValues["Dropdown"] = "Dropdown";
|
|
129
|
+
VariantDisplayTypeValues["SwatchDropdown"] = "SwatchDropdown";
|
|
130
|
+
VariantDisplayTypeValues["SwatchGrid"] = "SwatchGrid";
|
|
131
|
+
VariantDisplayTypeValues["SwatchList"] = "SwatchList";
|
|
132
|
+
})(VariantDisplayTypeValues || (VariantDisplayTypeValues = {}));
|
|
133
|
+
var BadgeTypeValues;
|
|
134
|
+
(function (BadgeTypeValues) {
|
|
135
|
+
BadgeTypeValues["Image"] = "Image";
|
|
136
|
+
BadgeTypeValues["Text"] = "Text";
|
|
137
|
+
})(BadgeTypeValues || (BadgeTypeValues = {}));
|
|
138
|
+
var BadgeImagePlacementValues;
|
|
139
|
+
(function (BadgeImagePlacementValues) {
|
|
140
|
+
BadgeImagePlacementValues["BottomCenter"] = "Bottom Center";
|
|
141
|
+
BadgeImagePlacementValues["BottomLeft"] = "Bottom Left";
|
|
142
|
+
BadgeImagePlacementValues["BottomRight"] = "Bottom Right";
|
|
143
|
+
BadgeImagePlacementValues["None"] = "None";
|
|
144
|
+
BadgeImagePlacementValues["TopCenter"] = "Top Center";
|
|
145
|
+
BadgeImagePlacementValues["TopLeft"] = "Top Left";
|
|
146
|
+
BadgeImagePlacementValues["TopRight"] = "Top Right";
|
|
147
|
+
})(BadgeImagePlacementValues || (BadgeImagePlacementValues = {}));
|
|
148
|
+
var BadgeStyleValues;
|
|
149
|
+
(function (BadgeStyleValues) {
|
|
150
|
+
BadgeStyleValues["Rectangle"] = "Rectangle";
|
|
151
|
+
BadgeStyleValues["Round"] = "Round";
|
|
152
|
+
})(BadgeStyleValues || (BadgeStyleValues = {}));
|
|
153
|
+
|
|
154
|
+
const config = {
|
|
155
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
156
|
+
SHOP_API_URL: '',
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
class AddProductToCurrentCartError extends ResponseError {
|
|
160
|
+
constructor(response, message) {
|
|
161
|
+
super(response, message);
|
|
162
|
+
this.name = 'AddProductToCurrentCartError';
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
function useAddProductToCurrentCart() {
|
|
166
|
+
const queryClient = useQueryClient();
|
|
167
|
+
const queryKey = ['carts', 'current', 'cartlines'];
|
|
168
|
+
return useMutation({
|
|
169
|
+
mutationFn: async (productOrderData) => {
|
|
170
|
+
const res = await fetch(`${config.SHOP_API_URL}/api/v1/carts/current/cartlines`, {
|
|
171
|
+
body: JSON.stringify(productOrderData),
|
|
172
|
+
credentials: 'include',
|
|
173
|
+
headers: {
|
|
174
|
+
'Content-Type': 'application/json',
|
|
175
|
+
},
|
|
176
|
+
method: 'POST',
|
|
177
|
+
});
|
|
178
|
+
if (!res.ok)
|
|
179
|
+
throw new AddProductToCurrentCartError(res, `Failed to add product ${productOrderData.productId} to cart`);
|
|
180
|
+
const cartLine = (await res.json());
|
|
181
|
+
if (cartLine.productId !== productOrderData.productId)
|
|
182
|
+
throw new Error(`Product ${productOrderData.productId} has not been added to the current cart`);
|
|
183
|
+
const cartLines = queryClient.getQueryData(queryKey) ||
|
|
184
|
+
[];
|
|
185
|
+
queryClient.setQueryData(queryKey, cartLines.some(cl => cl.id === cartLine.id)
|
|
186
|
+
? cartLines.map(cl => (cl.id === cartLine.id ? cartLine : cl))
|
|
187
|
+
: cartLines.concat(cartLine));
|
|
188
|
+
// Invalidate the related current cart query cache
|
|
189
|
+
queryClient.invalidateQueries({ queryKey: ['carts', 'current'] });
|
|
190
|
+
return cartLine;
|
|
191
|
+
},
|
|
192
|
+
onError: () => {
|
|
193
|
+
queryClient.invalidateQueries({ queryKey });
|
|
194
|
+
},
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
class DeleteCartLineByIdError extends ResponseError {
|
|
199
|
+
constructor(response, message) {
|
|
200
|
+
super(response, message);
|
|
201
|
+
this.name = 'DeleteCartLineByIdError';
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
function useDeleteCartLineById() {
|
|
205
|
+
const queryClient = useQueryClient();
|
|
206
|
+
const queryKey = ['carts', 'current', 'cartlines'];
|
|
207
|
+
return useMutation({
|
|
208
|
+
mutationFn: async (cartLineId) => {
|
|
209
|
+
const res = await fetch(`${config.SHOP_API_URL}/api/v1/carts/current/cartlines/${cartLineId}`, {
|
|
210
|
+
credentials: 'include',
|
|
211
|
+
headers: {
|
|
212
|
+
'Content-Type': 'application/json',
|
|
213
|
+
},
|
|
214
|
+
method: 'DELETE',
|
|
215
|
+
});
|
|
216
|
+
if (!res.ok)
|
|
217
|
+
throw new DeleteCartLineByIdError(res, `Failed to delete cart line with id ${cartLineId}`);
|
|
218
|
+
const cartLines = queryClient.getQueryData(queryKey);
|
|
219
|
+
queryClient.setQueryData(queryKey, cartLines?.filter(line => line.id !== cartLineId));
|
|
220
|
+
// Invalidate the related current cart query cache
|
|
221
|
+
queryClient.invalidateQueries({ queryKey: ['carts', 'current'] });
|
|
222
|
+
},
|
|
223
|
+
onError: () => {
|
|
224
|
+
queryClient.invalidateQueries({ queryKey });
|
|
225
|
+
},
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
class FetchCurrentCartLinesError extends ResponseError {
|
|
230
|
+
constructor(response, message) {
|
|
231
|
+
super(response, message);
|
|
232
|
+
this.name = 'FetchCurrentCartLinesError';
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
function useFetchCurrentCartLines() {
|
|
236
|
+
return useQuery({
|
|
237
|
+
queryFn: async () => {
|
|
238
|
+
const res = await fetch(`${config.SHOP_API_URL}/api/v1/carts/current/cartlines?page=1&pageSize=999`, {
|
|
239
|
+
credentials: 'include',
|
|
240
|
+
});
|
|
241
|
+
if (!res.ok)
|
|
242
|
+
throw new FetchCurrentCartLinesError(res);
|
|
243
|
+
const result = (await res.json());
|
|
244
|
+
return result.cartLines;
|
|
245
|
+
},
|
|
246
|
+
queryKey: ['carts', 'current', 'cartlines'],
|
|
247
|
+
retry: false,
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
class UpdateCartLineByIdError extends ResponseError {
|
|
252
|
+
constructor(response, message) {
|
|
253
|
+
super(response, message);
|
|
254
|
+
this.name = 'UpdateCartLineByIdError';
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
function useUpdateCartLineById() {
|
|
258
|
+
const queryClient = useQueryClient();
|
|
259
|
+
const queryKey = ['carts', 'current', 'cartlines'];
|
|
260
|
+
return useMutation({
|
|
261
|
+
mutationFn: async ({ cartLine: _cartLine, cartLineId }) => {
|
|
262
|
+
const res = await fetch(`${config.SHOP_API_URL}/api/v1/carts/current/cartlines/${cartLineId}`, {
|
|
263
|
+
body: JSON.stringify(_cartLine),
|
|
264
|
+
credentials: 'include',
|
|
265
|
+
headers: {
|
|
266
|
+
'Content-Type': 'application/json',
|
|
267
|
+
},
|
|
268
|
+
method: 'PATCH',
|
|
269
|
+
});
|
|
270
|
+
if (!res.ok)
|
|
271
|
+
throw new UpdateCartLineByIdError(res, `Failed to update cart line with ${cartLineId}`);
|
|
272
|
+
// Invalidate the related current cart query cache
|
|
273
|
+
queryClient.invalidateQueries({ queryKey: ['carts', 'current'] });
|
|
274
|
+
},
|
|
275
|
+
onError: () => {
|
|
276
|
+
queryClient.invalidateQueries({ queryKey });
|
|
277
|
+
},
|
|
278
|
+
onMutate: async ({ cartLine }) => {
|
|
279
|
+
await queryClient.cancelQueries({ queryKey });
|
|
280
|
+
const cartLines = (queryClient.getQueryData(queryKey) ||
|
|
281
|
+
[]);
|
|
282
|
+
const previousCartLine = cartLines.find(line => line.id === cartLine.id);
|
|
283
|
+
queryClient.setQueryData(queryKey, cartLines.some(cl => cl.id === cartLine.id)
|
|
284
|
+
? cartLines.map(cl => (cl.id === cartLine.id ? cartLine : cl))
|
|
285
|
+
: cartLines.concat(cartLine));
|
|
286
|
+
// Return a context with the previous and new todo
|
|
287
|
+
return { newCartLine: cartLine, previousCartLine };
|
|
288
|
+
},
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
|
|
16
292
|
/* eslint-disable sort-keys-fix/sort-keys-fix */
|
|
17
293
|
const breakpoints$1 = {
|
|
18
294
|
sm: 0,
|
|
@@ -199,32 +475,16 @@ function useGlobalState(key, initialState) {
|
|
|
199
475
|
}
|
|
200
476
|
|
|
201
477
|
function CartProvider(props) {
|
|
202
|
-
|
|
203
|
-
useEffect(() => {
|
|
204
|
-
updateState(props);
|
|
205
|
-
}, [props, updateState]);
|
|
478
|
+
useGlobalState('cart', props);
|
|
206
479
|
return null;
|
|
207
480
|
}
|
|
208
|
-
function
|
|
481
|
+
function useCartEvents() {
|
|
209
482
|
const [state] = useGlobalState('cart');
|
|
210
483
|
if (!state) {
|
|
211
484
|
throw new Error('useCart must be used together with the CartProvider');
|
|
212
485
|
}
|
|
213
486
|
return state;
|
|
214
487
|
}
|
|
215
|
-
function useProductCartLine(productId) {
|
|
216
|
-
const { addToCart, currentCart, isLoaded, isLoading, loadCurrentCart, removeCartLine, updateCartLine, } = useCart();
|
|
217
|
-
return {
|
|
218
|
-
addToCart,
|
|
219
|
-
cartLine: currentCart?.cartLines?.find(cl => cl.productId === productId),
|
|
220
|
-
currentCart,
|
|
221
|
-
isLoaded,
|
|
222
|
-
isLoading,
|
|
223
|
-
loadCurrentCart,
|
|
224
|
-
removeCartLine,
|
|
225
|
-
updateCartLine,
|
|
226
|
-
};
|
|
227
|
-
}
|
|
228
488
|
|
|
229
489
|
function FavoriteProvider(props) {
|
|
230
490
|
const [, updateState] = useGlobalState('favorite', props);
|
|
@@ -244,6 +504,54 @@ function useFavorite(productId) {
|
|
|
244
504
|
};
|
|
245
505
|
}
|
|
246
506
|
|
|
507
|
+
function RouteProvider({ children, navigate }) {
|
|
508
|
+
useGlobalState('routing', { navigate });
|
|
509
|
+
return jsx(Fragment, { children: children });
|
|
510
|
+
}
|
|
511
|
+
function useNavigate() {
|
|
512
|
+
const [state] = useGlobalState('routing');
|
|
513
|
+
if (!state) {
|
|
514
|
+
throw new Error('RouteProvider not found');
|
|
515
|
+
}
|
|
516
|
+
return state.navigate;
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
function RouteLink({ children, ...props }) {
|
|
520
|
+
const navigate = useNavigate();
|
|
521
|
+
function onClick(e) {
|
|
522
|
+
if (!props.href)
|
|
523
|
+
return;
|
|
524
|
+
e.preventDefault();
|
|
525
|
+
navigate(props.href, props.route);
|
|
526
|
+
}
|
|
527
|
+
function onHoverStart() {
|
|
528
|
+
// TODO: Implement prefetch
|
|
529
|
+
}
|
|
530
|
+
return (jsx(Link
|
|
531
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
532
|
+
// @ts-ignore
|
|
533
|
+
, {
|
|
534
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
535
|
+
// @ts-ignore
|
|
536
|
+
onClick: onClick, onHoverStart: onHoverStart, ...props, children: children }));
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
function RouteButton({ children, ...props }) {
|
|
540
|
+
const navigate = useNavigate();
|
|
541
|
+
return (jsx(Button$1
|
|
542
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
543
|
+
// @ts-ignore
|
|
544
|
+
, {
|
|
545
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
546
|
+
// @ts-ignore
|
|
547
|
+
onClick: e => {
|
|
548
|
+
if (!props.href)
|
|
549
|
+
return;
|
|
550
|
+
e.preventDefault();
|
|
551
|
+
navigate(props.href, props.route);
|
|
552
|
+
}, ...props, children: children }));
|
|
553
|
+
}
|
|
554
|
+
|
|
247
555
|
function ChevronLeftFilledIcon(props) {
|
|
248
556
|
return (jsx("svg", { height: "13", viewBox: "0 0 13 13", width: "13", xmlns: "http://www.w3.org/2000/svg", ...props, children: jsx("path", { d: "m3.889 6 5.025-5c.19.082.378.198.562.35.184.15.359.332.524.544L5.84 5.988 10 9.996c-.17.216-.344.407-.524.573-.18.166-.367.31-.562.431L3.889 6z", fill: "currentColor", fillRule: "evenodd" }) }));
|
|
249
557
|
}
|
|
@@ -254,46 +562,26 @@ function HomeFilledIcon(props) {
|
|
|
254
562
|
|
|
255
563
|
var styles$C = {"breadcrumbs":"breadcrumb-module-CQGse","breadcrumb":"breadcrumb-module-hxhDY","link":"breadcrumb-module-fp2Q6","icon":"breadcrumb-module-uIn3w","previous-icon":"breadcrumb-module-K-wMJ"};
|
|
256
564
|
|
|
257
|
-
function Breadcrumb({ links }) {
|
|
258
|
-
const { lg } = useBreakpoint();
|
|
259
|
-
if (links.length <= 1)
|
|
260
|
-
return null;
|
|
261
|
-
return lg ? BreadcrumbLong({ links }) : BreadcrumbShort({ links });
|
|
262
|
-
}
|
|
263
565
|
function BreadcrumbShort({ links }) {
|
|
264
566
|
const homeLink = links[0];
|
|
265
567
|
const previousLink = links[links.length - 2];
|
|
266
|
-
return (jsx(Breadcrumbs, { className: styles$C.breadcrumbs, children: jsx(Breadcrumb$1, { className: styles$C.breadcrumb, children:
|
|
568
|
+
return (jsx(Breadcrumbs, { className: styles$C.breadcrumbs, children: jsx(Breadcrumb$1, { className: styles$C.breadcrumb, children: jsxs(RouteLink, { className: styles$C.link, isDisabled: false, children: [jsx(ChevronLeftFilledIcon, { className: styles$C.icon }), previousLink === undefined || previousLink === homeLink ? (jsx(HomeFilledIcon, { className: styles$C.icon })) : (jsx("span", { children: previousLink.label }))] }) }) }));
|
|
569
|
+
}
|
|
570
|
+
function BreadcrumbLongItem({ index, isDisabled, link, }) {
|
|
571
|
+
return (jsx(Breadcrumb$1, { className: styles$C.breadcrumb, children: jsxs(RouteLink, { className: styles$C.link, href: link.href, isDisabled: isDisabled, children: [jsx(ChevronLeftFilledIcon, { className: clsx(styles$C['previous-icon'], styles$C.icon) }), link.label] }) }, index));
|
|
267
572
|
}
|
|
268
573
|
function BreadcrumbLong({ links }) {
|
|
269
574
|
const linksWithoutFirst = links.slice(1);
|
|
270
575
|
const homeLink = links[0];
|
|
271
576
|
if (!homeLink)
|
|
272
577
|
return null;
|
|
273
|
-
return (jsxs(Breadcrumbs, { className: styles$C.breadcrumbs, children: [jsx(Breadcrumb$1, { className: styles$C.breadcrumb, children: jsx(
|
|
578
|
+
return (jsxs(Breadcrumbs, { className: styles$C.breadcrumbs, children: [jsx(Breadcrumb$1, { className: styles$C.breadcrumb, children: jsx(RouteLink, { className: styles$C.link, href: homeLink.href, children: jsx(HomeFilledIcon, { className: clsx(styles$C['home-icon'], styles$C.icon) }) }) }), linksWithoutFirst.map((link, index) => (jsx(BreadcrumbLongItem, { index: index, isDisabled: linksWithoutFirst.length - 1 === index, link: link }, index)))] }));
|
|
274
579
|
}
|
|
275
|
-
|
|
276
|
-
const
|
|
277
|
-
|
|
278
|
-
});
|
|
279
|
-
|
|
280
|
-
function ProductListingPageProvider({ children, data, error, isError, isLoading, }) {
|
|
281
|
-
return (jsx(ProductListingPageContext.Provider, { value: { data, error, isError, isLoading }, children: children }));
|
|
282
|
-
}
|
|
283
|
-
function useProductListingPageProvider() {
|
|
284
|
-
return useContext(ProductListingPageContext);
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
function useBreadcrumb() {
|
|
288
|
-
const { data, isLoading } = useProductListingPageProvider();
|
|
289
|
-
return { breadCrumb: data?.breadCrumb, isLoading };
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
function ConnectedBreadcrumb() {
|
|
293
|
-
const { breadCrumb } = useBreadcrumb();
|
|
294
|
-
if (!breadCrumb)
|
|
580
|
+
function Breadcrumb({ links }) {
|
|
581
|
+
const { lg } = useBreakpoint();
|
|
582
|
+
if (links.length <= 1)
|
|
295
583
|
return null;
|
|
296
|
-
return
|
|
584
|
+
return lg ? BreadcrumbLong({ links }) : BreadcrumbShort({ links });
|
|
297
585
|
}
|
|
298
586
|
|
|
299
587
|
function TextAlignedArrowIcon(props) {
|
|
@@ -333,11 +621,15 @@ function FavoriteButton({ isFavorite, onPress }) {
|
|
|
333
621
|
|
|
334
622
|
var styles$y = {"link-button":"link-button-module-6i75g"};
|
|
335
623
|
|
|
336
|
-
function LinkButton({ children, className, href, isDisabled, onPress, target, }) {
|
|
337
|
-
if (
|
|
338
|
-
return (jsx(
|
|
624
|
+
function LinkButton({ children, className, href, isDisabled, onPress, route, target, type = href ? 'link' : 'button', }) {
|
|
625
|
+
if (type === 'link') {
|
|
626
|
+
return (jsx(RouteLink, { className: clsx(styles$y['link-button'], className), href: href, isDisabled: isDisabled, onPress: onPress, route: route, target: target, children: children }));
|
|
627
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
628
|
+
}
|
|
629
|
+
else if (type === 'button') {
|
|
630
|
+
return (jsx(RouteButton, { className: clsx(styles$y['link-button'], className), href: href, isDisabled: isDisabled, onPress: onPress, route: route, type: "button", children: children }));
|
|
339
631
|
}
|
|
340
|
-
|
|
632
|
+
throw new Error('Invalid type ${type} for LinkButton component');
|
|
341
633
|
}
|
|
342
634
|
|
|
343
635
|
var styles$x = {"field-error":"field-error-module-FXnIg"};
|
|
@@ -402,10 +694,10 @@ function NumberField({ autoFocus, autoGrow, defaultValue, formatOptions = { styl
|
|
|
402
694
|
inputRef.current.focus();
|
|
403
695
|
inputRef.current.selectionStart = inputRef.current.value.length || 0;
|
|
404
696
|
}, 500);
|
|
405
|
-
return (jsxs(NumberField$1, { "aria-label": label, autoFocus: autoFocus, className: clsx(styles$u.field, styles$u[size]), defaultValue: defaultValue, formatOptions: formatOptions, isDisabled: isDisabled, isInvalid: isInvalid, isReadOnly: isReadOnly, isRequired: isRequired, maxValue: maxValue, minValue: minValue, name: name, onChange: onChange, onInput: onInput,
|
|
697
|
+
return (jsxs(NumberField$1, { "aria-label": label, autoFocus: autoFocus, className: clsx(styles$u.field, styles$u[size]), defaultValue: defaultValue, formatOptions: formatOptions, isDisabled: isDisabled, isInvalid: isInvalid, isReadOnly: isReadOnly, isRequired: isRequired, maxValue: maxValue, minValue: minValue, name: name, onChange: onChange, onInput: onInput, value: value, children: [showLabel && jsx(Label, { isRequired: isRequired, children: label }), jsxs("div", { className: styles$u['button-input-container'], children: [withButtons && (jsx(Button$1, { isDisabled: isDisabled,
|
|
406
698
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
407
699
|
// @ts-expect-error
|
|
408
|
-
onClick: e => e.preventDefault(), onPressEnd: onFocusInput, onPressStart: e => e.target.focus(), slot: "decrement", children: (value || 0) <= 1 ? jsx(TrashOutlinedIcon, {}) : jsx(MinusFilledIcon, {}) })), jsx(Input, { ref: inputRef, autoGrow: autoGrow, maxLength: maxLength, placeholder: placeholder, size: size }), withButtons && (jsx(Button$1, { isDisabled: isDisabled,
|
|
700
|
+
onClick: e => e.preventDefault(), onPressEnd: onFocusInput, onPressStart: e => e.target.focus(), slot: "decrement", children: (value || 0) <= 1 ? jsx(TrashOutlinedIcon, {}) : jsx(MinusFilledIcon, {}) })), jsx(Input, { ref: inputRef, autoGrow: autoGrow, maxLength: maxLength, onKeyUp: e => onKeyUp?.(e), placeholder: placeholder, size: size }), withButtons && (jsx(Button$1, { isDisabled: isDisabled,
|
|
409
701
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
410
702
|
// @ts-expect-error
|
|
411
703
|
onClick: e => e.preventDefault(), onPressEnd: onFocusInput, onPressStart: e => e.target.focus(), slot: "increment", children: jsx(PlusFilledIcon, {}) }))] }), jsx(FieldError, {})] }));
|
|
@@ -464,7 +756,19 @@ const ensureNumber = (value) => {
|
|
|
464
756
|
};
|
|
465
757
|
function SpinnerState({ isDisabled, onChange, onManualInput, quantity, }) {
|
|
466
758
|
const [internalQuantity, setInternalQuantity] = useState(quantity);
|
|
467
|
-
const
|
|
759
|
+
const mounted = useRef(false);
|
|
760
|
+
const onDebouncedChange = useDebouncedCallback(value => {
|
|
761
|
+
// Prevent calling the debounced onChange callback after the component is unmounted
|
|
762
|
+
if (!mounted.current)
|
|
763
|
+
return;
|
|
764
|
+
onChange(value);
|
|
765
|
+
}, 500);
|
|
766
|
+
useEffect(() => {
|
|
767
|
+
mounted.current = true;
|
|
768
|
+
return () => {
|
|
769
|
+
mounted.current = false;
|
|
770
|
+
};
|
|
771
|
+
}, []);
|
|
468
772
|
useEffect(() => {
|
|
469
773
|
setInternalQuantity(quantity);
|
|
470
774
|
}, [quantity]);
|
|
@@ -495,48 +799,45 @@ function ManualInputState({ isDisabled, onCancel, onConfirm, quantity, }) {
|
|
|
495
799
|
}
|
|
496
800
|
|
|
497
801
|
const ConnectedAddToCartButton = ({ productId }) => {
|
|
498
|
-
const
|
|
499
|
-
const
|
|
500
|
-
const {
|
|
501
|
-
const
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
loadCurrentCart();
|
|
506
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
507
|
-
}, [isLoading || isLoaded]);
|
|
508
|
-
useEffect(() => {
|
|
509
|
-
if (cartLine === undefined)
|
|
510
|
-
setCartLineState(_cartLine);
|
|
511
|
-
setPreviousState(quantity || 0);
|
|
512
|
-
if (quantity !== undefined && quantity !== 0)
|
|
513
|
-
return;
|
|
514
|
-
setQuantity(_cartLine?.qtyOrdered || 0);
|
|
515
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
516
|
-
}, [_cartLine]);
|
|
517
|
-
useEffect(() => {
|
|
518
|
-
if (quantity === 0)
|
|
519
|
-
setCartLineState(undefined);
|
|
520
|
-
}, [quantity]);
|
|
802
|
+
const { isPending: isPendingAddToCart, mutate: addToCart } = useAddProductToCurrentCart();
|
|
803
|
+
const { data: cartLines, isLoading: isLoadingCartLines } = useFetchCurrentCartLines();
|
|
804
|
+
const { isPending: isPendingDeleteCartLine, mutate: deleteCartLine } = useDeleteCartLineById();
|
|
805
|
+
const { mutate: updateCartLine } = useUpdateCartLineById();
|
|
806
|
+
const { onCartLineAdded, onCartLineError, onCartLineRemoved, onCartLineUpdated, } = useCartEvents();
|
|
807
|
+
const cartLine = cartLines?.find(line => line.productId === productId);
|
|
808
|
+
const quantity = cartLine?.qtyOrdered || 0;
|
|
521
809
|
const handleChange = (quantity) => {
|
|
522
|
-
setQuantity(quantity);
|
|
523
810
|
if (cartLine) {
|
|
524
811
|
if (quantity === 0) {
|
|
525
|
-
|
|
812
|
+
deleteCartLine(cartLine.id, {
|
|
813
|
+
onError: error => onCartLineError?.(error, cartLine),
|
|
814
|
+
onSuccess: () => {
|
|
815
|
+
onCartLineRemoved?.(cartLine);
|
|
816
|
+
},
|
|
817
|
+
});
|
|
526
818
|
}
|
|
527
819
|
else {
|
|
528
|
-
updateCartLine({
|
|
820
|
+
updateCartLine({
|
|
821
|
+
cartLine: { ...cartLine, qtyOrdered: quantity },
|
|
822
|
+
cartLineId: cartLine.id,
|
|
823
|
+
}, {
|
|
824
|
+
onError: error => onCartLineError?.(error, cartLine),
|
|
825
|
+
onSuccess: () => {
|
|
826
|
+
onCartLineUpdated?.({ ...cartLine, qtyOrdered: quantity });
|
|
827
|
+
},
|
|
828
|
+
});
|
|
529
829
|
}
|
|
530
830
|
}
|
|
531
831
|
else {
|
|
532
|
-
addToCart({ productId, quantity }
|
|
832
|
+
addToCart({ productId, qtyOrdered: quantity, unitOfMeasure: '' }, {
|
|
833
|
+
onError: error => onCartLineError?.(error, cartLine),
|
|
834
|
+
onSuccess: cartLine => {
|
|
835
|
+
onCartLineAdded?.(cartLine);
|
|
836
|
+
},
|
|
837
|
+
});
|
|
533
838
|
}
|
|
534
839
|
};
|
|
535
|
-
return (jsx(AddToCartButton, { isDisabled:
|
|
536
|
-
!isLoaded ||
|
|
537
|
-
(isLoading &&
|
|
538
|
-
((quantity === 0 && previousQuantity !== 0) ||
|
|
539
|
-
(quantity === 1 && previousQuantity === 0))), onChange: handleChange, quantity: quantity || 0 }));
|
|
840
|
+
return (jsx(AddToCartButton, { isDisabled: isPendingDeleteCartLine || isLoadingCartLines || isPendingAddToCart, onChange: handleChange, quantity: quantity }));
|
|
540
841
|
};
|
|
541
842
|
|
|
542
843
|
var styles$s = {"tag":"tag-module-B7r15","body":"tag-module-4cfCf","shape":"tag-module-c7CRb"};
|
|
@@ -544,7 +845,7 @@ var styles$s = {"tag":"tag-module-B7r15","body":"tag-module-4cfCf","shape":"tag-
|
|
|
544
845
|
function Tag({ children }) {
|
|
545
846
|
if (!children)
|
|
546
847
|
return null;
|
|
547
|
-
return (jsxs("div", { className: styles$s.tag, children: [jsx("div", { className: styles$s.body, children: children }), jsx("svg", { className: styles$s.shape, height: "16", viewBox: "0 0
|
|
848
|
+
return (jsxs("div", { className: styles$s.tag, children: [jsx("div", { className: styles$s.body, children: children }), jsx("svg", { className: styles$s.shape, height: "16", viewBox: "0 0 9 16", width: "9", xmlns: "http://www.w3.org/2000/svg", children: jsx("path", { d: "M1.92461763,0 L0,0 L0,16 L1.92461763,16 L6.4117887,16 L8.87489381,7.57121588 C9.23711515,6.3325062 8.79482383,4.99454094 7.78060408,4.2560794 L1.92461763,0 Z", fill: "currentColor" }) })] }));
|
|
548
849
|
}
|
|
549
850
|
|
|
550
851
|
const IntlContext = createContext({
|
|
@@ -606,20 +907,25 @@ var styles$p = {"image":"image-module-lg7Kj","contain":"image-module-KFEgG","cov
|
|
|
606
907
|
const breakpointToWidth = {
|
|
607
908
|
lg: 1440,
|
|
608
909
|
md: 1024,
|
|
609
|
-
sm: 414,
|
|
610
910
|
};
|
|
611
|
-
function Image({ alt, className, fallbackSrc = 'https://res.cloudinary.com/dkz9eknwh/image/upload/v1716545808/images/product-card/fallback_p6ngjz.svg', fit = 'cover', height, loading = 'eager',
|
|
911
|
+
function Image({ alt, className, fallbackSrc = 'https://res.cloudinary.com/dkz9eknwh/image/upload/v1716545808/images/product-card/fallback_p6ngjz.svg', fit = 'cover', height, loading = 'eager', src, srcSet: srcSetProp, title, width, }) {
|
|
612
912
|
const [hasError, setHasError] = useState(false);
|
|
613
913
|
const srcSet = srcSetProp
|
|
614
914
|
? srcSetProp.map(({ url, width }) => `${url} ${width}w`).join(', ')
|
|
615
915
|
: undefined;
|
|
616
|
-
const
|
|
617
|
-
?
|
|
618
|
-
.map((
|
|
619
|
-
const
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
916
|
+
const sizesString = srcSetProp
|
|
917
|
+
? srcSetProp
|
|
918
|
+
.map((image, index, array) => {
|
|
919
|
+
const breakpoint = image.breakpoint;
|
|
920
|
+
if (breakpoint === 'lg') {
|
|
921
|
+
return `${image.width}px`;
|
|
922
|
+
}
|
|
923
|
+
else {
|
|
924
|
+
const nextBreakpointWidth = array[index + 1]
|
|
925
|
+
? breakpointToWidth[array[index + 1]?.breakpoint ?? 'sm'] - 1
|
|
926
|
+
: null;
|
|
927
|
+
return `(max-width: ${nextBreakpointWidth}px) ${image.width}px`;
|
|
928
|
+
}
|
|
623
929
|
})
|
|
624
930
|
.join(', ')
|
|
625
931
|
: undefined;
|
|
@@ -628,22 +934,19 @@ function Image({ alt, className, fallbackSrc = 'https://res.cloudinary.com/dkz9e
|
|
|
628
934
|
};
|
|
629
935
|
return (jsx("img", { alt: alt, className: clsx({
|
|
630
936
|
[styles$p['has-error']]: hasError,
|
|
631
|
-
}, styles$p.image, styles$p[fit], className), height: height, loading: loading, onError: handleError, sizes:
|
|
937
|
+
}, styles$p.image, styles$p[fit], className), height: height, loading: loading, onError: handleError, sizes: sizesString, src: hasError ? fallbackSrc : src, srcSet: srcSet, title: title, width: width }));
|
|
632
938
|
}
|
|
633
939
|
|
|
634
940
|
var styles$o = {"product-card":"product-card-module-pLaiB","favorite-button":"product-card-module-tvEdz","content":"product-card-module-e0kMu","top":"product-card-module-Q0VvF","tag":"product-card-module-HkWBE","title":"product-card-module-CStNi","bottom":"product-card-module-kD2tU","image":"product-card-module-p-zoi","price":"product-card-module-irW0D","add-to-cart-button":"product-card-module-SnCvX"};
|
|
635
941
|
|
|
636
|
-
function ProductCard({ addToCartButton: AddToCartButton, favoriteButton: FavoriteButton, href, image
|
|
637
|
-
return (jsxs(
|
|
638
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
639
|
-
// @ts-expect-error
|
|
640
|
-
onClick: onClick, onPress: onPress, children: [jsx("div", { className: styles$o.image, children: jsx(Image, { alt: alt, fit: fit, src: src, title: imageTitle }) }), jsx("div", { className: styles$o['favorite-button'], children: FavoriteButton && FavoriteButton }), jsxs("div", { className: styles$o.content, children: [jsxs("div", { className: styles$o.top, children: [jsx("div", { className: styles$o.tag, children: tags?.map(tag => (jsx(Tag, { children: jsx(FormattedMessage, { optional: true, fallbackValue: tag, id: `tag.${tag.toLowerCase()}` }) }, tag))) }), jsx("h2", { className: styles$o.title, children: title }), jsx(ProductSku, { sku: sku })] }), jsxs("div", { className: styles$o.bottom, children: [jsx("div", { className: styles$o.price, children: jsx(ProductPrice, { isVatIncluded: price.isVatIncluded, originalPrice: price.originalPrice, price: price.price }) }), jsx("div", { className: styles$o['add-to-cart-button'], children: AddToCartButton })] })] })] }));
|
|
942
|
+
function ProductCard({ addToCartButton: AddToCartButton, favoriteButton: FavoriteButton, href, image, price, sku, tags, title, }) {
|
|
943
|
+
return (jsxs(RouteLink, { className: styles$o['product-card'], href: href, children: [jsx("div", { className: styles$o.image, children: jsx(Image, { ...image }) }), jsx("div", { className: styles$o['favorite-button'], children: FavoriteButton && FavoriteButton }), jsxs("div", { className: styles$o.content, children: [jsxs("div", { className: styles$o.top, children: [jsx("div", { className: styles$o.tag, children: tags?.map(tag => (jsx(Tag, { children: jsx(FormattedMessage, { optional: true, fallbackValue: tag, id: `tag.${tag.toLowerCase()}` }) }, tag))) }), jsx("h2", { className: styles$o.title, children: title }), jsx(ProductSku, { sku: sku })] }), jsxs("div", { className: styles$o.bottom, children: [jsx("div", { className: styles$o.price, children: jsx(ProductPrice, { isVatIncluded: price.isVatIncluded, originalPrice: price.originalPrice, price: price.price }) }), jsx("div", { className: styles$o['add-to-cart-button'], children: AddToCartButton })] })] })] }));
|
|
641
944
|
}
|
|
642
945
|
|
|
643
946
|
var styles$n = {"category-card":"category-card-module-4NUjH","title":"category-card-module-LEhh3","is-selected":"category-card-module-vJ7vB","image-container":"category-card-module-oNTrK"};
|
|
644
947
|
|
|
645
948
|
function CategoryCard({ href, image, isSelected = false, title, }) {
|
|
646
|
-
return (jsxs(
|
|
949
|
+
return (jsxs(RouteLink, { className: clsx({
|
|
647
950
|
[styles$n['is-selected']]: isSelected,
|
|
648
951
|
}, styles$n['category-card']), href: href, children: [jsx("div", { className: styles$n['image-container'], children: jsx(Image, { ...image, fit: "contain" }) }), jsx("p", { className: styles$n.title, children: title })] }));
|
|
649
952
|
}
|
|
@@ -5931,9 +6234,9 @@ function Heading({ children, className, italic, size = 'xxl', tag, uppercase, })
|
|
|
5931
6234
|
|
|
5932
6235
|
var styles$b = {"page":"page-module-XtZ9Y","breadcrumb":"page-module-ohh9z","title":"page-module-TEmve"};
|
|
5933
6236
|
|
|
5934
|
-
function Page({ children, className, title }) {
|
|
6237
|
+
function Page({ breadCrumb, children, className, title }) {
|
|
5935
6238
|
const { lg, xxl } = useBreakpoint();
|
|
5936
|
-
return (jsxs(PageContainer, { className: clsx(styles$b.page, className), children: [jsx("div", { className: styles$b.breadcrumb, children: jsx(
|
|
6239
|
+
return (jsxs(PageContainer, { className: clsx(styles$b.page, className), children: [jsx("div", { className: styles$b.breadcrumb, children: jsx(Breadcrumb, { links: breadCrumb }) }), title && (jsx(Heading, { italic: true, uppercase: true, className: styles$b.title, size: xxl ? 'xl' : lg ? 'm' : 's', tag: "h1", children: title })), children] }));
|
|
5937
6240
|
}
|
|
5938
6241
|
|
|
5939
6242
|
function CloseFilledIcon(props) {
|
|
@@ -6028,7 +6331,7 @@ function ChevronRightFilledIcon(props) {
|
|
|
6028
6331
|
var styles$8 = {"pagination":"pagination-module-k4OgY","page-number-container":"pagination-module-oq89A"};
|
|
6029
6332
|
|
|
6030
6333
|
function Pagination({ currentPage, onChange, totalPages, }) {
|
|
6031
|
-
return (jsxs("div", { className: styles$8.pagination, children: [jsx(IconButton, {
|
|
6334
|
+
return (jsxs("div", { className: styles$8.pagination, children: [jsx(IconButton, { isDisabled: currentPage === 1, onPress: () => onChange(currentPage - 1), children: jsx(ChevronLeftFilledIcon, {}) }), jsxs("div", { className: styles$8['page-number-container'], children: [jsx(NumberField, { autoGrow: true, label: "current-page", maxValue: totalPages, minValue: 1, onChange: onChange, value: currentPage }), jsx(FormattedMessage, { id: "of" }), jsx("div", { children: totalPages })] }), jsx(IconButton, { isDisabled: currentPage >= totalPages, onPress: () => onChange(currentPage + 1), children: jsx(ChevronRightFilledIcon, {}) })] }));
|
|
6032
6335
|
}
|
|
6033
6336
|
|
|
6034
6337
|
function AlgoliaPagination({ onChange }) {
|
|
@@ -6177,10 +6480,10 @@ const AlgoliaContext = createContext({
|
|
|
6177
6480
|
setOnline: () => { },
|
|
6178
6481
|
toggleOnline: () => { },
|
|
6179
6482
|
});
|
|
6180
|
-
function AlgoliaProvider({
|
|
6483
|
+
function AlgoliaProvider({ categoryPages, children, languageCode, offlineSearchClient, online: _online = true, routing, searchClient, }) {
|
|
6181
6484
|
const [online, setOnline] = useState(_online);
|
|
6182
6485
|
const algoliaIndex = getAlgoliaIndex(environment, languageCode);
|
|
6183
|
-
if (!
|
|
6486
|
+
if (!categoryPages) {
|
|
6184
6487
|
// TODO: Implement loading page
|
|
6185
6488
|
return null;
|
|
6186
6489
|
}
|
|
@@ -6191,9 +6494,7 @@ function AlgoliaProvider({ category, children, languageCode, offlineSearchClient
|
|
|
6191
6494
|
}, children: jsxs(InstantSearch, { future: {
|
|
6192
6495
|
persistHierarchicalRootCount: true,
|
|
6193
6496
|
preserveSharedStateOnUnmount: true,
|
|
6194
|
-
}, indexName: algoliaIndex.default, routing: routing || createQueryStringRouting(algoliaIndex), searchClient: online ? searchClient : offlineSearchClient || searchClient, children: [jsx(Configure, { analytics: false, filters:
|
|
6195
|
-
? `categoryPages: '${category.join(' > ')}'`
|
|
6196
|
-
: undefined, maxValuesPerFacet: 100, ruleContexts: ['storefront'] }), children] }) }));
|
|
6497
|
+
}, indexName: algoliaIndex.default, routing: routing || createQueryStringRouting(algoliaIndex), searchClient: online ? searchClient : offlineSearchClient || searchClient, children: [jsx(Configure, { analytics: false, filters: `categoryPages: "${categoryPages}"`, maxValuesPerFacet: 100, ruleContexts: ['storefront'] }), children] }) }));
|
|
6197
6498
|
}
|
|
6198
6499
|
function useAlgolia() {
|
|
6199
6500
|
return useContext(AlgoliaContext);
|
|
@@ -6246,6 +6547,17 @@ function ConnectedProductCart({ productId, ...props }) {
|
|
|
6246
6547
|
return (jsx(ProductCard, { ...props, addToCartButton: jsx(ConnectedAddToCartButton, { productId: productId }) }));
|
|
6247
6548
|
}
|
|
6248
6549
|
|
|
6550
|
+
const ProductListingPageContext = createContext({
|
|
6551
|
+
data: undefined,
|
|
6552
|
+
});
|
|
6553
|
+
|
|
6554
|
+
function ProductListingPageProvider({ children, data, error, isError, isLoading, }) {
|
|
6555
|
+
return (jsx(ProductListingPageContext.Provider, { value: { data, error, isError, isLoading }, children: children }));
|
|
6556
|
+
}
|
|
6557
|
+
function useProductListingPageProvider() {
|
|
6558
|
+
return useContext(ProductListingPageContext);
|
|
6559
|
+
}
|
|
6560
|
+
|
|
6249
6561
|
function useSubcatagories() {
|
|
6250
6562
|
const { data, isLoading } = useProductListingPageProvider();
|
|
6251
6563
|
return { isLoading, subcategories: data?.subcategories };
|
|
@@ -6258,52 +6570,6 @@ function ConnectedCategoryCarousel() {
|
|
|
6258
6570
|
return jsx(CategoryCarousel, { categories: subcategories });
|
|
6259
6571
|
}
|
|
6260
6572
|
|
|
6261
|
-
class ResponseError extends Error {
|
|
6262
|
-
constructor(response) {
|
|
6263
|
-
super(response.statusText);
|
|
6264
|
-
Object.defineProperty(this, "response", {
|
|
6265
|
-
enumerable: true,
|
|
6266
|
-
configurable: true,
|
|
6267
|
-
writable: true,
|
|
6268
|
-
value: void 0
|
|
6269
|
-
});
|
|
6270
|
-
Object.defineProperty(this, "status", {
|
|
6271
|
-
enumerable: true,
|
|
6272
|
-
configurable: true,
|
|
6273
|
-
writable: true,
|
|
6274
|
-
value: void 0
|
|
6275
|
-
});
|
|
6276
|
-
Object.defineProperty(this, "statusText", {
|
|
6277
|
-
enumerable: true,
|
|
6278
|
-
configurable: true,
|
|
6279
|
-
writable: true,
|
|
6280
|
-
value: void 0
|
|
6281
|
-
});
|
|
6282
|
-
Object.defineProperty(this, "type", {
|
|
6283
|
-
enumerable: true,
|
|
6284
|
-
configurable: true,
|
|
6285
|
-
writable: true,
|
|
6286
|
-
value: void 0
|
|
6287
|
-
});
|
|
6288
|
-
Object.defineProperty(this, "url", {
|
|
6289
|
-
enumerable: true,
|
|
6290
|
-
configurable: true,
|
|
6291
|
-
writable: true,
|
|
6292
|
-
value: void 0
|
|
6293
|
-
});
|
|
6294
|
-
this.message = response.statusText;
|
|
6295
|
-
this.name = 'ResponseError';
|
|
6296
|
-
this.response = response;
|
|
6297
|
-
this.status = response.status;
|
|
6298
|
-
this.statusText = response.statusText;
|
|
6299
|
-
this.type = response.type;
|
|
6300
|
-
this.url = response.url;
|
|
6301
|
-
}
|
|
6302
|
-
}
|
|
6303
|
-
function isResponseError(error) {
|
|
6304
|
-
return error instanceof ResponseError;
|
|
6305
|
-
}
|
|
6306
|
-
|
|
6307
6573
|
const scrollToTop = (scrollOptions) => {
|
|
6308
6574
|
window.scrollTo({
|
|
6309
6575
|
behavior: 'smooth',
|
|
@@ -6347,48 +6613,6 @@ const ToggleSidebarButton = () => {
|
|
|
6347
6613
|
return (jsx(Button, { color: "secondary", icon: jsx(FilterOutlinedIcon, {}), onPress: toggle, size: "sm", variant: "outline", children: isOpen ? (jsx(FormattedMessage, { id: "Hide filters" })) : (jsx(FormattedMessage, { id: "Show filters" })) }));
|
|
6348
6614
|
};
|
|
6349
6615
|
|
|
6350
|
-
function useFetchProductListingPageData(bffUrl, { languageCode, pageUrl }) {
|
|
6351
|
-
return useQuery({
|
|
6352
|
-
queryFn: async () => {
|
|
6353
|
-
const response = await fetch(`${bffUrl}/api/v1/plp/?pageUrl=${pageUrl}`, {
|
|
6354
|
-
headers: { 'Current-Language-Id': languageCode },
|
|
6355
|
-
});
|
|
6356
|
-
if (!response.ok)
|
|
6357
|
-
throw new ResponseError(response);
|
|
6358
|
-
return (await response.json());
|
|
6359
|
-
},
|
|
6360
|
-
queryKey: [bffUrl, 'product-listing-page-data', pageUrl, languageCode],
|
|
6361
|
-
retry: false,
|
|
6362
|
-
select: (data) => {
|
|
6363
|
-
return {
|
|
6364
|
-
banner: data.banner,
|
|
6365
|
-
breadCrumb: data.breadCrumb.map(breadCrumb => ({
|
|
6366
|
-
href: breadCrumb.url,
|
|
6367
|
-
label: breadCrumb.text,
|
|
6368
|
-
})),
|
|
6369
|
-
category: {
|
|
6370
|
-
href: data.categories.path,
|
|
6371
|
-
image: {
|
|
6372
|
-
alt: data.categories.imageAltText,
|
|
6373
|
-
src: data.categories.smallImagePath,
|
|
6374
|
-
title: data.categories.shortDescription,
|
|
6375
|
-
},
|
|
6376
|
-
title: data.categories.shortDescription,
|
|
6377
|
-
},
|
|
6378
|
-
subcategories: data.categories.subCategories?.map(subcategory => ({
|
|
6379
|
-
href: subcategory.path,
|
|
6380
|
-
image: {
|
|
6381
|
-
alt: subcategory.imageAltText,
|
|
6382
|
-
src: subcategory.smallImagePath,
|
|
6383
|
-
title: subcategory.shortDescription,
|
|
6384
|
-
},
|
|
6385
|
-
title: subcategory.shortDescription,
|
|
6386
|
-
})),
|
|
6387
|
-
};
|
|
6388
|
-
},
|
|
6389
|
-
});
|
|
6390
|
-
}
|
|
6391
|
-
|
|
6392
6616
|
var styles$6 = {"product-listing":"product-listing-page-module-dmIHF","header":"product-listing-page-module-Oz76Z","action-bar":"product-listing-page-module-XxGrr","sidebar-toggle":"product-listing-page-module-F7bxy","sort":"product-listing-page-module-aQzHr","count":"product-listing-page-module-zx79v","categories":"product-listing-page-module-R4aOl","product-grid-container":"product-listing-page-module-ICkKg","product-grid":"product-listing-page-module-LHE7z","pagination":"product-listing-page-module-xsRaj"};
|
|
6393
6617
|
|
|
6394
6618
|
function ProductListingPage({ bffUrl, pageUrl, searchClient, }) {
|
|
@@ -6405,8 +6629,8 @@ function ProductListingPage({ bffUrl, pageUrl, searchClient, }) {
|
|
|
6405
6629
|
return null;
|
|
6406
6630
|
}
|
|
6407
6631
|
const category = data.breadCrumb.slice(1).map(breadCrumb => breadCrumb.label);
|
|
6408
|
-
return (jsx(ProductListingPageProvider, { data: data, error: error, isError: isError, isLoading: isFetching, children: jsx(AlgoliaProvider, {
|
|
6409
|
-
createSonicSearchClient(`${bffUrl}${bffUrl.endsWith('/') ? '' : '/'}search`), children: jsx(Page, { className: styles$6['product-listing'], title: category.slice().pop(), children: jsx(ProductListingPageContent, {}) }) }) }));
|
|
6632
|
+
return (jsx(ProductListingPageProvider, { data: data, error: error, isError: isError, isLoading: isFetching, children: jsx(AlgoliaProvider, { categoryPages: data.categoryPages, languageCode: languageCode, offlineSearchClient: offlineSearchClient, searchClient: searchClient ||
|
|
6633
|
+
createSonicSearchClient(`${bffUrl}${bffUrl.endsWith('/') ? '' : '/'}search`), children: jsx(Page, { breadCrumb: data.breadCrumb, className: styles$6['product-listing'], title: category.slice().pop(), children: jsx(ProductListingPageContent, {}) }) }) }));
|
|
6410
6634
|
}
|
|
6411
6635
|
function ProductListingPageContent() {
|
|
6412
6636
|
const { toggle } = useSidebar();
|
|
@@ -6414,30 +6638,11 @@ function ProductListingPageContent() {
|
|
|
6414
6638
|
}
|
|
6415
6639
|
function ProductOverview() {
|
|
6416
6640
|
const { hits: productHits } = useHits();
|
|
6417
|
-
|
|
6418
|
-
return (jsx(ProductOverviewGrid, { children: productHits.map(productHit => (jsx(ConnectedProductCart, { href: `${baseUrl}${baseUrl && baseUrl.endsWith('/') ? '' : '/'}${productHit.id}-${productHit.name.replace(/ /g, '-')}`, image: {
|
|
6641
|
+
return (jsx(ProductOverviewGrid, { children: productHits.map(productHit => (jsx(ConnectedProductCart, { href: `/Product/${productHit.storefrontSlug}`, image: {
|
|
6419
6642
|
alt: productHit.name,
|
|
6420
6643
|
fit: 'contain',
|
|
6421
|
-
|
|
6422
|
-
src: productHit.images?.find(image => image.quality === 'large')
|
|
6644
|
+
src: productHit.images?.find(image => image.quality === 'medium')
|
|
6423
6645
|
?.url || '',
|
|
6424
|
-
srcSet: [
|
|
6425
|
-
{
|
|
6426
|
-
url: productHit.images?.find(image => image.quality === 'small')
|
|
6427
|
-
?.url || '',
|
|
6428
|
-
width: 122,
|
|
6429
|
-
},
|
|
6430
|
-
{
|
|
6431
|
-
url: productHit.images?.find(image => image.quality === 'medium')
|
|
6432
|
-
?.url || '',
|
|
6433
|
-
width: 204,
|
|
6434
|
-
},
|
|
6435
|
-
{
|
|
6436
|
-
url: productHit.images?.find(image => image.quality === 'large')
|
|
6437
|
-
?.url || '',
|
|
6438
|
-
width: 288,
|
|
6439
|
-
},
|
|
6440
|
-
],
|
|
6441
6646
|
title: productHit.name,
|
|
6442
6647
|
}, price: {
|
|
6443
6648
|
isVatIncluded: productHit.isVatIncluded,
|
|
@@ -6491,7 +6696,7 @@ var styles$4 = {"sidebar-container":"sidebar-provider-module-rjeCL","transition"
|
|
|
6491
6696
|
|
|
6492
6697
|
function SidebarDetectBreakpoint() {
|
|
6493
6698
|
const xxl = useIsBreakpoint('xxl');
|
|
6494
|
-
const lastBreakpoint = useRef(
|
|
6699
|
+
const lastBreakpoint = useRef(null);
|
|
6495
6700
|
const { close, isOpen, open } = useSidebar();
|
|
6496
6701
|
const [transition, setTransition] = useState(false);
|
|
6497
6702
|
useScrollLock(isOpen && !xxl);
|
|
@@ -6977,26 +7182,8 @@ function ProductResultsSection() {
|
|
|
6977
7182
|
}), addToCartButton: jsx(AddToCartButton, { quantity: 0 }), image: {
|
|
6978
7183
|
alt: item.name,
|
|
6979
7184
|
fit: 'contain',
|
|
6980
|
-
|
|
6981
|
-
src: item.images?.find(image => image.quality === 'large')?.url ||
|
|
7185
|
+
src: item.images?.find(image => image.quality === 'medium')?.url ||
|
|
6982
7186
|
'',
|
|
6983
|
-
srcSet: [
|
|
6984
|
-
{
|
|
6985
|
-
url: item.images?.find(image => image.quality === 'small')
|
|
6986
|
-
?.url || '',
|
|
6987
|
-
width: 122,
|
|
6988
|
-
},
|
|
6989
|
-
{
|
|
6990
|
-
url: item.images?.find(image => image.quality === 'medium')
|
|
6991
|
-
?.url || '',
|
|
6992
|
-
width: 204,
|
|
6993
|
-
},
|
|
6994
|
-
{
|
|
6995
|
-
url: item.images?.find(image => image.quality === 'large')
|
|
6996
|
-
?.url || '',
|
|
6997
|
-
width: 288,
|
|
6998
|
-
},
|
|
6999
|
-
],
|
|
7000
7187
|
title: item.name,
|
|
7001
7188
|
}, price: {
|
|
7002
7189
|
isVatIncluded: item.isVatIncluded,
|
|
@@ -7046,4 +7233,4 @@ function GlobalSearch({ children, searchClient }) {
|
|
|
7046
7233
|
return (jsx(GlobalSearchContainer, { children: jsx(AlgoliaSearchProvider, { searchClient: searchClient, children: jsxs("div", { className: styles['search-wrapper'], children: [children, jsx("div", { className: styles['search-root'], children: jsx(SearchRoot, {}) })] }) }) }));
|
|
7047
7234
|
}
|
|
7048
7235
|
|
|
7049
|
-
export { Accordion, AddToCartButton, AlgoliaCategories, AlgoliaFilterPanel, AlgoliaFilterSection, AlgoliaMultiSelectFilterSection, AlgoliaPagination, AlgoliaProvider, AlgoliaResultsCount, AlgoliaSortBy, Breadcrumb, Button, CartFilledIcon, CartOutlinedIcon, CartProvider, CategoryCarousel, Checkbox, ColorCheckbox, ConnectedAddToCartButton,
|
|
7236
|
+
export { Accordion, AddProductToCurrentCartError, AddToCartButton, AlgoliaCategories, AlgoliaFilterPanel, AlgoliaFilterSection, AlgoliaMultiSelectFilterSection, AlgoliaPagination, AlgoliaProvider, AlgoliaResultsCount, AlgoliaSortBy, AvailabilityMessageType, BadgeImagePlacementValues, BadgeStyleValues, BadgeTypeValues, Breadcrumb, Button, CartFilledIcon, CartOutlinedIcon, CartProvider, CategoryCarousel, Checkbox, ColorCheckbox, ConnectedAddToCartButton, CurrencyPositioningType, DehashedOutlinedIcon, DeleteCartLineByIdError, FavoriteButton, FavoriteFilledIcon, FavoriteOutlinedIcon, FavoriteProvider, FetchCurrentCartLinesError, FetchProductListingPageDataError, FormattedMessage, GlobalSearch, GlobalSearchContainer, GlobalSearchDisclosureContext, GlobalStateProvider, GlobalStateProviderContext, HashedOutlinedIcon, IconButton, Image, IntlProvider, LeftArrowFilledIcon, LinkButton, MultiSelect, NumberField, Page, PageContainer, ProductCard, ProductListingPage, ProductOverviewGrid, ProductPrice, ProductSku, RightArrowFilledIcon, RouteButton, RouteLink, RouteProvider, Select, ShowAll, Sidebar, SidebarDetectBreakpoint, SidebarProvider, TextAlignedArrowIcon, TextField, UpdateCartLineByIdError, VariantDisplayTypeValues, breakpoints$1 as breakpoints, createSonicSearchClient, useAddProductToCurrentCart, useAlgolia, useAlgoliaSearch, useBreakpoint, useCartEvents, useDebouncedCallback, useDeleteCartLineById, useDisclosure, useFavorite, useFetchCurrentCartLines, useFetchProductListingPageData, useFormattedMessage, useGlobalSearchDisclosure, useGlobalState, useNavigate, useScrollLock, useUpdateCartLineById };
|