@behio/storefront-sdk 0.42.0 → 1.0.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-BKNtLTcu.d.mts} +122 -46
- package/dist/{client-B0vlHxB1.d.ts → client-BKNtLTcu.d.ts} +122 -46
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/index.mjs +1 -1
- 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 +140 -46
- package/dist/react.d.ts +140 -46
- package/dist/react.js +215 -151
- package/dist/react.mjs +149 -86
- package/package.json +1 -1
package/dist/react.mjs
CHANGED
|
@@ -535,8 +535,7 @@ var CatalogModule = class {
|
|
|
535
535
|
if (query.inStock !== void 0) q.inStock = query.inStock;
|
|
536
536
|
if (query.ratingMin !== void 0) q.ratingMin = query.ratingMin;
|
|
537
537
|
if (query.search) q.search = query.search;
|
|
538
|
-
if (query.
|
|
539
|
-
q.customFields = JSON.stringify(query.customFields);
|
|
538
|
+
if (query.parameters) q.parameters = JSON.stringify(query.parameters);
|
|
540
539
|
if (query.facets) q.facets = JSON.stringify(query.facets);
|
|
541
540
|
if (query.ids && query.ids.length > 0) q.ids = query.ids;
|
|
542
541
|
if (query.slugs && query.slugs.length > 0) q.slugs = query.slugs;
|
|
@@ -628,18 +627,52 @@ var CatalogModule = class {
|
|
|
628
627
|
}
|
|
629
628
|
);
|
|
630
629
|
}
|
|
631
|
-
/**
|
|
632
|
-
|
|
630
|
+
/**
|
|
631
|
+
* Available filters for a dynamic filter UI.
|
|
632
|
+
*
|
|
633
|
+
* Derived from curated PARAMETERS the merchant marked filterable, so a
|
|
634
|
+
* visitor can never filter by something that does not appear in the
|
|
635
|
+
* product's parameters. Labels are per language, hence `locale`.
|
|
636
|
+
*/
|
|
637
|
+
async getFilters(options) {
|
|
638
|
+
return this.client.request(
|
|
639
|
+
"GET",
|
|
640
|
+
"/catalog/filters",
|
|
641
|
+
{ query: { locale: options?.locale } }
|
|
642
|
+
);
|
|
643
|
+
}
|
|
644
|
+
/**
|
|
645
|
+
* Curated parameter groups of a product, already resolved (label, value,
|
|
646
|
+
* unit, order). Returns an ARRAY of groups so a template can lay them out
|
|
647
|
+
* however it likes: one group as a spec table, another as badges.
|
|
648
|
+
*
|
|
649
|
+
* A variant's own parameters ride along on `ProductDetail.variants[]`, so
|
|
650
|
+
* this call is for the parent product.
|
|
651
|
+
*/
|
|
652
|
+
async getProductParameters(slug, options) {
|
|
633
653
|
return this.client.request(
|
|
634
654
|
"GET",
|
|
635
|
-
|
|
655
|
+
`/catalog/products/${slug}/parameters`,
|
|
656
|
+
{ query: { locale: options?.locale } }
|
|
636
657
|
);
|
|
637
658
|
}
|
|
638
659
|
/**
|
|
639
|
-
*
|
|
640
|
-
*
|
|
641
|
-
*
|
|
642
|
-
|
|
660
|
+
* One specific parameter group of a product, by its slug. 404 when the
|
|
661
|
+
* product does not have that group, which is deliberate: the caller asked
|
|
662
|
+
* for a named thing, so an empty array would hide a wrong slug.
|
|
663
|
+
*/
|
|
664
|
+
async getProductParameterGroup(slug, groupSlug, options) {
|
|
665
|
+
return this.client.request(
|
|
666
|
+
"GET",
|
|
667
|
+
`/catalog/products/${slug}/parameters/${groupSlug}`,
|
|
668
|
+
{ query: { locale: options?.locale } }
|
|
669
|
+
);
|
|
670
|
+
}
|
|
671
|
+
/**
|
|
672
|
+
* Facet groups + selection-aware counts for the current filter set
|
|
673
|
+
* (parameters, labels, price, availability, rating, subcategories). Pass the
|
|
674
|
+
* SAME query you pass to `getProducts` (category, search, price, inStock,
|
|
675
|
+
* ratingMin, parameters, facets slugs, labels): counts are computed with
|
|
643
676
|
* that facet excluded, and values that drop to 0 are still returned (render
|
|
644
677
|
* them disabled). Use this to build an Alza-style filter sidebar.
|
|
645
678
|
*/
|
|
@@ -655,8 +688,7 @@ var CatalogModule = class {
|
|
|
655
688
|
if (query.inStock !== void 0) q.inStock = query.inStock;
|
|
656
689
|
if (query.ratingMin !== void 0) q.ratingMin = query.ratingMin;
|
|
657
690
|
if (query.search) q.search = query.search;
|
|
658
|
-
if (query.
|
|
659
|
-
q.customFields = JSON.stringify(query.customFields);
|
|
691
|
+
if (query.parameters) q.parameters = JSON.stringify(query.parameters);
|
|
660
692
|
if (query.facets) q.facets = JSON.stringify(query.facets);
|
|
661
693
|
if (query.labels && query.labels.length > 0) q.labels = query.labels;
|
|
662
694
|
if (query.categories && query.categories.length > 0)
|
|
@@ -2065,10 +2097,11 @@ function useFeatured(options) {
|
|
|
2065
2097
|
import { useQuery as useQuery6 } from "@tanstack/react-query";
|
|
2066
2098
|
function useFilters(options) {
|
|
2067
2099
|
const { client } = useBehio();
|
|
2100
|
+
const locale = options?.locale;
|
|
2068
2101
|
return useQuery6({
|
|
2069
|
-
queryKey: ["behio", "filters"],
|
|
2102
|
+
queryKey: ["behio", "filters", locale ?? null],
|
|
2070
2103
|
queryFn: async () => {
|
|
2071
|
-
const result = await unwrap(client.catalog.getFilters());
|
|
2104
|
+
const result = await unwrap(client.catalog.getFilters({ locale }));
|
|
2072
2105
|
return result.filters;
|
|
2073
2106
|
},
|
|
2074
2107
|
enabled: options?.enabled !== false
|
|
@@ -2086,9 +2119,38 @@ function useFacets(query, options) {
|
|
|
2086
2119
|
});
|
|
2087
2120
|
}
|
|
2088
2121
|
|
|
2122
|
+
// src/react/hooks/use-product-parameters.ts
|
|
2123
|
+
import { useQuery as useQuery8 } from "@tanstack/react-query";
|
|
2124
|
+
function useProductParameters(slug, options) {
|
|
2125
|
+
const { client } = useBehio();
|
|
2126
|
+
const { locale, groupSlug } = options ?? {};
|
|
2127
|
+
return useQuery8({
|
|
2128
|
+
queryKey: [
|
|
2129
|
+
"behio",
|
|
2130
|
+
"product-parameters",
|
|
2131
|
+
slug,
|
|
2132
|
+
locale ?? null,
|
|
2133
|
+
groupSlug ?? null
|
|
2134
|
+
],
|
|
2135
|
+
queryFn: async () => {
|
|
2136
|
+
if (groupSlug) {
|
|
2137
|
+
const group = await unwrap(
|
|
2138
|
+
client.catalog.getProductParameterGroup(slug, groupSlug, { locale })
|
|
2139
|
+
);
|
|
2140
|
+
return [group];
|
|
2141
|
+
}
|
|
2142
|
+
const result = await unwrap(
|
|
2143
|
+
client.catalog.getProductParameters(slug, { locale })
|
|
2144
|
+
);
|
|
2145
|
+
return result.groups;
|
|
2146
|
+
},
|
|
2147
|
+
enabled: options?.enabled !== false && !!slug
|
|
2148
|
+
});
|
|
2149
|
+
}
|
|
2150
|
+
|
|
2089
2151
|
// src/react/hooks/use-search.ts
|
|
2090
2152
|
import { useState as useState3, useEffect as useEffect2 } from "react";
|
|
2091
|
-
import { useQuery as
|
|
2153
|
+
import { useQuery as useQuery9 } from "@tanstack/react-query";
|
|
2092
2154
|
function useSearch(query, options) {
|
|
2093
2155
|
const { client } = useBehio();
|
|
2094
2156
|
const debounceMs = options?.debounceMs ?? 300;
|
|
@@ -2101,7 +2163,7 @@ function useSearch(query, options) {
|
|
|
2101
2163
|
const timer = setTimeout(() => setDebouncedQuery(query), debounceMs);
|
|
2102
2164
|
return () => clearTimeout(timer);
|
|
2103
2165
|
}, [query, debounceMs]);
|
|
2104
|
-
return
|
|
2166
|
+
return useQuery9({
|
|
2105
2167
|
queryKey: ["behio", "search", debouncedQuery, options?.page, options?.limit],
|
|
2106
2168
|
queryFn: () => unwrap(client.catalog.search(debouncedQuery, {
|
|
2107
2169
|
page: options?.page,
|
|
@@ -2113,7 +2175,7 @@ function useSearch(query, options) {
|
|
|
2113
2175
|
|
|
2114
2176
|
// src/react/hooks/use-cart.ts
|
|
2115
2177
|
import { useCallback as useCallback3 } from "react";
|
|
2116
|
-
import { useQuery as
|
|
2178
|
+
import { useQuery as useQuery10, useMutation, useQueryClient } from "@tanstack/react-query";
|
|
2117
2179
|
var CART_KEY = ["behio", "cart"];
|
|
2118
2180
|
function useCart(options) {
|
|
2119
2181
|
const { client, storage } = useBehio();
|
|
@@ -2122,7 +2184,7 @@ function useCart(options) {
|
|
|
2122
2184
|
data: cart,
|
|
2123
2185
|
isLoading,
|
|
2124
2186
|
error
|
|
2125
|
-
} =
|
|
2187
|
+
} = useQuery10({
|
|
2126
2188
|
queryKey: [...CART_KEY],
|
|
2127
2189
|
queryFn: () => unwrap(client.cart.get()),
|
|
2128
2190
|
// Only fetch if we have a cart session or are logged in
|
|
@@ -2272,13 +2334,13 @@ function useCart(options) {
|
|
|
2272
2334
|
}
|
|
2273
2335
|
|
|
2274
2336
|
// src/react/hooks/use-cart-count.ts
|
|
2275
|
-
import { useQuery as
|
|
2337
|
+
import { useQuery as useQuery11, useQueryClient as useQueryClient2 } from "@tanstack/react-query";
|
|
2276
2338
|
var CART_KEY2 = ["behio", "cart"];
|
|
2277
2339
|
function useCartCount(options) {
|
|
2278
2340
|
const { client } = useBehio();
|
|
2279
2341
|
const queryClient = useQueryClient2();
|
|
2280
2342
|
const cachedCart = queryClient.getQueryData([...CART_KEY2]);
|
|
2281
|
-
const { data } =
|
|
2343
|
+
const { data } = useQuery11({
|
|
2282
2344
|
queryKey: [...CART_KEY2],
|
|
2283
2345
|
queryFn: () => unwrap(client.cart.get()),
|
|
2284
2346
|
enabled: options?.enabled !== false && !cachedCart && (!!client.getCartSession() || !!client.getAccessToken())
|
|
@@ -2289,7 +2351,7 @@ function useCartCount(options) {
|
|
|
2289
2351
|
|
|
2290
2352
|
// src/react/hooks/use-auth.ts
|
|
2291
2353
|
import { useCallback as useCallback4 } from "react";
|
|
2292
|
-
import { useQuery as
|
|
2354
|
+
import { useQuery as useQuery12, useMutation as useMutation2, useQueryClient as useQueryClient3 } from "@tanstack/react-query";
|
|
2293
2355
|
var CUSTOMER_KEY = ["behio", "customer"];
|
|
2294
2356
|
var CART_KEY3 = ["behio", "cart"];
|
|
2295
2357
|
function useAuth() {
|
|
@@ -2299,7 +2361,7 @@ function useAuth() {
|
|
|
2299
2361
|
const {
|
|
2300
2362
|
data: customer,
|
|
2301
2363
|
isLoading
|
|
2302
|
-
} =
|
|
2364
|
+
} = useQuery12({
|
|
2303
2365
|
queryKey: [...CUSTOMER_KEY],
|
|
2304
2366
|
queryFn: () => unwrap(client.customer.getProfile()),
|
|
2305
2367
|
enabled: isLoggedIn
|
|
@@ -2412,7 +2474,7 @@ function useAuth() {
|
|
|
2412
2474
|
|
|
2413
2475
|
// src/react/hooks/use-customer.ts
|
|
2414
2476
|
import { useCallback as useCallback5 } from "react";
|
|
2415
|
-
import { useQuery as
|
|
2477
|
+
import { useQuery as useQuery13, useMutation as useMutation3, useQueryClient as useQueryClient4 } from "@tanstack/react-query";
|
|
2416
2478
|
var CUSTOMER_KEY2 = ["behio", "customer"];
|
|
2417
2479
|
function useCustomer(options) {
|
|
2418
2480
|
const { client } = useBehio();
|
|
@@ -2421,7 +2483,7 @@ function useCustomer(options) {
|
|
|
2421
2483
|
data,
|
|
2422
2484
|
isLoading,
|
|
2423
2485
|
error
|
|
2424
|
-
} =
|
|
2486
|
+
} = useQuery13({
|
|
2425
2487
|
queryKey: [...CUSTOMER_KEY2],
|
|
2426
2488
|
queryFn: () => unwrap(client.customer.getProfile()),
|
|
2427
2489
|
enabled: options?.enabled !== false && !!client.getAccessToken()
|
|
@@ -2447,7 +2509,7 @@ function useCustomer(options) {
|
|
|
2447
2509
|
|
|
2448
2510
|
// src/react/hooks/use-addresses.ts
|
|
2449
2511
|
import { useCallback as useCallback6 } from "react";
|
|
2450
|
-
import { useQuery as
|
|
2512
|
+
import { useQuery as useQuery14, useMutation as useMutation4, useQueryClient as useQueryClient5 } from "@tanstack/react-query";
|
|
2451
2513
|
var ADDRESSES_KEY = ["behio", "addresses"];
|
|
2452
2514
|
function useAddresses(options) {
|
|
2453
2515
|
const { client } = useBehio();
|
|
@@ -2456,7 +2518,7 @@ function useAddresses(options) {
|
|
|
2456
2518
|
data,
|
|
2457
2519
|
isLoading,
|
|
2458
2520
|
error
|
|
2459
|
-
} =
|
|
2521
|
+
} = useQuery14({
|
|
2460
2522
|
queryKey: [...ADDRESSES_KEY],
|
|
2461
2523
|
queryFn: async () => {
|
|
2462
2524
|
const result = await unwrap(client.customer.getAddresses());
|
|
@@ -2508,7 +2570,7 @@ function useAddresses(options) {
|
|
|
2508
2570
|
|
|
2509
2571
|
// src/react/hooks/use-address-autocomplete.ts
|
|
2510
2572
|
import { useState as useState4, useEffect as useEffect3, useRef as useRef2, useCallback as useCallback7 } from "react";
|
|
2511
|
-
import { useQuery as
|
|
2573
|
+
import { useQuery as useQuery15 } from "@tanstack/react-query";
|
|
2512
2574
|
var AC_KEY = ["behio", "address-autocomplete"];
|
|
2513
2575
|
function useAddressAutocomplete(options) {
|
|
2514
2576
|
const { country, debounce = 300, minChars = 3, enabled = true } = options;
|
|
@@ -2531,7 +2593,7 @@ function useAddressAutocomplete(options) {
|
|
|
2531
2593
|
if (timerRef.current) clearTimeout(timerRef.current);
|
|
2532
2594
|
};
|
|
2533
2595
|
}, [query, debounce, minChars]);
|
|
2534
|
-
const { data, isLoading } =
|
|
2596
|
+
const { data, isLoading } = useQuery15({
|
|
2535
2597
|
queryKey: [...AC_KEY, debouncedQuery, country],
|
|
2536
2598
|
queryFn: () => unwrap(client.addresses.autocomplete(debouncedQuery, country)),
|
|
2537
2599
|
enabled: enabled && debouncedQuery.length >= minChars,
|
|
@@ -2571,11 +2633,11 @@ function useAddressAutocomplete(options) {
|
|
|
2571
2633
|
}
|
|
2572
2634
|
|
|
2573
2635
|
// src/react/hooks/use-loyalty.ts
|
|
2574
|
-
import { useQuery as
|
|
2636
|
+
import { useQuery as useQuery16 } from "@tanstack/react-query";
|
|
2575
2637
|
var LOYALTY_KEY = ["behio", "loyalty"];
|
|
2576
2638
|
function useLoyalty(options) {
|
|
2577
2639
|
const { client } = useBehio();
|
|
2578
|
-
const { data, isLoading, error, refetch } =
|
|
2640
|
+
const { data, isLoading, error, refetch } = useQuery16({
|
|
2579
2641
|
queryKey: [...LOYALTY_KEY],
|
|
2580
2642
|
queryFn: () => unwrap(client.customer.getLoyalty()),
|
|
2581
2643
|
enabled: options?.enabled !== false && !!client.getAccessToken()
|
|
@@ -2584,11 +2646,11 @@ function useLoyalty(options) {
|
|
|
2584
2646
|
}
|
|
2585
2647
|
|
|
2586
2648
|
// src/react/hooks/use-courses.ts
|
|
2587
|
-
import { useMutation as useMutation5, useQuery as
|
|
2649
|
+
import { useMutation as useMutation5, useQuery as useQuery17, useQueryClient as useQueryClient7 } from "@tanstack/react-query";
|
|
2588
2650
|
var COURSES_KEY = ["behio", "courses"];
|
|
2589
2651
|
function useCourses(options) {
|
|
2590
2652
|
const { client } = useBehio();
|
|
2591
|
-
const { data, isLoading, error, refetch } =
|
|
2653
|
+
const { data, isLoading, error, refetch } = useQuery17({
|
|
2592
2654
|
queryKey: [...COURSES_KEY],
|
|
2593
2655
|
queryFn: () => unwrap(client.customer.getCourses()),
|
|
2594
2656
|
enabled: options?.enabled !== false && !!client.getAccessToken()
|
|
@@ -2598,7 +2660,7 @@ function useCourses(options) {
|
|
|
2598
2660
|
function useCourse(courseId, options) {
|
|
2599
2661
|
const { client } = useBehio();
|
|
2600
2662
|
const queryClient = useQueryClient7();
|
|
2601
|
-
const { data, isLoading, error, refetch } =
|
|
2663
|
+
const { data, isLoading, error, refetch } = useQuery17({
|
|
2602
2664
|
queryKey: [...COURSES_KEY, courseId],
|
|
2603
2665
|
queryFn: () => unwrap(client.customer.getCourse(courseId)),
|
|
2604
2666
|
enabled: options?.enabled !== false && !!courseId && !!client.getAccessToken()
|
|
@@ -2621,7 +2683,7 @@ function useCourse(courseId, options) {
|
|
|
2621
2683
|
function useLessonQuiz(courseId, lessonId, options) {
|
|
2622
2684
|
const { client } = useBehio();
|
|
2623
2685
|
const queryClient = useQueryClient7();
|
|
2624
|
-
const { data, isLoading, error, refetch } =
|
|
2686
|
+
const { data, isLoading, error, refetch } = useQuery17({
|
|
2625
2687
|
queryKey: [...COURSES_KEY, courseId, "quiz", lessonId],
|
|
2626
2688
|
queryFn: () => unwrap(
|
|
2627
2689
|
client.customer.getLessonQuiz(courseId, lessonId)
|
|
@@ -2656,7 +2718,7 @@ function useLessonQuiz(courseId, lessonId, options) {
|
|
|
2656
2718
|
}
|
|
2657
2719
|
function useCourseCertificates(options) {
|
|
2658
2720
|
const { client } = useBehio();
|
|
2659
|
-
const { data, isLoading, error, refetch } =
|
|
2721
|
+
const { data, isLoading, error, refetch } = useQuery17({
|
|
2660
2722
|
queryKey: [...COURSES_KEY, "certificates"],
|
|
2661
2723
|
queryFn: () => unwrap(client.customer.getCourseCertificates()),
|
|
2662
2724
|
enabled: options?.enabled !== false && !!client.getAccessToken()
|
|
@@ -2665,7 +2727,7 @@ function useCourseCertificates(options) {
|
|
|
2665
2727
|
}
|
|
2666
2728
|
function useCertificateVerification(code, options) {
|
|
2667
2729
|
const { client } = useBehio();
|
|
2668
|
-
const { data, isLoading, error, refetch } =
|
|
2730
|
+
const { data, isLoading, error, refetch } = useQuery17(
|
|
2669
2731
|
{
|
|
2670
2732
|
queryKey: ["behio", "certificate-verification", code],
|
|
2671
2733
|
queryFn: () => unwrap(client.certificates.verify(code)),
|
|
@@ -2677,12 +2739,12 @@ function useCertificateVerification(code, options) {
|
|
|
2677
2739
|
}
|
|
2678
2740
|
|
|
2679
2741
|
// src/react/hooks/use-lesson-tutor.ts
|
|
2680
|
-
import { useMutation as useMutation6, useQuery as
|
|
2742
|
+
import { useMutation as useMutation6, useQuery as useQuery18, useQueryClient as useQueryClient8 } from "@tanstack/react-query";
|
|
2681
2743
|
var TUTOR_KEY = ["behio", "course-tutor"];
|
|
2682
2744
|
function useLessonTutor(courseId, lessonId, options) {
|
|
2683
2745
|
const { client } = useBehio();
|
|
2684
2746
|
const queryClient = useQueryClient8();
|
|
2685
|
-
const { data, isLoading, error, refetch } =
|
|
2747
|
+
const { data, isLoading, error, refetch } = useQuery18({
|
|
2686
2748
|
queryKey: [...TUTOR_KEY, courseId, lessonId],
|
|
2687
2749
|
queryFn: () => unwrap(
|
|
2688
2750
|
client.customer.getLessonTutorThread(
|
|
@@ -2721,13 +2783,13 @@ function useLessonTutor(courseId, lessonId, options) {
|
|
|
2721
2783
|
}
|
|
2722
2784
|
|
|
2723
2785
|
// src/react/hooks/use-lesson-comments.ts
|
|
2724
|
-
import { useMutation as useMutation7, useQuery as
|
|
2786
|
+
import { useMutation as useMutation7, useQuery as useQuery19, useQueryClient as useQueryClient9 } from "@tanstack/react-query";
|
|
2725
2787
|
var COMMENTS_KEY = ["behio", "course-comments"];
|
|
2726
2788
|
function useLessonComments(courseId, lessonId, options) {
|
|
2727
2789
|
const { client } = useBehio();
|
|
2728
2790
|
const queryClient = useQueryClient9();
|
|
2729
2791
|
const page = options?.page ?? 1;
|
|
2730
|
-
const { data, isLoading, error, refetch } =
|
|
2792
|
+
const { data, isLoading, error, refetch } = useQuery19({
|
|
2731
2793
|
queryKey: [...COMMENTS_KEY, courseId, lessonId, page],
|
|
2732
2794
|
queryFn: () => unwrap(
|
|
2733
2795
|
client.customer.getLessonComments(
|
|
@@ -2784,12 +2846,12 @@ function useLessonComments(courseId, lessonId, options) {
|
|
|
2784
2846
|
}
|
|
2785
2847
|
|
|
2786
2848
|
// src/react/hooks/use-lesson-note.ts
|
|
2787
|
-
import { useMutation as useMutation8, useQuery as
|
|
2849
|
+
import { useMutation as useMutation8, useQuery as useQuery20, useQueryClient as useQueryClient10 } from "@tanstack/react-query";
|
|
2788
2850
|
var NOTE_KEY = ["behio", "course-note"];
|
|
2789
2851
|
function useLessonNote(courseId, lessonId, options) {
|
|
2790
2852
|
const { client } = useBehio();
|
|
2791
2853
|
const queryClient = useQueryClient10();
|
|
2792
|
-
const { data, isLoading, error, refetch } =
|
|
2854
|
+
const { data, isLoading, error, refetch } = useQuery20({
|
|
2793
2855
|
queryKey: [...NOTE_KEY, courseId, lessonId],
|
|
2794
2856
|
queryFn: () => unwrap(
|
|
2795
2857
|
client.customer.getLessonNote(courseId, lessonId)
|
|
@@ -2825,12 +2887,12 @@ function useLessonNote(courseId, lessonId, options) {
|
|
|
2825
2887
|
}
|
|
2826
2888
|
|
|
2827
2889
|
// src/react/hooks/use-subscriptions.ts
|
|
2828
|
-
import { useQuery as
|
|
2890
|
+
import { useQuery as useQuery21, useMutation as useMutation9, useQueryClient as useQueryClient11 } from "@tanstack/react-query";
|
|
2829
2891
|
var SUBSCRIPTIONS_KEY = ["behio", "subscriptions"];
|
|
2830
2892
|
function useSubscriptions(options) {
|
|
2831
2893
|
const { client } = useBehio();
|
|
2832
2894
|
const qc = useQueryClient11();
|
|
2833
|
-
const query =
|
|
2895
|
+
const query = useQuery21({
|
|
2834
2896
|
queryKey: [...SUBSCRIPTIONS_KEY],
|
|
2835
2897
|
queryFn: () => unwrap(client.subscriptions.list()),
|
|
2836
2898
|
enabled: options?.enabled !== false && !!client.getAccessToken()
|
|
@@ -2863,11 +2925,11 @@ function useSubscriptions(options) {
|
|
|
2863
2925
|
}
|
|
2864
2926
|
|
|
2865
2927
|
// src/react/hooks/use-pickup-points.ts
|
|
2866
|
-
import { useQuery as
|
|
2928
|
+
import { useQuery as useQuery22 } from "@tanstack/react-query";
|
|
2867
2929
|
function usePickupPoints(input) {
|
|
2868
2930
|
const { client } = useBehio();
|
|
2869
2931
|
const { methodId, query, country, limit, enabled } = input;
|
|
2870
|
-
const { data, isLoading, error, refetch } =
|
|
2932
|
+
const { data, isLoading, error, refetch } = useQuery22({
|
|
2871
2933
|
queryKey: ["behio", "pickup-points", methodId, query ?? "", country ?? "", limit ?? 30],
|
|
2872
2934
|
queryFn: () => unwrap(
|
|
2873
2935
|
client.shipping.getPickupPoints({
|
|
@@ -2883,12 +2945,12 @@ function usePickupPoints(input) {
|
|
|
2883
2945
|
}
|
|
2884
2946
|
|
|
2885
2947
|
// src/react/hooks/use-shipping-methods.ts
|
|
2886
|
-
import { useQuery as
|
|
2948
|
+
import { useQuery as useQuery23 } from "@tanstack/react-query";
|
|
2887
2949
|
function useShippingMethods(options) {
|
|
2888
2950
|
const { client, currency: activeCurrency } = useBehio();
|
|
2889
2951
|
const currency = options?.currency ?? activeCurrency;
|
|
2890
2952
|
const { country, cartTotal, cartWeightKg } = options ?? {};
|
|
2891
|
-
const { data, isLoading, error, refetch } =
|
|
2953
|
+
const { data, isLoading, error, refetch } = useQuery23({
|
|
2892
2954
|
queryKey: [
|
|
2893
2955
|
"behio",
|
|
2894
2956
|
"shipping-methods",
|
|
@@ -2904,12 +2966,12 @@ function useShippingMethods(options) {
|
|
|
2904
2966
|
}
|
|
2905
2967
|
|
|
2906
2968
|
// src/react/hooks/use-shipping-quote.ts
|
|
2907
|
-
import { useQuery as
|
|
2969
|
+
import { useQuery as useQuery24 } from "@tanstack/react-query";
|
|
2908
2970
|
function useShippingQuote(options) {
|
|
2909
2971
|
const { client, currency: activeCurrency } = useBehio();
|
|
2910
2972
|
const { destinationAddress, items, cartTotal, enabled } = options ?? {};
|
|
2911
2973
|
const currency = options?.currency ?? activeCurrency;
|
|
2912
|
-
const { data, isLoading, error, refetch } =
|
|
2974
|
+
const { data, isLoading, error, refetch } = useQuery24({
|
|
2913
2975
|
queryKey: [
|
|
2914
2976
|
"behio",
|
|
2915
2977
|
"shipping-quote",
|
|
@@ -2932,11 +2994,11 @@ function useShippingQuote(options) {
|
|
|
2932
2994
|
}
|
|
2933
2995
|
|
|
2934
2996
|
// src/react/hooks/use-payment-methods.ts
|
|
2935
|
-
import { useQuery as
|
|
2997
|
+
import { useQuery as useQuery25 } from "@tanstack/react-query";
|
|
2936
2998
|
function usePaymentMethods(options) {
|
|
2937
2999
|
const { client, currency: activeCurrency } = useBehio();
|
|
2938
3000
|
const currency = options?.currency ?? activeCurrency;
|
|
2939
|
-
const { data, isLoading, error, refetch } =
|
|
3001
|
+
const { data, isLoading, error, refetch } = useQuery25({
|
|
2940
3002
|
queryKey: ["behio", "payment-methods", currency ?? ""],
|
|
2941
3003
|
queryFn: () => unwrap(client.catalog.listPaymentMethods({ currency })),
|
|
2942
3004
|
enabled: options?.enabled !== false
|
|
@@ -2946,7 +3008,7 @@ function usePaymentMethods(options) {
|
|
|
2946
3008
|
|
|
2947
3009
|
// src/react/hooks/use-personal-offers.ts
|
|
2948
3010
|
import { useCallback as useCallback8, useEffect as useEffect4, useState as useState5 } from "react";
|
|
2949
|
-
import { useMutation as useMutation10, useQuery as
|
|
3011
|
+
import { useMutation as useMutation10, useQuery as useQuery26, useQueryClient as useQueryClient12 } from "@tanstack/react-query";
|
|
2950
3012
|
function usePersonalOffers(options) {
|
|
2951
3013
|
const { client } = useBehio();
|
|
2952
3014
|
const queryClient = useQueryClient12();
|
|
@@ -2967,7 +3029,7 @@ function usePersonalOffers(options) {
|
|
|
2967
3029
|
}, [client, explicitVid]);
|
|
2968
3030
|
const visitorId = explicitVid ?? polledVid;
|
|
2969
3031
|
const queryKey = ["behio", "personal-offers", visitorId ?? ""];
|
|
2970
|
-
const { data, isLoading, error, refetch } =
|
|
3032
|
+
const { data, isLoading, error, refetch } = useQuery26({
|
|
2971
3033
|
queryKey,
|
|
2972
3034
|
queryFn: () => unwrap(client.getPersonalOffers(visitorId)),
|
|
2973
3035
|
enabled: options?.enabled !== false && !!visitorId
|
|
@@ -3101,7 +3163,7 @@ function useOrders(options) {
|
|
|
3101
3163
|
|
|
3102
3164
|
// src/react/hooks/use-order.ts
|
|
3103
3165
|
import { useCallback as useCallback11 } from "react";
|
|
3104
|
-
import { useQuery as
|
|
3166
|
+
import { useQuery as useQuery27, useMutation as useMutation12, useQueryClient as useQueryClient13 } from "@tanstack/react-query";
|
|
3105
3167
|
function useOrder(orderNumber, options) {
|
|
3106
3168
|
const { client } = useBehio();
|
|
3107
3169
|
const queryClient = useQueryClient13();
|
|
@@ -3109,7 +3171,7 @@ function useOrder(orderNumber, options) {
|
|
|
3109
3171
|
data,
|
|
3110
3172
|
isLoading,
|
|
3111
3173
|
error
|
|
3112
|
-
} =
|
|
3174
|
+
} = useQuery27({
|
|
3113
3175
|
queryKey: ["behio", "order", orderNumber],
|
|
3114
3176
|
queryFn: () => unwrap(client.orders.get(orderNumber)),
|
|
3115
3177
|
enabled: options?.enabled !== false && !!orderNumber && !!client.getAccessToken()
|
|
@@ -3228,10 +3290,10 @@ function useCheckout() {
|
|
|
3228
3290
|
}
|
|
3229
3291
|
|
|
3230
3292
|
// src/react/hooks/use-pages.ts
|
|
3231
|
-
import { useQuery as
|
|
3293
|
+
import { useQuery as useQuery28 } from "@tanstack/react-query";
|
|
3232
3294
|
function usePages(locale, options) {
|
|
3233
3295
|
const { client } = useBehio();
|
|
3234
|
-
return
|
|
3296
|
+
return useQuery28({
|
|
3235
3297
|
queryKey: ["behio", "pages", locale],
|
|
3236
3298
|
queryFn: async () => {
|
|
3237
3299
|
const result = await unwrap(client.pages.list(locale));
|
|
@@ -3242,7 +3304,7 @@ function usePages(locale, options) {
|
|
|
3242
3304
|
}
|
|
3243
3305
|
function usePage(slug, locale, options) {
|
|
3244
3306
|
const { client } = useBehio();
|
|
3245
|
-
return
|
|
3307
|
+
return useQuery28({
|
|
3246
3308
|
queryKey: ["behio", "page", slug, locale],
|
|
3247
3309
|
queryFn: () => unwrap(client.pages.get(slug, locale)),
|
|
3248
3310
|
enabled: options?.enabled !== false && !!slug
|
|
@@ -3250,10 +3312,10 @@ function usePage(slug, locale, options) {
|
|
|
3250
3312
|
}
|
|
3251
3313
|
|
|
3252
3314
|
// src/react/hooks/use-shop-info.ts
|
|
3253
|
-
import { useQuery as
|
|
3315
|
+
import { useQuery as useQuery29 } from "@tanstack/react-query";
|
|
3254
3316
|
function useShopInfo(options) {
|
|
3255
3317
|
const { client } = useBehio();
|
|
3256
|
-
return
|
|
3318
|
+
return useQuery29({
|
|
3257
3319
|
queryKey: ["behio", "shop-info"],
|
|
3258
3320
|
queryFn: () => unwrap(client.getShopInfo()),
|
|
3259
3321
|
enabled: options?.enabled !== false
|
|
@@ -3261,10 +3323,10 @@ function useShopInfo(options) {
|
|
|
3261
3323
|
}
|
|
3262
3324
|
|
|
3263
3325
|
// src/react/hooks/use-shop-scripts.ts
|
|
3264
|
-
import { useQuery as
|
|
3326
|
+
import { useQuery as useQuery30 } from "@tanstack/react-query";
|
|
3265
3327
|
function useShopScripts(options) {
|
|
3266
3328
|
const { client } = useBehio();
|
|
3267
|
-
return
|
|
3329
|
+
return useQuery30({
|
|
3268
3330
|
queryKey: ["behio", "shop-scripts"],
|
|
3269
3331
|
queryFn: () => unwrap(client.getShopScripts()),
|
|
3270
3332
|
enabled: options?.enabled !== false
|
|
@@ -3272,11 +3334,11 @@ function useShopScripts(options) {
|
|
|
3272
3334
|
}
|
|
3273
3335
|
|
|
3274
3336
|
// src/react/hooks/use-shop-seo.ts
|
|
3275
|
-
import { useQuery as
|
|
3337
|
+
import { useQuery as useQuery31 } from "@tanstack/react-query";
|
|
3276
3338
|
function useShopSeo(options) {
|
|
3277
3339
|
const { client } = useBehio();
|
|
3278
3340
|
const { locale, initialData, enabled = true } = options ?? {};
|
|
3279
|
-
return
|
|
3341
|
+
return useQuery31({
|
|
3280
3342
|
queryKey: ["behio", "shop-seo", locale ?? "_default"],
|
|
3281
3343
|
queryFn: () => unwrap(client.getShopSeo(locale)),
|
|
3282
3344
|
initialData,
|
|
@@ -3339,11 +3401,11 @@ function CurrencySwitcher({
|
|
|
3339
3401
|
import { useEffect as useEffect5, useMemo as useMemo4, useState as useState9 } from "react";
|
|
3340
3402
|
|
|
3341
3403
|
// src/react/hooks/use-consent.ts
|
|
3342
|
-
import { useQuery as
|
|
3404
|
+
import { useQuery as useQuery32, useMutation as useMutation15, useQueryClient as useQueryClient15 } from "@tanstack/react-query";
|
|
3343
3405
|
function useCookieConsent(visitorId) {
|
|
3344
3406
|
const { client } = useBehio();
|
|
3345
3407
|
const qc = useQueryClient15();
|
|
3346
|
-
const query =
|
|
3408
|
+
const query = useQuery32({
|
|
3347
3409
|
queryKey: ["behio", "consent", visitorId],
|
|
3348
3410
|
queryFn: () => unwrap(client.consent.get(visitorId)),
|
|
3349
3411
|
enabled: Boolean(visitorId)
|
|
@@ -3711,10 +3773,10 @@ function utmFromSearch(search) {
|
|
|
3711
3773
|
}
|
|
3712
3774
|
|
|
3713
3775
|
// src/react/hooks/use-bundles.ts
|
|
3714
|
-
import { useQuery as
|
|
3776
|
+
import { useQuery as useQuery33 } from "@tanstack/react-query";
|
|
3715
3777
|
function useBundles(options) {
|
|
3716
3778
|
const { client } = useBehio();
|
|
3717
|
-
return
|
|
3779
|
+
return useQuery33({
|
|
3718
3780
|
queryKey: ["behio", "bundles"],
|
|
3719
3781
|
queryFn: () => unwrap(client.catalog.getBundles()),
|
|
3720
3782
|
enabled: options?.enabled ?? true,
|
|
@@ -3723,7 +3785,7 @@ function useBundles(options) {
|
|
|
3723
3785
|
}
|
|
3724
3786
|
function useBundle(slug, options) {
|
|
3725
3787
|
const { client } = useBehio();
|
|
3726
|
-
return
|
|
3788
|
+
return useQuery33({
|
|
3727
3789
|
queryKey: ["behio", "bundle", slug],
|
|
3728
3790
|
queryFn: () => unwrap(client.catalog.getBundle(slug)),
|
|
3729
3791
|
enabled: Boolean(slug) && (options?.enabled ?? true),
|
|
@@ -3732,10 +3794,10 @@ function useBundle(slug, options) {
|
|
|
3732
3794
|
}
|
|
3733
3795
|
|
|
3734
3796
|
// src/react/hooks/use-product-group.ts
|
|
3735
|
-
import { useQuery as
|
|
3797
|
+
import { useQuery as useQuery34 } from "@tanstack/react-query";
|
|
3736
3798
|
function useProductGroup(slug, options) {
|
|
3737
3799
|
const { client } = useBehio();
|
|
3738
|
-
return
|
|
3800
|
+
return useQuery34({
|
|
3739
3801
|
queryKey: ["behio", "product-group", slug, options?.locale, options?.currency],
|
|
3740
3802
|
queryFn: () => unwrap(
|
|
3741
3803
|
client.catalog.getProductGroup(slug, {
|
|
@@ -3749,10 +3811,10 @@ function useProductGroup(slug, options) {
|
|
|
3749
3811
|
}
|
|
3750
3812
|
|
|
3751
3813
|
// src/react/hooks/use-cross-sell.ts
|
|
3752
|
-
import { useQuery as
|
|
3814
|
+
import { useQuery as useQuery35 } from "@tanstack/react-query";
|
|
3753
3815
|
function useCrossSell(productSlug, options) {
|
|
3754
3816
|
const { client } = useBehio();
|
|
3755
|
-
return
|
|
3817
|
+
return useQuery35({
|
|
3756
3818
|
queryKey: ["behio", "cross-sell", productSlug, options?.locale, options?.currency],
|
|
3757
3819
|
queryFn: () => unwrap(
|
|
3758
3820
|
client.catalog.getCrossSell(productSlug, {
|
|
@@ -3766,10 +3828,10 @@ function useCrossSell(productSlug, options) {
|
|
|
3766
3828
|
}
|
|
3767
3829
|
|
|
3768
3830
|
// src/react/hooks/use-product-promotions.ts
|
|
3769
|
-
import { useQuery as
|
|
3831
|
+
import { useQuery as useQuery36 } from "@tanstack/react-query";
|
|
3770
3832
|
function useProductPromotions(productSlug, options) {
|
|
3771
3833
|
const { client } = useBehio();
|
|
3772
|
-
return
|
|
3834
|
+
return useQuery36({
|
|
3773
3835
|
queryKey: ["behio", "product-promotions", productSlug],
|
|
3774
3836
|
queryFn: () => unwrap(client.catalog.getProductPromotions(productSlug)),
|
|
3775
3837
|
enabled: Boolean(productSlug) && (options?.enabled ?? true),
|
|
@@ -3778,11 +3840,11 @@ function useProductPromotions(productSlug, options) {
|
|
|
3778
3840
|
}
|
|
3779
3841
|
|
|
3780
3842
|
// src/react/hooks/use-gift-card.ts
|
|
3781
|
-
import { useQuery as
|
|
3843
|
+
import { useQuery as useQuery37 } from "@tanstack/react-query";
|
|
3782
3844
|
function useGiftCardBalance(code, options) {
|
|
3783
3845
|
const { client } = useBehio();
|
|
3784
3846
|
const trimmed = code?.trim();
|
|
3785
|
-
return
|
|
3847
|
+
return useQuery37({
|
|
3786
3848
|
queryKey: ["behio", "gift-card-balance", trimmed],
|
|
3787
3849
|
queryFn: () => unwrap(client.catalog.checkGiftCard(trimmed)),
|
|
3788
3850
|
enabled: Boolean(trimmed && trimmed.length >= 6) && (options?.enabled ?? true)
|
|
@@ -3790,11 +3852,11 @@ function useGiftCardBalance(code, options) {
|
|
|
3790
3852
|
}
|
|
3791
3853
|
|
|
3792
3854
|
// src/react/hooks/use-wishlist.ts
|
|
3793
|
-
import { useQuery as
|
|
3855
|
+
import { useQuery as useQuery38, useMutation as useMutation16, useQueryClient as useQueryClient16 } from "@tanstack/react-query";
|
|
3794
3856
|
function useWishlist(options) {
|
|
3795
3857
|
const { client } = useBehio();
|
|
3796
3858
|
const qc = useQueryClient16();
|
|
3797
|
-
const query =
|
|
3859
|
+
const query = useQuery38({
|
|
3798
3860
|
queryKey: ["behio", "wishlist"],
|
|
3799
3861
|
queryFn: () => unwrap(client.wishlist.get()),
|
|
3800
3862
|
enabled: options?.enabled ?? true
|
|
@@ -3817,7 +3879,7 @@ function useWishlist(options) {
|
|
|
3817
3879
|
}
|
|
3818
3880
|
function useIsInWishlist(productId) {
|
|
3819
3881
|
const { client } = useBehio();
|
|
3820
|
-
return
|
|
3882
|
+
return useQuery38({
|
|
3821
3883
|
queryKey: ["behio", "wishlist-check", productId],
|
|
3822
3884
|
queryFn: () => unwrap(client.wishlist.isInWishlist(productId)),
|
|
3823
3885
|
enabled: Boolean(productId)
|
|
@@ -3825,10 +3887,10 @@ function useIsInWishlist(productId) {
|
|
|
3825
3887
|
}
|
|
3826
3888
|
|
|
3827
3889
|
// src/react/hooks/use-reviews.ts
|
|
3828
|
-
import { useQuery as
|
|
3890
|
+
import { useQuery as useQuery39, useMutation as useMutation17, useQueryClient as useQueryClient17 } from "@tanstack/react-query";
|
|
3829
3891
|
function useProductReviews(productId, options) {
|
|
3830
3892
|
const { client } = useBehio();
|
|
3831
|
-
return
|
|
3893
|
+
return useQuery39({
|
|
3832
3894
|
queryKey: ["behio", "reviews", productId, options?.page ?? 1],
|
|
3833
3895
|
queryFn: () => unwrap(client.reviews.getProductReviews(productId, options?.page, options?.limit)),
|
|
3834
3896
|
enabled: Boolean(productId) && (options?.enabled ?? true)
|
|
@@ -3844,7 +3906,7 @@ function useSubmitReview() {
|
|
|
3844
3906
|
}
|
|
3845
3907
|
|
|
3846
3908
|
// src/react/hooks/use-returns.ts
|
|
3847
|
-
import { useQuery as
|
|
3909
|
+
import { useQuery as useQuery40, useMutation as useMutation18 } from "@tanstack/react-query";
|
|
3848
3910
|
function useLookupReturnableOrder() {
|
|
3849
3911
|
const { client } = useBehio();
|
|
3850
3912
|
return useMutation18({
|
|
@@ -3859,7 +3921,7 @@ function useSubmitReturn() {
|
|
|
3859
3921
|
}
|
|
3860
3922
|
function useReturnStatus(returnId, email) {
|
|
3861
3923
|
const { client } = useBehio();
|
|
3862
|
-
return
|
|
3924
|
+
return useQuery40({
|
|
3863
3925
|
queryKey: ["behio", "return-status", returnId],
|
|
3864
3926
|
queryFn: () => unwrap(client.returns.getStatus(returnId, email)),
|
|
3865
3927
|
enabled: Boolean(returnId && email)
|
|
@@ -3867,7 +3929,7 @@ function useReturnStatus(returnId, email) {
|
|
|
3867
3929
|
}
|
|
3868
3930
|
|
|
3869
3931
|
// src/react/hooks/use-quotes.ts
|
|
3870
|
-
import { useMutation as useMutation19, useQuery as
|
|
3932
|
+
import { useMutation as useMutation19, useQuery as useQuery41 } from "@tanstack/react-query";
|
|
3871
3933
|
function useSubmitQuote() {
|
|
3872
3934
|
const { client } = useBehio();
|
|
3873
3935
|
return useMutation19({
|
|
@@ -3876,7 +3938,7 @@ function useSubmitQuote() {
|
|
|
3876
3938
|
}
|
|
3877
3939
|
function useQuoteStatus(quoteId, email) {
|
|
3878
3940
|
const { client } = useBehio();
|
|
3879
|
-
return
|
|
3941
|
+
return useQuery41({
|
|
3880
3942
|
queryKey: ["behio", "quote-status", quoteId],
|
|
3881
3943
|
queryFn: () => unwrap(client.quotes.getStatus(quoteId, email)),
|
|
3882
3944
|
enabled: Boolean(quoteId && email)
|
|
@@ -4064,6 +4126,7 @@ export {
|
|
|
4064
4126
|
usePickupPoints,
|
|
4065
4127
|
useProduct,
|
|
4066
4128
|
useProductGroup,
|
|
4129
|
+
useProductParameters,
|
|
4067
4130
|
useProductPromotions,
|
|
4068
4131
|
useProductReviews,
|
|
4069
4132
|
useProducts,
|