@simpleapps-com/augur-hooks 1.0.7 → 1.0.8
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/{customer-quotes-G2WMZu_X.d.cts → customer-quotes-Bdeo_I1q.d.cts} +10 -3
- package/dist/{customer-quotes-G2WMZu_X.d.ts → customer-quotes-Bdeo_I1q.d.ts} +10 -3
- package/dist/index.cjs +129 -94
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -4
- package/dist/index.d.ts +5 -4
- package/dist/index.js +73 -38
- package/dist/index.js.map +1 -1
- package/dist/server.d.cts +1 -1
- package/dist/server.d.ts +1 -1
- package/package.json +3 -3
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { G as GetItemCategoryApiOptions, B as BatchInvMastDocParam, P as PageData, S as SearchSuggestionsResponse, a as SearchSuggestion, A as AugurCallbacks, b as AugurApiClient, c as PersistenceConfig } from './customer-quotes-
|
|
2
|
-
export { d as AugurHooksProvider, e as BatchQueryConfig, f as executeBatchQuery, g as getBatchInvMastDocKey, h as getBatchInvMastDocOptions, i as getCartPricingQueryOptions, j as getCategoryItemsInfiniteKey, k as getCategoryItemsInfiniteOptions, l as getCustomerInvoiceDetailKey, m as getCustomerInvoicesKey, n as getCustomerOrderDetailKey, o as getCustomerOrdersKey, p as getCustomerQuoteDetailKey, q as getCustomerQuotesKey, r as getInvMastDocKey, s as getInvMastDocOptions, t as getInvMastKey, u as getInvMastOptions, v as getInvMastStockKey, w as getInvMastStockOptions, x as getItemAttributesKey, y as getItemAttributesOptions, z as getItemCategoryKey, C as getItemCategoryOptions, D as getItemDetailsKey, E as getItemDetailsOptions, F as getItemPriceKey, H as getItemPriceOptions, I as getItemSearchInfiniteKey, J as getItemSearchInfiniteOptions, K as getJoomlaContentKey, L as getJoomlaContentListKey, M as getJoomlaContentListOptions, N as getJoomlaContentOptions, O as getJoomlaMenuDocKey, Q as getJoomlaMenuDocOptions, R as getJoomlaMenuKey, T as getJoomlaMenuOptions, U as getProductCategoryKey, V as getProductCategoryOptions, W as getProductSearchKey, X as getProductSearchOptions, Y as getSearchSuggestionsKey, Z as getSearchSuggestionsOptions, _ as useAugurApi, $ as useAugurApiOptional, a0 as useAugurAuth, a1 as useAugurCache, a2 as useAugurOptions } from './customer-quotes-
|
|
1
|
+
import { G as GetItemCategoryApiOptions, B as BatchInvMastDocParam, P as PageData, S as SearchSuggestionsResponse, a as SearchSuggestion, A as AugurCallbacks, b as AugurApiClient, c as PersistenceConfig } from './customer-quotes-Bdeo_I1q.cjs';
|
|
2
|
+
export { d as AugurHooksProvider, e as BatchQueryConfig, f as executeBatchQuery, g as getBatchInvMastDocKey, h as getBatchInvMastDocOptions, i as getCartPricingQueryOptions, j as getCategoryItemsInfiniteKey, k as getCategoryItemsInfiniteOptions, l as getCustomerInvoiceDetailKey, m as getCustomerInvoicesKey, n as getCustomerOrderDetailKey, o as getCustomerOrdersKey, p as getCustomerQuoteDetailKey, q as getCustomerQuotesKey, r as getInvMastDocKey, s as getInvMastDocOptions, t as getInvMastKey, u as getInvMastOptions, v as getInvMastStockKey, w as getInvMastStockOptions, x as getItemAttributesKey, y as getItemAttributesOptions, z as getItemCategoryKey, C as getItemCategoryOptions, D as getItemDetailsKey, E as getItemDetailsOptions, F as getItemPriceKey, H as getItemPriceOptions, I as getItemSearchInfiniteKey, J as getItemSearchInfiniteOptions, K as getJoomlaContentKey, L as getJoomlaContentListKey, M as getJoomlaContentListOptions, N as getJoomlaContentOptions, O as getJoomlaMenuDocKey, Q as getJoomlaMenuDocOptions, R as getJoomlaMenuKey, T as getJoomlaMenuOptions, U as getProductCategoryKey, V as getProductCategoryOptions, W as getProductSearchKey, X as getProductSearchOptions, Y as getSearchSuggestionsKey, Z as getSearchSuggestionsOptions, _ as useAugurApi, $ as useAugurApiOptional, a0 as useAugurAuth, a1 as useAugurCache, a2 as useAugurOptions, a3 as useAugurSite } from './customer-quotes-Bdeo_I1q.cjs';
|
|
3
3
|
import { InfiniteScrollPage, CacheConfig, AugurAuthContext } from '@simpleapps-com/augur-core';
|
|
4
|
-
export { AugurAuthContext, CacheConfig, CacheProvider, CacheTierConfig, DeepQueryOptions, EdgeCacheValue, InfiniteScrollPage, ProxyMutationOptions, ProxyQueryOptions } from '@simpleapps-com/augur-core';
|
|
4
|
+
export { AugurAuthContext, AugurSiteConfig, AugurSiteDefaults, AugurSiteFormatting, CacheConfig, CacheProvider, CacheTierConfig, DeepQueryOptions, EdgeCacheValue, InfiniteScrollPage, ProxyMutationOptions, ProxyQueryOptions } from '@simpleapps-com/augur-core';
|
|
5
5
|
import * as zustand from 'zustand';
|
|
6
6
|
import * as _simpleapps_com_augur_utils from '@simpleapps-com/augur-utils';
|
|
7
7
|
import { TCartLine, TItemsFilters, TPriceData, TInvMastDoc, TCategory, TItemDetails, TAttribute, TJoomlaContent, TJoomlaContentFilters, MenuItem, TMenuFilters, ImageConfig, ImageUrlOptions } from '@simpleapps-com/augur-utils';
|
|
@@ -78,7 +78,8 @@ declare function useDebounce<T>(value: T, delay?: number): T;
|
|
|
78
78
|
|
|
79
79
|
/**
|
|
80
80
|
* Hook that returns a price formatter.
|
|
81
|
-
*
|
|
81
|
+
* Reads defaults from site config when params are omitted.
|
|
82
|
+
* Explicit params override site config.
|
|
82
83
|
*/
|
|
83
84
|
declare function useFormatPrice(locale?: string, currency?: string): {
|
|
84
85
|
formatPrice: (price: number) => string;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { G as GetItemCategoryApiOptions, B as BatchInvMastDocParam, P as PageData, S as SearchSuggestionsResponse, a as SearchSuggestion, A as AugurCallbacks, b as AugurApiClient, c as PersistenceConfig } from './customer-quotes-
|
|
2
|
-
export { d as AugurHooksProvider, e as BatchQueryConfig, f as executeBatchQuery, g as getBatchInvMastDocKey, h as getBatchInvMastDocOptions, i as getCartPricingQueryOptions, j as getCategoryItemsInfiniteKey, k as getCategoryItemsInfiniteOptions, l as getCustomerInvoiceDetailKey, m as getCustomerInvoicesKey, n as getCustomerOrderDetailKey, o as getCustomerOrdersKey, p as getCustomerQuoteDetailKey, q as getCustomerQuotesKey, r as getInvMastDocKey, s as getInvMastDocOptions, t as getInvMastKey, u as getInvMastOptions, v as getInvMastStockKey, w as getInvMastStockOptions, x as getItemAttributesKey, y as getItemAttributesOptions, z as getItemCategoryKey, C as getItemCategoryOptions, D as getItemDetailsKey, E as getItemDetailsOptions, F as getItemPriceKey, H as getItemPriceOptions, I as getItemSearchInfiniteKey, J as getItemSearchInfiniteOptions, K as getJoomlaContentKey, L as getJoomlaContentListKey, M as getJoomlaContentListOptions, N as getJoomlaContentOptions, O as getJoomlaMenuDocKey, Q as getJoomlaMenuDocOptions, R as getJoomlaMenuKey, T as getJoomlaMenuOptions, U as getProductCategoryKey, V as getProductCategoryOptions, W as getProductSearchKey, X as getProductSearchOptions, Y as getSearchSuggestionsKey, Z as getSearchSuggestionsOptions, _ as useAugurApi, $ as useAugurApiOptional, a0 as useAugurAuth, a1 as useAugurCache, a2 as useAugurOptions } from './customer-quotes-
|
|
1
|
+
import { G as GetItemCategoryApiOptions, B as BatchInvMastDocParam, P as PageData, S as SearchSuggestionsResponse, a as SearchSuggestion, A as AugurCallbacks, b as AugurApiClient, c as PersistenceConfig } from './customer-quotes-Bdeo_I1q.js';
|
|
2
|
+
export { d as AugurHooksProvider, e as BatchQueryConfig, f as executeBatchQuery, g as getBatchInvMastDocKey, h as getBatchInvMastDocOptions, i as getCartPricingQueryOptions, j as getCategoryItemsInfiniteKey, k as getCategoryItemsInfiniteOptions, l as getCustomerInvoiceDetailKey, m as getCustomerInvoicesKey, n as getCustomerOrderDetailKey, o as getCustomerOrdersKey, p as getCustomerQuoteDetailKey, q as getCustomerQuotesKey, r as getInvMastDocKey, s as getInvMastDocOptions, t as getInvMastKey, u as getInvMastOptions, v as getInvMastStockKey, w as getInvMastStockOptions, x as getItemAttributesKey, y as getItemAttributesOptions, z as getItemCategoryKey, C as getItemCategoryOptions, D as getItemDetailsKey, E as getItemDetailsOptions, F as getItemPriceKey, H as getItemPriceOptions, I as getItemSearchInfiniteKey, J as getItemSearchInfiniteOptions, K as getJoomlaContentKey, L as getJoomlaContentListKey, M as getJoomlaContentListOptions, N as getJoomlaContentOptions, O as getJoomlaMenuDocKey, Q as getJoomlaMenuDocOptions, R as getJoomlaMenuKey, T as getJoomlaMenuOptions, U as getProductCategoryKey, V as getProductCategoryOptions, W as getProductSearchKey, X as getProductSearchOptions, Y as getSearchSuggestionsKey, Z as getSearchSuggestionsOptions, _ as useAugurApi, $ as useAugurApiOptional, a0 as useAugurAuth, a1 as useAugurCache, a2 as useAugurOptions, a3 as useAugurSite } from './customer-quotes-Bdeo_I1q.js';
|
|
3
3
|
import { InfiniteScrollPage, CacheConfig, AugurAuthContext } from '@simpleapps-com/augur-core';
|
|
4
|
-
export { AugurAuthContext, CacheConfig, CacheProvider, CacheTierConfig, DeepQueryOptions, EdgeCacheValue, InfiniteScrollPage, ProxyMutationOptions, ProxyQueryOptions } from '@simpleapps-com/augur-core';
|
|
4
|
+
export { AugurAuthContext, AugurSiteConfig, AugurSiteDefaults, AugurSiteFormatting, CacheConfig, CacheProvider, CacheTierConfig, DeepQueryOptions, EdgeCacheValue, InfiniteScrollPage, ProxyMutationOptions, ProxyQueryOptions } from '@simpleapps-com/augur-core';
|
|
5
5
|
import * as zustand from 'zustand';
|
|
6
6
|
import * as _simpleapps_com_augur_utils from '@simpleapps-com/augur-utils';
|
|
7
7
|
import { TCartLine, TItemsFilters, TPriceData, TInvMastDoc, TCategory, TItemDetails, TAttribute, TJoomlaContent, TJoomlaContentFilters, MenuItem, TMenuFilters, ImageConfig, ImageUrlOptions } from '@simpleapps-com/augur-utils';
|
|
@@ -78,7 +78,8 @@ declare function useDebounce<T>(value: T, delay?: number): T;
|
|
|
78
78
|
|
|
79
79
|
/**
|
|
80
80
|
* Hook that returns a price formatter.
|
|
81
|
-
*
|
|
81
|
+
* Reads defaults from site config when params are omitted.
|
|
82
|
+
* Explicit params override site config.
|
|
82
83
|
*/
|
|
83
84
|
declare function useFormatPrice(locale?: string, currency?: string): {
|
|
84
85
|
formatPrice: (price: number) => string;
|
package/dist/index.js
CHANGED
|
@@ -59,11 +59,13 @@ var AugurAuthReactContext = createContext(
|
|
|
59
59
|
);
|
|
60
60
|
var AugurCacheContext = createContext(void 0);
|
|
61
61
|
var AugurOptionsContext = createContext(null);
|
|
62
|
+
var AugurSiteContext = createContext(void 0);
|
|
62
63
|
function AugurHooksProvider({
|
|
63
64
|
api,
|
|
64
65
|
callbacks,
|
|
65
66
|
auth,
|
|
66
67
|
cache,
|
|
68
|
+
site,
|
|
67
69
|
children
|
|
68
70
|
}) {
|
|
69
71
|
if (process.env.NODE_ENV === "development" && !api && !callbacks) {
|
|
@@ -77,7 +79,7 @@ function AugurHooksProvider({
|
|
|
77
79
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
78
80
|
[api]
|
|
79
81
|
);
|
|
80
|
-
return /* @__PURE__ */ jsx(AugurApiContext.Provider, { value: api ?? null, children: /* @__PURE__ */ jsx(AugurCallbacksContext.Provider, { value: callbacks, children: /* @__PURE__ */ jsx(AugurAuthReactContext.Provider, { value: auth, children: /* @__PURE__ */ jsx(AugurCacheContext.Provider, { value: cache, children: /* @__PURE__ */ jsx(AugurOptionsContext.Provider, { value: options, children }) }) }) }) });
|
|
82
|
+
return /* @__PURE__ */ jsx(AugurApiContext.Provider, { value: api ?? null, children: /* @__PURE__ */ jsx(AugurCallbacksContext.Provider, { value: callbacks, children: /* @__PURE__ */ jsx(AugurAuthReactContext.Provider, { value: auth, children: /* @__PURE__ */ jsx(AugurCacheContext.Provider, { value: cache, children: /* @__PURE__ */ jsx(AugurSiteContext.Provider, { value: site, children: /* @__PURE__ */ jsx(AugurOptionsContext.Provider, { value: options, children }) }) }) }) }) });
|
|
81
83
|
}
|
|
82
84
|
function useAugurOptions() {
|
|
83
85
|
const options = useContext(AugurOptionsContext);
|
|
@@ -109,6 +111,9 @@ function useAugurAuth() {
|
|
|
109
111
|
function useAugurCache() {
|
|
110
112
|
return useContext(AugurCacheContext);
|
|
111
113
|
}
|
|
114
|
+
function useAugurSite() {
|
|
115
|
+
return useContext(AugurSiteContext);
|
|
116
|
+
}
|
|
112
117
|
|
|
113
118
|
// src/stores/cart-store.ts
|
|
114
119
|
import { create } from "zustand";
|
|
@@ -187,12 +192,17 @@ function useDebounce(value, delay = 500) {
|
|
|
187
192
|
}
|
|
188
193
|
|
|
189
194
|
// src/hooks/use-format-price.ts
|
|
190
|
-
function useFormatPrice(locale
|
|
195
|
+
function useFormatPrice(locale, currency) {
|
|
196
|
+
const site = useAugurSite();
|
|
197
|
+
const effectiveLocale = locale ?? site?.formatting?.locale ?? "en-US";
|
|
198
|
+
const effectiveCurrency = currency ?? site?.formatting?.currency ?? "USD";
|
|
199
|
+
const precision = site?.formatting?.precision ?? 2;
|
|
191
200
|
const formatPrice = (price) => {
|
|
192
|
-
return new Intl.NumberFormat(
|
|
201
|
+
return new Intl.NumberFormat(effectiveLocale, {
|
|
193
202
|
style: "currency",
|
|
194
|
-
currency,
|
|
195
|
-
minimumFractionDigits:
|
|
203
|
+
currency: effectiveCurrency,
|
|
204
|
+
minimumFractionDigits: precision,
|
|
205
|
+
maximumFractionDigits: precision
|
|
196
206
|
}).format(price);
|
|
197
207
|
};
|
|
198
208
|
return { formatPrice };
|
|
@@ -207,7 +217,8 @@ function useItemPrice(itemId, customerId, quantity = 1, options = {}) {
|
|
|
207
217
|
const callbacks = useAugurCallbacks();
|
|
208
218
|
const auth = useAugurAuth();
|
|
209
219
|
const cache = useAugurCache();
|
|
210
|
-
const
|
|
220
|
+
const site = useAugurSite();
|
|
221
|
+
const effectiveCustomerId = customerId ?? auth?.customerId ?? site?.defaults?.customerId;
|
|
211
222
|
const defaultOptions = getItemPriceOptions(api, itemId, effectiveCustomerId, quantity, cache);
|
|
212
223
|
const resolvedQueryFn = options.queryFn ?? (callbacks?.getItemPrice ? () => callbacks.getItemPrice(itemId, effectiveCustomerId, quantity) : void 0);
|
|
213
224
|
const query = useQuery({
|
|
@@ -767,8 +778,9 @@ function useCartPricing(options = {}) {
|
|
|
767
778
|
const callbacks = useAugurCallbacks();
|
|
768
779
|
const auth = useAugurAuth();
|
|
769
780
|
const cache = useAugurCache();
|
|
781
|
+
const site = useAugurSite();
|
|
770
782
|
const cartLines = useCartLines();
|
|
771
|
-
const customerId = options.customerId ?? auth?.customerId;
|
|
783
|
+
const customerId = options.customerId ?? auth?.customerId ?? site?.defaults?.customerId;
|
|
772
784
|
const priceFn = options.queryFn ?? callbacks?.getItemPrice;
|
|
773
785
|
const priceQueries = useQueries({
|
|
774
786
|
queries: cartLines.map((line) => {
|
|
@@ -1016,18 +1028,23 @@ function useJoomlaMenuDoc(menuId, options = {}) {
|
|
|
1016
1028
|
|
|
1017
1029
|
// src/hooks/use-customer-orders.ts
|
|
1018
1030
|
import { useQuery as useQuery17 } from "@tanstack/react-query";
|
|
1031
|
+
var EMPTY_LIST = { data: [], total: 0 };
|
|
1019
1032
|
function useCustomerOrders(customerId, params, options = {}) {
|
|
1020
1033
|
const callbacks = useAugurCallbacks();
|
|
1021
1034
|
const auth = useAugurAuth();
|
|
1022
|
-
const
|
|
1035
|
+
const site = useAugurSite();
|
|
1036
|
+
const effectiveCustomerId = customerId ?? auth?.customerId ?? site?.defaults?.customerId;
|
|
1037
|
+
const resolvedQueryFn = options.queryFn ?? (callbacks?.getCustomerOrders ? () => callbacks.getCustomerOrders(effectiveCustomerId, params) : void 0);
|
|
1038
|
+
const enabled = (options.enabled ?? true) && !!effectiveCustomerId && !!resolvedQueryFn;
|
|
1023
1039
|
const { data, isLoading, error } = useQuery17({
|
|
1024
1040
|
queryKey: getCustomerOrdersKey(effectiveCustomerId, params),
|
|
1025
|
-
queryFn:
|
|
1026
|
-
enabled
|
|
1041
|
+
queryFn: resolvedQueryFn,
|
|
1042
|
+
enabled
|
|
1027
1043
|
});
|
|
1044
|
+
const result = data || EMPTY_LIST;
|
|
1028
1045
|
return {
|
|
1029
|
-
orders: data
|
|
1030
|
-
total:
|
|
1046
|
+
orders: result.data,
|
|
1047
|
+
total: result.total,
|
|
1031
1048
|
isLoading,
|
|
1032
1049
|
error
|
|
1033
1050
|
};
|
|
@@ -1035,14 +1052,17 @@ function useCustomerOrders(customerId, params, options = {}) {
|
|
|
1035
1052
|
function useOrderDetail(customerId, orderId, options = {}) {
|
|
1036
1053
|
const callbacks = useAugurCallbacks();
|
|
1037
1054
|
const auth = useAugurAuth();
|
|
1038
|
-
const
|
|
1055
|
+
const site = useAugurSite();
|
|
1056
|
+
const effectiveCustomerId = customerId ?? auth?.customerId ?? site?.defaults?.customerId;
|
|
1057
|
+
const resolvedQueryFn = options.queryFn ?? (callbacks?.getCustomerOrderDetail ? () => callbacks.getCustomerOrderDetail(effectiveCustomerId, orderId) : void 0);
|
|
1058
|
+
const enabled = (options.enabled ?? true) && !!effectiveCustomerId && !!orderId && !!resolvedQueryFn;
|
|
1039
1059
|
const { data, isLoading, error } = useQuery17({
|
|
1040
1060
|
queryKey: getCustomerOrderDetailKey(effectiveCustomerId, orderId),
|
|
1041
|
-
queryFn:
|
|
1042
|
-
enabled
|
|
1061
|
+
queryFn: resolvedQueryFn,
|
|
1062
|
+
enabled
|
|
1043
1063
|
});
|
|
1044
1064
|
return {
|
|
1045
|
-
order: data
|
|
1065
|
+
order: data || null,
|
|
1046
1066
|
isLoading,
|
|
1047
1067
|
error
|
|
1048
1068
|
};
|
|
@@ -1050,18 +1070,23 @@ function useOrderDetail(customerId, orderId, options = {}) {
|
|
|
1050
1070
|
|
|
1051
1071
|
// src/hooks/use-customer-invoices.ts
|
|
1052
1072
|
import { useQuery as useQuery18 } from "@tanstack/react-query";
|
|
1073
|
+
var EMPTY_LIST2 = { data: [], total: 0 };
|
|
1053
1074
|
function useCustomerInvoices(customerId, params, options = {}) {
|
|
1054
1075
|
const callbacks = useAugurCallbacks();
|
|
1055
1076
|
const auth = useAugurAuth();
|
|
1056
|
-
const
|
|
1077
|
+
const site = useAugurSite();
|
|
1078
|
+
const effectiveCustomerId = customerId ?? auth?.customerId ?? site?.defaults?.customerId;
|
|
1079
|
+
const resolvedQueryFn = options.queryFn ?? (callbacks?.getCustomerInvoices ? () => callbacks.getCustomerInvoices(effectiveCustomerId, params) : void 0);
|
|
1080
|
+
const enabled = (options.enabled ?? true) && !!effectiveCustomerId && !!resolvedQueryFn;
|
|
1057
1081
|
const { data, isLoading, error } = useQuery18({
|
|
1058
1082
|
queryKey: getCustomerInvoicesKey(effectiveCustomerId, params),
|
|
1059
|
-
queryFn:
|
|
1060
|
-
enabled
|
|
1083
|
+
queryFn: resolvedQueryFn,
|
|
1084
|
+
enabled
|
|
1061
1085
|
});
|
|
1086
|
+
const result = data || EMPTY_LIST2;
|
|
1062
1087
|
return {
|
|
1063
|
-
invoices: data
|
|
1064
|
-
total:
|
|
1088
|
+
invoices: result.data,
|
|
1089
|
+
total: result.total,
|
|
1065
1090
|
isLoading,
|
|
1066
1091
|
error
|
|
1067
1092
|
};
|
|
@@ -1069,17 +1094,17 @@ function useCustomerInvoices(customerId, params, options = {}) {
|
|
|
1069
1094
|
function useInvoiceDetail(customerId, invoiceNo, options = {}) {
|
|
1070
1095
|
const callbacks = useAugurCallbacks();
|
|
1071
1096
|
const auth = useAugurAuth();
|
|
1072
|
-
const
|
|
1097
|
+
const site = useAugurSite();
|
|
1098
|
+
const effectiveCustomerId = customerId ?? auth?.customerId ?? site?.defaults?.customerId;
|
|
1099
|
+
const resolvedQueryFn = options.queryFn ?? (callbacks?.getCustomerInvoiceDetail ? () => callbacks.getCustomerInvoiceDetail(effectiveCustomerId, invoiceNo) : void 0);
|
|
1100
|
+
const enabled = (options.enabled ?? true) && !!effectiveCustomerId && !!invoiceNo && !!resolvedQueryFn;
|
|
1073
1101
|
const { data, isLoading, error } = useQuery18({
|
|
1074
1102
|
queryKey: getCustomerInvoiceDetailKey(effectiveCustomerId, invoiceNo),
|
|
1075
|
-
queryFn:
|
|
1076
|
-
|
|
1077
|
-
invoiceNo
|
|
1078
|
-
)),
|
|
1079
|
-
enabled: (options.enabled ?? true) && !!effectiveCustomerId && !!invoiceNo && !!(options.queryFn ?? callbacks?.getCustomerInvoiceDetail)
|
|
1103
|
+
queryFn: resolvedQueryFn,
|
|
1104
|
+
enabled
|
|
1080
1105
|
});
|
|
1081
1106
|
return {
|
|
1082
|
-
invoice: data
|
|
1107
|
+
invoice: data || null,
|
|
1083
1108
|
isLoading,
|
|
1084
1109
|
error
|
|
1085
1110
|
};
|
|
@@ -1087,18 +1112,23 @@ function useInvoiceDetail(customerId, invoiceNo, options = {}) {
|
|
|
1087
1112
|
|
|
1088
1113
|
// src/hooks/use-customer-quotes.ts
|
|
1089
1114
|
import { useQuery as useQuery19 } from "@tanstack/react-query";
|
|
1115
|
+
var EMPTY_LIST3 = { data: [], total: 0 };
|
|
1090
1116
|
function useCustomerQuotes(customerId, params, options = {}) {
|
|
1091
1117
|
const callbacks = useAugurCallbacks();
|
|
1092
1118
|
const auth = useAugurAuth();
|
|
1093
|
-
const
|
|
1119
|
+
const site = useAugurSite();
|
|
1120
|
+
const effectiveCustomerId = customerId ?? auth?.customerId ?? site?.defaults?.customerId;
|
|
1121
|
+
const resolvedQueryFn = options.queryFn ?? (callbacks?.getCustomerQuotes ? () => callbacks.getCustomerQuotes(effectiveCustomerId, params) : void 0);
|
|
1122
|
+
const enabled = (options.enabled ?? true) && !!effectiveCustomerId && !!resolvedQueryFn;
|
|
1094
1123
|
const { data, isLoading, error } = useQuery19({
|
|
1095
1124
|
queryKey: getCustomerQuotesKey(effectiveCustomerId, params),
|
|
1096
|
-
queryFn:
|
|
1097
|
-
enabled
|
|
1125
|
+
queryFn: resolvedQueryFn,
|
|
1126
|
+
enabled
|
|
1098
1127
|
});
|
|
1128
|
+
const result = data || EMPTY_LIST3;
|
|
1099
1129
|
return {
|
|
1100
|
-
quotes: data
|
|
1101
|
-
total:
|
|
1130
|
+
quotes: result.data,
|
|
1131
|
+
total: result.total,
|
|
1102
1132
|
isLoading,
|
|
1103
1133
|
error
|
|
1104
1134
|
};
|
|
@@ -1106,14 +1136,17 @@ function useCustomerQuotes(customerId, params, options = {}) {
|
|
|
1106
1136
|
function useQuoteDetail(customerId, quoteNo, options = {}) {
|
|
1107
1137
|
const callbacks = useAugurCallbacks();
|
|
1108
1138
|
const auth = useAugurAuth();
|
|
1109
|
-
const
|
|
1139
|
+
const site = useAugurSite();
|
|
1140
|
+
const effectiveCustomerId = customerId ?? auth?.customerId ?? site?.defaults?.customerId;
|
|
1141
|
+
const resolvedQueryFn = options.queryFn ?? (callbacks?.getCustomerQuoteDetail ? () => callbacks.getCustomerQuoteDetail(effectiveCustomerId, quoteNo) : void 0);
|
|
1142
|
+
const enabled = (options.enabled ?? true) && !!effectiveCustomerId && !!quoteNo && !!resolvedQueryFn;
|
|
1110
1143
|
const { data, isLoading, error } = useQuery19({
|
|
1111
1144
|
queryKey: getCustomerQuoteDetailKey(effectiveCustomerId, quoteNo),
|
|
1112
|
-
queryFn:
|
|
1113
|
-
enabled
|
|
1145
|
+
queryFn: resolvedQueryFn,
|
|
1146
|
+
enabled
|
|
1114
1147
|
});
|
|
1115
1148
|
return {
|
|
1116
|
-
quote: data
|
|
1149
|
+
quote: data || null,
|
|
1117
1150
|
isLoading,
|
|
1118
1151
|
error
|
|
1119
1152
|
};
|
|
@@ -1126,7 +1159,7 @@ function createSiteHooks(config = {}) {
|
|
|
1126
1159
|
function Provider({ api, auth, children }) {
|
|
1127
1160
|
const mergedAuth = {
|
|
1128
1161
|
status: auth?.status ?? "unauthenticated",
|
|
1129
|
-
customerId: auth?.customerId
|
|
1162
|
+
customerId: auth?.customerId,
|
|
1130
1163
|
userId: auth?.userId,
|
|
1131
1164
|
cartHdrUid: auth?.cartHdrUid
|
|
1132
1165
|
};
|
|
@@ -1135,6 +1168,7 @@ function createSiteHooks(config = {}) {
|
|
|
1135
1168
|
callbacks,
|
|
1136
1169
|
auth: mergedAuth,
|
|
1137
1170
|
cache,
|
|
1171
|
+
site: defaultCustomerId ? { name: "", defaults: { customerId: defaultCustomerId } } : void 0,
|
|
1138
1172
|
children
|
|
1139
1173
|
});
|
|
1140
1174
|
}
|
|
@@ -1403,6 +1437,7 @@ export {
|
|
|
1403
1437
|
useAugurCache,
|
|
1404
1438
|
useAugurOptions,
|
|
1405
1439
|
useAugurPersistence,
|
|
1440
|
+
useAugurSite,
|
|
1406
1441
|
useBatchInvMastDoc,
|
|
1407
1442
|
useCartActions,
|
|
1408
1443
|
useCartHdrUid,
|