@behio/storefront-sdk 0.42.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-3TPJG2WV.js → chunk-ODAMBLGY.js} +52 -20
- package/dist/{chunk-QOZYQMK2.mjs → chunk-WMZH72WS.mjs} +43 -11
- package/dist/{client-B0vlHxB1.d.mts → client-CiowRIBp.d.mts} +185 -46
- package/dist/{client-B0vlHxB1.d.ts → client-CiowRIBp.d.ts} +185 -46
- package/dist/index.d.mts +103 -3
- package/dist/index.d.ts +103 -3
- package/dist/index.js +113 -9
- package/dist/index.mjs +109 -5
- package/dist/next.d.mts +1 -1
- package/dist/next.d.ts +1 -1
- package/dist/next.js +2 -2
- package/dist/next.mjs +1 -1
- package/dist/react.d.mts +203 -46
- package/dist/react.d.ts +203 -46
- package/dist/react.js +215 -151
- package/dist/react.mjs +149 -86
- package/package.json +1 -1
package/dist/react.js
CHANGED
|
@@ -83,6 +83,7 @@ __export(react_exports, {
|
|
|
83
83
|
usePickupPoints: () => usePickupPoints,
|
|
84
84
|
useProduct: () => useProduct,
|
|
85
85
|
useProductGroup: () => useProductGroup,
|
|
86
|
+
useProductParameters: () => useProductParameters,
|
|
86
87
|
useProductPromotions: () => useProductPromotions,
|
|
87
88
|
useProductReviews: () => useProductReviews,
|
|
88
89
|
useProducts: () => useProducts,
|
|
@@ -637,8 +638,7 @@ var CatalogModule = class {
|
|
|
637
638
|
if (query.inStock !== void 0) q.inStock = query.inStock;
|
|
638
639
|
if (query.ratingMin !== void 0) q.ratingMin = query.ratingMin;
|
|
639
640
|
if (query.search) q.search = query.search;
|
|
640
|
-
if (query.
|
|
641
|
-
q.customFields = JSON.stringify(query.customFields);
|
|
641
|
+
if (query.parameters) q.parameters = JSON.stringify(query.parameters);
|
|
642
642
|
if (query.facets) q.facets = JSON.stringify(query.facets);
|
|
643
643
|
if (query.ids && query.ids.length > 0) q.ids = query.ids;
|
|
644
644
|
if (query.slugs && query.slugs.length > 0) q.slugs = query.slugs;
|
|
@@ -730,18 +730,52 @@ var CatalogModule = class {
|
|
|
730
730
|
}
|
|
731
731
|
);
|
|
732
732
|
}
|
|
733
|
-
/**
|
|
734
|
-
|
|
733
|
+
/**
|
|
734
|
+
* Available filters for a dynamic filter UI.
|
|
735
|
+
*
|
|
736
|
+
* Derived from curated PARAMETERS the merchant marked filterable, so a
|
|
737
|
+
* visitor can never filter by something that does not appear in the
|
|
738
|
+
* product's parameters. Labels are per language, hence `locale`.
|
|
739
|
+
*/
|
|
740
|
+
async getFilters(options) {
|
|
741
|
+
return this.client.request(
|
|
742
|
+
"GET",
|
|
743
|
+
"/catalog/filters",
|
|
744
|
+
{ query: { locale: options?.locale } }
|
|
745
|
+
);
|
|
746
|
+
}
|
|
747
|
+
/**
|
|
748
|
+
* Curated parameter groups of a product, already resolved (label, value,
|
|
749
|
+
* unit, order). Returns an ARRAY of groups so a template can lay them out
|
|
750
|
+
* however it likes: one group as a spec table, another as badges.
|
|
751
|
+
*
|
|
752
|
+
* A variant's own parameters ride along on `ProductDetail.variants[]`, so
|
|
753
|
+
* this call is for the parent product.
|
|
754
|
+
*/
|
|
755
|
+
async getProductParameters(slug, options) {
|
|
735
756
|
return this.client.request(
|
|
736
757
|
"GET",
|
|
737
|
-
|
|
758
|
+
`/catalog/products/${slug}/parameters`,
|
|
759
|
+
{ query: { locale: options?.locale } }
|
|
738
760
|
);
|
|
739
761
|
}
|
|
740
762
|
/**
|
|
741
|
-
*
|
|
742
|
-
*
|
|
743
|
-
*
|
|
744
|
-
|
|
763
|
+
* One specific parameter group of a product, by its slug. 404 when the
|
|
764
|
+
* product does not have that group, which is deliberate: the caller asked
|
|
765
|
+
* for a named thing, so an empty array would hide a wrong slug.
|
|
766
|
+
*/
|
|
767
|
+
async getProductParameterGroup(slug, groupSlug, options) {
|
|
768
|
+
return this.client.request(
|
|
769
|
+
"GET",
|
|
770
|
+
`/catalog/products/${slug}/parameters/${groupSlug}`,
|
|
771
|
+
{ query: { locale: options?.locale } }
|
|
772
|
+
);
|
|
773
|
+
}
|
|
774
|
+
/**
|
|
775
|
+
* Facet groups + selection-aware counts for the current filter set
|
|
776
|
+
* (parameters, labels, price, availability, rating, subcategories). Pass the
|
|
777
|
+
* SAME query you pass to `getProducts` (category, search, price, inStock,
|
|
778
|
+
* ratingMin, parameters, facets slugs, labels): counts are computed with
|
|
745
779
|
* that facet excluded, and values that drop to 0 are still returned (render
|
|
746
780
|
* them disabled). Use this to build an Alza-style filter sidebar.
|
|
747
781
|
*/
|
|
@@ -757,8 +791,7 @@ var CatalogModule = class {
|
|
|
757
791
|
if (query.inStock !== void 0) q.inStock = query.inStock;
|
|
758
792
|
if (query.ratingMin !== void 0) q.ratingMin = query.ratingMin;
|
|
759
793
|
if (query.search) q.search = query.search;
|
|
760
|
-
if (query.
|
|
761
|
-
q.customFields = JSON.stringify(query.customFields);
|
|
794
|
+
if (query.parameters) q.parameters = JSON.stringify(query.parameters);
|
|
762
795
|
if (query.facets) q.facets = JSON.stringify(query.facets);
|
|
763
796
|
if (query.labels && query.labels.length > 0) q.labels = query.labels;
|
|
764
797
|
if (query.categories && query.categories.length > 0)
|
|
@@ -2167,10 +2200,11 @@ function useFeatured(options) {
|
|
|
2167
2200
|
var import_react_query8 = require("@tanstack/react-query");
|
|
2168
2201
|
function useFilters(options) {
|
|
2169
2202
|
const { client } = useBehio();
|
|
2203
|
+
const locale = options?.locale;
|
|
2170
2204
|
return (0, import_react_query8.useQuery)({
|
|
2171
|
-
queryKey: ["behio", "filters"],
|
|
2205
|
+
queryKey: ["behio", "filters", locale ?? null],
|
|
2172
2206
|
queryFn: async () => {
|
|
2173
|
-
const result = await unwrap(client.catalog.getFilters());
|
|
2207
|
+
const result = await unwrap(client.catalog.getFilters({ locale }));
|
|
2174
2208
|
return result.filters;
|
|
2175
2209
|
},
|
|
2176
2210
|
enabled: options?.enabled !== false
|
|
@@ -2188,9 +2222,38 @@ function useFacets(query, options) {
|
|
|
2188
2222
|
});
|
|
2189
2223
|
}
|
|
2190
2224
|
|
|
2225
|
+
// src/react/hooks/use-product-parameters.ts
|
|
2226
|
+
var import_react_query10 = require("@tanstack/react-query");
|
|
2227
|
+
function useProductParameters(slug, options) {
|
|
2228
|
+
const { client } = useBehio();
|
|
2229
|
+
const { locale, groupSlug } = options ?? {};
|
|
2230
|
+
return (0, import_react_query10.useQuery)({
|
|
2231
|
+
queryKey: [
|
|
2232
|
+
"behio",
|
|
2233
|
+
"product-parameters",
|
|
2234
|
+
slug,
|
|
2235
|
+
locale ?? null,
|
|
2236
|
+
groupSlug ?? null
|
|
2237
|
+
],
|
|
2238
|
+
queryFn: async () => {
|
|
2239
|
+
if (groupSlug) {
|
|
2240
|
+
const group = await unwrap(
|
|
2241
|
+
client.catalog.getProductParameterGroup(slug, groupSlug, { locale })
|
|
2242
|
+
);
|
|
2243
|
+
return [group];
|
|
2244
|
+
}
|
|
2245
|
+
const result = await unwrap(
|
|
2246
|
+
client.catalog.getProductParameters(slug, { locale })
|
|
2247
|
+
);
|
|
2248
|
+
return result.groups;
|
|
2249
|
+
},
|
|
2250
|
+
enabled: options?.enabled !== false && !!slug
|
|
2251
|
+
});
|
|
2252
|
+
}
|
|
2253
|
+
|
|
2191
2254
|
// src/react/hooks/use-search.ts
|
|
2192
2255
|
var import_react4 = require("react");
|
|
2193
|
-
var
|
|
2256
|
+
var import_react_query11 = require("@tanstack/react-query");
|
|
2194
2257
|
function useSearch(query, options) {
|
|
2195
2258
|
const { client } = useBehio();
|
|
2196
2259
|
const debounceMs = options?.debounceMs ?? 300;
|
|
@@ -2203,7 +2266,7 @@ function useSearch(query, options) {
|
|
|
2203
2266
|
const timer = setTimeout(() => setDebouncedQuery(query), debounceMs);
|
|
2204
2267
|
return () => clearTimeout(timer);
|
|
2205
2268
|
}, [query, debounceMs]);
|
|
2206
|
-
return (0,
|
|
2269
|
+
return (0, import_react_query11.useQuery)({
|
|
2207
2270
|
queryKey: ["behio", "search", debouncedQuery, options?.page, options?.limit],
|
|
2208
2271
|
queryFn: () => unwrap(client.catalog.search(debouncedQuery, {
|
|
2209
2272
|
page: options?.page,
|
|
@@ -2215,22 +2278,22 @@ function useSearch(query, options) {
|
|
|
2215
2278
|
|
|
2216
2279
|
// src/react/hooks/use-cart.ts
|
|
2217
2280
|
var import_react5 = require("react");
|
|
2218
|
-
var
|
|
2281
|
+
var import_react_query12 = require("@tanstack/react-query");
|
|
2219
2282
|
var CART_KEY = ["behio", "cart"];
|
|
2220
2283
|
function useCart(options) {
|
|
2221
2284
|
const { client, storage } = useBehio();
|
|
2222
|
-
const queryClient = (0,
|
|
2285
|
+
const queryClient = (0, import_react_query12.useQueryClient)();
|
|
2223
2286
|
const {
|
|
2224
2287
|
data: cart,
|
|
2225
2288
|
isLoading,
|
|
2226
2289
|
error
|
|
2227
|
-
} = (0,
|
|
2290
|
+
} = (0, import_react_query12.useQuery)({
|
|
2228
2291
|
queryKey: [...CART_KEY],
|
|
2229
2292
|
queryFn: () => unwrap(client.cart.get()),
|
|
2230
2293
|
// Only fetch if we have a cart session or are logged in
|
|
2231
2294
|
enabled: options?.enabled !== false && (!!client.getCartSession() || !!client.getAccessToken())
|
|
2232
2295
|
});
|
|
2233
|
-
const addMutation = (0,
|
|
2296
|
+
const addMutation = (0, import_react_query12.useMutation)({
|
|
2234
2297
|
mutationFn: async ({ productId, quantity }) => {
|
|
2235
2298
|
return unwrap(client.cart.addItem({ productId, quantity: quantity ?? 1 }));
|
|
2236
2299
|
},
|
|
@@ -2241,7 +2304,7 @@ function useCart(options) {
|
|
|
2241
2304
|
queryClient.setQueryData([...CART_KEY], result);
|
|
2242
2305
|
}
|
|
2243
2306
|
});
|
|
2244
|
-
const updateMutation = (0,
|
|
2307
|
+
const updateMutation = (0, import_react_query12.useMutation)({
|
|
2245
2308
|
mutationFn: async ({ itemId, quantity }) => {
|
|
2246
2309
|
return unwrap(client.cart.updateQuantity(itemId, quantity));
|
|
2247
2310
|
},
|
|
@@ -2269,7 +2332,7 @@ function useCart(options) {
|
|
|
2269
2332
|
queryClient.invalidateQueries({ queryKey: [...CART_KEY] });
|
|
2270
2333
|
}
|
|
2271
2334
|
});
|
|
2272
|
-
const removeMutation = (0,
|
|
2335
|
+
const removeMutation = (0, import_react_query12.useMutation)({
|
|
2273
2336
|
mutationFn: async (itemId) => {
|
|
2274
2337
|
return unwrap(client.cart.removeItem(itemId));
|
|
2275
2338
|
},
|
|
@@ -2295,7 +2358,7 @@ function useCart(options) {
|
|
|
2295
2358
|
queryClient.invalidateQueries({ queryKey: [...CART_KEY] });
|
|
2296
2359
|
}
|
|
2297
2360
|
});
|
|
2298
|
-
const clearMutation = (0,
|
|
2361
|
+
const clearMutation = (0, import_react_query12.useMutation)({
|
|
2299
2362
|
mutationFn: () => unwrap(client.cart.clear()),
|
|
2300
2363
|
onSuccess: () => {
|
|
2301
2364
|
queryClient.setQueryData([...CART_KEY], null);
|
|
@@ -2303,19 +2366,19 @@ function useCart(options) {
|
|
|
2303
2366
|
storage.remove(STORAGE_KEYS.CART_SESSION);
|
|
2304
2367
|
}
|
|
2305
2368
|
});
|
|
2306
|
-
const applyDiscountMutation = (0,
|
|
2369
|
+
const applyDiscountMutation = (0, import_react_query12.useMutation)({
|
|
2307
2370
|
mutationFn: (code) => unwrap(client.cart.applyDiscount(code)),
|
|
2308
2371
|
onSuccess: (result) => {
|
|
2309
2372
|
queryClient.setQueryData([...CART_KEY], result);
|
|
2310
2373
|
}
|
|
2311
2374
|
});
|
|
2312
|
-
const removeDiscountMutation = (0,
|
|
2375
|
+
const removeDiscountMutation = (0, import_react_query12.useMutation)({
|
|
2313
2376
|
mutationFn: () => unwrap(client.cart.removeDiscount()),
|
|
2314
2377
|
onSuccess: (result) => {
|
|
2315
2378
|
queryClient.setQueryData([...CART_KEY], result);
|
|
2316
2379
|
}
|
|
2317
2380
|
});
|
|
2318
|
-
const mergeMutation = (0,
|
|
2381
|
+
const mergeMutation = (0, import_react_query12.useMutation)({
|
|
2319
2382
|
mutationFn: () => unwrap(client.cart.merge()),
|
|
2320
2383
|
onSuccess: (result) => {
|
|
2321
2384
|
queryClient.setQueryData([...CART_KEY], result);
|
|
@@ -2374,13 +2437,13 @@ function useCart(options) {
|
|
|
2374
2437
|
}
|
|
2375
2438
|
|
|
2376
2439
|
// src/react/hooks/use-cart-count.ts
|
|
2377
|
-
var
|
|
2440
|
+
var import_react_query13 = require("@tanstack/react-query");
|
|
2378
2441
|
var CART_KEY2 = ["behio", "cart"];
|
|
2379
2442
|
function useCartCount(options) {
|
|
2380
2443
|
const { client } = useBehio();
|
|
2381
|
-
const queryClient = (0,
|
|
2444
|
+
const queryClient = (0, import_react_query13.useQueryClient)();
|
|
2382
2445
|
const cachedCart = queryClient.getQueryData([...CART_KEY2]);
|
|
2383
|
-
const { data } = (0,
|
|
2446
|
+
const { data } = (0, import_react_query13.useQuery)({
|
|
2384
2447
|
queryKey: [...CART_KEY2],
|
|
2385
2448
|
queryFn: () => unwrap(client.cart.get()),
|
|
2386
2449
|
enabled: options?.enabled !== false && !cachedCart && (!!client.getCartSession() || !!client.getAccessToken())
|
|
@@ -2391,17 +2454,17 @@ function useCartCount(options) {
|
|
|
2391
2454
|
|
|
2392
2455
|
// src/react/hooks/use-auth.ts
|
|
2393
2456
|
var import_react6 = require("react");
|
|
2394
|
-
var
|
|
2457
|
+
var import_react_query14 = require("@tanstack/react-query");
|
|
2395
2458
|
var CUSTOMER_KEY = ["behio", "customer"];
|
|
2396
2459
|
var CART_KEY3 = ["behio", "cart"];
|
|
2397
2460
|
function useAuth() {
|
|
2398
2461
|
const { client, storage } = useBehio();
|
|
2399
|
-
const queryClient = (0,
|
|
2462
|
+
const queryClient = (0, import_react_query14.useQueryClient)();
|
|
2400
2463
|
const isLoggedIn = !!client.getAccessToken();
|
|
2401
2464
|
const {
|
|
2402
2465
|
data: customer,
|
|
2403
2466
|
isLoading
|
|
2404
|
-
} = (0,
|
|
2467
|
+
} = (0, import_react_query14.useQuery)({
|
|
2405
2468
|
queryKey: [...CUSTOMER_KEY],
|
|
2406
2469
|
queryFn: () => unwrap(client.customer.getProfile()),
|
|
2407
2470
|
enabled: isLoggedIn
|
|
@@ -2434,7 +2497,7 @@ function useAuth() {
|
|
|
2434
2497
|
}
|
|
2435
2498
|
queryClient.invalidateQueries({ queryKey: [...CART_KEY3] });
|
|
2436
2499
|
}, [client, storage, queryClient]);
|
|
2437
|
-
const loginMutation = (0,
|
|
2500
|
+
const loginMutation = (0, import_react_query14.useMutation)({
|
|
2438
2501
|
mutationFn: async ({ email, password }) => {
|
|
2439
2502
|
return unwrap(client.auth.login({ email, password }));
|
|
2440
2503
|
},
|
|
@@ -2443,7 +2506,7 @@ function useAuth() {
|
|
|
2443
2506
|
await postAuth();
|
|
2444
2507
|
}
|
|
2445
2508
|
});
|
|
2446
|
-
const registerMutation = (0,
|
|
2509
|
+
const registerMutation = (0, import_react_query14.useMutation)({
|
|
2447
2510
|
mutationFn: async (input) => {
|
|
2448
2511
|
return unwrap(client.auth.register(input));
|
|
2449
2512
|
},
|
|
@@ -2454,19 +2517,19 @@ function useAuth() {
|
|
|
2454
2517
|
}
|
|
2455
2518
|
}
|
|
2456
2519
|
});
|
|
2457
|
-
const logoutMutation = (0,
|
|
2520
|
+
const logoutMutation = (0, import_react_query14.useMutation)({
|
|
2458
2521
|
mutationFn: () => unwrap(client.auth.logout()),
|
|
2459
2522
|
onSettled: () => {
|
|
2460
2523
|
clearAuth();
|
|
2461
2524
|
}
|
|
2462
2525
|
});
|
|
2463
|
-
const forgotPasswordMutation = (0,
|
|
2526
|
+
const forgotPasswordMutation = (0, import_react_query14.useMutation)({
|
|
2464
2527
|
mutationFn: (email) => unwrap(client.auth.forgotPassword(email))
|
|
2465
2528
|
});
|
|
2466
|
-
const resetPasswordMutation = (0,
|
|
2529
|
+
const resetPasswordMutation = (0, import_react_query14.useMutation)({
|
|
2467
2530
|
mutationFn: ({ token, newPassword }) => unwrap(client.auth.resetPassword(token, newPassword))
|
|
2468
2531
|
});
|
|
2469
|
-
const verifyEmailMutation = (0,
|
|
2532
|
+
const verifyEmailMutation = (0, import_react_query14.useMutation)({
|
|
2470
2533
|
mutationFn: (token) => unwrap(client.auth.verifyEmail(token))
|
|
2471
2534
|
});
|
|
2472
2535
|
const login = (0, import_react6.useCallback)(
|
|
@@ -2514,21 +2577,21 @@ function useAuth() {
|
|
|
2514
2577
|
|
|
2515
2578
|
// src/react/hooks/use-customer.ts
|
|
2516
2579
|
var import_react7 = require("react");
|
|
2517
|
-
var
|
|
2580
|
+
var import_react_query15 = require("@tanstack/react-query");
|
|
2518
2581
|
var CUSTOMER_KEY2 = ["behio", "customer"];
|
|
2519
2582
|
function useCustomer(options) {
|
|
2520
2583
|
const { client } = useBehio();
|
|
2521
|
-
const queryClient = (0,
|
|
2584
|
+
const queryClient = (0, import_react_query15.useQueryClient)();
|
|
2522
2585
|
const {
|
|
2523
2586
|
data,
|
|
2524
2587
|
isLoading,
|
|
2525
2588
|
error
|
|
2526
|
-
} = (0,
|
|
2589
|
+
} = (0, import_react_query15.useQuery)({
|
|
2527
2590
|
queryKey: [...CUSTOMER_KEY2],
|
|
2528
2591
|
queryFn: () => unwrap(client.customer.getProfile()),
|
|
2529
2592
|
enabled: options?.enabled !== false && !!client.getAccessToken()
|
|
2530
2593
|
});
|
|
2531
|
-
const updateMutation = (0,
|
|
2594
|
+
const updateMutation = (0, import_react_query15.useMutation)({
|
|
2532
2595
|
mutationFn: (data2) => unwrap(client.customer.updateProfile(data2)),
|
|
2533
2596
|
onSuccess: (updated) => {
|
|
2534
2597
|
queryClient.setQueryData([...CUSTOMER_KEY2], updated);
|
|
@@ -2549,16 +2612,16 @@ function useCustomer(options) {
|
|
|
2549
2612
|
|
|
2550
2613
|
// src/react/hooks/use-addresses.ts
|
|
2551
2614
|
var import_react8 = require("react");
|
|
2552
|
-
var
|
|
2615
|
+
var import_react_query16 = require("@tanstack/react-query");
|
|
2553
2616
|
var ADDRESSES_KEY = ["behio", "addresses"];
|
|
2554
2617
|
function useAddresses(options) {
|
|
2555
2618
|
const { client } = useBehio();
|
|
2556
|
-
const queryClient = (0,
|
|
2619
|
+
const queryClient = (0, import_react_query16.useQueryClient)();
|
|
2557
2620
|
const {
|
|
2558
2621
|
data,
|
|
2559
2622
|
isLoading,
|
|
2560
2623
|
error
|
|
2561
|
-
} = (0,
|
|
2624
|
+
} = (0, import_react_query16.useQuery)({
|
|
2562
2625
|
queryKey: [...ADDRESSES_KEY],
|
|
2563
2626
|
queryFn: async () => {
|
|
2564
2627
|
const result = await unwrap(client.customer.getAddresses());
|
|
@@ -2566,19 +2629,19 @@ function useAddresses(options) {
|
|
|
2566
2629
|
},
|
|
2567
2630
|
enabled: options?.enabled !== false && !!client.getAccessToken()
|
|
2568
2631
|
});
|
|
2569
|
-
const createMutation = (0,
|
|
2632
|
+
const createMutation = (0, import_react_query16.useMutation)({
|
|
2570
2633
|
mutationFn: (address) => unwrap(client.customer.createAddress(address)),
|
|
2571
2634
|
onSuccess: () => {
|
|
2572
2635
|
queryClient.invalidateQueries({ queryKey: [...ADDRESSES_KEY] });
|
|
2573
2636
|
}
|
|
2574
2637
|
});
|
|
2575
|
-
const updateMutation = (0,
|
|
2638
|
+
const updateMutation = (0, import_react_query16.useMutation)({
|
|
2576
2639
|
mutationFn: ({ addressId, data: data2 }) => unwrap(client.customer.updateAddress(addressId, data2)),
|
|
2577
2640
|
onSuccess: () => {
|
|
2578
2641
|
queryClient.invalidateQueries({ queryKey: [...ADDRESSES_KEY] });
|
|
2579
2642
|
}
|
|
2580
2643
|
});
|
|
2581
|
-
const deleteMutation = (0,
|
|
2644
|
+
const deleteMutation = (0, import_react_query16.useMutation)({
|
|
2582
2645
|
mutationFn: (addressId) => unwrap(client.customer.deleteAddress(addressId)),
|
|
2583
2646
|
onSuccess: () => {
|
|
2584
2647
|
queryClient.invalidateQueries({ queryKey: [...ADDRESSES_KEY] });
|
|
@@ -2610,7 +2673,7 @@ function useAddresses(options) {
|
|
|
2610
2673
|
|
|
2611
2674
|
// src/react/hooks/use-address-autocomplete.ts
|
|
2612
2675
|
var import_react9 = require("react");
|
|
2613
|
-
var
|
|
2676
|
+
var import_react_query17 = require("@tanstack/react-query");
|
|
2614
2677
|
var AC_KEY = ["behio", "address-autocomplete"];
|
|
2615
2678
|
function useAddressAutocomplete(options) {
|
|
2616
2679
|
const { country, debounce = 300, minChars = 3, enabled = true } = options;
|
|
@@ -2633,7 +2696,7 @@ function useAddressAutocomplete(options) {
|
|
|
2633
2696
|
if (timerRef.current) clearTimeout(timerRef.current);
|
|
2634
2697
|
};
|
|
2635
2698
|
}, [query, debounce, minChars]);
|
|
2636
|
-
const { data, isLoading } = (0,
|
|
2699
|
+
const { data, isLoading } = (0, import_react_query17.useQuery)({
|
|
2637
2700
|
queryKey: [...AC_KEY, debouncedQuery, country],
|
|
2638
2701
|
queryFn: () => unwrap(client.addresses.autocomplete(debouncedQuery, country)),
|
|
2639
2702
|
enabled: enabled && debouncedQuery.length >= minChars,
|
|
@@ -2673,11 +2736,11 @@ function useAddressAutocomplete(options) {
|
|
|
2673
2736
|
}
|
|
2674
2737
|
|
|
2675
2738
|
// src/react/hooks/use-loyalty.ts
|
|
2676
|
-
var
|
|
2739
|
+
var import_react_query18 = require("@tanstack/react-query");
|
|
2677
2740
|
var LOYALTY_KEY = ["behio", "loyalty"];
|
|
2678
2741
|
function useLoyalty(options) {
|
|
2679
2742
|
const { client } = useBehio();
|
|
2680
|
-
const { data, isLoading, error, refetch } = (0,
|
|
2743
|
+
const { data, isLoading, error, refetch } = (0, import_react_query18.useQuery)({
|
|
2681
2744
|
queryKey: [...LOYALTY_KEY],
|
|
2682
2745
|
queryFn: () => unwrap(client.customer.getLoyalty()),
|
|
2683
2746
|
enabled: options?.enabled !== false && !!client.getAccessToken()
|
|
@@ -2686,11 +2749,11 @@ function useLoyalty(options) {
|
|
|
2686
2749
|
}
|
|
2687
2750
|
|
|
2688
2751
|
// src/react/hooks/use-courses.ts
|
|
2689
|
-
var
|
|
2752
|
+
var import_react_query19 = require("@tanstack/react-query");
|
|
2690
2753
|
var COURSES_KEY = ["behio", "courses"];
|
|
2691
2754
|
function useCourses(options) {
|
|
2692
2755
|
const { client } = useBehio();
|
|
2693
|
-
const { data, isLoading, error, refetch } = (0,
|
|
2756
|
+
const { data, isLoading, error, refetch } = (0, import_react_query19.useQuery)({
|
|
2694
2757
|
queryKey: [...COURSES_KEY],
|
|
2695
2758
|
queryFn: () => unwrap(client.customer.getCourses()),
|
|
2696
2759
|
enabled: options?.enabled !== false && !!client.getAccessToken()
|
|
@@ -2699,13 +2762,13 @@ function useCourses(options) {
|
|
|
2699
2762
|
}
|
|
2700
2763
|
function useCourse(courseId, options) {
|
|
2701
2764
|
const { client } = useBehio();
|
|
2702
|
-
const queryClient = (0,
|
|
2703
|
-
const { data, isLoading, error, refetch } = (0,
|
|
2765
|
+
const queryClient = (0, import_react_query19.useQueryClient)();
|
|
2766
|
+
const { data, isLoading, error, refetch } = (0, import_react_query19.useQuery)({
|
|
2704
2767
|
queryKey: [...COURSES_KEY, courseId],
|
|
2705
2768
|
queryFn: () => unwrap(client.customer.getCourse(courseId)),
|
|
2706
2769
|
enabled: options?.enabled !== false && !!courseId && !!client.getAccessToken()
|
|
2707
2770
|
});
|
|
2708
|
-
const complete = (0,
|
|
2771
|
+
const complete = (0, import_react_query19.useMutation)({
|
|
2709
2772
|
mutationFn: ({ lessonId }) => unwrap(client.customer.completeLesson(courseId, lessonId)),
|
|
2710
2773
|
onSuccess: () => {
|
|
2711
2774
|
void queryClient.invalidateQueries({ queryKey: [...COURSES_KEY] });
|
|
@@ -2722,15 +2785,15 @@ function useCourse(courseId, options) {
|
|
|
2722
2785
|
}
|
|
2723
2786
|
function useLessonQuiz(courseId, lessonId, options) {
|
|
2724
2787
|
const { client } = useBehio();
|
|
2725
|
-
const queryClient = (0,
|
|
2726
|
-
const { data, isLoading, error, refetch } = (0,
|
|
2788
|
+
const queryClient = (0, import_react_query19.useQueryClient)();
|
|
2789
|
+
const { data, isLoading, error, refetch } = (0, import_react_query19.useQuery)({
|
|
2727
2790
|
queryKey: [...COURSES_KEY, courseId, "quiz", lessonId],
|
|
2728
2791
|
queryFn: () => unwrap(
|
|
2729
2792
|
client.customer.getLessonQuiz(courseId, lessonId)
|
|
2730
2793
|
),
|
|
2731
2794
|
enabled: options?.enabled !== false && !!courseId && !!lessonId && !!client.getAccessToken()
|
|
2732
2795
|
});
|
|
2733
|
-
const submit = (0,
|
|
2796
|
+
const submit = (0, import_react_query19.useMutation)(
|
|
2734
2797
|
{
|
|
2735
2798
|
mutationFn: ({ answers }) => unwrap(
|
|
2736
2799
|
client.customer.submitLessonQuiz(
|
|
@@ -2758,7 +2821,7 @@ function useLessonQuiz(courseId, lessonId, options) {
|
|
|
2758
2821
|
}
|
|
2759
2822
|
function useCourseCertificates(options) {
|
|
2760
2823
|
const { client } = useBehio();
|
|
2761
|
-
const { data, isLoading, error, refetch } = (0,
|
|
2824
|
+
const { data, isLoading, error, refetch } = (0, import_react_query19.useQuery)({
|
|
2762
2825
|
queryKey: [...COURSES_KEY, "certificates"],
|
|
2763
2826
|
queryFn: () => unwrap(client.customer.getCourseCertificates()),
|
|
2764
2827
|
enabled: options?.enabled !== false && !!client.getAccessToken()
|
|
@@ -2767,7 +2830,7 @@ function useCourseCertificates(options) {
|
|
|
2767
2830
|
}
|
|
2768
2831
|
function useCertificateVerification(code, options) {
|
|
2769
2832
|
const { client } = useBehio();
|
|
2770
|
-
const { data, isLoading, error, refetch } = (0,
|
|
2833
|
+
const { data, isLoading, error, refetch } = (0, import_react_query19.useQuery)(
|
|
2771
2834
|
{
|
|
2772
2835
|
queryKey: ["behio", "certificate-verification", code],
|
|
2773
2836
|
queryFn: () => unwrap(client.certificates.verify(code)),
|
|
@@ -2779,12 +2842,12 @@ function useCertificateVerification(code, options) {
|
|
|
2779
2842
|
}
|
|
2780
2843
|
|
|
2781
2844
|
// src/react/hooks/use-lesson-tutor.ts
|
|
2782
|
-
var
|
|
2845
|
+
var import_react_query20 = require("@tanstack/react-query");
|
|
2783
2846
|
var TUTOR_KEY = ["behio", "course-tutor"];
|
|
2784
2847
|
function useLessonTutor(courseId, lessonId, options) {
|
|
2785
2848
|
const { client } = useBehio();
|
|
2786
|
-
const queryClient = (0,
|
|
2787
|
-
const { data, isLoading, error, refetch } = (0,
|
|
2849
|
+
const queryClient = (0, import_react_query20.useQueryClient)();
|
|
2850
|
+
const { data, isLoading, error, refetch } = (0, import_react_query20.useQuery)({
|
|
2788
2851
|
queryKey: [...TUTOR_KEY, courseId, lessonId],
|
|
2789
2852
|
queryFn: () => unwrap(
|
|
2790
2853
|
client.customer.getLessonTutorThread(
|
|
@@ -2794,7 +2857,7 @@ function useLessonTutor(courseId, lessonId, options) {
|
|
|
2794
2857
|
),
|
|
2795
2858
|
enabled: options?.enabled !== false && !!courseId && !!lessonId && !!client.getAccessToken()
|
|
2796
2859
|
});
|
|
2797
|
-
const ask = (0,
|
|
2860
|
+
const ask = (0, import_react_query20.useMutation)({
|
|
2798
2861
|
mutationFn: ({ question }) => unwrap(
|
|
2799
2862
|
client.customer.askLessonTutor(
|
|
2800
2863
|
courseId,
|
|
@@ -2823,13 +2886,13 @@ function useLessonTutor(courseId, lessonId, options) {
|
|
|
2823
2886
|
}
|
|
2824
2887
|
|
|
2825
2888
|
// src/react/hooks/use-lesson-comments.ts
|
|
2826
|
-
var
|
|
2889
|
+
var import_react_query21 = require("@tanstack/react-query");
|
|
2827
2890
|
var COMMENTS_KEY = ["behio", "course-comments"];
|
|
2828
2891
|
function useLessonComments(courseId, lessonId, options) {
|
|
2829
2892
|
const { client } = useBehio();
|
|
2830
|
-
const queryClient = (0,
|
|
2893
|
+
const queryClient = (0, import_react_query21.useQueryClient)();
|
|
2831
2894
|
const page = options?.page ?? 1;
|
|
2832
|
-
const { data, isLoading, error, refetch } = (0,
|
|
2895
|
+
const { data, isLoading, error, refetch } = (0, import_react_query21.useQuery)({
|
|
2833
2896
|
queryKey: [...COMMENTS_KEY, courseId, lessonId, page],
|
|
2834
2897
|
queryFn: () => unwrap(
|
|
2835
2898
|
client.customer.getLessonComments(
|
|
@@ -2843,7 +2906,7 @@ function useLessonComments(courseId, lessonId, options) {
|
|
|
2843
2906
|
const invalidate = () => queryClient.invalidateQueries({
|
|
2844
2907
|
queryKey: [...COMMENTS_KEY, courseId, lessonId]
|
|
2845
2908
|
});
|
|
2846
|
-
const post = (0,
|
|
2909
|
+
const post = (0, import_react_query21.useMutation)({
|
|
2847
2910
|
mutationFn: ({ body, parentId }) => unwrap(
|
|
2848
2911
|
client.customer.postLessonComment(
|
|
2849
2912
|
courseId,
|
|
@@ -2856,7 +2919,7 @@ function useLessonComments(courseId, lessonId, options) {
|
|
|
2856
2919
|
void invalidate();
|
|
2857
2920
|
}
|
|
2858
2921
|
});
|
|
2859
|
-
const remove = (0,
|
|
2922
|
+
const remove = (0, import_react_query21.useMutation)({
|
|
2860
2923
|
mutationFn: ({ commentId }) => unwrap(
|
|
2861
2924
|
client.customer.deleteLessonComment(
|
|
2862
2925
|
courseId,
|
|
@@ -2886,19 +2949,19 @@ function useLessonComments(courseId, lessonId, options) {
|
|
|
2886
2949
|
}
|
|
2887
2950
|
|
|
2888
2951
|
// src/react/hooks/use-lesson-note.ts
|
|
2889
|
-
var
|
|
2952
|
+
var import_react_query22 = require("@tanstack/react-query");
|
|
2890
2953
|
var NOTE_KEY = ["behio", "course-note"];
|
|
2891
2954
|
function useLessonNote(courseId, lessonId, options) {
|
|
2892
2955
|
const { client } = useBehio();
|
|
2893
|
-
const queryClient = (0,
|
|
2894
|
-
const { data, isLoading, error, refetch } = (0,
|
|
2956
|
+
const queryClient = (0, import_react_query22.useQueryClient)();
|
|
2957
|
+
const { data, isLoading, error, refetch } = (0, import_react_query22.useQuery)({
|
|
2895
2958
|
queryKey: [...NOTE_KEY, courseId, lessonId],
|
|
2896
2959
|
queryFn: () => unwrap(
|
|
2897
2960
|
client.customer.getLessonNote(courseId, lessonId)
|
|
2898
2961
|
),
|
|
2899
2962
|
enabled: options?.enabled !== false && !!courseId && !!lessonId && !!client.getAccessToken()
|
|
2900
2963
|
});
|
|
2901
|
-
const save = (0,
|
|
2964
|
+
const save = (0, import_react_query22.useMutation)({
|
|
2902
2965
|
mutationFn: ({ body }) => unwrap(
|
|
2903
2966
|
client.customer.saveLessonNote(
|
|
2904
2967
|
courseId,
|
|
@@ -2927,26 +2990,26 @@ function useLessonNote(courseId, lessonId, options) {
|
|
|
2927
2990
|
}
|
|
2928
2991
|
|
|
2929
2992
|
// src/react/hooks/use-subscriptions.ts
|
|
2930
|
-
var
|
|
2993
|
+
var import_react_query23 = require("@tanstack/react-query");
|
|
2931
2994
|
var SUBSCRIPTIONS_KEY = ["behio", "subscriptions"];
|
|
2932
2995
|
function useSubscriptions(options) {
|
|
2933
2996
|
const { client } = useBehio();
|
|
2934
|
-
const qc = (0,
|
|
2935
|
-
const query = (0,
|
|
2997
|
+
const qc = (0, import_react_query23.useQueryClient)();
|
|
2998
|
+
const query = (0, import_react_query23.useQuery)({
|
|
2936
2999
|
queryKey: [...SUBSCRIPTIONS_KEY],
|
|
2937
3000
|
queryFn: () => unwrap(client.subscriptions.list()),
|
|
2938
3001
|
enabled: options?.enabled !== false && !!client.getAccessToken()
|
|
2939
3002
|
});
|
|
2940
3003
|
const invalidate = () => qc.invalidateQueries({ queryKey: [...SUBSCRIPTIONS_KEY] });
|
|
2941
|
-
const pauseMutation = (0,
|
|
3004
|
+
const pauseMutation = (0, import_react_query23.useMutation)({
|
|
2942
3005
|
mutationFn: (subscriptionId) => unwrap(client.subscriptions.pause(subscriptionId)),
|
|
2943
3006
|
onSuccess: invalidate
|
|
2944
3007
|
});
|
|
2945
|
-
const resumeMutation = (0,
|
|
3008
|
+
const resumeMutation = (0, import_react_query23.useMutation)({
|
|
2946
3009
|
mutationFn: (subscriptionId) => unwrap(client.subscriptions.resume(subscriptionId)),
|
|
2947
3010
|
onSuccess: invalidate
|
|
2948
3011
|
});
|
|
2949
|
-
const cancelMutation = (0,
|
|
3012
|
+
const cancelMutation = (0, import_react_query23.useMutation)({
|
|
2950
3013
|
mutationFn: (subscriptionId) => unwrap(client.subscriptions.cancel(subscriptionId)),
|
|
2951
3014
|
onSuccess: invalidate
|
|
2952
3015
|
});
|
|
@@ -2965,11 +3028,11 @@ function useSubscriptions(options) {
|
|
|
2965
3028
|
}
|
|
2966
3029
|
|
|
2967
3030
|
// src/react/hooks/use-pickup-points.ts
|
|
2968
|
-
var
|
|
3031
|
+
var import_react_query24 = require("@tanstack/react-query");
|
|
2969
3032
|
function usePickupPoints(input) {
|
|
2970
3033
|
const { client } = useBehio();
|
|
2971
3034
|
const { methodId, query, country, limit, enabled } = input;
|
|
2972
|
-
const { data, isLoading, error, refetch } = (0,
|
|
3035
|
+
const { data, isLoading, error, refetch } = (0, import_react_query24.useQuery)({
|
|
2973
3036
|
queryKey: ["behio", "pickup-points", methodId, query ?? "", country ?? "", limit ?? 30],
|
|
2974
3037
|
queryFn: () => unwrap(
|
|
2975
3038
|
client.shipping.getPickupPoints({
|
|
@@ -2985,12 +3048,12 @@ function usePickupPoints(input) {
|
|
|
2985
3048
|
}
|
|
2986
3049
|
|
|
2987
3050
|
// src/react/hooks/use-shipping-methods.ts
|
|
2988
|
-
var
|
|
3051
|
+
var import_react_query25 = require("@tanstack/react-query");
|
|
2989
3052
|
function useShippingMethods(options) {
|
|
2990
3053
|
const { client, currency: activeCurrency } = useBehio();
|
|
2991
3054
|
const currency = options?.currency ?? activeCurrency;
|
|
2992
3055
|
const { country, cartTotal, cartWeightKg } = options ?? {};
|
|
2993
|
-
const { data, isLoading, error, refetch } = (0,
|
|
3056
|
+
const { data, isLoading, error, refetch } = (0, import_react_query25.useQuery)({
|
|
2994
3057
|
queryKey: [
|
|
2995
3058
|
"behio",
|
|
2996
3059
|
"shipping-methods",
|
|
@@ -3006,12 +3069,12 @@ function useShippingMethods(options) {
|
|
|
3006
3069
|
}
|
|
3007
3070
|
|
|
3008
3071
|
// src/react/hooks/use-shipping-quote.ts
|
|
3009
|
-
var
|
|
3072
|
+
var import_react_query26 = require("@tanstack/react-query");
|
|
3010
3073
|
function useShippingQuote(options) {
|
|
3011
3074
|
const { client, currency: activeCurrency } = useBehio();
|
|
3012
3075
|
const { destinationAddress, items, cartTotal, enabled } = options ?? {};
|
|
3013
3076
|
const currency = options?.currency ?? activeCurrency;
|
|
3014
|
-
const { data, isLoading, error, refetch } = (0,
|
|
3077
|
+
const { data, isLoading, error, refetch } = (0, import_react_query26.useQuery)({
|
|
3015
3078
|
queryKey: [
|
|
3016
3079
|
"behio",
|
|
3017
3080
|
"shipping-quote",
|
|
@@ -3034,11 +3097,11 @@ function useShippingQuote(options) {
|
|
|
3034
3097
|
}
|
|
3035
3098
|
|
|
3036
3099
|
// src/react/hooks/use-payment-methods.ts
|
|
3037
|
-
var
|
|
3100
|
+
var import_react_query27 = require("@tanstack/react-query");
|
|
3038
3101
|
function usePaymentMethods(options) {
|
|
3039
3102
|
const { client, currency: activeCurrency } = useBehio();
|
|
3040
3103
|
const currency = options?.currency ?? activeCurrency;
|
|
3041
|
-
const { data, isLoading, error, refetch } = (0,
|
|
3104
|
+
const { data, isLoading, error, refetch } = (0, import_react_query27.useQuery)({
|
|
3042
3105
|
queryKey: ["behio", "payment-methods", currency ?? ""],
|
|
3043
3106
|
queryFn: () => unwrap(client.catalog.listPaymentMethods({ currency })),
|
|
3044
3107
|
enabled: options?.enabled !== false
|
|
@@ -3048,10 +3111,10 @@ function usePaymentMethods(options) {
|
|
|
3048
3111
|
|
|
3049
3112
|
// src/react/hooks/use-personal-offers.ts
|
|
3050
3113
|
var import_react10 = require("react");
|
|
3051
|
-
var
|
|
3114
|
+
var import_react_query28 = require("@tanstack/react-query");
|
|
3052
3115
|
function usePersonalOffers(options) {
|
|
3053
3116
|
const { client } = useBehio();
|
|
3054
|
-
const queryClient = (0,
|
|
3117
|
+
const queryClient = (0, import_react_query28.useQueryClient)();
|
|
3055
3118
|
const [polledVid, setPolledVid] = (0, import_react10.useState)(null);
|
|
3056
3119
|
const explicitVid = options?.visitorId;
|
|
3057
3120
|
(0, import_react10.useEffect)(() => {
|
|
@@ -3069,12 +3132,12 @@ function usePersonalOffers(options) {
|
|
|
3069
3132
|
}, [client, explicitVid]);
|
|
3070
3133
|
const visitorId = explicitVid ?? polledVid;
|
|
3071
3134
|
const queryKey = ["behio", "personal-offers", visitorId ?? ""];
|
|
3072
|
-
const { data, isLoading, error, refetch } = (0,
|
|
3135
|
+
const { data, isLoading, error, refetch } = (0, import_react_query28.useQuery)({
|
|
3073
3136
|
queryKey,
|
|
3074
3137
|
queryFn: () => unwrap(client.getPersonalOffers(visitorId)),
|
|
3075
3138
|
enabled: options?.enabled !== false && !!visitorId
|
|
3076
3139
|
});
|
|
3077
|
-
const claimMutation = (0,
|
|
3140
|
+
const claimMutation = (0, import_react_query28.useMutation)({
|
|
3078
3141
|
mutationFn: ({ offerId, email }) => unwrap(client.claimOfferByEmail(offerId, { visitorId, email })),
|
|
3079
3142
|
onSuccess: (result, { offerId }) => {
|
|
3080
3143
|
queryClient.setQueryData(
|
|
@@ -3136,28 +3199,28 @@ function useAnalyticsEvents() {
|
|
|
3136
3199
|
}
|
|
3137
3200
|
|
|
3138
3201
|
// src/react/hooks/use-newsletter.ts
|
|
3139
|
-
var
|
|
3202
|
+
var import_react_query29 = require("@tanstack/react-query");
|
|
3140
3203
|
function useNewsletterSubscribe() {
|
|
3141
3204
|
const { client } = useBehio();
|
|
3142
|
-
return (0,
|
|
3205
|
+
return (0, import_react_query29.useMutation)({
|
|
3143
3206
|
mutationFn: (input) => unwrap(client.newsletter.subscribe(input))
|
|
3144
3207
|
});
|
|
3145
3208
|
}
|
|
3146
3209
|
function useNewsletterUnsubscribe() {
|
|
3147
3210
|
const { client } = useBehio();
|
|
3148
|
-
return (0,
|
|
3211
|
+
return (0, import_react_query29.useMutation)({
|
|
3149
3212
|
mutationFn: (email) => unwrap(client.newsletter.unsubscribe(email))
|
|
3150
3213
|
});
|
|
3151
3214
|
}
|
|
3152
3215
|
|
|
3153
3216
|
// src/react/hooks/use-orders.ts
|
|
3154
3217
|
var import_react12 = require("react");
|
|
3155
|
-
var
|
|
3218
|
+
var import_react_query30 = require("@tanstack/react-query");
|
|
3156
3219
|
function useOrders(options) {
|
|
3157
3220
|
const { client } = useBehio();
|
|
3158
3221
|
const { page: initialPage, limit, enabled } = options ?? {};
|
|
3159
3222
|
const [page, setPage] = (0, import_react12.useState)(initialPage ?? 1);
|
|
3160
|
-
const infinite = (0,
|
|
3223
|
+
const infinite = (0, import_react_query30.useInfiniteQuery)({
|
|
3161
3224
|
queryKey: ["behio", "orders", limit, page],
|
|
3162
3225
|
queryFn: ({ pageParam }) => unwrap(client.orders.list({ limit, page: pageParam })),
|
|
3163
3226
|
initialPageParam: page,
|
|
@@ -3203,20 +3266,20 @@ function useOrders(options) {
|
|
|
3203
3266
|
|
|
3204
3267
|
// src/react/hooks/use-order.ts
|
|
3205
3268
|
var import_react13 = require("react");
|
|
3206
|
-
var
|
|
3269
|
+
var import_react_query31 = require("@tanstack/react-query");
|
|
3207
3270
|
function useOrder(orderNumber, options) {
|
|
3208
3271
|
const { client } = useBehio();
|
|
3209
|
-
const queryClient = (0,
|
|
3272
|
+
const queryClient = (0, import_react_query31.useQueryClient)();
|
|
3210
3273
|
const {
|
|
3211
3274
|
data,
|
|
3212
3275
|
isLoading,
|
|
3213
3276
|
error
|
|
3214
|
-
} = (0,
|
|
3277
|
+
} = (0, import_react_query31.useQuery)({
|
|
3215
3278
|
queryKey: ["behio", "order", orderNumber],
|
|
3216
3279
|
queryFn: () => unwrap(client.orders.get(orderNumber)),
|
|
3217
3280
|
enabled: options?.enabled !== false && !!orderNumber && !!client.getAccessToken()
|
|
3218
3281
|
});
|
|
3219
|
-
const cancelMutation = (0,
|
|
3282
|
+
const cancelMutation = (0, import_react_query31.useMutation)({
|
|
3220
3283
|
mutationFn: () => unwrap(client.orders.cancel(orderNumber)),
|
|
3221
3284
|
onSuccess: (updated) => {
|
|
3222
3285
|
queryClient.setQueryData(["behio", "order", orderNumber], updated);
|
|
@@ -3238,21 +3301,21 @@ function useOrder(orderNumber, options) {
|
|
|
3238
3301
|
|
|
3239
3302
|
// src/react/hooks/use-order-access.ts
|
|
3240
3303
|
var import_react14 = require("react");
|
|
3241
|
-
var
|
|
3304
|
+
var import_react_query32 = require("@tanstack/react-query");
|
|
3242
3305
|
function useOrderAccess() {
|
|
3243
3306
|
const { client } = useBehio();
|
|
3244
3307
|
const [orderNumber, setOrderNumber] = (0, import_react14.useState)(null);
|
|
3245
3308
|
const [email, setEmail] = (0, import_react14.useState)(null);
|
|
3246
3309
|
const [order, setOrder] = (0, import_react14.useState)(null);
|
|
3247
3310
|
const [accessToken, setAccessToken] = (0, import_react14.useState)(null);
|
|
3248
|
-
const requestMutation = (0,
|
|
3311
|
+
const requestMutation = (0, import_react_query32.useMutation)({
|
|
3249
3312
|
mutationFn: (input) => unwrap(client.orders.requestAccessCode(input.orderNumber, input.email)),
|
|
3250
3313
|
onSuccess: (_data, input) => {
|
|
3251
3314
|
setOrderNumber(input.orderNumber);
|
|
3252
3315
|
setEmail(input.email);
|
|
3253
3316
|
}
|
|
3254
3317
|
});
|
|
3255
|
-
const verifyMutation = (0,
|
|
3318
|
+
const verifyMutation = (0, import_react_query32.useMutation)({
|
|
3256
3319
|
mutationFn: (code) => {
|
|
3257
3320
|
if (!orderNumber || !email) {
|
|
3258
3321
|
throw new Error("Request a code before verifying");
|
|
@@ -3298,12 +3361,12 @@ function useOrderAccess() {
|
|
|
3298
3361
|
|
|
3299
3362
|
// src/react/hooks/use-checkout.ts
|
|
3300
3363
|
var import_react15 = require("react");
|
|
3301
|
-
var
|
|
3364
|
+
var import_react_query33 = require("@tanstack/react-query");
|
|
3302
3365
|
function useCheckout() {
|
|
3303
3366
|
const { client, storage } = useBehio();
|
|
3304
|
-
const queryClient = (0,
|
|
3367
|
+
const queryClient = (0, import_react_query33.useQueryClient)();
|
|
3305
3368
|
const [order, setOrder] = (0, import_react15.useState)(null);
|
|
3306
|
-
const mutation = (0,
|
|
3369
|
+
const mutation = (0, import_react_query33.useMutation)({
|
|
3307
3370
|
mutationFn: (input) => unwrap(client.checkout.createOrder(input)),
|
|
3308
3371
|
onSuccess: (result) => {
|
|
3309
3372
|
setOrder(result);
|
|
@@ -3330,10 +3393,10 @@ function useCheckout() {
|
|
|
3330
3393
|
}
|
|
3331
3394
|
|
|
3332
3395
|
// src/react/hooks/use-pages.ts
|
|
3333
|
-
var
|
|
3396
|
+
var import_react_query34 = require("@tanstack/react-query");
|
|
3334
3397
|
function usePages(locale, options) {
|
|
3335
3398
|
const { client } = useBehio();
|
|
3336
|
-
return (0,
|
|
3399
|
+
return (0, import_react_query34.useQuery)({
|
|
3337
3400
|
queryKey: ["behio", "pages", locale],
|
|
3338
3401
|
queryFn: async () => {
|
|
3339
3402
|
const result = await unwrap(client.pages.list(locale));
|
|
@@ -3344,7 +3407,7 @@ function usePages(locale, options) {
|
|
|
3344
3407
|
}
|
|
3345
3408
|
function usePage(slug, locale, options) {
|
|
3346
3409
|
const { client } = useBehio();
|
|
3347
|
-
return (0,
|
|
3410
|
+
return (0, import_react_query34.useQuery)({
|
|
3348
3411
|
queryKey: ["behio", "page", slug, locale],
|
|
3349
3412
|
queryFn: () => unwrap(client.pages.get(slug, locale)),
|
|
3350
3413
|
enabled: options?.enabled !== false && !!slug
|
|
@@ -3352,10 +3415,10 @@ function usePage(slug, locale, options) {
|
|
|
3352
3415
|
}
|
|
3353
3416
|
|
|
3354
3417
|
// src/react/hooks/use-shop-info.ts
|
|
3355
|
-
var
|
|
3418
|
+
var import_react_query35 = require("@tanstack/react-query");
|
|
3356
3419
|
function useShopInfo(options) {
|
|
3357
3420
|
const { client } = useBehio();
|
|
3358
|
-
return (0,
|
|
3421
|
+
return (0, import_react_query35.useQuery)({
|
|
3359
3422
|
queryKey: ["behio", "shop-info"],
|
|
3360
3423
|
queryFn: () => unwrap(client.getShopInfo()),
|
|
3361
3424
|
enabled: options?.enabled !== false
|
|
@@ -3363,10 +3426,10 @@ function useShopInfo(options) {
|
|
|
3363
3426
|
}
|
|
3364
3427
|
|
|
3365
3428
|
// src/react/hooks/use-shop-scripts.ts
|
|
3366
|
-
var
|
|
3429
|
+
var import_react_query36 = require("@tanstack/react-query");
|
|
3367
3430
|
function useShopScripts(options) {
|
|
3368
3431
|
const { client } = useBehio();
|
|
3369
|
-
return (0,
|
|
3432
|
+
return (0, import_react_query36.useQuery)({
|
|
3370
3433
|
queryKey: ["behio", "shop-scripts"],
|
|
3371
3434
|
queryFn: () => unwrap(client.getShopScripts()),
|
|
3372
3435
|
enabled: options?.enabled !== false
|
|
@@ -3374,11 +3437,11 @@ function useShopScripts(options) {
|
|
|
3374
3437
|
}
|
|
3375
3438
|
|
|
3376
3439
|
// src/react/hooks/use-shop-seo.ts
|
|
3377
|
-
var
|
|
3440
|
+
var import_react_query37 = require("@tanstack/react-query");
|
|
3378
3441
|
function useShopSeo(options) {
|
|
3379
3442
|
const { client } = useBehio();
|
|
3380
3443
|
const { locale, initialData, enabled = true } = options ?? {};
|
|
3381
|
-
return (0,
|
|
3444
|
+
return (0, import_react_query37.useQuery)({
|
|
3382
3445
|
queryKey: ["behio", "shop-seo", locale ?? "_default"],
|
|
3383
3446
|
queryFn: () => unwrap(client.getShopSeo(locale)),
|
|
3384
3447
|
initialData,
|
|
@@ -3441,20 +3504,20 @@ function CurrencySwitcher({
|
|
|
3441
3504
|
var import_react16 = require("react");
|
|
3442
3505
|
|
|
3443
3506
|
// src/react/hooks/use-consent.ts
|
|
3444
|
-
var
|
|
3507
|
+
var import_react_query38 = require("@tanstack/react-query");
|
|
3445
3508
|
function useCookieConsent(visitorId) {
|
|
3446
3509
|
const { client } = useBehio();
|
|
3447
|
-
const qc = (0,
|
|
3448
|
-
const query = (0,
|
|
3510
|
+
const qc = (0, import_react_query38.useQueryClient)();
|
|
3511
|
+
const query = (0, import_react_query38.useQuery)({
|
|
3449
3512
|
queryKey: ["behio", "consent", visitorId],
|
|
3450
3513
|
queryFn: () => unwrap(client.consent.get(visitorId)),
|
|
3451
3514
|
enabled: Boolean(visitorId)
|
|
3452
3515
|
});
|
|
3453
|
-
const recordMutation = (0,
|
|
3516
|
+
const recordMutation = (0, import_react_query38.useMutation)({
|
|
3454
3517
|
mutationFn: (input) => unwrap(client.consent.record(input)),
|
|
3455
3518
|
onSuccess: () => qc.invalidateQueries({ queryKey: ["behio", "consent"] })
|
|
3456
3519
|
});
|
|
3457
|
-
const revokeMutation = (0,
|
|
3520
|
+
const revokeMutation = (0, import_react_query38.useMutation)({
|
|
3458
3521
|
mutationFn: () => unwrap(client.consent.revoke(visitorId)),
|
|
3459
3522
|
onSuccess: () => qc.invalidateQueries({ queryKey: ["behio", "consent"] })
|
|
3460
3523
|
});
|
|
@@ -3813,10 +3876,10 @@ function utmFromSearch(search) {
|
|
|
3813
3876
|
}
|
|
3814
3877
|
|
|
3815
3878
|
// src/react/hooks/use-bundles.ts
|
|
3816
|
-
var
|
|
3879
|
+
var import_react_query39 = require("@tanstack/react-query");
|
|
3817
3880
|
function useBundles(options) {
|
|
3818
3881
|
const { client } = useBehio();
|
|
3819
|
-
return (0,
|
|
3882
|
+
return (0, import_react_query39.useQuery)({
|
|
3820
3883
|
queryKey: ["behio", "bundles"],
|
|
3821
3884
|
queryFn: () => unwrap(client.catalog.getBundles()),
|
|
3822
3885
|
enabled: options?.enabled ?? true,
|
|
@@ -3825,7 +3888,7 @@ function useBundles(options) {
|
|
|
3825
3888
|
}
|
|
3826
3889
|
function useBundle(slug, options) {
|
|
3827
3890
|
const { client } = useBehio();
|
|
3828
|
-
return (0,
|
|
3891
|
+
return (0, import_react_query39.useQuery)({
|
|
3829
3892
|
queryKey: ["behio", "bundle", slug],
|
|
3830
3893
|
queryFn: () => unwrap(client.catalog.getBundle(slug)),
|
|
3831
3894
|
enabled: Boolean(slug) && (options?.enabled ?? true),
|
|
@@ -3834,10 +3897,10 @@ function useBundle(slug, options) {
|
|
|
3834
3897
|
}
|
|
3835
3898
|
|
|
3836
3899
|
// src/react/hooks/use-product-group.ts
|
|
3837
|
-
var
|
|
3900
|
+
var import_react_query40 = require("@tanstack/react-query");
|
|
3838
3901
|
function useProductGroup(slug, options) {
|
|
3839
3902
|
const { client } = useBehio();
|
|
3840
|
-
return (0,
|
|
3903
|
+
return (0, import_react_query40.useQuery)({
|
|
3841
3904
|
queryKey: ["behio", "product-group", slug, options?.locale, options?.currency],
|
|
3842
3905
|
queryFn: () => unwrap(
|
|
3843
3906
|
client.catalog.getProductGroup(slug, {
|
|
@@ -3851,10 +3914,10 @@ function useProductGroup(slug, options) {
|
|
|
3851
3914
|
}
|
|
3852
3915
|
|
|
3853
3916
|
// src/react/hooks/use-cross-sell.ts
|
|
3854
|
-
var
|
|
3917
|
+
var import_react_query41 = require("@tanstack/react-query");
|
|
3855
3918
|
function useCrossSell(productSlug, options) {
|
|
3856
3919
|
const { client } = useBehio();
|
|
3857
|
-
return (0,
|
|
3920
|
+
return (0, import_react_query41.useQuery)({
|
|
3858
3921
|
queryKey: ["behio", "cross-sell", productSlug, options?.locale, options?.currency],
|
|
3859
3922
|
queryFn: () => unwrap(
|
|
3860
3923
|
client.catalog.getCrossSell(productSlug, {
|
|
@@ -3868,10 +3931,10 @@ function useCrossSell(productSlug, options) {
|
|
|
3868
3931
|
}
|
|
3869
3932
|
|
|
3870
3933
|
// src/react/hooks/use-product-promotions.ts
|
|
3871
|
-
var
|
|
3934
|
+
var import_react_query42 = require("@tanstack/react-query");
|
|
3872
3935
|
function useProductPromotions(productSlug, options) {
|
|
3873
3936
|
const { client } = useBehio();
|
|
3874
|
-
return (0,
|
|
3937
|
+
return (0, import_react_query42.useQuery)({
|
|
3875
3938
|
queryKey: ["behio", "product-promotions", productSlug],
|
|
3876
3939
|
queryFn: () => unwrap(client.catalog.getProductPromotions(productSlug)),
|
|
3877
3940
|
enabled: Boolean(productSlug) && (options?.enabled ?? true),
|
|
@@ -3880,11 +3943,11 @@ function useProductPromotions(productSlug, options) {
|
|
|
3880
3943
|
}
|
|
3881
3944
|
|
|
3882
3945
|
// src/react/hooks/use-gift-card.ts
|
|
3883
|
-
var
|
|
3946
|
+
var import_react_query43 = require("@tanstack/react-query");
|
|
3884
3947
|
function useGiftCardBalance(code, options) {
|
|
3885
3948
|
const { client } = useBehio();
|
|
3886
3949
|
const trimmed = code?.trim();
|
|
3887
|
-
return (0,
|
|
3950
|
+
return (0, import_react_query43.useQuery)({
|
|
3888
3951
|
queryKey: ["behio", "gift-card-balance", trimmed],
|
|
3889
3952
|
queryFn: () => unwrap(client.catalog.checkGiftCard(trimmed)),
|
|
3890
3953
|
enabled: Boolean(trimmed && trimmed.length >= 6) && (options?.enabled ?? true)
|
|
@@ -3892,20 +3955,20 @@ function useGiftCardBalance(code, options) {
|
|
|
3892
3955
|
}
|
|
3893
3956
|
|
|
3894
3957
|
// src/react/hooks/use-wishlist.ts
|
|
3895
|
-
var
|
|
3958
|
+
var import_react_query44 = require("@tanstack/react-query");
|
|
3896
3959
|
function useWishlist(options) {
|
|
3897
3960
|
const { client } = useBehio();
|
|
3898
|
-
const qc = (0,
|
|
3899
|
-
const query = (0,
|
|
3961
|
+
const qc = (0, import_react_query44.useQueryClient)();
|
|
3962
|
+
const query = (0, import_react_query44.useQuery)({
|
|
3900
3963
|
queryKey: ["behio", "wishlist"],
|
|
3901
3964
|
queryFn: () => unwrap(client.wishlist.get()),
|
|
3902
3965
|
enabled: options?.enabled ?? true
|
|
3903
3966
|
});
|
|
3904
|
-
const addMutation = (0,
|
|
3967
|
+
const addMutation = (0, import_react_query44.useMutation)({
|
|
3905
3968
|
mutationFn: (productId) => unwrap(client.wishlist.add(productId)),
|
|
3906
3969
|
onSuccess: () => qc.invalidateQueries({ queryKey: ["behio", "wishlist"] })
|
|
3907
3970
|
});
|
|
3908
|
-
const removeMutation = (0,
|
|
3971
|
+
const removeMutation = (0, import_react_query44.useMutation)({
|
|
3909
3972
|
mutationFn: (productId) => unwrap(client.wishlist.remove(productId)),
|
|
3910
3973
|
onSuccess: () => qc.invalidateQueries({ queryKey: ["behio", "wishlist"] })
|
|
3911
3974
|
});
|
|
@@ -3919,7 +3982,7 @@ function useWishlist(options) {
|
|
|
3919
3982
|
}
|
|
3920
3983
|
function useIsInWishlist(productId) {
|
|
3921
3984
|
const { client } = useBehio();
|
|
3922
|
-
return (0,
|
|
3985
|
+
return (0, import_react_query44.useQuery)({
|
|
3923
3986
|
queryKey: ["behio", "wishlist-check", productId],
|
|
3924
3987
|
queryFn: () => unwrap(client.wishlist.isInWishlist(productId)),
|
|
3925
3988
|
enabled: Boolean(productId)
|
|
@@ -3927,10 +3990,10 @@ function useIsInWishlist(productId) {
|
|
|
3927
3990
|
}
|
|
3928
3991
|
|
|
3929
3992
|
// src/react/hooks/use-reviews.ts
|
|
3930
|
-
var
|
|
3993
|
+
var import_react_query45 = require("@tanstack/react-query");
|
|
3931
3994
|
function useProductReviews(productId, options) {
|
|
3932
3995
|
const { client } = useBehio();
|
|
3933
|
-
return (0,
|
|
3996
|
+
return (0, import_react_query45.useQuery)({
|
|
3934
3997
|
queryKey: ["behio", "reviews", productId, options?.page ?? 1],
|
|
3935
3998
|
queryFn: () => unwrap(client.reviews.getProductReviews(productId, options?.page, options?.limit)),
|
|
3936
3999
|
enabled: Boolean(productId) && (options?.enabled ?? true)
|
|
@@ -3938,30 +4001,30 @@ function useProductReviews(productId, options) {
|
|
|
3938
4001
|
}
|
|
3939
4002
|
function useSubmitReview() {
|
|
3940
4003
|
const { client } = useBehio();
|
|
3941
|
-
const qc = (0,
|
|
3942
|
-
return (0,
|
|
4004
|
+
const qc = (0, import_react_query45.useQueryClient)();
|
|
4005
|
+
return (0, import_react_query45.useMutation)({
|
|
3943
4006
|
mutationFn: (input) => unwrap(client.reviews.submit(input)),
|
|
3944
4007
|
onSuccess: (_, input) => qc.invalidateQueries({ queryKey: ["behio", "reviews", input.productId] })
|
|
3945
4008
|
});
|
|
3946
4009
|
}
|
|
3947
4010
|
|
|
3948
4011
|
// src/react/hooks/use-returns.ts
|
|
3949
|
-
var
|
|
4012
|
+
var import_react_query46 = require("@tanstack/react-query");
|
|
3950
4013
|
function useLookupReturnableOrder() {
|
|
3951
4014
|
const { client } = useBehio();
|
|
3952
|
-
return (0,
|
|
4015
|
+
return (0, import_react_query46.useMutation)({
|
|
3953
4016
|
mutationFn: ({ orderNumber, email }) => unwrap(client.returns.lookupOrder(orderNumber, email))
|
|
3954
4017
|
});
|
|
3955
4018
|
}
|
|
3956
4019
|
function useSubmitReturn() {
|
|
3957
4020
|
const { client } = useBehio();
|
|
3958
|
-
return (0,
|
|
4021
|
+
return (0, import_react_query46.useMutation)({
|
|
3959
4022
|
mutationFn: (input) => unwrap(client.returns.submit(input))
|
|
3960
4023
|
});
|
|
3961
4024
|
}
|
|
3962
4025
|
function useReturnStatus(returnId, email) {
|
|
3963
4026
|
const { client } = useBehio();
|
|
3964
|
-
return (0,
|
|
4027
|
+
return (0, import_react_query46.useQuery)({
|
|
3965
4028
|
queryKey: ["behio", "return-status", returnId],
|
|
3966
4029
|
queryFn: () => unwrap(client.returns.getStatus(returnId, email)),
|
|
3967
4030
|
enabled: Boolean(returnId && email)
|
|
@@ -3969,16 +4032,16 @@ function useReturnStatus(returnId, email) {
|
|
|
3969
4032
|
}
|
|
3970
4033
|
|
|
3971
4034
|
// src/react/hooks/use-quotes.ts
|
|
3972
|
-
var
|
|
4035
|
+
var import_react_query47 = require("@tanstack/react-query");
|
|
3973
4036
|
function useSubmitQuote() {
|
|
3974
4037
|
const { client } = useBehio();
|
|
3975
|
-
return (0,
|
|
4038
|
+
return (0, import_react_query47.useMutation)({
|
|
3976
4039
|
mutationFn: (input) => unwrap(client.quotes.submit(input))
|
|
3977
4040
|
});
|
|
3978
4041
|
}
|
|
3979
4042
|
function useQuoteStatus(quoteId, email) {
|
|
3980
4043
|
const { client } = useBehio();
|
|
3981
|
-
return (0,
|
|
4044
|
+
return (0, import_react_query47.useQuery)({
|
|
3982
4045
|
queryKey: ["behio", "quote-status", quoteId],
|
|
3983
4046
|
queryFn: () => unwrap(client.quotes.getStatus(quoteId, email)),
|
|
3984
4047
|
enabled: Boolean(quoteId && email)
|
|
@@ -3986,10 +4049,10 @@ function useQuoteStatus(quoteId, email) {
|
|
|
3986
4049
|
}
|
|
3987
4050
|
|
|
3988
4051
|
// src/react/hooks/use-back-in-stock.ts
|
|
3989
|
-
var
|
|
4052
|
+
var import_react_query48 = require("@tanstack/react-query");
|
|
3990
4053
|
function useNotifyWhenAvailable() {
|
|
3991
4054
|
const { client } = useBehio();
|
|
3992
|
-
return (0,
|
|
4055
|
+
return (0, import_react_query48.useMutation)({
|
|
3993
4056
|
mutationFn: ({ productId, email }) => unwrap(client.catalog.notifyWhenAvailable(productId, email))
|
|
3994
4057
|
});
|
|
3995
4058
|
}
|
|
@@ -4167,6 +4230,7 @@ async function revokeAnalyticsConsent(client) {
|
|
|
4167
4230
|
usePickupPoints,
|
|
4168
4231
|
useProduct,
|
|
4169
4232
|
useProductGroup,
|
|
4233
|
+
useProductParameters,
|
|
4170
4234
|
useProductPromotions,
|
|
4171
4235
|
useProductReviews,
|
|
4172
4236
|
useProducts,
|