@simpleapps-com/augur-hooks 1.0.8 → 1.0.9
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-CPPFLOLS.js → chunk-DDN6MAPI.js} +33 -1
- package/dist/chunk-DDN6MAPI.js.map +1 -0
- package/dist/{chunk-C7JC34SM.cjs → chunk-DYM6U3QO.cjs} +98 -66
- package/dist/chunk-DYM6U3QO.cjs.map +1 -0
- package/dist/{customer-quotes-Bdeo_I1q.d.cts → customer-quotes-DIpZNjT1.d.cts} +12 -2
- package/dist/{customer-quotes-Bdeo_I1q.d.ts → customer-quotes-DIpZNjT1.d.ts} +12 -2
- package/dist/index.cjs +175 -115
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +85 -15
- package/dist/index.d.ts +85 -15
- package/dist/index.js +111 -51
- package/dist/index.js.map +1 -1
- package/dist/server.cjs +6 -2
- package/dist/server.cjs.map +1 -1
- package/dist/server.d.cts +1 -1
- package/dist/server.d.ts +1 -1
- package/dist/server.js +5 -1
- package/dist/server.js.map +1 -1
- package/package.json +3 -3
- package/dist/chunk-C7JC34SM.cjs.map +0 -1
- package/dist/chunk-CPPFLOLS.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -40,8 +40,10 @@ import {
|
|
|
40
40
|
getProductSearchKey,
|
|
41
41
|
getProductSearchOptions,
|
|
42
42
|
getSearchSuggestionsKey,
|
|
43
|
-
getSearchSuggestionsOptions
|
|
44
|
-
|
|
43
|
+
getSearchSuggestionsOptions,
|
|
44
|
+
getStockKey,
|
|
45
|
+
getStockOptions
|
|
46
|
+
} from "./chunk-DDN6MAPI.js";
|
|
45
47
|
import {
|
|
46
48
|
useImageWithFallback
|
|
47
49
|
} from "./chunk-LTBEP4MC.js";
|
|
@@ -192,18 +194,36 @@ function useDebounce(value, delay = 500) {
|
|
|
192
194
|
}
|
|
193
195
|
|
|
194
196
|
// src/hooks/use-format-price.ts
|
|
195
|
-
function
|
|
197
|
+
function normaliseOptions(optionsOrLocale, legacyCurrency) {
|
|
198
|
+
if (typeof optionsOrLocale === "string") {
|
|
199
|
+
return { locale: optionsOrLocale, currency: legacyCurrency };
|
|
200
|
+
}
|
|
201
|
+
return optionsOrLocale ?? {};
|
|
202
|
+
}
|
|
203
|
+
function resolveFormatting(opts, siteFormatting) {
|
|
204
|
+
return {
|
|
205
|
+
locale: opts.locale ?? siteFormatting?.locale ?? "en-US",
|
|
206
|
+
currency: opts.currency ?? siteFormatting?.currency ?? "USD",
|
|
207
|
+
precision: opts.precision ?? siteFormatting?.precision ?? 2,
|
|
208
|
+
zeroLabel: opts.zeroLabel ?? siteFormatting?.zeroLabel
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
function useFormatPrice(optionsOrLocale, legacyCurrency) {
|
|
196
212
|
const site = useAugurSite();
|
|
197
|
-
const
|
|
198
|
-
const
|
|
199
|
-
const
|
|
200
|
-
|
|
201
|
-
|
|
213
|
+
const opts = normaliseOptions(optionsOrLocale, legacyCurrency);
|
|
214
|
+
const { locale, currency, precision: basePrecision, zeroLabel } = resolveFormatting(opts, site?.formatting);
|
|
215
|
+
const formatPrice = (price, callOptions) => {
|
|
216
|
+
const effectiveValue = price * (callOptions?.quantity ?? 1);
|
|
217
|
+
if (effectiveValue === 0 && zeroLabel !== void 0) {
|
|
218
|
+
return zeroLabel;
|
|
219
|
+
}
|
|
220
|
+
const precision = callOptions?.precision ?? basePrecision;
|
|
221
|
+
return new Intl.NumberFormat(locale, {
|
|
202
222
|
style: "currency",
|
|
203
|
-
currency
|
|
223
|
+
currency,
|
|
204
224
|
minimumFractionDigits: precision,
|
|
205
225
|
maximumFractionDigits: precision
|
|
206
|
-
}).format(
|
|
226
|
+
}).format(effectiveValue);
|
|
207
227
|
};
|
|
208
228
|
return { formatPrice };
|
|
209
229
|
}
|
|
@@ -314,8 +334,45 @@ function useInvMastStock(invMastUid, options = {}) {
|
|
|
314
334
|
};
|
|
315
335
|
}
|
|
316
336
|
|
|
337
|
+
// src/hooks/use-stock.ts
|
|
338
|
+
import { useMemo as useMemo3 } from "react";
|
|
339
|
+
import { useQuery as useQuery6 } from "@tanstack/react-query";
|
|
340
|
+
import { resolveStock } from "@simpleapps-com/augur-utils";
|
|
341
|
+
function useStock(invMastUid, options = {}) {
|
|
342
|
+
const api = useAugurApiOptional();
|
|
343
|
+
const callbacks = useAugurCallbacks();
|
|
344
|
+
const cache = useAugurCache();
|
|
345
|
+
const queryOpts = getStockOptions(api, invMastUid, cache);
|
|
346
|
+
const resolvedQueryFn = options.queryFn ?? (callbacks?.getStock ? () => callbacks.getStock(invMastUid) : void 0);
|
|
347
|
+
const query = useQuery6({
|
|
348
|
+
...queryOpts,
|
|
349
|
+
...resolvedQueryFn ? { queryFn: resolvedQueryFn } : {},
|
|
350
|
+
enabled: (options.enabled ?? true) && !!invMastUid,
|
|
351
|
+
retry: 3,
|
|
352
|
+
/* v8 ignore start */
|
|
353
|
+
retryDelay: (attemptIndex) => Math.min(1e3 * 2 ** attemptIndex, 1e4)
|
|
354
|
+
/* v8 ignore stop */
|
|
355
|
+
});
|
|
356
|
+
const resolved = useMemo3(
|
|
357
|
+
() => resolveStock({
|
|
358
|
+
stock: query.data ?? null,
|
|
359
|
+
companyKey: options.companyKey,
|
|
360
|
+
round: options.round,
|
|
361
|
+
lowStockThreshold: options.lowStockThreshold,
|
|
362
|
+
showQuantity: options.showQuantity
|
|
363
|
+
}),
|
|
364
|
+
[query.data, options.companyKey, options.round, options.lowStockThreshold, options.showQuantity]
|
|
365
|
+
);
|
|
366
|
+
return {
|
|
367
|
+
stock: query.data ?? null,
|
|
368
|
+
resolved,
|
|
369
|
+
loading: query.isLoading,
|
|
370
|
+
error: query.error
|
|
371
|
+
};
|
|
372
|
+
}
|
|
373
|
+
|
|
317
374
|
// src/hooks/use-batch-inv-mast-doc.ts
|
|
318
|
-
import { useQuery as
|
|
375
|
+
import { useQuery as useQuery7, useQueryClient } from "@tanstack/react-query";
|
|
319
376
|
function useBatchInvMastDoc(params, options = {}) {
|
|
320
377
|
const api = useAugurApiOptional();
|
|
321
378
|
const callbacks = useAugurCallbacks();
|
|
@@ -333,7 +390,7 @@ function useBatchInvMastDoc(params, options = {}) {
|
|
|
333
390
|
const fallbackOpts = getBatchInvMastDocOptions(api, uncached, includePricing, cache);
|
|
334
391
|
return fallbackOpts.queryFn();
|
|
335
392
|
};
|
|
336
|
-
const { data, isLoading, error } =
|
|
393
|
+
const { data, isLoading, error } = useQuery7({
|
|
337
394
|
queryKey: batchOpts.queryKey,
|
|
338
395
|
queryFn: () => executeBatchQuery({
|
|
339
396
|
params,
|
|
@@ -351,7 +408,7 @@ function useBatchInvMastDoc(params, options = {}) {
|
|
|
351
408
|
}
|
|
352
409
|
|
|
353
410
|
// src/hooks/use-product-category.ts
|
|
354
|
-
import { useQuery as
|
|
411
|
+
import { useQuery as useQuery8 } from "@tanstack/react-query";
|
|
355
412
|
function resolveData(data) {
|
|
356
413
|
return {
|
|
357
414
|
childrenTotal: data?.childrenTotal ?? 0,
|
|
@@ -370,7 +427,7 @@ function useProductCategory(itemCategoryUid, options = {}) {
|
|
|
370
427
|
queryFn: () => Promise.reject()
|
|
371
428
|
};
|
|
372
429
|
const resolvedQueryFn = options.queryFn ?? (callbacks?.getProductCategory ? () => callbacks.getProductCategory(itemCategoryUid) : void 0);
|
|
373
|
-
const { data, isLoading, error } =
|
|
430
|
+
const { data, isLoading, error } = useQuery8({
|
|
374
431
|
...baseOptions,
|
|
375
432
|
...resolvedQueryFn ? { queryFn: resolvedQueryFn } : {},
|
|
376
433
|
enabled: (options.enabled ?? true) && !!itemCategoryUid,
|
|
@@ -387,12 +444,12 @@ function useProductCategory(itemCategoryUid, options = {}) {
|
|
|
387
444
|
}
|
|
388
445
|
|
|
389
446
|
// src/hooks/use-item-details.ts
|
|
390
|
-
import { useQuery as
|
|
447
|
+
import { useQuery as useQuery9 } from "@tanstack/react-query";
|
|
391
448
|
function useItemDetails(itemId, options = {}) {
|
|
392
449
|
const api = useAugurApiOptional();
|
|
393
450
|
const callbacks = useAugurCallbacks();
|
|
394
451
|
const cache = useAugurCache();
|
|
395
|
-
const { data, isLoading, error } =
|
|
452
|
+
const { data, isLoading, error } = useQuery9({
|
|
396
453
|
...itemId ? getItemDetailsOptions(api, itemId, cache) : {
|
|
397
454
|
queryKey: getItemDetailsKey(""),
|
|
398
455
|
/* v8 ignore next */
|
|
@@ -415,12 +472,12 @@ function useItemDetails(itemId, options = {}) {
|
|
|
415
472
|
}
|
|
416
473
|
|
|
417
474
|
// src/hooks/use-item-attributes.ts
|
|
418
|
-
import { useQuery as
|
|
475
|
+
import { useQuery as useQuery10 } from "@tanstack/react-query";
|
|
419
476
|
function useItemAttributes(itemCategoryUid, options = {}) {
|
|
420
477
|
const api = useAugurApiOptional();
|
|
421
478
|
const callbacks = useAugurCallbacks();
|
|
422
479
|
const cache = useAugurCache();
|
|
423
|
-
const { data, isLoading, error } =
|
|
480
|
+
const { data, isLoading, error } = useQuery10({
|
|
424
481
|
...itemCategoryUid ? getItemAttributesOptions(api, itemCategoryUid, cache) : {
|
|
425
482
|
queryKey: getItemAttributesKey(null),
|
|
426
483
|
/* v8 ignore next */
|
|
@@ -441,13 +498,13 @@ function useItemAttributes(itemCategoryUid, options = {}) {
|
|
|
441
498
|
}
|
|
442
499
|
|
|
443
500
|
// src/hooks/use-product-search.ts
|
|
444
|
-
import { useQuery as
|
|
501
|
+
import { useQuery as useQuery11 } from "@tanstack/react-query";
|
|
445
502
|
function useProductSearch(pageData, options = {}) {
|
|
446
503
|
const api = useAugurApiOptional();
|
|
447
504
|
const callbacks = useAugurCallbacks();
|
|
448
505
|
const cache = useAugurCache();
|
|
449
506
|
const defaultOptions = getProductSearchOptions(api, pageData, cache);
|
|
450
|
-
const { data, isLoading, error } =
|
|
507
|
+
const { data, isLoading, error } = useQuery11({
|
|
451
508
|
...defaultOptions,
|
|
452
509
|
...options.queryFn ?? callbacks?.getProductSearch ? { queryFn: options.queryFn ?? (() => callbacks.getProductSearch(pageData)) } : {},
|
|
453
510
|
retry: 3,
|
|
@@ -464,7 +521,7 @@ function useProductSearch(pageData, options = {}) {
|
|
|
464
521
|
}
|
|
465
522
|
|
|
466
523
|
// src/hooks/use-search-suggestions.ts
|
|
467
|
-
import { useQuery as
|
|
524
|
+
import { useQuery as useQuery12 } from "@tanstack/react-query";
|
|
468
525
|
function useSearchSuggestions(query, options = {}) {
|
|
469
526
|
const api = useAugurApiOptional();
|
|
470
527
|
const callbacks = useAugurCallbacks();
|
|
@@ -473,7 +530,7 @@ function useSearchSuggestions(query, options = {}) {
|
|
|
473
530
|
const offset = options.offset ?? 0;
|
|
474
531
|
const enabled = (options.enabled ?? true) && query.trim().length > 0;
|
|
475
532
|
const defaultOptions = getSearchSuggestionsOptions(api, query, limit, offset, cache);
|
|
476
|
-
const { data, isLoading, error } =
|
|
533
|
+
const { data, isLoading, error } = useQuery12({
|
|
477
534
|
...defaultOptions,
|
|
478
535
|
...options.queryFn ?? callbacks?.getSearchSuggestions ? { queryFn: options.queryFn ?? (() => callbacks.getSearchSuggestions(query, limit, offset)) } : {},
|
|
479
536
|
enabled
|
|
@@ -670,8 +727,8 @@ function useCartActions(callbacks) {
|
|
|
670
727
|
}
|
|
671
728
|
|
|
672
729
|
// src/hooks/use-cart-initialization.ts
|
|
673
|
-
import { useEffect as useEffect2, useMemo as
|
|
674
|
-
import { useQuery as
|
|
730
|
+
import { useEffect as useEffect2, useMemo as useMemo4, useRef } from "react";
|
|
731
|
+
import { useQuery as useQuery13, useQueryClient as useQueryClient3 } from "@tanstack/react-query";
|
|
675
732
|
var MAX_RETRY_ATTEMPTS = 7;
|
|
676
733
|
var RETRY_DELAY_MS = 1e3;
|
|
677
734
|
function useCartInitialization(session, callbacks) {
|
|
@@ -684,7 +741,7 @@ function useCartInitialization(session, callbacks) {
|
|
|
684
741
|
const effectiveStatus = session.status;
|
|
685
742
|
const effectiveUserId = session.userId ?? auth?.userId;
|
|
686
743
|
const effectiveCartHdrUid = session.cartHdrUid ?? auth?.cartHdrUid;
|
|
687
|
-
const effectiveSession =
|
|
744
|
+
const effectiveSession = useMemo4(
|
|
688
745
|
() => ({ status: effectiveStatus, userId: effectiveUserId, cartHdrUid: effectiveCartHdrUid }),
|
|
689
746
|
[effectiveStatus, effectiveUserId, effectiveCartHdrUid]
|
|
690
747
|
);
|
|
@@ -752,7 +809,7 @@ function useCartInitialization(session, callbacks) {
|
|
|
752
809
|
initializeGuestCart();
|
|
753
810
|
}
|
|
754
811
|
}, [effectiveSession, cartHdrUid, setCartHdrUid, callbacks]);
|
|
755
|
-
const { data: cartLinesData } =
|
|
812
|
+
const { data: cartLinesData } = useQuery13({
|
|
756
813
|
queryKey: ["cartLines", cartHdrUid],
|
|
757
814
|
queryFn: async () => await callbacks.getCartLines(Number(cartHdrUid)) ?? [],
|
|
758
815
|
enabled: !!cartHdrUid
|
|
@@ -770,7 +827,7 @@ function useCartInitialization(session, callbacks) {
|
|
|
770
827
|
}
|
|
771
828
|
|
|
772
829
|
// src/hooks/use-cart-pricing.ts
|
|
773
|
-
import { useMemo as
|
|
830
|
+
import { useMemo as useMemo5 } from "react";
|
|
774
831
|
import { useQueries } from "@tanstack/react-query";
|
|
775
832
|
import { derivePrice as derivePrice2 } from "@simpleapps-com/augur-utils";
|
|
776
833
|
function useCartPricing(options = {}) {
|
|
@@ -797,7 +854,7 @@ function useCartPricing(options = {}) {
|
|
|
797
854
|
};
|
|
798
855
|
})
|
|
799
856
|
});
|
|
800
|
-
const prices =
|
|
857
|
+
const prices = useMemo5(() => {
|
|
801
858
|
const map = {};
|
|
802
859
|
cartLines.forEach((line, index) => {
|
|
803
860
|
const queryResult = priceQueries[index];
|
|
@@ -811,17 +868,17 @@ function useCartPricing(options = {}) {
|
|
|
811
868
|
});
|
|
812
869
|
return map;
|
|
813
870
|
}, [cartLines, priceQueries]);
|
|
814
|
-
const getUnitPrice =
|
|
871
|
+
const getUnitPrice = useMemo5(() => {
|
|
815
872
|
return (itemId) => {
|
|
816
873
|
return prices[itemId?.toUpperCase()]?.unitPrice ?? 0;
|
|
817
874
|
};
|
|
818
875
|
}, [prices]);
|
|
819
|
-
const getItemTotal =
|
|
876
|
+
const getItemTotal = useMemo5(() => {
|
|
820
877
|
return (itemId, quantity) => {
|
|
821
878
|
return getUnitPrice(itemId) * quantity;
|
|
822
879
|
};
|
|
823
880
|
}, [getUnitPrice]);
|
|
824
|
-
const subtotal =
|
|
881
|
+
const subtotal = useMemo5(() => {
|
|
825
882
|
return cartLines.reduce((sum, line) => {
|
|
826
883
|
const unitPrice = prices[line.itemId.toUpperCase()]?.unitPrice ?? 0;
|
|
827
884
|
return sum + unitPrice * line.quantity;
|
|
@@ -939,12 +996,12 @@ function useItemSearchInfinite(itemsFilters, itemCategoryUid, options = {}) {
|
|
|
939
996
|
}
|
|
940
997
|
|
|
941
998
|
// src/hooks/use-joomla-content.ts
|
|
942
|
-
import { useQuery as
|
|
999
|
+
import { useQuery as useQuery14 } from "@tanstack/react-query";
|
|
943
1000
|
function useJoomlaContent(articleId, options = {}) {
|
|
944
1001
|
const api = useAugurApiOptional();
|
|
945
1002
|
const callbacks = useAugurCallbacks();
|
|
946
1003
|
const cache = useAugurCache();
|
|
947
|
-
const { data, isLoading, error } =
|
|
1004
|
+
const { data, isLoading, error } = useQuery14({
|
|
948
1005
|
...articleId ? getJoomlaContentOptions(api, articleId, cache) : {
|
|
949
1006
|
queryKey: getJoomlaContentKey(""),
|
|
950
1007
|
/* v8 ignore next */
|
|
@@ -961,12 +1018,12 @@ function useJoomlaContent(articleId, options = {}) {
|
|
|
961
1018
|
}
|
|
962
1019
|
|
|
963
1020
|
// src/hooks/use-joomla-content-list.ts
|
|
964
|
-
import { useQuery as
|
|
1021
|
+
import { useQuery as useQuery15 } from "@tanstack/react-query";
|
|
965
1022
|
function useJoomlaContentList(categoryId, options = {}) {
|
|
966
1023
|
const api = useAugurApiOptional();
|
|
967
1024
|
const callbacks = useAugurCallbacks();
|
|
968
1025
|
const cache = useAugurCache();
|
|
969
|
-
const { data, isLoading, error } =
|
|
1026
|
+
const { data, isLoading, error } = useQuery15({
|
|
970
1027
|
...categoryId ? getJoomlaContentListOptions(api, categoryId, options.filters, cache) : {
|
|
971
1028
|
queryKey: getJoomlaContentListKey(""),
|
|
972
1029
|
/* v8 ignore next */
|
|
@@ -985,12 +1042,12 @@ function useJoomlaContentList(categoryId, options = {}) {
|
|
|
985
1042
|
}
|
|
986
1043
|
|
|
987
1044
|
// src/hooks/use-joomla-menu.ts
|
|
988
|
-
import { useQuery as
|
|
1045
|
+
import { useQuery as useQuery16 } from "@tanstack/react-query";
|
|
989
1046
|
function useJoomlaMenu(options = {}) {
|
|
990
1047
|
const api = useAugurApiOptional();
|
|
991
1048
|
const callbacks = useAugurCallbacks();
|
|
992
1049
|
const cache = useAugurCache();
|
|
993
|
-
const { data, isLoading, error } =
|
|
1050
|
+
const { data, isLoading, error } = useQuery16({
|
|
994
1051
|
...getJoomlaMenuOptions(api, options.filters, cache),
|
|
995
1052
|
...options.queryFn ?? callbacks?.getJoomlaMenu ? {
|
|
996
1053
|
queryFn: options.queryFn ?? (() => callbacks.getJoomlaMenu(options.filters))
|
|
@@ -1005,12 +1062,12 @@ function useJoomlaMenu(options = {}) {
|
|
|
1005
1062
|
}
|
|
1006
1063
|
|
|
1007
1064
|
// src/hooks/use-joomla-menu-doc.ts
|
|
1008
|
-
import { useQuery as
|
|
1065
|
+
import { useQuery as useQuery17 } from "@tanstack/react-query";
|
|
1009
1066
|
function useJoomlaMenuDoc(menuId, options = {}) {
|
|
1010
1067
|
const api = useAugurApiOptional();
|
|
1011
1068
|
const callbacks = useAugurCallbacks();
|
|
1012
1069
|
const cache = useAugurCache();
|
|
1013
|
-
const { data, isLoading, error } =
|
|
1070
|
+
const { data, isLoading, error } = useQuery17({
|
|
1014
1071
|
...menuId ? getJoomlaMenuDocOptions(api, menuId, cache) : {
|
|
1015
1072
|
queryKey: getJoomlaMenuDocKey(""),
|
|
1016
1073
|
/* v8 ignore next */
|
|
@@ -1027,7 +1084,7 @@ function useJoomlaMenuDoc(menuId, options = {}) {
|
|
|
1027
1084
|
}
|
|
1028
1085
|
|
|
1029
1086
|
// src/hooks/use-customer-orders.ts
|
|
1030
|
-
import { useQuery as
|
|
1087
|
+
import { useQuery as useQuery18 } from "@tanstack/react-query";
|
|
1031
1088
|
var EMPTY_LIST = { data: [], total: 0 };
|
|
1032
1089
|
function useCustomerOrders(customerId, params, options = {}) {
|
|
1033
1090
|
const callbacks = useAugurCallbacks();
|
|
@@ -1036,7 +1093,7 @@ function useCustomerOrders(customerId, params, options = {}) {
|
|
|
1036
1093
|
const effectiveCustomerId = customerId ?? auth?.customerId ?? site?.defaults?.customerId;
|
|
1037
1094
|
const resolvedQueryFn = options.queryFn ?? (callbacks?.getCustomerOrders ? () => callbacks.getCustomerOrders(effectiveCustomerId, params) : void 0);
|
|
1038
1095
|
const enabled = (options.enabled ?? true) && !!effectiveCustomerId && !!resolvedQueryFn;
|
|
1039
|
-
const { data, isLoading, error } =
|
|
1096
|
+
const { data, isLoading, error } = useQuery18({
|
|
1040
1097
|
queryKey: getCustomerOrdersKey(effectiveCustomerId, params),
|
|
1041
1098
|
queryFn: resolvedQueryFn,
|
|
1042
1099
|
enabled
|
|
@@ -1056,7 +1113,7 @@ function useOrderDetail(customerId, orderId, options = {}) {
|
|
|
1056
1113
|
const effectiveCustomerId = customerId ?? auth?.customerId ?? site?.defaults?.customerId;
|
|
1057
1114
|
const resolvedQueryFn = options.queryFn ?? (callbacks?.getCustomerOrderDetail ? () => callbacks.getCustomerOrderDetail(effectiveCustomerId, orderId) : void 0);
|
|
1058
1115
|
const enabled = (options.enabled ?? true) && !!effectiveCustomerId && !!orderId && !!resolvedQueryFn;
|
|
1059
|
-
const { data, isLoading, error } =
|
|
1116
|
+
const { data, isLoading, error } = useQuery18({
|
|
1060
1117
|
queryKey: getCustomerOrderDetailKey(effectiveCustomerId, orderId),
|
|
1061
1118
|
queryFn: resolvedQueryFn,
|
|
1062
1119
|
enabled
|
|
@@ -1069,7 +1126,7 @@ function useOrderDetail(customerId, orderId, options = {}) {
|
|
|
1069
1126
|
}
|
|
1070
1127
|
|
|
1071
1128
|
// src/hooks/use-customer-invoices.ts
|
|
1072
|
-
import { useQuery as
|
|
1129
|
+
import { useQuery as useQuery19 } from "@tanstack/react-query";
|
|
1073
1130
|
var EMPTY_LIST2 = { data: [], total: 0 };
|
|
1074
1131
|
function useCustomerInvoices(customerId, params, options = {}) {
|
|
1075
1132
|
const callbacks = useAugurCallbacks();
|
|
@@ -1078,7 +1135,7 @@ function useCustomerInvoices(customerId, params, options = {}) {
|
|
|
1078
1135
|
const effectiveCustomerId = customerId ?? auth?.customerId ?? site?.defaults?.customerId;
|
|
1079
1136
|
const resolvedQueryFn = options.queryFn ?? (callbacks?.getCustomerInvoices ? () => callbacks.getCustomerInvoices(effectiveCustomerId, params) : void 0);
|
|
1080
1137
|
const enabled = (options.enabled ?? true) && !!effectiveCustomerId && !!resolvedQueryFn;
|
|
1081
|
-
const { data, isLoading, error } =
|
|
1138
|
+
const { data, isLoading, error } = useQuery19({
|
|
1082
1139
|
queryKey: getCustomerInvoicesKey(effectiveCustomerId, params),
|
|
1083
1140
|
queryFn: resolvedQueryFn,
|
|
1084
1141
|
enabled
|
|
@@ -1098,7 +1155,7 @@ function useInvoiceDetail(customerId, invoiceNo, options = {}) {
|
|
|
1098
1155
|
const effectiveCustomerId = customerId ?? auth?.customerId ?? site?.defaults?.customerId;
|
|
1099
1156
|
const resolvedQueryFn = options.queryFn ?? (callbacks?.getCustomerInvoiceDetail ? () => callbacks.getCustomerInvoiceDetail(effectiveCustomerId, invoiceNo) : void 0);
|
|
1100
1157
|
const enabled = (options.enabled ?? true) && !!effectiveCustomerId && !!invoiceNo && !!resolvedQueryFn;
|
|
1101
|
-
const { data, isLoading, error } =
|
|
1158
|
+
const { data, isLoading, error } = useQuery19({
|
|
1102
1159
|
queryKey: getCustomerInvoiceDetailKey(effectiveCustomerId, invoiceNo),
|
|
1103
1160
|
queryFn: resolvedQueryFn,
|
|
1104
1161
|
enabled
|
|
@@ -1111,7 +1168,7 @@ function useInvoiceDetail(customerId, invoiceNo, options = {}) {
|
|
|
1111
1168
|
}
|
|
1112
1169
|
|
|
1113
1170
|
// src/hooks/use-customer-quotes.ts
|
|
1114
|
-
import { useQuery as
|
|
1171
|
+
import { useQuery as useQuery20 } from "@tanstack/react-query";
|
|
1115
1172
|
var EMPTY_LIST3 = { data: [], total: 0 };
|
|
1116
1173
|
function useCustomerQuotes(customerId, params, options = {}) {
|
|
1117
1174
|
const callbacks = useAugurCallbacks();
|
|
@@ -1120,7 +1177,7 @@ function useCustomerQuotes(customerId, params, options = {}) {
|
|
|
1120
1177
|
const effectiveCustomerId = customerId ?? auth?.customerId ?? site?.defaults?.customerId;
|
|
1121
1178
|
const resolvedQueryFn = options.queryFn ?? (callbacks?.getCustomerQuotes ? () => callbacks.getCustomerQuotes(effectiveCustomerId, params) : void 0);
|
|
1122
1179
|
const enabled = (options.enabled ?? true) && !!effectiveCustomerId && !!resolvedQueryFn;
|
|
1123
|
-
const { data, isLoading, error } =
|
|
1180
|
+
const { data, isLoading, error } = useQuery20({
|
|
1124
1181
|
queryKey: getCustomerQuotesKey(effectiveCustomerId, params),
|
|
1125
1182
|
queryFn: resolvedQueryFn,
|
|
1126
1183
|
enabled
|
|
@@ -1140,7 +1197,7 @@ function useQuoteDetail(customerId, quoteNo, options = {}) {
|
|
|
1140
1197
|
const effectiveCustomerId = customerId ?? auth?.customerId ?? site?.defaults?.customerId;
|
|
1141
1198
|
const resolvedQueryFn = options.queryFn ?? (callbacks?.getCustomerQuoteDetail ? () => callbacks.getCustomerQuoteDetail(effectiveCustomerId, quoteNo) : void 0);
|
|
1142
1199
|
const enabled = (options.enabled ?? true) && !!effectiveCustomerId && !!quoteNo && !!resolvedQueryFn;
|
|
1143
|
-
const { data, isLoading, error } =
|
|
1200
|
+
const { data, isLoading, error } = useQuery20({
|
|
1144
1201
|
queryKey: getCustomerQuoteDetailKey(effectiveCustomerId, quoteNo),
|
|
1145
1202
|
queryFn: resolvedQueryFn,
|
|
1146
1203
|
enabled
|
|
@@ -1226,7 +1283,7 @@ function createSiteHooks(config = {}) {
|
|
|
1226
1283
|
}
|
|
1227
1284
|
|
|
1228
1285
|
// src/persistence/use-persistence.ts
|
|
1229
|
-
import { useState as useState2, useEffect as useEffect4, useMemo as
|
|
1286
|
+
import { useState as useState2, useEffect as useEffect4, useMemo as useMemo6 } from "react";
|
|
1230
1287
|
|
|
1231
1288
|
// src/persistence/serializer.ts
|
|
1232
1289
|
function serialize(data) {
|
|
@@ -1371,7 +1428,7 @@ function useAugurPersistence(config) {
|
|
|
1371
1428
|
useStorageMonitor(config);
|
|
1372
1429
|
const isDev = typeof process !== "undefined" && process.env?.NODE_ENV === "development";
|
|
1373
1430
|
const { persistableKeys } = config;
|
|
1374
|
-
const dehydrateOptions =
|
|
1431
|
+
const dehydrateOptions = useMemo6(() => ({
|
|
1375
1432
|
shouldDehydrateQuery: (query) => {
|
|
1376
1433
|
const key = query.queryKey;
|
|
1377
1434
|
if (!Array.isArray(key) || key.length === 0) return false;
|
|
@@ -1431,6 +1488,8 @@ export {
|
|
|
1431
1488
|
getProductSearchOptions,
|
|
1432
1489
|
getSearchSuggestionsKey,
|
|
1433
1490
|
getSearchSuggestionsOptions,
|
|
1491
|
+
getStockKey,
|
|
1492
|
+
getStockOptions,
|
|
1434
1493
|
useAugurApi,
|
|
1435
1494
|
useAugurApiOptional,
|
|
1436
1495
|
useAugurAuth,
|
|
@@ -1475,6 +1534,7 @@ export {
|
|
|
1475
1534
|
useQuoteDetail,
|
|
1476
1535
|
useSearchSuggestions,
|
|
1477
1536
|
useSetCartHdrUid,
|
|
1478
|
-
useSetCartLines
|
|
1537
|
+
useSetCartLines,
|
|
1538
|
+
useStock
|
|
1479
1539
|
};
|
|
1480
1540
|
//# sourceMappingURL=index.js.map
|