@viu/emporix-sdk-react 2.0.0 → 2.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/CHANGELOG.md +18 -0
- package/README.md +3 -0
- package/dist/{chunk-N3VDSKCT.js → chunk-4HVAOJTW.js} +102 -6
- package/dist/chunk-4HVAOJTW.js.map +1 -0
- package/dist/hooks.cjs +103 -3
- package/dist/hooks.cjs.map +1 -1
- package/dist/hooks.d.cts +48 -2
- package/dist/hooks.d.ts +48 -2
- package/dist/hooks.js +1 -1
- package/dist/index.cjs +103 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/package.json +3 -3
- package/dist/chunk-N3VDSKCT.js.map +0 -1
package/dist/hooks.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Customer, AuthContext, Product, PaginatedItems, Category, CategoryNode, Cart, CartItemInput, CartItemUpdate, CartAddress, CartCreated, CreateCartInput, CheckoutResult, CheckoutInput, QuoteCheckoutInput, PaymentMode, PriceMatchByContextInput, PriceMatch, Media, SegmentCategoryTree, SegmentItem, Segment, PasswordChangeInput, CustomerUpdateInput, Address, AddressCreateInput, AddressUpdateInput, PasswordResetRequestInput, PasswordResetConfirmInput, Site, LegalEntity, ContactAssignment, Location, IamGroup, ContactAssignmentCreate, LegalEntityCreate, LocationCreate, LegalEntityUpdate, ContactAssignmentUpdate, LocationUpdate, OrderStatus, Order, SalesOrderPatch } from '@viu/emporix-sdk';
|
|
1
|
+
import { Customer, AuthContext, Product, PaginatedItems, Category, CategoryNode, Cart, CartItemInput, CartItemUpdate, CartAddress, CartCreated, CreateCartInput, CheckoutResult, CheckoutInput, QuoteCheckoutInput, PaymentMode, PriceMatchByContextInput, PriceMatch, Media, SegmentCategoryTree, SegmentItem, Segment, PasswordChangeInput, CustomerUpdateInput, Address, AddressCreateInput, AddressUpdateInput, PasswordResetRequestInput, PasswordResetConfirmInput, Site, LegalEntity, ContactAssignment, Location, IamGroup, ContactAssignmentCreate, LegalEntityCreate, LocationCreate, LegalEntityUpdate, ContactAssignmentUpdate, LocationUpdate, OrderStatus, Order, SalesOrderPatch, Availability } from '@viu/emporix-sdk';
|
|
2
2
|
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
3
3
|
import { UseQueryResult, UseInfiniteQueryResult, UseMutationResult } from '@tanstack/react-query';
|
|
4
4
|
import { S as SiteContextValue } from './provider-BhvQWnnh.cjs';
|
|
@@ -74,6 +74,16 @@ declare function useProductSearch(query: string | undefined, params?: {
|
|
|
74
74
|
pageSize?: number;
|
|
75
75
|
}, options?: QueryOpts): UseQueryResult<PaginatedItems<Product>>;
|
|
76
76
|
|
|
77
|
+
type UseVariantChildrenOptions = QueryOpts & {
|
|
78
|
+
pageSize?: number;
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* Resolves the VARIANT children of a PARENT_VARIANT product via
|
|
82
|
+
* `products.listVariantChildren`. The cache key contains `parentVariantId`.
|
|
83
|
+
* Disabled until `parentVariantId` is a non-empty string.
|
|
84
|
+
*/
|
|
85
|
+
declare function useVariantChildren(parentVariantId: string | undefined, options?: UseVariantChildrenOptions): UseQueryResult<Product[]>;
|
|
86
|
+
|
|
77
87
|
/** Fetches one category. */
|
|
78
88
|
declare function useCategory(categoryId: string, options?: QueryOpts): UseQueryResult<Category>;
|
|
79
89
|
/** Fetches one page of categories. */
|
|
@@ -202,6 +212,18 @@ declare function useMatchPrices(input: PriceMatchByContextInput, options?: {
|
|
|
202
212
|
customerToken?: string | null;
|
|
203
213
|
}): UseQueryResult<PriceMatch[]>;
|
|
204
214
|
|
|
215
|
+
/**
|
|
216
|
+
* Like {@link useMatchPrices} but chunks large `items` arrays via
|
|
217
|
+
* `prices.matchByContextChunked` (default 50 items per request, 4 in flight).
|
|
218
|
+
* Result order is not guaranteed — match by `priceId` / `itemRef.id`.
|
|
219
|
+
*/
|
|
220
|
+
declare function useMatchPricesChunked(input: PriceMatchByContextInput, options?: {
|
|
221
|
+
enabled?: boolean;
|
|
222
|
+
customerToken?: string | null;
|
|
223
|
+
chunkSize?: number;
|
|
224
|
+
concurrency?: number;
|
|
225
|
+
}): UseQueryResult<PriceMatch[]>;
|
|
226
|
+
|
|
205
227
|
/**
|
|
206
228
|
* Reads `productMedia` from the existing product query — no Media-Service
|
|
207
229
|
* call (those need a server-only scope). For admin/server flows, use
|
|
@@ -526,4 +548,28 @@ interface UseUpdateSalesOrderVars {
|
|
|
526
548
|
*/
|
|
527
549
|
declare function useUpdateSalesOrder(): UseMutationResult<Order, unknown, UseUpdateSalesOrderVars>;
|
|
528
550
|
|
|
529
|
-
|
|
551
|
+
interface UseAvailabilityOptions {
|
|
552
|
+
enabled?: boolean;
|
|
553
|
+
customerToken?: string | null;
|
|
554
|
+
defaultAvailableOnNotFound?: boolean;
|
|
555
|
+
}
|
|
556
|
+
/**
|
|
557
|
+
* Reads availability for one product on one site via `availability.get`.
|
|
558
|
+
* Defaults to the anonymous token; pass `customerToken` for a customer context.
|
|
559
|
+
*/
|
|
560
|
+
declare function useAvailability(productId: string, siteCode: string, options?: UseAvailabilityOptions): UseQueryResult<Availability>;
|
|
561
|
+
|
|
562
|
+
interface UseAvailabilitiesOptions {
|
|
563
|
+
enabled?: boolean;
|
|
564
|
+
customerToken?: string | null;
|
|
565
|
+
defaultAvailableOnNotFound?: boolean;
|
|
566
|
+
}
|
|
567
|
+
/**
|
|
568
|
+
* Reads availability for many products on one site via `availability.getMany`
|
|
569
|
+
* (a single batch request). Returns records in input order; missing products
|
|
570
|
+
* are `{ available: false }` (or `{ available: true }` with
|
|
571
|
+
* `defaultAvailableOnNotFound`).
|
|
572
|
+
*/
|
|
573
|
+
declare function useAvailabilities(productIds: string[], siteCode: string, options?: UseAvailabilitiesOptions): UseQueryResult<Availability[]>;
|
|
574
|
+
|
|
575
|
+
export { type AddressMutationsApi, type CartMutationsApi, type CheckoutApi, type CompanySwitcherApi, type CustomerSessionApi, type PasswordResetApi, type UseAvailabilitiesOptions, type UseAvailabilityOptions, type UseCancelOrderVars, type UseMyOrdersInfiniteOptions, type UseMyOrdersOptions, type UseOrderOptions, type UseOrderTransitionVars, type UseReorderResult, type UseReorderVars, type UseUpdateSalesOrderVars, type UseVariantChildrenOptions, useActiveCart, useAddressMutations, useAssignContact, useAvailabilities, useAvailability, useCancelOrder, useCart, useCartMutations, useCategories, useCategoriesInfinite, useCategory, useCategoryTree, useChangePassword, useCheckout, useCompany, useCompanyContacts, useCompanyGroups, useCompanyLocations, useCompanySwitcher, useCreateCart, useCreateCompany, useCreateLocation, useCustomerAddresses, useCustomerSession, useDefaultSite, useDeleteCompany, useDeleteLocation, useMatchPrices, useMatchPricesChunked, useMyCompanies, useMyOrders, useMyOrdersInfinite, useMySegmentCategories, useMySegmentCategoriesInfinite, useMySegmentCategoryTree, useMySegmentItems, useMySegmentProducts, useMySegmentProductsInfinite, useMySegments, useOrder, useOrderTransition, usePasswordReset, usePaymentModes, useProduct, useProductByCode, useProductMedia, useProductSearch, useProducts, useProductsInCategory, useProductsInCategoryInfinite, useProductsInfinite, useReorder, useSalesOrder, useSiteContext, useSites, useUnassignContact, useUpdateCompany, useUpdateContactAssignment, useUpdateCustomer, useUpdateLocation, useUpdateSalesOrder, useVariantChildren };
|
package/dist/hooks.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Customer, AuthContext, Product, PaginatedItems, Category, CategoryNode, Cart, CartItemInput, CartItemUpdate, CartAddress, CartCreated, CreateCartInput, CheckoutResult, CheckoutInput, QuoteCheckoutInput, PaymentMode, PriceMatchByContextInput, PriceMatch, Media, SegmentCategoryTree, SegmentItem, Segment, PasswordChangeInput, CustomerUpdateInput, Address, AddressCreateInput, AddressUpdateInput, PasswordResetRequestInput, PasswordResetConfirmInput, Site, LegalEntity, ContactAssignment, Location, IamGroup, ContactAssignmentCreate, LegalEntityCreate, LocationCreate, LegalEntityUpdate, ContactAssignmentUpdate, LocationUpdate, OrderStatus, Order, SalesOrderPatch } from '@viu/emporix-sdk';
|
|
1
|
+
import { Customer, AuthContext, Product, PaginatedItems, Category, CategoryNode, Cart, CartItemInput, CartItemUpdate, CartAddress, CartCreated, CreateCartInput, CheckoutResult, CheckoutInput, QuoteCheckoutInput, PaymentMode, PriceMatchByContextInput, PriceMatch, Media, SegmentCategoryTree, SegmentItem, Segment, PasswordChangeInput, CustomerUpdateInput, Address, AddressCreateInput, AddressUpdateInput, PasswordResetRequestInput, PasswordResetConfirmInput, Site, LegalEntity, ContactAssignment, Location, IamGroup, ContactAssignmentCreate, LegalEntityCreate, LocationCreate, LegalEntityUpdate, ContactAssignmentUpdate, LocationUpdate, OrderStatus, Order, SalesOrderPatch, Availability } from '@viu/emporix-sdk';
|
|
2
2
|
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
3
3
|
import { UseQueryResult, UseInfiniteQueryResult, UseMutationResult } from '@tanstack/react-query';
|
|
4
4
|
import { S as SiteContextValue } from './provider-fvcYdqqX.js';
|
|
@@ -74,6 +74,16 @@ declare function useProductSearch(query: string | undefined, params?: {
|
|
|
74
74
|
pageSize?: number;
|
|
75
75
|
}, options?: QueryOpts): UseQueryResult<PaginatedItems<Product>>;
|
|
76
76
|
|
|
77
|
+
type UseVariantChildrenOptions = QueryOpts & {
|
|
78
|
+
pageSize?: number;
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* Resolves the VARIANT children of a PARENT_VARIANT product via
|
|
82
|
+
* `products.listVariantChildren`. The cache key contains `parentVariantId`.
|
|
83
|
+
* Disabled until `parentVariantId` is a non-empty string.
|
|
84
|
+
*/
|
|
85
|
+
declare function useVariantChildren(parentVariantId: string | undefined, options?: UseVariantChildrenOptions): UseQueryResult<Product[]>;
|
|
86
|
+
|
|
77
87
|
/** Fetches one category. */
|
|
78
88
|
declare function useCategory(categoryId: string, options?: QueryOpts): UseQueryResult<Category>;
|
|
79
89
|
/** Fetches one page of categories. */
|
|
@@ -202,6 +212,18 @@ declare function useMatchPrices(input: PriceMatchByContextInput, options?: {
|
|
|
202
212
|
customerToken?: string | null;
|
|
203
213
|
}): UseQueryResult<PriceMatch[]>;
|
|
204
214
|
|
|
215
|
+
/**
|
|
216
|
+
* Like {@link useMatchPrices} but chunks large `items` arrays via
|
|
217
|
+
* `prices.matchByContextChunked` (default 50 items per request, 4 in flight).
|
|
218
|
+
* Result order is not guaranteed — match by `priceId` / `itemRef.id`.
|
|
219
|
+
*/
|
|
220
|
+
declare function useMatchPricesChunked(input: PriceMatchByContextInput, options?: {
|
|
221
|
+
enabled?: boolean;
|
|
222
|
+
customerToken?: string | null;
|
|
223
|
+
chunkSize?: number;
|
|
224
|
+
concurrency?: number;
|
|
225
|
+
}): UseQueryResult<PriceMatch[]>;
|
|
226
|
+
|
|
205
227
|
/**
|
|
206
228
|
* Reads `productMedia` from the existing product query — no Media-Service
|
|
207
229
|
* call (those need a server-only scope). For admin/server flows, use
|
|
@@ -526,4 +548,28 @@ interface UseUpdateSalesOrderVars {
|
|
|
526
548
|
*/
|
|
527
549
|
declare function useUpdateSalesOrder(): UseMutationResult<Order, unknown, UseUpdateSalesOrderVars>;
|
|
528
550
|
|
|
529
|
-
|
|
551
|
+
interface UseAvailabilityOptions {
|
|
552
|
+
enabled?: boolean;
|
|
553
|
+
customerToken?: string | null;
|
|
554
|
+
defaultAvailableOnNotFound?: boolean;
|
|
555
|
+
}
|
|
556
|
+
/**
|
|
557
|
+
* Reads availability for one product on one site via `availability.get`.
|
|
558
|
+
* Defaults to the anonymous token; pass `customerToken` for a customer context.
|
|
559
|
+
*/
|
|
560
|
+
declare function useAvailability(productId: string, siteCode: string, options?: UseAvailabilityOptions): UseQueryResult<Availability>;
|
|
561
|
+
|
|
562
|
+
interface UseAvailabilitiesOptions {
|
|
563
|
+
enabled?: boolean;
|
|
564
|
+
customerToken?: string | null;
|
|
565
|
+
defaultAvailableOnNotFound?: boolean;
|
|
566
|
+
}
|
|
567
|
+
/**
|
|
568
|
+
* Reads availability for many products on one site via `availability.getMany`
|
|
569
|
+
* (a single batch request). Returns records in input order; missing products
|
|
570
|
+
* are `{ available: false }` (or `{ available: true }` with
|
|
571
|
+
* `defaultAvailableOnNotFound`).
|
|
572
|
+
*/
|
|
573
|
+
declare function useAvailabilities(productIds: string[], siteCode: string, options?: UseAvailabilitiesOptions): UseQueryResult<Availability[]>;
|
|
574
|
+
|
|
575
|
+
export { type AddressMutationsApi, type CartMutationsApi, type CheckoutApi, type CompanySwitcherApi, type CustomerSessionApi, type PasswordResetApi, type UseAvailabilitiesOptions, type UseAvailabilityOptions, type UseCancelOrderVars, type UseMyOrdersInfiniteOptions, type UseMyOrdersOptions, type UseOrderOptions, type UseOrderTransitionVars, type UseReorderResult, type UseReorderVars, type UseUpdateSalesOrderVars, type UseVariantChildrenOptions, useActiveCart, useAddressMutations, useAssignContact, useAvailabilities, useAvailability, useCancelOrder, useCart, useCartMutations, useCategories, useCategoriesInfinite, useCategory, useCategoryTree, useChangePassword, useCheckout, useCompany, useCompanyContacts, useCompanyGroups, useCompanyLocations, useCompanySwitcher, useCreateCart, useCreateCompany, useCreateLocation, useCustomerAddresses, useCustomerSession, useDefaultSite, useDeleteCompany, useDeleteLocation, useMatchPrices, useMatchPricesChunked, useMyCompanies, useMyOrders, useMyOrdersInfinite, useMySegmentCategories, useMySegmentCategoriesInfinite, useMySegmentCategoryTree, useMySegmentItems, useMySegmentProducts, useMySegmentProductsInfinite, useMySegments, useOrder, useOrderTransition, usePasswordReset, usePaymentModes, useProduct, useProductByCode, useProductMedia, useProductSearch, useProducts, useProductsInCategory, useProductsInCategoryInfinite, useProductsInfinite, useReorder, useSalesOrder, useSiteContext, useSites, useUnassignContact, useUpdateCompany, useUpdateContactAssignment, useUpdateCustomer, useUpdateLocation, useUpdateSalesOrder, useVariantChildren };
|
package/dist/hooks.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { useActiveCart, useAddressMutations, useAssignContact, useCancelOrder, useCart, useCartMutations, useCategories, useCategoriesInfinite, useCategory, useCategoryTree, useChangePassword, useCheckout, useCompany, useCompanyContacts, useCompanyGroups, useCompanyLocations, useCompanySwitcher, useCreateCart, useCreateCompany, useCreateLocation, useCustomerAddresses, useCustomerSession, useDefaultSite, useDeleteCompany, useDeleteLocation, useMatchPrices, useMyCompanies, useMyOrders, useMyOrdersInfinite, useMySegmentCategories, useMySegmentCategoriesInfinite, useMySegmentCategoryTree, useMySegmentItems, useMySegmentProducts, useMySegmentProductsInfinite, useMySegments, useOrder, useOrderTransition, usePasswordReset, usePaymentModes, useProduct, useProductByCode, useProductMedia, useProductSearch, useProducts, useProductsInCategory, useProductsInCategoryInfinite, useProductsInfinite, useReorder, useSalesOrder, useSiteContext, useSites, useUnassignContact, useUpdateCompany, useUpdateContactAssignment, useUpdateCustomer, useUpdateLocation, useUpdateSalesOrder } from './chunk-
|
|
1
|
+
export { useActiveCart, useAddressMutations, useAssignContact, useAvailabilities, useAvailability, useCancelOrder, useCart, useCartMutations, useCategories, useCategoriesInfinite, useCategory, useCategoryTree, useChangePassword, useCheckout, useCompany, useCompanyContacts, useCompanyGroups, useCompanyLocations, useCompanySwitcher, useCreateCart, useCreateCompany, useCreateLocation, useCustomerAddresses, useCustomerSession, useDefaultSite, useDeleteCompany, useDeleteLocation, useMatchPrices, useMatchPricesChunked, useMyCompanies, useMyOrders, useMyOrdersInfinite, useMySegmentCategories, useMySegmentCategoriesInfinite, useMySegmentCategoryTree, useMySegmentItems, useMySegmentProducts, useMySegmentProductsInfinite, useMySegments, useOrder, useOrderTransition, usePasswordReset, usePaymentModes, useProduct, useProductByCode, useProductMedia, useProductSearch, useProducts, useProductsInCategory, useProductsInCategoryInfinite, useProductsInfinite, useReorder, useSalesOrder, useSiteContext, useSites, useUnassignContact, useUpdateCompany, useUpdateContactAssignment, useUpdateCustomer, useUpdateLocation, useUpdateSalesOrder, useVariantChildren } from './chunk-4HVAOJTW.js';
|
|
2
2
|
import './chunk-D43CSHK3.js';
|
|
3
3
|
import './chunk-FBQY2N7S.js';
|
|
4
4
|
//# sourceMappingURL=hooks.js.map
|
package/dist/index.cjs
CHANGED
|
@@ -931,6 +931,26 @@ function useProductSearch(query, params = {}, options = {}) {
|
|
|
931
931
|
staleTime: PRODUCTS_STALE_TIME
|
|
932
932
|
});
|
|
933
933
|
}
|
|
934
|
+
var VARIANT_CHILDREN_STALE_TIME = 6e4;
|
|
935
|
+
function useVariantChildren(parentVariantId, options = {}) {
|
|
936
|
+
const { client } = useEmporix();
|
|
937
|
+
const { ctx } = useReadAuth(options.auth);
|
|
938
|
+
const { siteCode } = useReadSite();
|
|
939
|
+
return reactQuery.useQuery({
|
|
940
|
+
queryKey: emporixKey(
|
|
941
|
+
"variant-children",
|
|
942
|
+
[parentVariantId, { pageSize: options.pageSize }],
|
|
943
|
+
{ tenant: client.tenant, authKind: ctx.kind, siteCode }
|
|
944
|
+
),
|
|
945
|
+
enabled: typeof parentVariantId === "string" && parentVariantId !== "",
|
|
946
|
+
queryFn: () => client.products.listVariantChildren(
|
|
947
|
+
parentVariantId,
|
|
948
|
+
options.pageSize !== void 0 ? { pageSize: options.pageSize } : {},
|
|
949
|
+
ctx
|
|
950
|
+
),
|
|
951
|
+
staleTime: VARIANT_CHILDREN_STALE_TIME
|
|
952
|
+
});
|
|
953
|
+
}
|
|
934
954
|
var CATEGORIES_STALE_TIME = 5 * 6e4;
|
|
935
955
|
function useCategory(categoryId, options = {}) {
|
|
936
956
|
const { client } = useEmporix();
|
|
@@ -1195,6 +1215,36 @@ function useMatchPrices(input, options = {}) {
|
|
|
1195
1215
|
staleTime: PRICES_STALE_TIME
|
|
1196
1216
|
});
|
|
1197
1217
|
}
|
|
1218
|
+
var PRICES_STALE_TIME2 = 6e4;
|
|
1219
|
+
function useMatchPricesChunked(input, options = {}) {
|
|
1220
|
+
const { client } = useEmporix();
|
|
1221
|
+
const { siteCode } = useReadSite();
|
|
1222
|
+
const ctx = options.customerToken ? emporixSdk.auth.customer(options.customerToken) : emporixSdk.auth.anonymous();
|
|
1223
|
+
return reactQuery.useQuery({
|
|
1224
|
+
queryKey: [
|
|
1225
|
+
"emporix",
|
|
1226
|
+
"match-prices-chunked",
|
|
1227
|
+
{
|
|
1228
|
+
tenant: client.tenant,
|
|
1229
|
+
input,
|
|
1230
|
+
anon: !options.customerToken,
|
|
1231
|
+
siteCode,
|
|
1232
|
+
chunkSize: options.chunkSize,
|
|
1233
|
+
concurrency: options.concurrency
|
|
1234
|
+
}
|
|
1235
|
+
],
|
|
1236
|
+
enabled: (options.enabled ?? true) && (input.items?.length ?? 0) > 0,
|
|
1237
|
+
queryFn: () => client.prices.matchByContextChunked(
|
|
1238
|
+
input,
|
|
1239
|
+
{
|
|
1240
|
+
...options.chunkSize !== void 0 ? { chunkSize: options.chunkSize } : {},
|
|
1241
|
+
...options.concurrency !== void 0 ? { concurrency: options.concurrency } : {}
|
|
1242
|
+
},
|
|
1243
|
+
ctx
|
|
1244
|
+
),
|
|
1245
|
+
staleTime: PRICES_STALE_TIME2
|
|
1246
|
+
});
|
|
1247
|
+
}
|
|
1198
1248
|
|
|
1199
1249
|
// src/hooks/use-product-media.ts
|
|
1200
1250
|
function useProductMedia(productId) {
|
|
@@ -1719,12 +1769,12 @@ function useUpdateSalesOrder() {
|
|
|
1719
1769
|
const qc = reactQuery.useQueryClient();
|
|
1720
1770
|
return reactQuery.useMutation({
|
|
1721
1771
|
mutationKey: ["emporix", "salesorders", "update"],
|
|
1722
|
-
mutationFn: async ({ orderId, patch, auth:
|
|
1723
|
-
if (!
|
|
1772
|
+
mutationFn: async ({ orderId, patch, auth: auth26, recalculate }) => {
|
|
1773
|
+
if (!auth26) throw new Error("useUpdateSalesOrder: requires an auth context");
|
|
1724
1774
|
return client.salesOrders.update(
|
|
1725
1775
|
orderId,
|
|
1726
1776
|
patch,
|
|
1727
|
-
|
|
1777
|
+
auth26,
|
|
1728
1778
|
recalculate !== void 0 ? { recalculate } : {}
|
|
1729
1779
|
);
|
|
1730
1780
|
},
|
|
@@ -1735,6 +1785,52 @@ function useUpdateSalesOrder() {
|
|
|
1735
1785
|
}
|
|
1736
1786
|
});
|
|
1737
1787
|
}
|
|
1788
|
+
var AVAILABILITY_STALE_TIME = 3e4;
|
|
1789
|
+
function useAvailability(productId, siteCode, options = {}) {
|
|
1790
|
+
const { client } = useEmporix();
|
|
1791
|
+
const ctx = options.customerToken ? emporixSdk.auth.customer(options.customerToken) : emporixSdk.auth.anonymous();
|
|
1792
|
+
return reactQuery.useQuery({
|
|
1793
|
+
queryKey: [
|
|
1794
|
+
"emporix",
|
|
1795
|
+
"availability",
|
|
1796
|
+
{
|
|
1797
|
+
tenant: client.tenant,
|
|
1798
|
+
productId,
|
|
1799
|
+
siteCode,
|
|
1800
|
+
anon: !options.customerToken,
|
|
1801
|
+
defaultAvailableOnNotFound: options.defaultAvailableOnNotFound ?? false
|
|
1802
|
+
}
|
|
1803
|
+
],
|
|
1804
|
+
enabled: (options.enabled ?? true) && Boolean(productId) && Boolean(siteCode),
|
|
1805
|
+
queryFn: () => client.availability.get(productId, siteCode, ctx, {
|
|
1806
|
+
defaultAvailableOnNotFound: options.defaultAvailableOnNotFound ?? false
|
|
1807
|
+
}),
|
|
1808
|
+
staleTime: AVAILABILITY_STALE_TIME
|
|
1809
|
+
});
|
|
1810
|
+
}
|
|
1811
|
+
var AVAILABILITY_STALE_TIME2 = 3e4;
|
|
1812
|
+
function useAvailabilities(productIds, siteCode, options = {}) {
|
|
1813
|
+
const { client } = useEmporix();
|
|
1814
|
+
const ctx = options.customerToken ? emporixSdk.auth.customer(options.customerToken) : emporixSdk.auth.anonymous();
|
|
1815
|
+
return reactQuery.useQuery({
|
|
1816
|
+
queryKey: [
|
|
1817
|
+
"emporix",
|
|
1818
|
+
"availabilities",
|
|
1819
|
+
{
|
|
1820
|
+
tenant: client.tenant,
|
|
1821
|
+
productIds,
|
|
1822
|
+
siteCode,
|
|
1823
|
+
anon: !options.customerToken,
|
|
1824
|
+
defaultAvailableOnNotFound: options.defaultAvailableOnNotFound ?? false
|
|
1825
|
+
}
|
|
1826
|
+
],
|
|
1827
|
+
enabled: (options.enabled ?? true) && productIds.length > 0 && Boolean(siteCode),
|
|
1828
|
+
queryFn: () => client.availability.getMany(productIds, siteCode, ctx, {
|
|
1829
|
+
defaultAvailableOnNotFound: options.defaultAvailableOnNotFound ?? false
|
|
1830
|
+
}),
|
|
1831
|
+
staleTime: AVAILABILITY_STALE_TIME2
|
|
1832
|
+
});
|
|
1833
|
+
}
|
|
1738
1834
|
var EmporixErrorBoundary = class extends react.Component {
|
|
1739
1835
|
state = { error: null };
|
|
1740
1836
|
static getDerivedStateFromError(error) {
|
|
@@ -1787,6 +1883,8 @@ exports.useActiveCart = useActiveCart;
|
|
|
1787
1883
|
exports.useActiveCompany = useActiveCompany;
|
|
1788
1884
|
exports.useAddressMutations = useAddressMutations;
|
|
1789
1885
|
exports.useAssignContact = useAssignContact;
|
|
1886
|
+
exports.useAvailabilities = useAvailabilities;
|
|
1887
|
+
exports.useAvailability = useAvailability;
|
|
1790
1888
|
exports.useCancelOrder = useCancelOrder;
|
|
1791
1889
|
exports.useCart = useCart;
|
|
1792
1890
|
exports.useCartMutations = useCartMutations;
|
|
@@ -1813,6 +1911,7 @@ exports.useEmporix = useEmporix;
|
|
|
1813
1911
|
exports.useEmporixErrorHandler = useEmporixErrorHandler;
|
|
1814
1912
|
exports.useEmporixTelemetry = useEmporixTelemetry;
|
|
1815
1913
|
exports.useMatchPrices = useMatchPrices;
|
|
1914
|
+
exports.useMatchPricesChunked = useMatchPricesChunked;
|
|
1816
1915
|
exports.useMyCompanies = useMyCompanies;
|
|
1817
1916
|
exports.useMyOrders = useMyOrders;
|
|
1818
1917
|
exports.useMyOrdersInfinite = useMyOrdersInfinite;
|
|
@@ -1845,5 +1944,6 @@ exports.useUpdateContactAssignment = useUpdateContactAssignment;
|
|
|
1845
1944
|
exports.useUpdateCustomer = useUpdateCustomer;
|
|
1846
1945
|
exports.useUpdateLocation = useUpdateLocation;
|
|
1847
1946
|
exports.useUpdateSalesOrder = useUpdateSalesOrder;
|
|
1947
|
+
exports.useVariantChildren = useVariantChildren;
|
|
1848
1948
|
//# sourceMappingURL=index.cjs.map
|
|
1849
1949
|
//# sourceMappingURL=index.cjs.map
|