@simpleapps-com/augur-hooks 0.1.0 → 0.1.1
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/index.cjs +65 -54
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +65 -54
- package/dist/index.js.map +1 -1
- package/dist/web.cjs +5 -3
- package/dist/web.cjs.map +1 -1
- package/dist/web.js +5 -3
- package/dist/web.js.map +1 -1
- package/package.json +11 -6
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
3
|
import * as zustand from 'zustand';
|
|
4
4
|
import * as _simpleapps_com_augur_utils from '@simpleapps-com/augur-utils';
|
|
5
|
-
import { TCartLine, TItemsFilters, TPriceData, TInvMastDoc, TCategory, TItemDetails, TProductCategory, TProductItem } from '@simpleapps-com/augur-utils';
|
|
5
|
+
import { TCartLine, TItemsFilters, TPriceData, TInvMastDoc, TCategory, TItemDetails, TProductCategory, TAttribute, TProductItem } from '@simpleapps-com/augur-utils';
|
|
6
6
|
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
7
7
|
import { QueryKey } from '@tanstack/react-query';
|
|
8
8
|
|
|
@@ -42,7 +42,7 @@ declare function useAugurApi(): AugurApiClient;
|
|
|
42
42
|
/** Parameters for product search queries. */
|
|
43
43
|
type PageData = {
|
|
44
44
|
categoryIdList?: string;
|
|
45
|
-
filters?:
|
|
45
|
+
filters?: Record<string, string>[];
|
|
46
46
|
limit: number;
|
|
47
47
|
page: number;
|
|
48
48
|
offset: number;
|
|
@@ -82,7 +82,7 @@ interface GetItemCategoryApiOptions {
|
|
|
82
82
|
childrenLimit?: number;
|
|
83
83
|
childrenOffset?: number;
|
|
84
84
|
classId5List?: string;
|
|
85
|
-
filters?: Record<string,
|
|
85
|
+
filters?: Record<string, string>;
|
|
86
86
|
orderBy?: string;
|
|
87
87
|
path?: string;
|
|
88
88
|
productCollection?: string;
|
|
@@ -362,7 +362,7 @@ declare function useItemDetails(itemId: number | string | undefined, options?: U
|
|
|
362
362
|
interface UseItemAttributesOptions {
|
|
363
363
|
enabled?: boolean;
|
|
364
364
|
queryFn?: () => Promise<{
|
|
365
|
-
attributes:
|
|
365
|
+
attributes: TAttribute[];
|
|
366
366
|
}>;
|
|
367
367
|
}
|
|
368
368
|
declare const getItemAttributesKey: (itemCategoryUid: number | string | null) => readonly ["itemAttributes", string | number | null];
|
package/dist/index.js
CHANGED
|
@@ -256,7 +256,9 @@ function useInvMastStock(invMastUid, options = {}) {
|
|
|
256
256
|
...options.queryFn ? { queryFn: options.queryFn } : {},
|
|
257
257
|
enabled: (options.enabled ?? true) && !!invMastUid,
|
|
258
258
|
retry: 3,
|
|
259
|
+
/* v8 ignore start */
|
|
259
260
|
retryDelay: (attemptIndex) => Math.min(1e3 * 2 ** attemptIndex, 1e4)
|
|
261
|
+
/* v8 ignore stop */
|
|
260
262
|
});
|
|
261
263
|
return {
|
|
262
264
|
qtyOnHand: data ?? null,
|
|
@@ -284,11 +286,17 @@ var getProductCategoryOptions = (api, itemCategoryUid) => ({
|
|
|
284
286
|
function useProductCategory(itemCategoryUid, options = {}) {
|
|
285
287
|
const api = useAugurApi();
|
|
286
288
|
const { data, isLoading, error } = useQuery6({
|
|
287
|
-
...itemCategoryUid ? getProductCategoryOptions(api, itemCategoryUid) : {
|
|
289
|
+
...itemCategoryUid ? getProductCategoryOptions(api, itemCategoryUid) : {
|
|
290
|
+
queryKey: getProductCategoryKey(null),
|
|
291
|
+
/* v8 ignore next */
|
|
292
|
+
queryFn: () => Promise.reject()
|
|
293
|
+
},
|
|
288
294
|
...options.queryFn ? { queryFn: options.queryFn } : {},
|
|
289
295
|
enabled: (options.enabled ?? true) && !!itemCategoryUid,
|
|
290
296
|
retry: 3,
|
|
297
|
+
/* v8 ignore start */
|
|
291
298
|
retryDelay: (attemptIndex) => Math.min(1e3 * 2 ** attemptIndex, 1e4)
|
|
299
|
+
/* v8 ignore stop */
|
|
292
300
|
});
|
|
293
301
|
return {
|
|
294
302
|
childrenTotal: data?.childrenTotal ?? 0,
|
|
@@ -318,11 +326,17 @@ var getItemDetailsOptions = (api, itemId) => ({
|
|
|
318
326
|
function useItemDetails(itemId, options = {}) {
|
|
319
327
|
const api = useAugurApi();
|
|
320
328
|
const { data, isLoading, error } = useQuery7({
|
|
321
|
-
...itemId ? getItemDetailsOptions(api, itemId) : {
|
|
329
|
+
...itemId ? getItemDetailsOptions(api, itemId) : {
|
|
330
|
+
queryKey: getItemDetailsKey(""),
|
|
331
|
+
/* v8 ignore next */
|
|
332
|
+
queryFn: () => Promise.reject()
|
|
333
|
+
},
|
|
322
334
|
...options.queryFn ? { queryFn: options.queryFn } : {},
|
|
323
335
|
enabled: (options.enabled ?? true) && !!itemId,
|
|
324
336
|
retry: 3,
|
|
337
|
+
/* v8 ignore start */
|
|
325
338
|
retryDelay: (attemptIndex) => Math.min(1e3 * 2 ** attemptIndex, 1e4)
|
|
339
|
+
/* v8 ignore stop */
|
|
326
340
|
});
|
|
327
341
|
const categoryList = data?.categoryList ?? [];
|
|
328
342
|
return {
|
|
@@ -356,12 +370,15 @@ function useItemAttributes(itemCategoryUid, options = {}) {
|
|
|
356
370
|
const { data, isLoading, error } = useQuery8({
|
|
357
371
|
...itemCategoryUid ? getItemAttributesOptions(api, itemCategoryUid) : {
|
|
358
372
|
queryKey: getItemAttributesKey(null),
|
|
373
|
+
/* v8 ignore next */
|
|
359
374
|
queryFn: () => Promise.reject()
|
|
360
375
|
},
|
|
361
376
|
...options.queryFn ? { queryFn: options.queryFn } : {},
|
|
362
377
|
enabled: (options.enabled ?? true) && !!itemCategoryUid,
|
|
363
378
|
retry: 3,
|
|
379
|
+
/* v8 ignore start */
|
|
364
380
|
retryDelay: (attemptIndex) => Math.min(1e3 * 2 ** attemptIndex, 1e4)
|
|
381
|
+
/* v8 ignore stop */
|
|
365
382
|
});
|
|
366
383
|
return {
|
|
367
384
|
attributes: data?.attributes ?? null,
|
|
@@ -405,7 +422,9 @@ function useProductSearch(pageData, options = {}) {
|
|
|
405
422
|
...defaultOptions,
|
|
406
423
|
...options.queryFn ? { queryFn: options.queryFn } : {},
|
|
407
424
|
retry: 3,
|
|
425
|
+
/* v8 ignore start */
|
|
408
426
|
retryDelay: (attemptIndex) => Math.min(1e3 * 2 ** attemptIndex, 1e4)
|
|
427
|
+
/* v8 ignore stop */
|
|
409
428
|
});
|
|
410
429
|
return {
|
|
411
430
|
productItems: data?.items ?? null,
|
|
@@ -454,13 +473,41 @@ function useSearchSuggestions(query, options = {}) {
|
|
|
454
473
|
// src/hooks/use-cart-actions.ts
|
|
455
474
|
import { useCallback } from "react";
|
|
456
475
|
import { useQueryClient } from "@tanstack/react-query";
|
|
476
|
+
function requireCartUid(cartHdrUid) {
|
|
477
|
+
const num = typeof cartHdrUid === "string" ? Number(cartHdrUid) : cartHdrUid;
|
|
478
|
+
if (!num) throw new Error("Cart UID is not set");
|
|
479
|
+
return num;
|
|
480
|
+
}
|
|
481
|
+
function buildOptimisticAdd(cartLines, item, cartHdrUid, itemId) {
|
|
482
|
+
const existingIndex = cartLines.findIndex(
|
|
483
|
+
(line) => line.invMastUid === item.invMastUid
|
|
484
|
+
);
|
|
485
|
+
if (existingIndex >= 0) {
|
|
486
|
+
return cartLines.map(
|
|
487
|
+
(line, index) => index === existingIndex ? { ...line, quantity: line.quantity + item.quantity } : line
|
|
488
|
+
);
|
|
489
|
+
}
|
|
490
|
+
return [
|
|
491
|
+
...cartLines,
|
|
492
|
+
{
|
|
493
|
+
cartHdrUid,
|
|
494
|
+
invMastUid: item.invMastUid,
|
|
495
|
+
invMastUidCount: 1,
|
|
496
|
+
isAssembly: "N",
|
|
497
|
+
itemId,
|
|
498
|
+
lineNo: cartLines.length + 1,
|
|
499
|
+
lineNote: null,
|
|
500
|
+
quantity: item.quantity,
|
|
501
|
+
unitOfMeasure: item.unitOfMeasure
|
|
502
|
+
}
|
|
503
|
+
];
|
|
504
|
+
}
|
|
457
505
|
function useCartActions(callbacks) {
|
|
458
506
|
const queryClient = useQueryClient();
|
|
459
507
|
const cartHdrUid = useCartHdrUid();
|
|
460
508
|
const cartLines = useCartLines();
|
|
461
509
|
const setCartLines = useSetCartLines();
|
|
462
510
|
const notify = callbacks.toast;
|
|
463
|
-
const cartHdrUidNum = typeof cartHdrUid === "string" ? Number(cartHdrUid) : cartHdrUid;
|
|
464
511
|
const invalidateCartCache = useCallback(() => {
|
|
465
512
|
queryClient.invalidateQueries({ queryKey: ["cartLines", cartHdrUid] });
|
|
466
513
|
queryClient.invalidateQueries({
|
|
@@ -470,35 +517,13 @@ function useCartActions(callbacks) {
|
|
|
470
517
|
const addToCart = useCallback(
|
|
471
518
|
async (item, options = {}) => {
|
|
472
519
|
const { showToast = true, itemId = "", onSuccess, onError } = options;
|
|
473
|
-
|
|
520
|
+
const uid = requireCartUid(cartHdrUid);
|
|
474
521
|
const previousCartLines = [...cartLines];
|
|
475
|
-
|
|
476
|
-
(line) => line.invMastUid === item.invMastUid
|
|
477
|
-
);
|
|
478
|
-
let optimisticCartLines;
|
|
479
|
-
if (existingIndex >= 0) {
|
|
480
|
-
optimisticCartLines = cartLines.map(
|
|
481
|
-
(line, index) => index === existingIndex ? { ...line, quantity: line.quantity + item.quantity } : line
|
|
482
|
-
);
|
|
483
|
-
} else {
|
|
484
|
-
const newLine = {
|
|
485
|
-
cartHdrUid: cartHdrUidNum,
|
|
486
|
-
invMastUid: item.invMastUid,
|
|
487
|
-
invMastUidCount: 1,
|
|
488
|
-
isAssembly: "N",
|
|
489
|
-
itemId,
|
|
490
|
-
lineNo: cartLines.length + 1,
|
|
491
|
-
lineNote: null,
|
|
492
|
-
quantity: item.quantity,
|
|
493
|
-
unitOfMeasure: item.unitOfMeasure
|
|
494
|
-
};
|
|
495
|
-
optimisticCartLines = [...cartLines, newLine];
|
|
496
|
-
}
|
|
497
|
-
setCartLines(optimisticCartLines);
|
|
522
|
+
setCartLines(buildOptimisticAdd(cartLines, item, uid, itemId));
|
|
498
523
|
try {
|
|
499
|
-
const success = await callbacks.addToCart(
|
|
524
|
+
const success = await callbacks.addToCart(uid, [
|
|
500
525
|
{
|
|
501
|
-
cartHdrUid:
|
|
526
|
+
cartHdrUid: uid,
|
|
502
527
|
invMastUid: item.invMastUid,
|
|
503
528
|
quantity: item.quantity,
|
|
504
529
|
unitOfMeasure: item.unitOfMeasure
|
|
@@ -507,9 +532,7 @@ function useCartActions(callbacks) {
|
|
|
507
532
|
if (!success) throw new Error("Failed to add item to cart");
|
|
508
533
|
invalidateCartCache();
|
|
509
534
|
if (showToast && notify?.info) {
|
|
510
|
-
notify.info(
|
|
511
|
-
`${item.quantity} x ${itemId || "Item"} added to cart`
|
|
512
|
-
);
|
|
535
|
+
notify.info(`${item.quantity} x ${itemId || "Item"} added to cart`);
|
|
513
536
|
}
|
|
514
537
|
onSuccess?.();
|
|
515
538
|
return true;
|
|
@@ -527,20 +550,14 @@ function useCartActions(callbacks) {
|
|
|
527
550
|
const updateQuantity = useCallback(
|
|
528
551
|
async (invMastUid, newQuantity, options = {}) => {
|
|
529
552
|
const { showToast = false, onSuccess, onError } = options;
|
|
530
|
-
|
|
553
|
+
const uid = requireCartUid(cartHdrUid);
|
|
531
554
|
const previousCartLines = [...cartLines];
|
|
532
|
-
const
|
|
555
|
+
const updatedLines = cartLines.map(
|
|
533
556
|
(line) => line.invMastUid === invMastUid ? { ...line, quantity: newQuantity } : line
|
|
534
557
|
);
|
|
535
|
-
setCartLines(
|
|
558
|
+
setCartLines(updatedLines);
|
|
536
559
|
try {
|
|
537
|
-
const
|
|
538
|
-
(line) => line.invMastUid === invMastUid ? { ...line, quantity: newQuantity } : line
|
|
539
|
-
);
|
|
540
|
-
const success = await callbacks.updateCartLines(
|
|
541
|
-
cartHdrUidNum,
|
|
542
|
-
updatedLines
|
|
543
|
-
);
|
|
560
|
+
const success = await callbacks.updateCartLines(uid, updatedLines);
|
|
544
561
|
if (!success) throw new Error("Failed to update quantity");
|
|
545
562
|
invalidateCartCache();
|
|
546
563
|
onSuccess?.();
|
|
@@ -559,20 +576,14 @@ function useCartActions(callbacks) {
|
|
|
559
576
|
const removeFromCart = useCallback(
|
|
560
577
|
async (invMastUid, options = {}) => {
|
|
561
578
|
const { showToast = true, itemId = "", onSuccess, onError } = options;
|
|
562
|
-
|
|
579
|
+
const uid = requireCartUid(cartHdrUid);
|
|
563
580
|
const previousCartLines = [...cartLines];
|
|
564
|
-
|
|
565
|
-
(line) => line.invMastUid !== invMastUid
|
|
566
|
-
);
|
|
567
|
-
setCartLines(optimisticCartLines);
|
|
581
|
+
setCartLines(cartLines.filter((line) => line.invMastUid !== invMastUid));
|
|
568
582
|
try {
|
|
569
|
-
const
|
|
583
|
+
const zeroedLines = cartLines.map(
|
|
570
584
|
(line) => line.invMastUid === invMastUid ? { ...line, quantity: 0 } : line
|
|
571
585
|
);
|
|
572
|
-
const success = await callbacks.updateCartLines(
|
|
573
|
-
cartHdrUidNum,
|
|
574
|
-
updatedLines
|
|
575
|
-
);
|
|
586
|
+
const success = await callbacks.updateCartLines(uid, zeroedLines);
|
|
576
587
|
if (!success) throw new Error("Failed to remove item");
|
|
577
588
|
invalidateCartCache();
|
|
578
589
|
if (showToast && notify?.info) {
|
|
@@ -594,11 +605,11 @@ function useCartActions(callbacks) {
|
|
|
594
605
|
const clearCart = useCallback(
|
|
595
606
|
async (options = {}) => {
|
|
596
607
|
const { showToast = true, onSuccess, onError } = options;
|
|
597
|
-
|
|
608
|
+
const uid = requireCartUid(cartHdrUid);
|
|
598
609
|
const previousCartLines = [...cartLines];
|
|
599
610
|
setCartLines([]);
|
|
600
611
|
try {
|
|
601
|
-
const success = await callbacks.deleteItemsFromCart(
|
|
612
|
+
const success = await callbacks.deleteItemsFromCart(uid);
|
|
602
613
|
if (!success) throw new Error("Failed to clear cart");
|
|
603
614
|
invalidateCartCache();
|
|
604
615
|
if (showToast && notify?.info) {
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/provider.tsx","../src/stores/cart-store.ts","../src/stores/items-filters-store.ts","../src/hooks/use-debounce.ts","../src/hooks/use-format-price.ts","../src/hooks/use-item-price.ts","../src/hooks/use-inv-mast-doc.ts","../src/hooks/use-item-category.ts","../src/hooks/use-inv-mast.ts","../src/hooks/use-inv-mast-stock.ts","../src/hooks/use-product-category.ts","../src/hooks/use-item-details.ts","../src/hooks/use-item-attributes.ts","../src/hooks/use-product-search.ts","../src/hooks/use-search-suggestions.ts","../src/hooks/use-cart-actions.ts","../src/hooks/use-cart-initialization.ts","../src/hooks/use-cart-pricing.ts","../src/hooks/use-pagination-prefetch.ts","../src/hooks/use-category-items-infinite.ts","../src/hooks/use-item-search-infinite.ts"],"sourcesContent":["import { createContext, useContext, type ReactNode } from \"react\";\n\n/**\n * Minimal type for the augur-api SDK instance.\n * Consumers provide their concrete AugurAPI instance; we keep the type\n * loose so augur-hooks doesn't need to depend directly on the SDK package.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type AugurApiClient = any;\n\ninterface AugurHooksProviderProps {\n api: AugurApiClient;\n children: ReactNode;\n}\n\nconst AugurApiContext = createContext<AugurApiClient | null>(null);\n\n/**\n * Provides the augur-api SDK instance to all hooks in the tree.\n *\n * ```tsx\n * import { AugurAPI } from \"@simpleapps-com/augur-api\";\n * const api = new AugurAPI({ baseUrl: \"...\", token: \"...\" });\n *\n * <AugurHooksProvider api={api}>\n * <App />\n * </AugurHooksProvider>\n * ```\n */\nexport function AugurHooksProvider({ api, children }: AugurHooksProviderProps) {\n return (\n <AugurApiContext.Provider value={api}>{children}</AugurApiContext.Provider>\n );\n}\n\n/**\n * Returns the augur-api SDK instance from context.\n * Throws if called outside of `<AugurHooksProvider>`.\n */\nexport function useAugurApi(): AugurApiClient {\n const api = useContext(AugurApiContext);\n if (!api) {\n throw new Error(\n \"useAugurApi must be used within an <AugurHooksProvider>. \" +\n \"Wrap your app with <AugurHooksProvider api={apiInstance}>.\",\n );\n }\n return api;\n}\n","import { create } from \"zustand\";\nimport { devtools } from \"zustand/middleware\";\nimport type { TCartLine } from \"@simpleapps-com/augur-utils\";\n\ninterface CartState {\n cartHdrUid: number | string | undefined;\n cartLines: TCartLine[];\n cartItemCount: number;\n setCartHdrUid: (cartHdrUid: number | string | undefined) => void;\n setCartLines: (cartLines: TCartLine[]) => void;\n}\n\nexport const useCartStore = create<CartState>()(\n devtools(\n (set) => ({\n cartHdrUid: undefined,\n cartLines: [],\n cartItemCount: 0,\n\n setCartHdrUid: (cartHdrUid) =>\n set({ cartHdrUid }, false, \"setCartHdrUid\"),\n\n setCartLines: (cartLines) => {\n const cartItemCount = cartLines.reduce(\n (sum, line) => sum + (line.quantity || 0),\n 0,\n );\n set({ cartLines, cartItemCount }, false, \"setCartLines\");\n },\n }),\n { name: \"CartStore\", enabled: process.env.NODE_ENV === \"development\" },\n ),\n);\n\n// Selector hooks -- only re-render when specific state changes\nexport const useCartHdrUid = () => useCartStore((s) => s.cartHdrUid);\nexport const useCartLines = () => useCartStore((s) => s.cartLines);\nexport const useCartItemCount = () => useCartStore((s) => s.cartItemCount);\nexport const useSetCartHdrUid = () => useCartStore((s) => s.setCartHdrUid);\nexport const useSetCartLines = () => useCartStore((s) => s.setCartLines);\n","import { create } from \"zustand\";\nimport { devtools } from \"zustand/middleware\";\nimport type { TItemsFilters } from \"@simpleapps-com/augur-utils\";\n\nconst DEFAULT_FILTER_STATE: TItemsFilters = {\n filters: [],\n limit: 12,\n offset: 0,\n sortBy: \"asc\",\n q: \"\",\n page: 1,\n};\n\ninterface ItemsFiltersState {\n initialFiltersState: TItemsFilters;\n itemsFilters: TItemsFilters;\n setItemsFilters: (itemFilters: TItemsFilters) => void;\n}\n\nexport const useItemFiltersStore = create<ItemsFiltersState>()(\n devtools(\n (set) => ({\n initialFiltersState: DEFAULT_FILTER_STATE,\n itemsFilters: DEFAULT_FILTER_STATE,\n setItemsFilters: (state) =>\n set({ itemsFilters: state }, false, \"setItemsFilters\"),\n }),\n {\n name: \"ItemsFiltersStore\",\n enabled: process.env.NODE_ENV === \"development\",\n },\n ),\n);\n","import { useEffect, useState } from \"react\";\n\n/**\n * Debounces a rapidly-changing value.\n * Returns the latest value only after `delay` ms of inactivity.\n */\nexport function useDebounce<T>(value: T, delay: number = 500): T {\n const [debouncedValue, setDebouncedValue] = useState<T>(value);\n\n useEffect(() => {\n const handler = setTimeout(() => {\n setDebouncedValue(value);\n }, delay);\n\n return () => {\n clearTimeout(handler);\n };\n }, [value, delay]);\n\n return debouncedValue;\n}\n","/**\n * Hook that returns a price formatter.\n * Wraps Intl.NumberFormat with configurable locale/currency.\n */\nexport function useFormatPrice(\n locale: string = \"en-US\",\n currency: string = \"USD\",\n) {\n const formatPrice = (price: number): string => {\n return new Intl.NumberFormat(locale, {\n style: \"currency\",\n currency,\n minimumFractionDigits: 2,\n }).format(price);\n };\n\n return { formatPrice };\n}\n","import { useQuery } from \"@tanstack/react-query\";\nimport { CACHE_CONFIG, type TPriceData } from \"@simpleapps-com/augur-utils\";\nimport { useAugurApi, type AugurApiClient } from \"../provider\";\n\ninterface UseItemPriceOptions {\n enabled?: boolean;\n /** Override the default queryFn (e.g. with a cached server action). */\n queryFn?: () => Promise<TPriceData>;\n}\n\nexport const PRICE_CACHE_OPTIONS = {\n ...CACHE_CONFIG.SEMI_STATIC,\n refetchOnReconnect: true,\n refetchOnWindowFocus: false,\n meta: { persist: true },\n} as const;\n\n/**\n * Generates a consistent query key for item price queries.\n * Usable in both client hooks and server-side prefetch.\n */\nexport const getItemPriceKey = (\n itemId: string | undefined,\n customerId: string | number | undefined,\n quantity: number = 1,\n) => {\n return [\"price\", itemId?.toUpperCase() || \"\", customerId, quantity] as const;\n};\n\n/**\n * Query options for item price. Accepts the SDK instance so it works\n * in both client (via provider) and server (via direct construction).\n */\nexport const getItemPriceOptions = (\n api: AugurApiClient,\n itemId: string | undefined,\n customerId: string | number | undefined,\n quantity: number = 1,\n) => ({\n queryKey: getItemPriceKey(itemId, customerId, quantity),\n queryFn: async (): Promise<TPriceData> => {\n const response = await api.pricing.priceEngine.get({\n itemId: itemId?.toUpperCase() || \"\",\n customerId: Number(customerId),\n quantity,\n });\n return response.data;\n },\n ...PRICE_CACHE_OPTIONS,\n});\n\n/**\n * Fetches and caches item pricing via the augur-api SDK.\n *\n * Pass `options.queryFn` to override with a cached server action:\n * ```ts\n * useItemPrice(itemId, customerId, 1, {\n * queryFn: () => getItemPriceCached(itemId, customerId, 1),\n * });\n * ```\n */\nexport function useItemPrice(\n itemId: string | undefined,\n customerId: string | number | undefined,\n quantity: number = 1,\n options: UseItemPriceOptions = {},\n) {\n const api = useAugurApi();\n const defaultOptions = getItemPriceOptions(api, itemId, customerId, quantity);\n\n return useQuery({\n ...defaultOptions,\n ...(options.queryFn ? { queryFn: options.queryFn } : {}),\n enabled: options.enabled ?? (Boolean(itemId) && Boolean(customerId)),\n retry: 3,\n });\n}\n","import { useQuery } from \"@tanstack/react-query\";\nimport { CACHE_CONFIG, type TInvMastDoc } from \"@simpleapps-com/augur-utils\";\nimport { useAugurApi, type AugurApiClient } from \"../provider\";\n\ninterface UseInvMastDocOptions {\n enabled?: boolean;\n includePricing?: \"Y\" | \"N\";\n /** Initial data from server -- enables instant render without loading state. */\n initialData?: TInvMastDoc;\n /** Override the default queryFn (e.g. with a cached server action). */\n queryFn?: () => Promise<TInvMastDoc>;\n}\n\nexport const INV_MAST_DOC_CACHE_OPTIONS = CACHE_CONFIG.STATIC;\n\n/**\n * Generates a consistent query key for inv mast doc queries.\n * Usable in both client hooks and server-side prefetch.\n */\nexport const getInvMastDocKey = (\n invMastUid: number,\n itemId: string,\n includePricing: \"Y\" | \"N\",\n) => {\n return [\n \"invMastDoc\",\n invMastUid,\n itemId.toUpperCase(),\n includePricing,\n ] as const;\n};\n\n/**\n * Query options for inv mast doc. Accepts the SDK instance so it works\n * in both client (via provider) and server (via direct construction).\n */\nexport const getInvMastDocOptions = (\n api: AugurApiClient,\n invMastUid: number,\n itemId: string,\n includePricing: \"Y\" | \"N\",\n) => ({\n queryKey: getInvMastDocKey(invMastUid, itemId, includePricing),\n queryFn: async (): Promise<TInvMastDoc> => {\n const response = await api.items.invMast.doc.list(invMastUid, {\n includePricing,\n });\n if (!response.data) throw new Error(\"Item not found\");\n return response.data;\n },\n ...INV_MAST_DOC_CACHE_OPTIONS,\n});\n\n/**\n * Fetches and caches an inventory master document via the augur-api SDK.\n */\nexport function useInvMastDoc(\n invMastUid: number,\n itemId: string,\n options: UseInvMastDocOptions = {},\n) {\n const api = useAugurApi();\n const queryOpts = getInvMastDocOptions(\n api,\n invMastUid,\n itemId,\n options.includePricing ?? \"N\",\n );\n\n const { data, isLoading, error } = useQuery<TInvMastDoc, Error>({\n ...queryOpts,\n ...(options.queryFn ? { queryFn: options.queryFn } : {}),\n enabled: options.enabled ?? true,\n initialData: options.initialData,\n });\n\n return { item: data, isLoading, error };\n}\n","import { useQuery } from \"@tanstack/react-query\";\nimport { CACHE_CONFIG, type TCategory } from \"@simpleapps-com/augur-utils\";\nimport { useAugurApi, type AugurApiClient } from \"../provider\";\nimport type { GetItemCategoryApiOptions } from \"../types\";\n\ninterface UseItemCategoryOptions {\n enabled?: boolean;\n apiOptions?: GetItemCategoryApiOptions;\n /** Override the default queryFn (e.g. with a cached server action). */\n queryFn?: () => Promise<TCategory>;\n}\n\nexport const CATEGORY_CACHE_OPTIONS = CACHE_CONFIG.STATIC;\n\ntype ItemCategoryQueryKey = readonly [\n \"itemCategory\",\n number,\n GetItemCategoryApiOptions | undefined,\n];\n\n/**\n * Generates a consistent query key for item category queries.\n * Usable in both client hooks and server-side prefetch.\n */\nexport const getItemCategoryKey = (\n itemCategoryUid: number,\n apiOptions?: GetItemCategoryApiOptions,\n): ItemCategoryQueryKey => {\n return [\"itemCategory\", itemCategoryUid, apiOptions] as const;\n};\n\n/**\n * Query options for item category. Accepts the SDK instance so it works\n * in both client (via provider) and server (via direct construction).\n */\nexport const getItemCategoryOptions = (\n api: AugurApiClient,\n itemCategoryUid: number,\n apiOptions?: GetItemCategoryApiOptions,\n) => ({\n queryKey: getItemCategoryKey(itemCategoryUid, apiOptions),\n queryFn: async (): Promise<TCategory> => {\n const response = await api.items.itemCategory.get(\n itemCategoryUid,\n apiOptions,\n );\n if (!response.data) throw new Error(\"Item category not found\");\n return response.data;\n },\n ...CATEGORY_CACHE_OPTIONS,\n});\n\n/**\n * Fetches and caches item category data via the augur-api SDK.\n */\nexport function useItemCategory(\n itemCategoryUid: number,\n options: UseItemCategoryOptions = {},\n) {\n const api = useAugurApi();\n const queryOpts = getItemCategoryOptions(\n api,\n itemCategoryUid,\n options.apiOptions,\n );\n\n const { data, isLoading, error } = useQuery<\n TCategory,\n Error,\n TCategory,\n ItemCategoryQueryKey\n >({\n ...queryOpts,\n ...(options.queryFn ? { queryFn: options.queryFn } : {}),\n enabled: options.enabled ?? true,\n });\n\n return { category: data, isLoading, error };\n}\n","import { useQuery } from \"@tanstack/react-query\";\nimport { CACHE_CONFIG, type TItemDetails } from \"@simpleapps-com/augur-utils\";\nimport { useAugurApi, type AugurApiClient } from \"../provider\";\n\ninterface UseInvMastOptions {\n enabled?: boolean;\n queryFn?: () => Promise<TItemDetails>;\n}\n\nexport const INV_MAST_CACHE_OPTIONS = CACHE_CONFIG.STATIC;\n\nexport const getInvMastKey = (invMastUid: number, itemId: string) => {\n return [\"invMast\", invMastUid, itemId.toUpperCase()] as const;\n};\n\nexport const getInvMastOptions = (\n api: AugurApiClient,\n invMastUid: number,\n itemId: string,\n) => ({\n queryKey: getInvMastKey(invMastUid, itemId),\n queryFn: async (): Promise<TItemDetails> => {\n const response = await api.items.invMast.get(invMastUid);\n if (!response.data) throw new Error(\"Item not found\");\n return response.data;\n },\n ...INV_MAST_CACHE_OPTIONS,\n});\n\nexport function useInvMast(\n invMastUid: number,\n itemId: string,\n options: UseInvMastOptions = {},\n) {\n const api = useAugurApi();\n const queryOpts = getInvMastOptions(api, invMastUid, itemId);\n\n const { data, isLoading, error } = useQuery<TItemDetails, Error>({\n ...queryOpts,\n ...(options.queryFn ? { queryFn: options.queryFn } : {}),\n enabled: options.enabled ?? true,\n });\n\n return { item: data, isLoading, error };\n}\n","import { useQuery } from \"@tanstack/react-query\";\nimport { CACHE_CONFIG, type TStockData } from \"@simpleapps-com/augur-utils\";\nimport { useAugurApi, type AugurApiClient } from \"../provider\";\n\ninterface UseInvMastStockOptions {\n enabled?: boolean;\n queryFn?: () => Promise<number>;\n}\n\nexport const getInvMastStockKey = (invMastUid: number | string) => {\n return [\"invMastStock\", invMastUid] as const;\n};\n\nexport const getInvMastStockOptions = (\n api: AugurApiClient,\n invMastUid: number | string,\n) => ({\n queryKey: getInvMastStockKey(invMastUid),\n queryFn: async (): Promise<number> => {\n const response = await api.items.invMast.stock.list(Number(invMastUid));\n const stockData: TStockData[] = response.data?.stockData ?? [];\n return stockData.reduce(\n (qty: number, stock: TStockData) => qty + stock.qtyOnHand,\n 0,\n );\n },\n ...CACHE_CONFIG.SEMI_STATIC,\n});\n\nexport function useInvMastStock(\n invMastUid: number | string,\n options: UseInvMastStockOptions = {},\n) {\n const api = useAugurApi();\n const queryOpts = getInvMastStockOptions(api, invMastUid);\n\n const { data, isLoading, error } = useQuery({\n ...queryOpts,\n ...(options.queryFn ? { queryFn: options.queryFn } : {}),\n enabled: (options.enabled ?? true) && !!invMastUid,\n retry: 3,\n retryDelay: (attemptIndex: number) =>\n Math.min(1000 * 2 ** attemptIndex, 10000),\n });\n\n return {\n qtyOnHand: data ?? null,\n loading: isLoading,\n error: error as Error | null,\n };\n}\n","import { useQuery } from \"@tanstack/react-query\";\nimport { CACHE_CONFIG, type TProductCategory } from \"@simpleapps-com/augur-utils\";\nimport { useAugurApi, type AugurApiClient } from \"../provider\";\n\ntype ProductCategoryResponse = {\n itemCategoryDesc: string;\n childrenTotal: number;\n children: TProductCategory[];\n categoryImage: string | null;\n};\n\ninterface UseProductCategoryOptions {\n enabled?: boolean;\n queryFn?: () => Promise<ProductCategoryResponse>;\n}\n\nexport const getProductCategoryKey = (\n itemCategoryUid: number | string | null,\n) => {\n return [\"productCategory\", itemCategoryUid] as const;\n};\n\nexport const getProductCategoryOptions = (\n api: AugurApiClient,\n itemCategoryUid: number | string,\n) => ({\n queryKey: getProductCategoryKey(itemCategoryUid),\n queryFn: async (): Promise<ProductCategoryResponse> => {\n const response = await api.items.itemCategory.get(\n Number(itemCategoryUid),\n );\n return response.data;\n },\n ...CACHE_CONFIG.STATIC,\n});\n\nexport function useProductCategory(\n itemCategoryUid: number | string | null,\n options: UseProductCategoryOptions = {},\n) {\n const api = useAugurApi();\n\n const { data, isLoading, error } = useQuery({\n ...(itemCategoryUid\n ? getProductCategoryOptions(api, itemCategoryUid)\n : { queryKey: getProductCategoryKey(null), queryFn: () => Promise.reject() }),\n ...(options.queryFn ? { queryFn: options.queryFn } : {}),\n enabled: (options.enabled ?? true) && !!itemCategoryUid,\n retry: 3,\n retryDelay: (attemptIndex: number) =>\n Math.min(1000 * 2 ** attemptIndex, 10000),\n });\n\n return {\n childrenTotal: data?.childrenTotal ?? 0,\n itemCategoryDesc: data?.itemCategoryDesc ?? \"\",\n productCategories: data?.children ?? null,\n productCategoryImage: data?.categoryImage ?? null,\n loading: isLoading,\n error: error as Error | null,\n };\n}\n","import { useQuery } from \"@tanstack/react-query\";\nimport { CACHE_CONFIG, type TItemDetails } from \"@simpleapps-com/augur-utils\";\nimport { useAugurApi, type AugurApiClient } from \"../provider\";\n\ninterface UseItemDetailsOptions {\n enabled?: boolean;\n queryFn?: () => Promise<TItemDetails>;\n}\n\nexport const getItemDetailsKey = (itemId: number | string) => {\n return [\"itemDetails\", itemId] as const;\n};\n\nexport const getItemDetailsOptions = (\n api: AugurApiClient,\n itemId: number | string,\n) => ({\n queryKey: getItemDetailsKey(itemId),\n queryFn: async (): Promise<TItemDetails> => {\n const response = await api.items.invMast.doc.list(Number(itemId));\n if (!response.data) throw new Error(\"Item not found\");\n return response.data;\n },\n ...CACHE_CONFIG.STATIC,\n});\n\nexport function useItemDetails(\n itemId: number | string | undefined,\n options: UseItemDetailsOptions = {},\n) {\n const api = useAugurApi();\n\n const { data, isLoading, error } = useQuery({\n ...(itemId\n ? getItemDetailsOptions(api, itemId)\n : { queryKey: getItemDetailsKey(\"\"), queryFn: () => Promise.reject() }),\n ...(options.queryFn ? { queryFn: options.queryFn } : {}),\n enabled: (options.enabled ?? true) && !!itemId,\n retry: 3,\n retryDelay: (attemptIndex: number) =>\n Math.min(1000 * 2 ** attemptIndex, 10000),\n });\n\n const categoryList = data?.categoryList ?? [];\n\n return {\n itemCategoryUid:\n categoryList.length > 0 ? categoryList[categoryList.length - 1] : null,\n itemDetails: data ?? null,\n loading: isLoading,\n error: error as Error | null,\n };\n}\n","import { useQuery } from \"@tanstack/react-query\";\nimport { CACHE_CONFIG } from \"@simpleapps-com/augur-utils\";\nimport { useAugurApi, type AugurApiClient } from \"../provider\";\n\ninterface UseItemAttributesOptions {\n enabled?: boolean;\n queryFn?: () => Promise<{ attributes: any[] }>;\n}\n\nexport const getItemAttributesKey = (\n itemCategoryUid: number | string | null,\n) => {\n return [\"itemAttributes\", itemCategoryUid] as const;\n};\n\nexport const getItemAttributesOptions = (\n api: AugurApiClient,\n itemCategoryUid: number | string,\n) => ({\n queryKey: getItemAttributesKey(itemCategoryUid),\n queryFn: async () => {\n const response = await api.openSearch.itemSearch.attributes.list({\n q: \"\",\n searchType: \"query\",\n classId5List: String(itemCategoryUid),\n });\n return response.data;\n },\n ...CACHE_CONFIG.STATIC,\n});\n\nexport function useItemAttributes(\n itemCategoryUid: number | string | null,\n options: UseItemAttributesOptions = {},\n) {\n const api = useAugurApi();\n\n const { data, isLoading, error } = useQuery({\n ...(itemCategoryUid\n ? getItemAttributesOptions(api, itemCategoryUid)\n : {\n queryKey: getItemAttributesKey(null),\n queryFn: () => Promise.reject(),\n }),\n ...(options.queryFn ? { queryFn: options.queryFn } : {}),\n enabled: (options.enabled ?? true) && !!itemCategoryUid,\n retry: 3,\n retryDelay: (attemptIndex: number) =>\n Math.min(1000 * 2 ** attemptIndex, 10000),\n });\n\n return {\n attributes: data?.attributes ?? null,\n loading: isLoading,\n error: error as Error | null,\n };\n}\n","import { useQuery } from \"@tanstack/react-query\";\nimport { CACHE_CONFIG, type TProductItem } from \"@simpleapps-com/augur-utils\";\nimport { useAugurApi, type AugurApiClient } from \"../provider\";\nimport type { PageData } from \"../types\";\n\ntype ProductSearchResponse = {\n items: TProductItem[];\n totalResults: number;\n};\n\ninterface UseProductSearchOptions {\n /** Override the default queryFn (e.g. with a cached server action). */\n queryFn?: () => Promise<ProductSearchResponse>;\n}\n\n/**\n * Generates a consistent query key for product search queries.\n */\nexport const getProductSearchKey = (pageData: PageData) => {\n return [\n \"productSearch\",\n pageData.q,\n pageData.limit,\n pageData.offset,\n pageData.sortBy,\n pageData.itemCategoryUid,\n ] as const;\n};\n\n/**\n * Query options for product search. Accepts the SDK instance so it works\n * in both client (via provider) and server (via direct construction).\n */\nexport const getProductSearchOptions = (\n api: AugurApiClient,\n pageData: PageData,\n) => ({\n queryKey: getProductSearchKey(pageData),\n queryFn: async (): Promise<ProductSearchResponse> => {\n const response = await api.openSearch.itemSearch.list({\n q: pageData.q,\n searchType: \"query\",\n size: pageData.limit,\n from: pageData.offset,\n classId5List: pageData.itemCategoryUid\n ? String(pageData.itemCategoryUid)\n : undefined,\n filters: pageData.filters\n ? JSON.stringify(pageData.filters)\n : undefined,\n });\n return response.data;\n },\n ...CACHE_CONFIG.SEMI_STATIC,\n});\n\n/**\n * Searches products via the augur-api OpenSearch endpoint.\n * Replaces the ampro-online pattern of fetching from a Next.js API route.\n */\nexport function useProductSearch(\n pageData: PageData,\n options: UseProductSearchOptions = {},\n) {\n const api = useAugurApi();\n const defaultOptions = getProductSearchOptions(api, pageData);\n\n const { data, isLoading, error } = useQuery({\n ...defaultOptions,\n ...(options.queryFn ? { queryFn: options.queryFn } : {}),\n retry: 3,\n retryDelay: (attemptIndex: number) =>\n Math.min(1000 * 2 ** attemptIndex, 10000),\n });\n\n return {\n productItems: data?.items ?? null,\n total: data?.totalResults ?? 0,\n loading: isLoading,\n error: error as Error | null,\n };\n}\n","import { useQuery } from \"@tanstack/react-query\";\nimport { CACHE_CONFIG } from \"@simpleapps-com/augur-utils\";\nimport { useAugurApi, type AugurApiClient } from \"../provider\";\nimport type { SearchSuggestionsResponse } from \"../types\";\n\ninterface UseSearchSuggestionsOptions {\n enabled?: boolean;\n limit?: number;\n offset?: number;\n /** Override the default queryFn (e.g. with a cached server action). */\n queryFn?: () => Promise<SearchSuggestionsResponse>;\n}\n\nconst SEARCH_SUGGESTIONS_CACHE_OPTIONS = CACHE_CONFIG.STATIC;\n\n/**\n * Generates a consistent query key for search suggestion queries.\n */\nexport const getSearchSuggestionsKey = (\n query: string,\n limit: number,\n offset: number,\n) => {\n return [\"searchSuggestions\", query, limit, offset] as const;\n};\n\n/**\n * Query options for search suggestions. Accepts the SDK instance so it works\n * in both client (via provider) and server (via direct construction).\n */\nexport const getSearchSuggestionsOptions = (\n api: AugurApiClient,\n query: string,\n limit: number = 10,\n offset: number = 0,\n) => ({\n queryKey: getSearchSuggestionsKey(query, limit, offset),\n queryFn: async (): Promise<SearchSuggestionsResponse> => {\n const response = await api.openSearch.suggestions.suggest.list({\n q: query,\n });\n return response.data;\n },\n ...SEARCH_SUGGESTIONS_CACHE_OPTIONS,\n});\n\n/**\n * Fetches search suggestions via the augur-api OpenSearch endpoint.\n * Replaces the ampro-online pattern of fetching from a Next.js API route.\n */\nexport function useSearchSuggestions(\n query: string,\n options: UseSearchSuggestionsOptions = {},\n) {\n const api = useAugurApi();\n const limit = options.limit ?? 10;\n const offset = options.offset ?? 0;\n const enabled = (options.enabled ?? true) && query.trim().length > 0;\n\n const defaultOptions = getSearchSuggestionsOptions(api, query, limit, offset);\n\n const { data, isLoading, error } = useQuery<\n SearchSuggestionsResponse,\n Error\n >({\n ...defaultOptions,\n ...(options.queryFn ? { queryFn: options.queryFn } : {}),\n enabled,\n });\n\n return {\n suggestions: data?.data ?? [],\n total: data?.total ?? 0,\n isLoading,\n error,\n };\n}\n","import { useCallback } from \"react\";\nimport { useQueryClient } from \"@tanstack/react-query\";\nimport type { TCartLine } from \"@simpleapps-com/augur-utils\";\nimport {\n useCartHdrUid,\n useCartLines,\n useSetCartLines,\n} from \"../stores/cart-store\";\n\ntype CartLineInput = Pick<\n TCartLine,\n \"invMastUid\" | \"quantity\" | \"unitOfMeasure\"\n> & {\n cartHdrUid?: number | string | undefined;\n};\n\n/** Site-specific callbacks injected into useCartActions. */\nexport interface CartActionCallbacks {\n /** Add items to cart via API. Returns true on success. */\n addToCart: (\n cartHdrUid: number,\n items: Array<{\n cartHdrUid: number;\n invMastUid: number;\n quantity: number;\n unitOfMeasure: string;\n }>,\n ) => Promise<boolean | unknown>;\n /** Update cart lines via API. Returns true on success. */\n updateCartLines: (\n cartHdrUid: number,\n lines: TCartLine[],\n ) => Promise<boolean | unknown>;\n /** Delete all items from cart via API. Returns true on success. */\n deleteItemsFromCart: (cartHdrUid: number) => Promise<boolean | unknown>;\n /** Optional toast notification callback. */\n toast?: {\n info?: (message: string) => void;\n error?: (message: string) => void;\n success?: (message: string) => void;\n };\n}\n\ninterface CartActionOptions {\n showToast?: boolean;\n itemId?: string;\n onSuccess?: () => void;\n onError?: (error: Error) => void;\n}\n\n/**\n * Optimistic cart actions hook with automatic rollback on failure.\n *\n * Accepts site-specific server action callbacks so the hook itself\n * has no dependency on any particular server action implementation.\n *\n * @example\n * ```tsx\n * import { useCartActions } from \"@simpleapps-com/augur-hooks\";\n * import { addToCart, updateCartLines, deleteItemsFromCart } from \"@/lib/actions/commerce\";\n * import { toast } from \"react-toastify\";\n *\n * const cart = useCartActions({\n * addToCart, updateCartLines, deleteItemsFromCart,\n * toast: { info: toast.info, error: toast.error },\n * });\n *\n * await cart.addToCart({ invMastUid: 123, quantity: 1, unitOfMeasure: \"EA\" });\n * ```\n */\nexport function useCartActions(callbacks: CartActionCallbacks) {\n const queryClient = useQueryClient();\n const cartHdrUid = useCartHdrUid();\n const cartLines = useCartLines();\n const setCartLines = useSetCartLines();\n const notify = callbacks.toast;\n\n const cartHdrUidNum = typeof cartHdrUid === \"string\" ? Number(cartHdrUid) : cartHdrUid;\n\n const invalidateCartCache = useCallback(() => {\n queryClient.invalidateQueries({ queryKey: [\"cartLines\", cartHdrUid] });\n queryClient.invalidateQueries({\n queryKey: [\"cart-also-bought\", cartHdrUid],\n });\n }, [queryClient, cartHdrUid]);\n\n const addToCart = useCallback(\n async (\n item: CartLineInput,\n options: CartActionOptions = {},\n ): Promise<boolean> => {\n const { showToast = true, itemId = \"\", onSuccess, onError } = options;\n if (!cartHdrUidNum) throw new Error(\"Cart UID is not set\");\n\n const previousCartLines = [...cartLines];\n\n // Optimistic update\n const existingIndex = cartLines.findIndex(\n (line) => line.invMastUid === item.invMastUid,\n );\n\n let optimisticCartLines: TCartLine[];\n if (existingIndex >= 0) {\n optimisticCartLines = cartLines.map((line, index) =>\n index === existingIndex\n ? { ...line, quantity: line.quantity + item.quantity }\n : line,\n );\n } else {\n const newLine: TCartLine = {\n cartHdrUid: cartHdrUidNum,\n invMastUid: item.invMastUid,\n invMastUidCount: 1,\n isAssembly: \"N\",\n itemId: itemId,\n lineNo: cartLines.length + 1,\n lineNote: null,\n quantity: item.quantity,\n unitOfMeasure: item.unitOfMeasure,\n };\n optimisticCartLines = [...cartLines, newLine];\n }\n\n setCartLines(optimisticCartLines);\n\n try {\n const success = await callbacks.addToCart(cartHdrUidNum, [\n {\n cartHdrUid: cartHdrUidNum,\n invMastUid: item.invMastUid,\n quantity: item.quantity,\n unitOfMeasure: item.unitOfMeasure,\n },\n ]);\n\n if (!success) throw new Error(\"Failed to add item to cart\");\n\n invalidateCartCache();\n\n if (showToast && notify?.info) {\n notify.info(\n `${item.quantity} x ${itemId || \"Item\"} added to cart`,\n );\n }\n\n onSuccess?.();\n return true;\n } catch (error) {\n setCartLines(previousCartLines);\n if (showToast && notify?.error) {\n notify.error(\"Failed to add item to cart. Please try again.\");\n }\n onError?.(error as Error);\n return false;\n }\n },\n [cartHdrUid, cartLines, setCartLines, invalidateCartCache, callbacks, notify],\n );\n\n const updateQuantity = useCallback(\n async (\n invMastUid: number,\n newQuantity: number,\n options: CartActionOptions = {},\n ): Promise<boolean> => {\n const { showToast = false, onSuccess, onError } = options;\n if (!cartHdrUidNum) throw new Error(\"Cart UID is not set\");\n\n const previousCartLines = [...cartLines];\n\n const optimisticCartLines = cartLines.map((line) =>\n line.invMastUid === invMastUid\n ? { ...line, quantity: newQuantity }\n : line,\n );\n setCartLines(optimisticCartLines);\n\n try {\n const updatedLines = cartLines.map((line) =>\n line.invMastUid === invMastUid\n ? { ...line, quantity: newQuantity }\n : line,\n );\n\n const success = await callbacks.updateCartLines(\n cartHdrUidNum,\n updatedLines,\n );\n if (!success) throw new Error(\"Failed to update quantity\");\n\n invalidateCartCache();\n onSuccess?.();\n return true;\n } catch (error) {\n setCartLines(previousCartLines);\n if (showToast && notify?.error) {\n notify.error(\"Failed to update quantity. Please try again.\");\n }\n onError?.(error as Error);\n return false;\n }\n },\n [cartHdrUid, cartLines, setCartLines, invalidateCartCache, callbacks, notify],\n );\n\n const removeFromCart = useCallback(\n async (\n invMastUid: number,\n options: CartActionOptions = {},\n ): Promise<boolean> => {\n const { showToast = true, itemId = \"\", onSuccess, onError } = options;\n if (!cartHdrUidNum) throw new Error(\"Cart UID is not set\");\n\n const previousCartLines = [...cartLines];\n\n const optimisticCartLines = cartLines.filter(\n (line) => line.invMastUid !== invMastUid,\n );\n setCartLines(optimisticCartLines);\n\n try {\n const updatedLines = cartLines.map((line) =>\n line.invMastUid === invMastUid ? { ...line, quantity: 0 } : line,\n );\n\n const success = await callbacks.updateCartLines(\n cartHdrUidNum,\n updatedLines,\n );\n if (!success) throw new Error(\"Failed to remove item\");\n\n invalidateCartCache();\n if (showToast && notify?.info) {\n notify.info(`${itemId || \"Item\"} removed from cart`);\n }\n onSuccess?.();\n return true;\n } catch (error) {\n setCartLines(previousCartLines);\n if (showToast && notify?.error) {\n notify.error(\"Failed to remove item. Please try again.\");\n }\n onError?.(error as Error);\n return false;\n }\n },\n [cartHdrUid, cartLines, setCartLines, invalidateCartCache, callbacks, notify],\n );\n\n const clearCart = useCallback(\n async (options: Omit<CartActionOptions, \"itemId\"> = {}): Promise<boolean> => {\n const { showToast = true, onSuccess, onError } = options;\n if (!cartHdrUidNum) throw new Error(\"Cart UID is not set\");\n\n const previousCartLines = [...cartLines];\n setCartLines([]);\n\n try {\n const success = await callbacks.deleteItemsFromCart(cartHdrUidNum);\n if (!success) throw new Error(\"Failed to clear cart\");\n\n invalidateCartCache();\n if (showToast && notify?.info) {\n notify.info(\"Cart cleared\");\n }\n onSuccess?.();\n return true;\n } catch (error) {\n setCartLines(previousCartLines);\n if (showToast && notify?.error) {\n notify.error(\"Failed to clear cart. Please try again.\");\n }\n onError?.(error as Error);\n return false;\n }\n },\n [cartHdrUid, cartLines, setCartLines, invalidateCartCache, callbacks, notify],\n );\n\n const isInCart = useCallback(\n (invMastUid: number): boolean => {\n return cartLines.some((line) => line.invMastUid === invMastUid);\n },\n [cartLines],\n );\n\n const getItemQuantity = useCallback(\n (invMastUid: number): number => {\n return cartLines.find((line) => line.invMastUid === invMastUid)?.quantity ?? 0;\n },\n [cartLines],\n );\n\n return {\n addToCart,\n updateQuantity,\n removeFromCart,\n clearCart,\n isInCart,\n getItemQuantity,\n cartHdrUid,\n cartLines,\n invalidateCartCache,\n };\n}\n","import { useEffect, useRef } from \"react\";\nimport { useQuery } from \"@tanstack/react-query\";\nimport { CACHE_CONFIG, type TCartLine } from \"@simpleapps-com/augur-utils\";\nimport {\n useCartHdrUid,\n useSetCartHdrUid,\n useSetCartLines,\n} from \"../stores/cart-store\";\n\nconst MAX_RETRY_ATTEMPTS = 7;\nconst RETRY_DELAY_MS = 1000;\n\n/** Session info passed from the consumer's auth system. */\nexport interface CartSessionInfo {\n /** Auth status: \"loading\" | \"authenticated\" | \"unauthenticated\" */\n status: \"loading\" | \"authenticated\" | \"unauthenticated\";\n /** User's ID (e.g., Joomla user ID). Undefined if not authenticated. */\n userId?: string | number;\n /** Cart header UID from the auth session, if available. */\n cartHdrUid?: number;\n}\n\n/** Site-specific callbacks injected into useCartInitialization. */\nexport interface CartInitCallbacks {\n /** Look up or create a cart header. Returns { cartHdrUid, cartToken? }. */\n cartHdrLookup: (\n userId: string | number,\n cartToken: string,\n ) => Promise<{ cartHdrUid: number; cartToken?: string } | null>;\n /** Fetch cart line items for a given cart header UID. */\n getCartLines: (cartHdrUid: number) => Promise<TCartLine[]>;\n /** Get the current cart token from cookies. */\n getCartToken: () => string | null;\n /** Save cart token to cookies. */\n saveCartToken: (token: string) => void;\n /** Generate a new unique cart token (e.g., uuidv4). */\n generateCartToken: () => string;\n}\n\n/**\n * Initialize cart state from session (authenticated) or cookie (guest).\n * Call once in the root layout.\n *\n * @example\n * ```tsx\n * import { useCartInitialization } from \"@simpleapps-com/augur-hooks\";\n * import { useSession } from \"next-auth/react\";\n * import { cartHdrLookup, getCartLines } from \"@/lib/actions/commerce\";\n * import { getCookie, setCookie } from \"cookies-next/client\";\n * import { v4 as uuidv4 } from \"uuid\";\n *\n * function CartInitializer() {\n * const { data: session, status } = useSession();\n *\n * useCartInitialization(\n * {\n * status,\n * userId: session?.user?.id,\n * cartHdrUid: session?.user?.cartHdrUid,\n * },\n * {\n * cartHdrLookup,\n * getCartLines,\n * getCartToken: () => getCookie(\"cartToken\") as string | null,\n * saveCartToken: (token) => setCookie(\"cartToken\", token, { maxAge: 604800, path: \"/\" }),\n * generateCartToken: uuidv4,\n * },\n * );\n *\n * return null;\n * }\n * ```\n */\nexport function useCartInitialization(\n session: CartSessionInfo,\n callbacks: CartInitCallbacks,\n) {\n const cartHdrUid = useCartHdrUid();\n const setCartHdrUid = useSetCartHdrUid();\n const setCartLines = useSetCartLines();\n\n const retryCountRef = useRef(0);\n const isInitializingRef = useRef(false);\n\n // Initialize cart header\n useEffect(() => {\n if (cartHdrUid || session.status === \"loading\") return;\n\n // Authenticated user — use session cartHdrUid\n if (session.cartHdrUid && session.status === \"authenticated\") {\n setCartHdrUid(session.cartHdrUid);\n return;\n }\n\n // Guest user — lookup/create cart\n if (session.status === \"unauthenticated\" && !isInitializingRef.current) {\n isInitializingRef.current = true;\n retryCountRef.current = 0;\n\n const initializeGuestCart = async () => {\n const existingToken = callbacks.getCartToken();\n const cartToken =\n existingToken && typeof existingToken === \"string\"\n ? existingToken\n : callbacks.generateCartToken();\n\n while (retryCountRef.current < MAX_RETRY_ATTEMPTS) {\n try {\n const cartHdr = await callbacks.cartHdrLookup(\"0\", cartToken);\n\n if (cartHdr && cartHdr.cartHdrUid !== 0) {\n callbacks.saveCartToken(cartToken);\n setCartHdrUid(cartHdr.cartHdrUid);\n isInitializingRef.current = false;\n return;\n }\n\n retryCountRef.current++;\n\n if (retryCountRef.current < MAX_RETRY_ATTEMPTS) {\n const delay = Math.min(\n RETRY_DELAY_MS * Math.pow(1.5, retryCountRef.current),\n 10000,\n );\n await new Promise((resolve) => setTimeout(resolve, delay));\n }\n } catch (error) {\n console.error(\n `Cart initialization attempt ${retryCountRef.current + 1} failed:`,\n error,\n );\n retryCountRef.current++;\n\n if (retryCountRef.current < MAX_RETRY_ATTEMPTS) {\n const delay = Math.min(\n RETRY_DELAY_MS * Math.pow(1.5, retryCountRef.current),\n 10000,\n );\n await new Promise((resolve) => setTimeout(resolve, delay));\n }\n }\n }\n\n console.error(\n `Cart initialization failed after ${MAX_RETRY_ATTEMPTS} attempts`,\n );\n isInitializingRef.current = false;\n };\n\n initializeGuestCart();\n }\n }, [session, cartHdrUid, setCartHdrUid, callbacks]);\n\n // Fetch cart lines when cartHdrUid is available\n const { data: cartLinesData } = useQuery({\n queryKey: [\"cartLines\", cartHdrUid],\n queryFn: () => callbacks.getCartLines(Number(cartHdrUid)),\n enabled: !!cartHdrUid,\n ...CACHE_CONFIG.CART,\n });\n\n // Sync cart lines to Zustand store\n useEffect(() => {\n if (cartLinesData) {\n setCartLines(cartLinesData);\n }\n }, [cartLinesData, setCartLines]);\n\n return {\n cartHdrUid,\n isInitializing: isInitializingRef.current,\n retryCount: retryCountRef.current,\n };\n}\n","import { useMemo } from \"react\";\nimport { useQueries } from \"@tanstack/react-query\";\nimport { useCartLines } from \"../stores/cart-store\";\nimport { getItemPriceOptions } from \"./use-item-price\";\nimport { useAugurApi } from \"../provider\";\n\nexport interface CartPriceData {\n unitPrice: number;\n priceData: Record<string, unknown> | null;\n}\n\nexport interface CartPricingResult {\n /** Map of itemId -> price data (with quantity-specific pricing) */\n prices: Record<string, CartPriceData>;\n /** Get unit price for an item (returns 0 if not found) */\n getUnitPrice: (itemId: string) => number;\n /** Get total price for an item (unitPrice * quantity) */\n getItemTotal: (itemId: string, quantity: number) => number;\n /** Cart subtotal (sum of all item totals) */\n subtotal: number;\n /** True if any price is still loading */\n isLoading: boolean;\n /** True if all prices loaded successfully */\n isSuccess: boolean;\n /** True if any price failed to load */\n isError: boolean;\n}\n\ninterface UseCartPricingOptions {\n customerId?: string | number;\n}\n\n/**\n * Centralized hook for cart/checkout pricing.\n *\n * Fetches prices for ALL cart items with their actual quantities\n * to support quantity-based price breaks. React Query dedupes\n * identical calls across components.\n */\nexport function useCartPricing(\n options: UseCartPricingOptions = {},\n): CartPricingResult {\n const api = useAugurApi();\n const cartLines = useCartLines();\n const { customerId } = options;\n\n const priceQueries = useQueries({\n queries: cartLines.map((line) => ({\n ...getItemPriceOptions(api, line.itemId, customerId, line.quantity),\n enabled: !!customerId && !!line.itemId,\n })),\n });\n\n const prices = useMemo(() => {\n const map: Record<string, CartPriceData> = {};\n cartLines.forEach((line, index) => {\n const queryResult = priceQueries[index];\n if (queryResult?.data) {\n map[line.itemId.toUpperCase()] = {\n unitPrice: queryResult.data.unitPrice ?? 0,\n priceData: queryResult.data as Record<string, unknown>,\n };\n }\n });\n return map;\n }, [cartLines, priceQueries]);\n\n const getUnitPrice = useMemo(() => {\n return (itemId: string): number => {\n return prices[itemId?.toUpperCase()]?.unitPrice ?? 0;\n };\n }, [prices]);\n\n const getItemTotal = useMemo(() => {\n return (itemId: string, quantity: number): number => {\n return getUnitPrice(itemId) * quantity;\n };\n }, [getUnitPrice]);\n\n const subtotal = useMemo(() => {\n return cartLines.reduce((sum, line) => {\n const unitPrice = prices[line.itemId.toUpperCase()]?.unitPrice ?? 0;\n return sum + unitPrice * line.quantity;\n }, 0);\n }, [cartLines, prices]);\n\n const isLoading = priceQueries.some((q) => q.isLoading);\n const isSuccess = priceQueries.every((q) => q.isSuccess);\n const isError = priceQueries.some((q) => q.isError);\n\n return {\n prices,\n getUnitPrice,\n getItemTotal,\n subtotal,\n isLoading,\n isSuccess,\n isError,\n };\n}\n\n/**\n * Get cart pricing query options for prefetching or parent components.\n */\nexport function getCartPricingQueryOptions(\n api: ReturnType<typeof useAugurApi>,\n cartLines: Array<{ itemId: string; quantity: number }>,\n customerId: string | number | undefined,\n) {\n return cartLines.map((line) => ({\n ...getItemPriceOptions(api, line.itemId, customerId, line.quantity),\n enabled: !!customerId && !!line.itemId,\n }));\n}\n","import { useQueryClient } from \"@tanstack/react-query\";\nimport { useCallback } from \"react\";\nimport type { QueryKey } from \"@tanstack/react-query\";\n\ninterface UsePaginationPrefetchOptions {\n /** Query key for the paginated data */\n queryKey: QueryKey;\n /** Function to fetch a page of data */\n queryFn: (offset: number) => Promise<unknown>;\n /** Number of items per page */\n pageSize: number;\n /** Stale time in ms (defaults to 10 minutes) */\n staleTime?: number;\n /** GC time in ms (defaults to 30 minutes) */\n gcTime?: number;\n enabled?: boolean;\n}\n\n/**\n * Prefetch adjacent pages on hover for instant pagination.\n * Accepts a generic queryFn so it works with any paginated resource.\n */\nexport const usePaginationPrefetch = ({\n queryKey,\n queryFn,\n pageSize,\n staleTime = 10 * 60 * 1000,\n gcTime = 30 * 60 * 1000,\n enabled = true,\n}: UsePaginationPrefetchOptions) => {\n const queryClient = useQueryClient();\n\n const prefetchPage = useCallback(\n async (page: number) => {\n if (!enabled) return;\n\n const offset = (page - 1) * pageSize;\n\n try {\n await queryClient.prefetchQuery({\n queryKey: [...queryKey, offset],\n queryFn: () => queryFn(offset),\n staleTime,\n gcTime,\n });\n } catch (error) {\n console.warn(`Error prefetching page ${page}:`, error);\n }\n },\n [queryKey, queryFn, pageSize, staleTime, gcTime, queryClient, enabled],\n );\n\n const handlePaginationHover = useCallback(\n (page: number) => {\n const timeoutId = setTimeout(() => prefetchPage(page), 150);\n return () => clearTimeout(timeoutId);\n },\n [prefetchPage],\n );\n\n return {\n prefetchPage,\n handlePaginationHover,\n };\n};\n","import { useInfiniteQuery } from \"@tanstack/react-query\";\nimport {\n CACHE_CONFIG,\n type TItemsFilters,\n type TProductItem,\n} from \"@simpleapps-com/augur-utils\";\nimport { useAugurApi } from \"../provider\";\n\ninterface CategoryItemsInfiniteResponse {\n data: TProductItem[];\n total: number;\n nextCursor?: number;\n}\n\ninterface UseCategoryItemsInfiniteOptions {\n enabled?: boolean;\n}\n\nexport const getCategoryItemsInfiniteKey = (\n itemCategoryUid: number,\n itemsFilters: TItemsFilters,\n) => {\n return [\n \"categoryItemsInfinite\",\n itemCategoryUid,\n JSON.stringify(itemsFilters),\n ] as const;\n};\n\n/**\n * Infinite scroll for category product listings.\n * Fetches pages of products via the augur-api SDK.\n */\nexport function useCategoryItemsInfinite(\n itemCategoryUid: number,\n itemsFilters: TItemsFilters,\n options: UseCategoryItemsInfiniteOptions = {},\n) {\n const api = useAugurApi();\n const { enabled = true } = options;\n\n return useInfiniteQuery<CategoryItemsInfiniteResponse>({\n queryKey: getCategoryItemsInfiniteKey(itemCategoryUid, itemsFilters),\n queryFn: async ({ pageParam = 0 }) => {\n const response = await api.openSearch.itemSearch.list({\n q: itemsFilters.q || \"\",\n searchType: \"query\",\n size: itemsFilters.limit,\n from: pageParam as number,\n classId5List: String(itemCategoryUid),\n filters: itemsFilters.filters?.length\n ? JSON.stringify(itemsFilters.filters)\n : undefined,\n });\n const items: TProductItem[] = response.data?.items ?? [];\n const total: number = response.data?.totalResults ?? 0;\n const nextOffset = (pageParam as number) + itemsFilters.limit;\n return {\n data: items,\n total,\n nextCursor: nextOffset < total ? nextOffset : undefined,\n };\n },\n initialPageParam: 0,\n getNextPageParam: (lastPage) => lastPage.nextCursor,\n ...CACHE_CONFIG.SEMI_STATIC,\n enabled: enabled && !!itemCategoryUid,\n });\n}\n","import { useInfiniteQuery } from \"@tanstack/react-query\";\nimport {\n CACHE_CONFIG,\n type TItemsFilters,\n type TProductItem,\n} from \"@simpleapps-com/augur-utils\";\nimport { useAugurApi } from \"../provider\";\n\ninterface ItemSearchInfiniteResponse {\n data: TProductItem[];\n total: number;\n nextCursor?: number;\n}\n\ninterface UseItemSearchInfiniteOptions {\n enabled?: boolean;\n}\n\nexport const getItemSearchInfiniteKey = (\n itemsFilters: TItemsFilters,\n itemCategoryUid?: number | string,\n) => {\n return [\n \"itemSearchInfinite\",\n JSON.stringify(itemsFilters),\n itemCategoryUid,\n ] as const;\n};\n\n/**\n * Infinite scroll for search results.\n * Fetches pages of products via the augur-api SDK OpenSearch endpoint.\n */\nexport function useItemSearchInfinite(\n itemsFilters: TItemsFilters,\n itemCategoryUid?: number | string,\n options: UseItemSearchInfiniteOptions = {},\n) {\n const api = useAugurApi();\n const { enabled = true } = options;\n\n return useInfiniteQuery<ItemSearchInfiniteResponse>({\n queryKey: getItemSearchInfiniteKey(itemsFilters, itemCategoryUid),\n queryFn: async ({ pageParam = 0 }) => {\n const response = await api.openSearch.itemSearch.list({\n q: itemsFilters.q,\n searchType: \"query\",\n size: itemsFilters.limit,\n from: pageParam as number,\n classId5List: itemCategoryUid\n ? String(itemCategoryUid)\n : undefined,\n filters: itemsFilters.filters?.length\n ? JSON.stringify(itemsFilters.filters)\n : undefined,\n });\n const items: TProductItem[] = response.data?.items ?? [];\n const total: number = response.data?.totalResults ?? 0;\n const nextOffset = (pageParam as number) + itemsFilters.limit;\n return {\n data: items,\n total,\n nextCursor: nextOffset < total ? nextOffset : undefined,\n };\n },\n initialPageParam: 0,\n getNextPageParam: (lastPage) => lastPage.nextCursor,\n ...CACHE_CONFIG.SEMI_STATIC,\n enabled: enabled && !!itemsFilters.q,\n meta: { persist: true },\n });\n}\n"],"mappings":";AAAA,SAAS,eAAe,kBAAkC;AA+BtD;AAhBJ,IAAM,kBAAkB,cAAqC,IAAI;AAc1D,SAAS,mBAAmB,EAAE,KAAK,SAAS,GAA4B;AAC7E,SACE,oBAAC,gBAAgB,UAAhB,EAAyB,OAAO,KAAM,UAAS;AAEpD;AAMO,SAAS,cAA8B;AAC5C,QAAM,MAAM,WAAW,eAAe;AACtC,MAAI,CAAC,KAAK;AACR,UAAM,IAAI;AAAA,MACR;AAAA,IAEF;AAAA,EACF;AACA,SAAO;AACT;;;AChDA,SAAS,cAAc;AACvB,SAAS,gBAAgB;AAWlB,IAAM,eAAe,OAAkB;AAAA,EAC5C;AAAA,IACE,CAAC,SAAS;AAAA,MACR,YAAY;AAAA,MACZ,WAAW,CAAC;AAAA,MACZ,eAAe;AAAA,MAEf,eAAe,CAAC,eACd,IAAI,EAAE,WAAW,GAAG,OAAO,eAAe;AAAA,MAE5C,cAAc,CAAC,cAAc;AAC3B,cAAM,gBAAgB,UAAU;AAAA,UAC9B,CAAC,KAAK,SAAS,OAAO,KAAK,YAAY;AAAA,UACvC;AAAA,QACF;AACA,YAAI,EAAE,WAAW,cAAc,GAAG,OAAO,cAAc;AAAA,MACzD;AAAA,IACF;AAAA,IACA,EAAE,MAAM,aAAa,SAAS,QAAQ,IAAI,aAAa,cAAc;AAAA,EACvE;AACF;AAGO,IAAM,gBAAgB,MAAM,aAAa,CAAC,MAAM,EAAE,UAAU;AAC5D,IAAM,eAAe,MAAM,aAAa,CAAC,MAAM,EAAE,SAAS;AAC1D,IAAM,mBAAmB,MAAM,aAAa,CAAC,MAAM,EAAE,aAAa;AAClE,IAAM,mBAAmB,M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,SAAS,WAAW,CAAC,CAAC,aAAa;AAAA,IACnC,MAAM,EAAE,SAAS,KAAK;AAAA,EACxB,CAAC;AACH;","names":["create","devtools","useQuery","CACHE_CONFIG","CACHE_CONFIG","useQuery","useQuery","CACHE_CONFIG","CACHE_CONFIG","useQuery","useQuery","CACHE_CONFIG","CACHE_CONFIG","useQuery","useQuery","CACHE_CONFIG","CACHE_CONFIG","useQuery","useQuery","CACHE_CONFIG","CACHE_CONFIG","useQuery","useQuery","CACHE_CONFIG","CACHE_CONFIG","useQuery","useQuery","CACHE_CONFIG","CACHE_CONFIG","useQuery","useQuery","CACHE_CONFIG","CACHE_CONFIG","useQuery","useQuery","CACHE_CONFIG","CACHE_CONFIG","useQuery","useEffect","useQuery","CACHE_CONFIG","useEffect","useQuery","CACHE_CONFIG","useQueryClient","useCallback","CACHE_CONFIG","CACHE_CONFIG","useInfiniteQuery","CACHE_CONFIG","useInfiniteQuery","CACHE_CONFIG"]}
|
|
1
|
+
{"version":3,"sources":["../src/provider.tsx","../src/stores/cart-store.ts","../src/stores/items-filters-store.ts","../src/hooks/use-debounce.ts","../src/hooks/use-format-price.ts","../src/hooks/use-item-price.ts","../src/hooks/use-inv-mast-doc.ts","../src/hooks/use-item-category.ts","../src/hooks/use-inv-mast.ts","../src/hooks/use-inv-mast-stock.ts","../src/hooks/use-product-category.ts","../src/hooks/use-item-details.ts","../src/hooks/use-item-attributes.ts","../src/hooks/use-product-search.ts","../src/hooks/use-search-suggestions.ts","../src/hooks/use-cart-actions.ts","../src/hooks/use-cart-initialization.ts","../src/hooks/use-cart-pricing.ts","../src/hooks/use-pagination-prefetch.ts","../src/hooks/use-category-items-infinite.ts","../src/hooks/use-item-search-infinite.ts"],"sourcesContent":["import { createContext, useContext, type ReactNode } from \"react\";\n\n/**\n * Minimal type for the augur-api SDK instance.\n * Consumers provide their concrete AugurAPI instance; we keep the type\n * loose so augur-hooks doesn't need to depend directly on the SDK package.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type AugurApiClient = any;\n\ninterface AugurHooksProviderProps {\n api: AugurApiClient;\n children: ReactNode;\n}\n\nconst AugurApiContext = createContext<AugurApiClient | null>(null);\n\n/**\n * Provides the augur-api SDK instance to all hooks in the tree.\n *\n * ```tsx\n * import { AugurAPI } from \"@simpleapps-com/augur-api\";\n * const api = new AugurAPI({ baseUrl: \"...\", token: \"...\" });\n *\n * <AugurHooksProvider api={api}>\n * <App />\n * </AugurHooksProvider>\n * ```\n */\nexport function AugurHooksProvider({ api, children }: AugurHooksProviderProps) {\n return (\n <AugurApiContext.Provider value={api}>{children}</AugurApiContext.Provider>\n );\n}\n\n/**\n * Returns the augur-api SDK instance from context.\n * Throws if called outside of `<AugurHooksProvider>`.\n */\nexport function useAugurApi(): AugurApiClient {\n const api = useContext(AugurApiContext);\n if (!api) {\n throw new Error(\n \"useAugurApi must be used within an <AugurHooksProvider>. \" +\n \"Wrap your app with <AugurHooksProvider api={apiInstance}>.\",\n );\n }\n return api;\n}\n","import { create } from \"zustand\";\nimport { devtools } from \"zustand/middleware\";\nimport type { TCartLine } from \"@simpleapps-com/augur-utils\";\n\ninterface CartState {\n cartHdrUid: number | string | undefined;\n cartLines: TCartLine[];\n cartItemCount: number;\n setCartHdrUid: (cartHdrUid: number | string | undefined) => void;\n setCartLines: (cartLines: TCartLine[]) => void;\n}\n\nexport const useCartStore = create<CartState>()(\n devtools(\n (set) => ({\n cartHdrUid: undefined,\n cartLines: [],\n cartItemCount: 0,\n\n setCartHdrUid: (cartHdrUid) =>\n set({ cartHdrUid }, false, \"setCartHdrUid\"),\n\n setCartLines: (cartLines) => {\n const cartItemCount = cartLines.reduce(\n (sum, line) => sum + (line.quantity || 0),\n 0,\n );\n set({ cartLines, cartItemCount }, false, \"setCartLines\");\n },\n }),\n { name: \"CartStore\", enabled: process.env.NODE_ENV === \"development\" },\n ),\n);\n\n// Selector hooks -- only re-render when specific state changes\nexport const useCartHdrUid = () => useCartStore((s) => s.cartHdrUid);\nexport const useCartLines = () => useCartStore((s) => s.cartLines);\nexport const useCartItemCount = () => useCartStore((s) => s.cartItemCount);\nexport const useSetCartHdrUid = () => useCartStore((s) => s.setCartHdrUid);\nexport const useSetCartLines = () => useCartStore((s) => s.setCartLines);\n","import { create } from \"zustand\";\nimport { devtools } from \"zustand/middleware\";\nimport type { TItemsFilters } from \"@simpleapps-com/augur-utils\";\n\nconst DEFAULT_FILTER_STATE: TItemsFilters = {\n filters: [],\n limit: 12,\n offset: 0,\n sortBy: \"asc\",\n q: \"\",\n page: 1,\n};\n\ninterface ItemsFiltersState {\n initialFiltersState: TItemsFilters;\n itemsFilters: TItemsFilters;\n setItemsFilters: (itemFilters: TItemsFilters) => void;\n}\n\nexport const useItemFiltersStore = create<ItemsFiltersState>()(\n devtools(\n (set) => ({\n initialFiltersState: DEFAULT_FILTER_STATE,\n itemsFilters: DEFAULT_FILTER_STATE,\n setItemsFilters: (state) =>\n set({ itemsFilters: state }, false, \"setItemsFilters\"),\n }),\n {\n name: \"ItemsFiltersStore\",\n enabled: process.env.NODE_ENV === \"development\",\n },\n ),\n);\n","import { useEffect, useState } from \"react\";\n\n/**\n * Debounces a rapidly-changing value.\n * Returns the latest value only after `delay` ms of inactivity.\n */\nexport function useDebounce<T>(value: T, delay: number = 500): T {\n const [debouncedValue, setDebouncedValue] = useState<T>(value);\n\n useEffect(() => {\n const handler = setTimeout(() => {\n setDebouncedValue(value);\n }, delay);\n\n return () => {\n clearTimeout(handler);\n };\n }, [value, delay]);\n\n return debouncedValue;\n}\n","/**\n * Hook that returns a price formatter.\n * Wraps Intl.NumberFormat with configurable locale/currency.\n */\nexport function useFormatPrice(\n locale: string = \"en-US\",\n currency: string = \"USD\",\n) {\n const formatPrice = (price: number): string => {\n return new Intl.NumberFormat(locale, {\n style: \"currency\",\n currency,\n minimumFractionDigits: 2,\n }).format(price);\n };\n\n return { formatPrice };\n}\n","import { useQuery } from \"@tanstack/react-query\";\nimport { CACHE_CONFIG, type TPriceData } from \"@simpleapps-com/augur-utils\";\nimport { useAugurApi, type AugurApiClient } from \"../provider\";\n\ninterface UseItemPriceOptions {\n enabled?: boolean;\n /** Override the default queryFn (e.g. with a cached server action). */\n queryFn?: () => Promise<TPriceData>;\n}\n\nexport const PRICE_CACHE_OPTIONS = {\n ...CACHE_CONFIG.SEMI_STATIC,\n refetchOnReconnect: true,\n refetchOnWindowFocus: false,\n meta: { persist: true },\n} as const;\n\n/**\n * Generates a consistent query key for item price queries.\n * Usable in both client hooks and server-side prefetch.\n */\nexport const getItemPriceKey = (\n itemId: string | undefined,\n customerId: string | number | undefined,\n quantity: number = 1,\n) => {\n return [\"price\", itemId?.toUpperCase() || \"\", customerId, quantity] as const;\n};\n\n/**\n * Query options for item price. Accepts the SDK instance so it works\n * in both client (via provider) and server (via direct construction).\n */\nexport const getItemPriceOptions = (\n api: AugurApiClient,\n itemId: string | undefined,\n customerId: string | number | undefined,\n quantity: number = 1,\n) => ({\n queryKey: getItemPriceKey(itemId, customerId, quantity),\n queryFn: async (): Promise<TPriceData> => {\n const response = await api.pricing.priceEngine.get({\n itemId: itemId?.toUpperCase() || \"\",\n customerId: Number(customerId),\n quantity,\n });\n return response.data;\n },\n ...PRICE_CACHE_OPTIONS,\n});\n\n/**\n * Fetches and caches item pricing via the augur-api SDK.\n *\n * Pass `options.queryFn` to override with a cached server action:\n * ```ts\n * useItemPrice(itemId, customerId, 1, {\n * queryFn: () => getItemPriceCached(itemId, customerId, 1),\n * });\n * ```\n */\nexport function useItemPrice(\n itemId: string | undefined,\n customerId: string | number | undefined,\n quantity: number = 1,\n options: UseItemPriceOptions = {},\n) {\n const api = useAugurApi();\n const defaultOptions = getItemPriceOptions(api, itemId, customerId, quantity);\n\n return useQuery({\n ...defaultOptions,\n ...(options.queryFn ? { queryFn: options.queryFn } : {}),\n enabled: options.enabled ?? (Boolean(itemId) && Boolean(customerId)),\n retry: 3,\n });\n}\n","import { useQuery } from \"@tanstack/react-query\";\nimport { CACHE_CONFIG, type TInvMastDoc } from \"@simpleapps-com/augur-utils\";\nimport { useAugurApi, type AugurApiClient } from \"../provider\";\n\ninterface UseInvMastDocOptions {\n enabled?: boolean;\n includePricing?: \"Y\" | \"N\";\n /** Initial data from server -- enables instant render without loading state. */\n initialData?: TInvMastDoc;\n /** Override the default queryFn (e.g. with a cached server action). */\n queryFn?: () => Promise<TInvMastDoc>;\n}\n\nexport const INV_MAST_DOC_CACHE_OPTIONS = CACHE_CONFIG.STATIC;\n\n/**\n * Generates a consistent query key for inv mast doc queries.\n * Usable in both client hooks and server-side prefetch.\n */\nexport const getInvMastDocKey = (\n invMastUid: number,\n itemId: string,\n includePricing: \"Y\" | \"N\",\n) => {\n return [\n \"invMastDoc\",\n invMastUid,\n itemId.toUpperCase(),\n includePricing,\n ] as const;\n};\n\n/**\n * Query options for inv mast doc. Accepts the SDK instance so it works\n * in both client (via provider) and server (via direct construction).\n */\nexport const getInvMastDocOptions = (\n api: AugurApiClient,\n invMastUid: number,\n itemId: string,\n includePricing: \"Y\" | \"N\",\n) => ({\n queryKey: getInvMastDocKey(invMastUid, itemId, includePricing),\n queryFn: async (): Promise<TInvMastDoc> => {\n const response = await api.items.invMast.doc.list(invMastUid, {\n includePricing,\n });\n if (!response.data) throw new Error(\"Item not found\");\n return response.data;\n },\n ...INV_MAST_DOC_CACHE_OPTIONS,\n});\n\n/**\n * Fetches and caches an inventory master document via the augur-api SDK.\n */\nexport function useInvMastDoc(\n invMastUid: number,\n itemId: string,\n options: UseInvMastDocOptions = {},\n) {\n const api = useAugurApi();\n const queryOpts = getInvMastDocOptions(\n api,\n invMastUid,\n itemId,\n options.includePricing ?? \"N\",\n );\n\n const { data, isLoading, error } = useQuery<TInvMastDoc, Error>({\n ...queryOpts,\n ...(options.queryFn ? { queryFn: options.queryFn } : {}),\n enabled: options.enabled ?? true,\n initialData: options.initialData,\n });\n\n return { item: data, isLoading, error };\n}\n","import { useQuery } from \"@tanstack/react-query\";\nimport { CACHE_CONFIG, type TCategory } from \"@simpleapps-com/augur-utils\";\nimport { useAugurApi, type AugurApiClient } from \"../provider\";\nimport type { GetItemCategoryApiOptions } from \"../types\";\n\ninterface UseItemCategoryOptions {\n enabled?: boolean;\n apiOptions?: GetItemCategoryApiOptions;\n /** Override the default queryFn (e.g. with a cached server action). */\n queryFn?: () => Promise<TCategory>;\n}\n\nexport const CATEGORY_CACHE_OPTIONS = CACHE_CONFIG.STATIC;\n\ntype ItemCategoryQueryKey = readonly [\n \"itemCategory\",\n number,\n GetItemCategoryApiOptions | undefined,\n];\n\n/**\n * Generates a consistent query key for item category queries.\n * Usable in both client hooks and server-side prefetch.\n */\nexport const getItemCategoryKey = (\n itemCategoryUid: number,\n apiOptions?: GetItemCategoryApiOptions,\n): ItemCategoryQueryKey => {\n return [\"itemCategory\", itemCategoryUid, apiOptions] as const;\n};\n\n/**\n * Query options for item category. Accepts the SDK instance so it works\n * in both client (via provider) and server (via direct construction).\n */\nexport const getItemCategoryOptions = (\n api: AugurApiClient,\n itemCategoryUid: number,\n apiOptions?: GetItemCategoryApiOptions,\n) => ({\n queryKey: getItemCategoryKey(itemCategoryUid, apiOptions),\n queryFn: async (): Promise<TCategory> => {\n const response = await api.items.itemCategory.get(\n itemCategoryUid,\n apiOptions,\n );\n if (!response.data) throw new Error(\"Item category not found\");\n return response.data;\n },\n ...CATEGORY_CACHE_OPTIONS,\n});\n\n/**\n * Fetches and caches item category data via the augur-api SDK.\n */\nexport function useItemCategory(\n itemCategoryUid: number,\n options: UseItemCategoryOptions = {},\n) {\n const api = useAugurApi();\n const queryOpts = getItemCategoryOptions(\n api,\n itemCategoryUid,\n options.apiOptions,\n );\n\n const { data, isLoading, error } = useQuery<\n TCategory,\n Error,\n TCategory,\n ItemCategoryQueryKey\n >({\n ...queryOpts,\n ...(options.queryFn ? { queryFn: options.queryFn } : {}),\n enabled: options.enabled ?? true,\n });\n\n return { category: data, isLoading, error };\n}\n","import { useQuery } from \"@tanstack/react-query\";\nimport { CACHE_CONFIG, type TItemDetails } from \"@simpleapps-com/augur-utils\";\nimport { useAugurApi, type AugurApiClient } from \"../provider\";\n\ninterface UseInvMastOptions {\n enabled?: boolean;\n queryFn?: () => Promise<TItemDetails>;\n}\n\nexport const INV_MAST_CACHE_OPTIONS = CACHE_CONFIG.STATIC;\n\nexport const getInvMastKey = (invMastUid: number, itemId: string) => {\n return [\"invMast\", invMastUid, itemId.toUpperCase()] as const;\n};\n\nexport const getInvMastOptions = (\n api: AugurApiClient,\n invMastUid: number,\n itemId: string,\n) => ({\n queryKey: getInvMastKey(invMastUid, itemId),\n queryFn: async (): Promise<TItemDetails> => {\n const response = await api.items.invMast.get(invMastUid);\n if (!response.data) throw new Error(\"Item not found\");\n return response.data;\n },\n ...INV_MAST_CACHE_OPTIONS,\n});\n\nexport function useInvMast(\n invMastUid: number,\n itemId: string,\n options: UseInvMastOptions = {},\n) {\n const api = useAugurApi();\n const queryOpts = getInvMastOptions(api, invMastUid, itemId);\n\n const { data, isLoading, error } = useQuery<TItemDetails, Error>({\n ...queryOpts,\n ...(options.queryFn ? { queryFn: options.queryFn } : {}),\n enabled: options.enabled ?? true,\n });\n\n return { item: data, isLoading, error };\n}\n","import { useQuery } from \"@tanstack/react-query\";\nimport { CACHE_CONFIG, type TStockData } from \"@simpleapps-com/augur-utils\";\nimport { useAugurApi, type AugurApiClient } from \"../provider\";\n\ninterface UseInvMastStockOptions {\n enabled?: boolean;\n queryFn?: () => Promise<number>;\n}\n\nexport const getInvMastStockKey = (invMastUid: number | string) => {\n return [\"invMastStock\", invMastUid] as const;\n};\n\nexport const getInvMastStockOptions = (\n api: AugurApiClient,\n invMastUid: number | string,\n) => ({\n queryKey: getInvMastStockKey(invMastUid),\n queryFn: async (): Promise<number> => {\n const response = await api.items.invMast.stock.list(Number(invMastUid));\n const stockData: TStockData[] = response.data?.stockData ?? [];\n return stockData.reduce(\n (qty: number, stock: TStockData) => qty + stock.qtyOnHand,\n 0,\n );\n },\n ...CACHE_CONFIG.SEMI_STATIC,\n});\n\nexport function useInvMastStock(\n invMastUid: number | string,\n options: UseInvMastStockOptions = {},\n) {\n const api = useAugurApi();\n const queryOpts = getInvMastStockOptions(api, invMastUid);\n\n const { data, isLoading, error } = useQuery({\n ...queryOpts,\n ...(options.queryFn ? { queryFn: options.queryFn } : {}),\n enabled: (options.enabled ?? true) && !!invMastUid,\n retry: 3,\n /* v8 ignore start */\n retryDelay: (attemptIndex: number) =>\n Math.min(1000 * 2 ** attemptIndex, 10000),\n /* v8 ignore stop */\n });\n\n return {\n qtyOnHand: data ?? null,\n loading: isLoading,\n error: error as Error | null,\n };\n}\n","import { useQuery } from \"@tanstack/react-query\";\nimport { CACHE_CONFIG, type TProductCategory } from \"@simpleapps-com/augur-utils\";\nimport { useAugurApi, type AugurApiClient } from \"../provider\";\n\ntype ProductCategoryResponse = {\n itemCategoryDesc: string;\n childrenTotal: number;\n children: TProductCategory[];\n categoryImage: string | null;\n};\n\ninterface UseProductCategoryOptions {\n enabled?: boolean;\n queryFn?: () => Promise<ProductCategoryResponse>;\n}\n\nexport const getProductCategoryKey = (\n itemCategoryUid: number | string | null,\n) => {\n return [\"productCategory\", itemCategoryUid] as const;\n};\n\nexport const getProductCategoryOptions = (\n api: AugurApiClient,\n itemCategoryUid: number | string,\n) => ({\n queryKey: getProductCategoryKey(itemCategoryUid),\n queryFn: async (): Promise<ProductCategoryResponse> => {\n const response = await api.items.itemCategory.get(\n Number(itemCategoryUid),\n );\n return response.data;\n },\n ...CACHE_CONFIG.STATIC,\n});\n\nexport function useProductCategory(\n itemCategoryUid: number | string | null,\n options: UseProductCategoryOptions = {},\n) {\n const api = useAugurApi();\n\n const { data, isLoading, error } = useQuery({\n ...(itemCategoryUid\n ? getProductCategoryOptions(api, itemCategoryUid)\n : { queryKey: getProductCategoryKey(null),\n /* v8 ignore next */\n queryFn: () => Promise.reject() }),\n ...(options.queryFn ? { queryFn: options.queryFn } : {}),\n enabled: (options.enabled ?? true) && !!itemCategoryUid,\n retry: 3,\n /* v8 ignore start */\n retryDelay: (attemptIndex: number) =>\n Math.min(1000 * 2 ** attemptIndex, 10000),\n /* v8 ignore stop */\n });\n\n return {\n childrenTotal: data?.childrenTotal ?? 0,\n itemCategoryDesc: data?.itemCategoryDesc ?? \"\",\n productCategories: data?.children ?? null,\n productCategoryImage: data?.categoryImage ?? null,\n loading: isLoading,\n error: error as Error | null,\n };\n}\n","import { useQuery } from \"@tanstack/react-query\";\nimport { CACHE_CONFIG, type TItemDetails } from \"@simpleapps-com/augur-utils\";\nimport { useAugurApi, type AugurApiClient } from \"../provider\";\n\ninterface UseItemDetailsOptions {\n enabled?: boolean;\n queryFn?: () => Promise<TItemDetails>;\n}\n\nexport const getItemDetailsKey = (itemId: number | string) => {\n return [\"itemDetails\", itemId] as const;\n};\n\nexport const getItemDetailsOptions = (\n api: AugurApiClient,\n itemId: number | string,\n) => ({\n queryKey: getItemDetailsKey(itemId),\n queryFn: async (): Promise<TItemDetails> => {\n const response = await api.items.invMast.doc.list(Number(itemId));\n if (!response.data) throw new Error(\"Item not found\");\n return response.data;\n },\n ...CACHE_CONFIG.STATIC,\n});\n\nexport function useItemDetails(\n itemId: number | string | undefined,\n options: UseItemDetailsOptions = {},\n) {\n const api = useAugurApi();\n\n const { data, isLoading, error } = useQuery({\n ...(itemId\n ? getItemDetailsOptions(api, itemId)\n : { queryKey: getItemDetailsKey(\"\"),\n /* v8 ignore next */\n queryFn: () => Promise.reject() }),\n ...(options.queryFn ? { queryFn: options.queryFn } : {}),\n enabled: (options.enabled ?? true) && !!itemId,\n retry: 3,\n /* v8 ignore start */\n retryDelay: (attemptIndex: number) =>\n Math.min(1000 * 2 ** attemptIndex, 10000),\n /* v8 ignore stop */\n });\n\n const categoryList = data?.categoryList ?? [];\n\n return {\n itemCategoryUid:\n categoryList.length > 0 ? categoryList[categoryList.length - 1] : null,\n itemDetails: data ?? null,\n loading: isLoading,\n error: error as Error | null,\n };\n}\n","import { useQuery } from \"@tanstack/react-query\";\nimport { CACHE_CONFIG, type TAttribute } from \"@simpleapps-com/augur-utils\";\nimport { useAugurApi, type AugurApiClient } from \"../provider\";\n\ninterface UseItemAttributesOptions {\n enabled?: boolean;\n queryFn?: () => Promise<{ attributes: TAttribute[] }>;\n}\n\nexport const getItemAttributesKey = (\n itemCategoryUid: number | string | null,\n) => {\n return [\"itemAttributes\", itemCategoryUid] as const;\n};\n\nexport const getItemAttributesOptions = (\n api: AugurApiClient,\n itemCategoryUid: number | string,\n) => ({\n queryKey: getItemAttributesKey(itemCategoryUid),\n queryFn: async () => {\n const response = await api.openSearch.itemSearch.attributes.list({\n q: \"\",\n searchType: \"query\",\n classId5List: String(itemCategoryUid),\n });\n return response.data;\n },\n ...CACHE_CONFIG.STATIC,\n});\n\nexport function useItemAttributes(\n itemCategoryUid: number | string | null,\n options: UseItemAttributesOptions = {},\n) {\n const api = useAugurApi();\n\n const { data, isLoading, error } = useQuery({\n ...(itemCategoryUid\n ? getItemAttributesOptions(api, itemCategoryUid)\n : {\n queryKey: getItemAttributesKey(null),\n /* v8 ignore next */\n queryFn: () => Promise.reject(),\n }),\n ...(options.queryFn ? { queryFn: options.queryFn } : {}),\n enabled: (options.enabled ?? true) && !!itemCategoryUid,\n retry: 3,\n /* v8 ignore start */\n retryDelay: (attemptIndex: number) =>\n Math.min(1000 * 2 ** attemptIndex, 10000),\n /* v8 ignore stop */\n });\n\n return {\n attributes: data?.attributes ?? null,\n loading: isLoading,\n error: error as Error | null,\n };\n}\n","import { useQuery } from \"@tanstack/react-query\";\nimport { CACHE_CONFIG, type TProductItem } from \"@simpleapps-com/augur-utils\";\nimport { useAugurApi, type AugurApiClient } from \"../provider\";\nimport type { PageData } from \"../types\";\n\ntype ProductSearchResponse = {\n items: TProductItem[];\n totalResults: number;\n};\n\ninterface UseProductSearchOptions {\n /** Override the default queryFn (e.g. with a cached server action). */\n queryFn?: () => Promise<ProductSearchResponse>;\n}\n\n/**\n * Generates a consistent query key for product search queries.\n */\nexport const getProductSearchKey = (pageData: PageData) => {\n return [\n \"productSearch\",\n pageData.q,\n pageData.limit,\n pageData.offset,\n pageData.sortBy,\n pageData.itemCategoryUid,\n ] as const;\n};\n\n/**\n * Query options for product search. Accepts the SDK instance so it works\n * in both client (via provider) and server (via direct construction).\n */\nexport const getProductSearchOptions = (\n api: AugurApiClient,\n pageData: PageData,\n) => ({\n queryKey: getProductSearchKey(pageData),\n queryFn: async (): Promise<ProductSearchResponse> => {\n const response = await api.openSearch.itemSearch.list({\n q: pageData.q,\n searchType: \"query\",\n size: pageData.limit,\n from: pageData.offset,\n classId5List: pageData.itemCategoryUid\n ? String(pageData.itemCategoryUid)\n : undefined,\n filters: pageData.filters\n ? JSON.stringify(pageData.filters)\n : undefined,\n });\n return response.data;\n },\n ...CACHE_CONFIG.SEMI_STATIC,\n});\n\n/**\n * Searches products via the augur-api OpenSearch endpoint.\n * Replaces the ampro-online pattern of fetching from a Next.js API route.\n */\nexport function useProductSearch(\n pageData: PageData,\n options: UseProductSearchOptions = {},\n) {\n const api = useAugurApi();\n const defaultOptions = getProductSearchOptions(api, pageData);\n\n const { data, isLoading, error } = useQuery({\n ...defaultOptions,\n ...(options.queryFn ? { queryFn: options.queryFn } : {}),\n retry: 3,\n /* v8 ignore start */\n retryDelay: (attemptIndex: number) =>\n Math.min(1000 * 2 ** attemptIndex, 10000),\n /* v8 ignore stop */\n });\n\n return {\n productItems: data?.items ?? null,\n total: data?.totalResults ?? 0,\n loading: isLoading,\n error: error as Error | null,\n };\n}\n","import { useQuery } from \"@tanstack/react-query\";\nimport { CACHE_CONFIG } from \"@simpleapps-com/augur-utils\";\nimport { useAugurApi, type AugurApiClient } from \"../provider\";\nimport type { SearchSuggestionsResponse } from \"../types\";\n\ninterface UseSearchSuggestionsOptions {\n enabled?: boolean;\n limit?: number;\n offset?: number;\n /** Override the default queryFn (e.g. with a cached server action). */\n queryFn?: () => Promise<SearchSuggestionsResponse>;\n}\n\nconst SEARCH_SUGGESTIONS_CACHE_OPTIONS = CACHE_CONFIG.STATIC;\n\n/**\n * Generates a consistent query key for search suggestion queries.\n */\nexport const getSearchSuggestionsKey = (\n query: string,\n limit: number,\n offset: number,\n) => {\n return [\"searchSuggestions\", query, limit, offset] as const;\n};\n\n/**\n * Query options for search suggestions. Accepts the SDK instance so it works\n * in both client (via provider) and server (via direct construction).\n */\nexport const getSearchSuggestionsOptions = (\n api: AugurApiClient,\n query: string,\n limit: number = 10,\n offset: number = 0,\n) => ({\n queryKey: getSearchSuggestionsKey(query, limit, offset),\n queryFn: async (): Promise<SearchSuggestionsResponse> => {\n const response = await api.openSearch.suggestions.suggest.list({\n q: query,\n });\n return response.data;\n },\n ...SEARCH_SUGGESTIONS_CACHE_OPTIONS,\n});\n\n/**\n * Fetches search suggestions via the augur-api OpenSearch endpoint.\n * Replaces the ampro-online pattern of fetching from a Next.js API route.\n */\nexport function useSearchSuggestions(\n query: string,\n options: UseSearchSuggestionsOptions = {},\n) {\n const api = useAugurApi();\n const limit = options.limit ?? 10;\n const offset = options.offset ?? 0;\n const enabled = (options.enabled ?? true) && query.trim().length > 0;\n\n const defaultOptions = getSearchSuggestionsOptions(api, query, limit, offset);\n\n const { data, isLoading, error } = useQuery<\n SearchSuggestionsResponse,\n Error\n >({\n ...defaultOptions,\n ...(options.queryFn ? { queryFn: options.queryFn } : {}),\n enabled,\n });\n\n return {\n suggestions: data?.data ?? [],\n total: data?.total ?? 0,\n isLoading,\n error,\n };\n}\n","import { useCallback } from \"react\";\nimport { useQueryClient } from \"@tanstack/react-query\";\nimport type { TCartLine } from \"@simpleapps-com/augur-utils\";\nimport {\n useCartHdrUid,\n useCartLines,\n useSetCartLines,\n} from \"../stores/cart-store\";\n\ntype CartLineInput = Pick<\n TCartLine,\n \"invMastUid\" | \"quantity\" | \"unitOfMeasure\"\n> & {\n cartHdrUid?: number | string | undefined;\n};\n\n/** Site-specific callbacks injected into useCartActions. */\nexport interface CartActionCallbacks {\n /** Add items to cart via API. Returns true on success. */\n addToCart: (\n cartHdrUid: number,\n items: Array<{\n cartHdrUid: number;\n invMastUid: number;\n quantity: number;\n unitOfMeasure: string;\n }>,\n ) => Promise<boolean | unknown>;\n /** Update cart lines via API. Returns true on success. */\n updateCartLines: (\n cartHdrUid: number,\n lines: TCartLine[],\n ) => Promise<boolean | unknown>;\n /** Delete all items from cart via API. Returns true on success. */\n deleteItemsFromCart: (cartHdrUid: number) => Promise<boolean | unknown>;\n /** Optional toast notification callback. */\n toast?: {\n info?: (message: string) => void;\n error?: (message: string) => void;\n success?: (message: string) => void;\n };\n}\n\ninterface CartActionOptions {\n showToast?: boolean;\n itemId?: string;\n onSuccess?: () => void;\n onError?: (error: Error) => void;\n}\n\nfunction requireCartUid(\n cartHdrUid: string | number | undefined,\n): number {\n const num = typeof cartHdrUid === \"string\" ? Number(cartHdrUid) : cartHdrUid;\n if (!num) throw new Error(\"Cart UID is not set\");\n return num;\n}\n\nfunction buildOptimisticAdd(\n cartLines: TCartLine[],\n item: CartLineInput,\n cartHdrUid: number,\n itemId: string,\n): TCartLine[] {\n const existingIndex = cartLines.findIndex(\n (line) => line.invMastUid === item.invMastUid,\n );\n\n if (existingIndex >= 0) {\n return cartLines.map((line, index) =>\n index === existingIndex\n ? { ...line, quantity: line.quantity + item.quantity }\n : line,\n );\n }\n\n return [\n ...cartLines,\n {\n cartHdrUid,\n invMastUid: item.invMastUid,\n invMastUidCount: 1,\n isAssembly: \"N\",\n itemId,\n lineNo: cartLines.length + 1,\n lineNote: null,\n quantity: item.quantity,\n unitOfMeasure: item.unitOfMeasure,\n },\n ];\n}\n\n/**\n * Optimistic cart actions hook with automatic rollback on failure.\n *\n * Accepts site-specific server action callbacks so the hook itself\n * has no dependency on any particular server action implementation.\n *\n * @example\n * ```tsx\n * import { useCartActions } from \"@simpleapps-com/augur-hooks\";\n * import { addToCart, updateCartLines, deleteItemsFromCart } from \"@/lib/actions/commerce\";\n * import { toast } from \"react-toastify\";\n *\n * const cart = useCartActions({\n * addToCart, updateCartLines, deleteItemsFromCart,\n * toast: { info: toast.info, error: toast.error },\n * });\n *\n * await cart.addToCart({ invMastUid: 123, quantity: 1, unitOfMeasure: \"EA\" });\n * ```\n */\nexport function useCartActions(callbacks: CartActionCallbacks) {\n const queryClient = useQueryClient();\n const cartHdrUid = useCartHdrUid();\n const cartLines = useCartLines();\n const setCartLines = useSetCartLines();\n const notify = callbacks.toast;\n\n const invalidateCartCache = useCallback(() => {\n queryClient.invalidateQueries({ queryKey: [\"cartLines\", cartHdrUid] });\n queryClient.invalidateQueries({\n queryKey: [\"cart-also-bought\", cartHdrUid],\n });\n }, [queryClient, cartHdrUid]);\n\n const addToCart = useCallback(\n async (\n item: CartLineInput,\n options: CartActionOptions = {},\n ): Promise<boolean> => {\n const { showToast = true, itemId = \"\", onSuccess, onError } = options;\n const uid = requireCartUid(cartHdrUid);\n const previousCartLines = [...cartLines];\n\n setCartLines(buildOptimisticAdd(cartLines, item, uid, itemId));\n\n try {\n const success = await callbacks.addToCart(uid, [\n {\n cartHdrUid: uid,\n invMastUid: item.invMastUid,\n quantity: item.quantity,\n unitOfMeasure: item.unitOfMeasure,\n },\n ]);\n if (!success) throw new Error(\"Failed to add item to cart\");\n\n invalidateCartCache();\n if (showToast && notify?.info) {\n notify.info(`${item.quantity} x ${itemId || \"Item\"} added to cart`);\n }\n onSuccess?.();\n return true;\n } catch (error) {\n setCartLines(previousCartLines);\n if (showToast && notify?.error) {\n notify.error(\"Failed to add item to cart. Please try again.\");\n }\n onError?.(error as Error);\n return false;\n }\n },\n [cartHdrUid, cartLines, setCartLines, invalidateCartCache, callbacks, notify],\n );\n\n const updateQuantity = useCallback(\n async (\n invMastUid: number,\n newQuantity: number,\n options: CartActionOptions = {},\n ): Promise<boolean> => {\n const { showToast = false, onSuccess, onError } = options;\n const uid = requireCartUid(cartHdrUid);\n const previousCartLines = [...cartLines];\n\n const updatedLines = cartLines.map((line) =>\n line.invMastUid === invMastUid\n ? { ...line, quantity: newQuantity }\n : line,\n );\n setCartLines(updatedLines);\n\n try {\n const success = await callbacks.updateCartLines(uid, updatedLines);\n if (!success) throw new Error(\"Failed to update quantity\");\n\n invalidateCartCache();\n onSuccess?.();\n return true;\n } catch (error) {\n setCartLines(previousCartLines);\n if (showToast && notify?.error) {\n notify.error(\"Failed to update quantity. Please try again.\");\n }\n onError?.(error as Error);\n return false;\n }\n },\n [cartHdrUid, cartLines, setCartLines, invalidateCartCache, callbacks, notify],\n );\n\n const removeFromCart = useCallback(\n async (\n invMastUid: number,\n options: CartActionOptions = {},\n ): Promise<boolean> => {\n const { showToast = true, itemId = \"\", onSuccess, onError } = options;\n const uid = requireCartUid(cartHdrUid);\n const previousCartLines = [...cartLines];\n\n setCartLines(cartLines.filter((line) => line.invMastUid !== invMastUid));\n\n try {\n const zeroedLines = cartLines.map((line) =>\n line.invMastUid === invMastUid ? { ...line, quantity: 0 } : line,\n );\n const success = await callbacks.updateCartLines(uid, zeroedLines);\n if (!success) throw new Error(\"Failed to remove item\");\n\n invalidateCartCache();\n if (showToast && notify?.info) {\n notify.info(`${itemId || \"Item\"} removed from cart`);\n }\n onSuccess?.();\n return true;\n } catch (error) {\n setCartLines(previousCartLines);\n if (showToast && notify?.error) {\n notify.error(\"Failed to remove item. Please try again.\");\n }\n onError?.(error as Error);\n return false;\n }\n },\n [cartHdrUid, cartLines, setCartLines, invalidateCartCache, callbacks, notify],\n );\n\n const clearCart = useCallback(\n async (options: Omit<CartActionOptions, \"itemId\"> = {}): Promise<boolean> => {\n const { showToast = true, onSuccess, onError } = options;\n const uid = requireCartUid(cartHdrUid);\n const previousCartLines = [...cartLines];\n setCartLines([]);\n\n try {\n const success = await callbacks.deleteItemsFromCart(uid);\n if (!success) throw new Error(\"Failed to clear cart\");\n\n invalidateCartCache();\n if (showToast && notify?.info) {\n notify.info(\"Cart cleared\");\n }\n onSuccess?.();\n return true;\n } catch (error) {\n setCartLines(previousCartLines);\n if (showToast && notify?.error) {\n notify.error(\"Failed to clear cart. Please try again.\");\n }\n onError?.(error as Error);\n return false;\n }\n },\n [cartHdrUid, cartLines, setCartLines, invalidateCartCache, callbacks, notify],\n );\n\n const isInCart = useCallback(\n (invMastUid: number): boolean => {\n return cartLines.some((line) => line.invMastUid === invMastUid);\n },\n [cartLines],\n );\n\n const getItemQuantity = useCallback(\n (invMastUid: number): number => {\n return cartLines.find((line) => line.invMastUid === invMastUid)?.quantity ?? 0;\n },\n [cartLines],\n );\n\n return {\n addToCart,\n updateQuantity,\n removeFromCart,\n clearCart,\n isInCart,\n getItemQuantity,\n cartHdrUid,\n cartLines,\n invalidateCartCache,\n };\n}\n","import { useEffect, useRef } from \"react\";\nimport { useQuery } from \"@tanstack/react-query\";\nimport { CACHE_CONFIG, type TCartLine } from \"@simpleapps-com/augur-utils\";\nimport {\n useCartHdrUid,\n useSetCartHdrUid,\n useSetCartLines,\n} from \"../stores/cart-store\";\n\nconst MAX_RETRY_ATTEMPTS = 7;\nconst RETRY_DELAY_MS = 1000;\n\n/** Session info passed from the consumer's auth system. */\nexport interface CartSessionInfo {\n /** Auth status: \"loading\" | \"authenticated\" | \"unauthenticated\" */\n status: \"loading\" | \"authenticated\" | \"unauthenticated\";\n /** User's ID (e.g., Joomla user ID). Undefined if not authenticated. */\n userId?: string | number;\n /** Cart header UID from the auth session, if available. */\n cartHdrUid?: number;\n}\n\n/** Site-specific callbacks injected into useCartInitialization. */\nexport interface CartInitCallbacks {\n /** Look up or create a cart header. Returns { cartHdrUid, cartToken? }. */\n cartHdrLookup: (\n userId: string | number,\n cartToken: string,\n ) => Promise<{ cartHdrUid: number; cartToken?: string } | null>;\n /** Fetch cart line items for a given cart header UID. */\n getCartLines: (cartHdrUid: number) => Promise<TCartLine[]>;\n /** Get the current cart token from cookies. */\n getCartToken: () => string | null;\n /** Save cart token to cookies. */\n saveCartToken: (token: string) => void;\n /** Generate a new unique cart token (e.g., uuidv4). */\n generateCartToken: () => string;\n}\n\n/**\n * Initialize cart state from session (authenticated) or cookie (guest).\n * Call once in the root layout.\n *\n * @example\n * ```tsx\n * import { useCartInitialization } from \"@simpleapps-com/augur-hooks\";\n * import { useSession } from \"next-auth/react\";\n * import { cartHdrLookup, getCartLines } from \"@/lib/actions/commerce\";\n * import { getCookie, setCookie } from \"cookies-next/client\";\n * import { v4 as uuidv4 } from \"uuid\";\n *\n * function CartInitializer() {\n * const { data: session, status } = useSession();\n *\n * useCartInitialization(\n * {\n * status,\n * userId: session?.user?.id,\n * cartHdrUid: session?.user?.cartHdrUid,\n * },\n * {\n * cartHdrLookup,\n * getCartLines,\n * getCartToken: () => getCookie(\"cartToken\") as string | null,\n * saveCartToken: (token) => setCookie(\"cartToken\", token, { maxAge: 604800, path: \"/\" }),\n * generateCartToken: uuidv4,\n * },\n * );\n *\n * return null;\n * }\n * ```\n */\nexport function useCartInitialization(\n session: CartSessionInfo,\n callbacks: CartInitCallbacks,\n) {\n const cartHdrUid = useCartHdrUid();\n const setCartHdrUid = useSetCartHdrUid();\n const setCartLines = useSetCartLines();\n\n const retryCountRef = useRef(0);\n const isInitializingRef = useRef(false);\n\n // Initialize cart header\n useEffect(() => {\n if (cartHdrUid || session.status === \"loading\") return;\n\n // Authenticated user — use session cartHdrUid\n if (session.cartHdrUid && session.status === \"authenticated\") {\n setCartHdrUid(session.cartHdrUid);\n return;\n }\n\n // Guest user — lookup/create cart\n if (session.status === \"unauthenticated\" && !isInitializingRef.current) {\n isInitializingRef.current = true;\n retryCountRef.current = 0;\n\n const initializeGuestCart = async () => {\n const existingToken = callbacks.getCartToken();\n const cartToken =\n existingToken && typeof existingToken === \"string\"\n ? existingToken\n : callbacks.generateCartToken();\n\n while (retryCountRef.current < MAX_RETRY_ATTEMPTS) {\n try {\n const cartHdr = await callbacks.cartHdrLookup(\"0\", cartToken);\n\n if (cartHdr && cartHdr.cartHdrUid !== 0) {\n callbacks.saveCartToken(cartToken);\n setCartHdrUid(cartHdr.cartHdrUid);\n isInitializingRef.current = false;\n return;\n }\n\n retryCountRef.current++;\n\n if (retryCountRef.current < MAX_RETRY_ATTEMPTS) {\n const delay = Math.min(\n RETRY_DELAY_MS * Math.pow(1.5, retryCountRef.current),\n 10000,\n );\n await new Promise((resolve) => setTimeout(resolve, delay));\n }\n } catch (error) {\n console.error(\n `Cart initialization attempt ${retryCountRef.current + 1} failed:`,\n error,\n );\n retryCountRef.current++;\n\n if (retryCountRef.current < MAX_RETRY_ATTEMPTS) {\n const delay = Math.min(\n RETRY_DELAY_MS * Math.pow(1.5, retryCountRef.current),\n 10000,\n );\n await new Promise((resolve) => setTimeout(resolve, delay));\n }\n }\n }\n\n console.error(\n `Cart initialization failed after ${MAX_RETRY_ATTEMPTS} attempts`,\n );\n isInitializingRef.current = false;\n };\n\n initializeGuestCart();\n }\n }, [session, cartHdrUid, setCartHdrUid, callbacks]);\n\n // Fetch cart lines when cartHdrUid is available\n const { data: cartLinesData } = useQuery({\n queryKey: [\"cartLines\", cartHdrUid],\n queryFn: () => callbacks.getCartLines(Number(cartHdrUid)),\n enabled: !!cartHdrUid,\n ...CACHE_CONFIG.CART,\n });\n\n // Sync cart lines to Zustand store\n useEffect(() => {\n if (cartLinesData) {\n setCartLines(cartLinesData);\n }\n }, [cartLinesData, setCartLines]);\n\n return {\n cartHdrUid,\n isInitializing: isInitializingRef.current,\n retryCount: retryCountRef.current,\n };\n}\n","import { useMemo } from \"react\";\nimport { useQueries } from \"@tanstack/react-query\";\nimport { useCartLines } from \"../stores/cart-store\";\nimport { getItemPriceOptions } from \"./use-item-price\";\nimport { useAugurApi } from \"../provider\";\n\nexport interface CartPriceData {\n unitPrice: number;\n priceData: Record<string, unknown> | null;\n}\n\nexport interface CartPricingResult {\n /** Map of itemId -> price data (with quantity-specific pricing) */\n prices: Record<string, CartPriceData>;\n /** Get unit price for an item (returns 0 if not found) */\n getUnitPrice: (itemId: string) => number;\n /** Get total price for an item (unitPrice * quantity) */\n getItemTotal: (itemId: string, quantity: number) => number;\n /** Cart subtotal (sum of all item totals) */\n subtotal: number;\n /** True if any price is still loading */\n isLoading: boolean;\n /** True if all prices loaded successfully */\n isSuccess: boolean;\n /** True if any price failed to load */\n isError: boolean;\n}\n\ninterface UseCartPricingOptions {\n customerId?: string | number;\n}\n\n/**\n * Centralized hook for cart/checkout pricing.\n *\n * Fetches prices for ALL cart items with their actual quantities\n * to support quantity-based price breaks. React Query dedupes\n * identical calls across components.\n */\nexport function useCartPricing(\n options: UseCartPricingOptions = {},\n): CartPricingResult {\n const api = useAugurApi();\n const cartLines = useCartLines();\n const { customerId } = options;\n\n const priceQueries = useQueries({\n queries: cartLines.map((line) => ({\n ...getItemPriceOptions(api, line.itemId, customerId, line.quantity),\n enabled: !!customerId && !!line.itemId,\n })),\n });\n\n const prices = useMemo(() => {\n const map: Record<string, CartPriceData> = {};\n cartLines.forEach((line, index) => {\n const queryResult = priceQueries[index];\n if (queryResult?.data) {\n map[line.itemId.toUpperCase()] = {\n unitPrice: queryResult.data.unitPrice ?? 0,\n priceData: queryResult.data as Record<string, unknown>,\n };\n }\n });\n return map;\n }, [cartLines, priceQueries]);\n\n const getUnitPrice = useMemo(() => {\n return (itemId: string): number => {\n return prices[itemId?.toUpperCase()]?.unitPrice ?? 0;\n };\n }, [prices]);\n\n const getItemTotal = useMemo(() => {\n return (itemId: string, quantity: number): number => {\n return getUnitPrice(itemId) * quantity;\n };\n }, [getUnitPrice]);\n\n const subtotal = useMemo(() => {\n return cartLines.reduce((sum, line) => {\n const unitPrice = prices[line.itemId.toUpperCase()]?.unitPrice ?? 0;\n return sum + unitPrice * line.quantity;\n }, 0);\n }, [cartLines, prices]);\n\n const isLoading = priceQueries.some((q) => q.isLoading);\n const isSuccess = priceQueries.every((q) => q.isSuccess);\n const isError = priceQueries.some((q) => q.isError);\n\n return {\n prices,\n getUnitPrice,\n getItemTotal,\n subtotal,\n isLoading,\n isSuccess,\n isError,\n };\n}\n\n/**\n * Get cart pricing query options for prefetching or parent components.\n */\nexport function getCartPricingQueryOptions(\n api: ReturnType<typeof useAugurApi>,\n cartLines: Array<{ itemId: string; quantity: number }>,\n customerId: string | number | undefined,\n) {\n return cartLines.map((line) => ({\n ...getItemPriceOptions(api, line.itemId, customerId, line.quantity),\n enabled: !!customerId && !!line.itemId,\n }));\n}\n","import { useQueryClient } from \"@tanstack/react-query\";\nimport { useCallback } from \"react\";\nimport type { QueryKey } from \"@tanstack/react-query\";\n\ninterface UsePaginationPrefetchOptions {\n /** Query key for the paginated data */\n queryKey: QueryKey;\n /** Function to fetch a page of data */\n queryFn: (offset: number) => Promise<unknown>;\n /** Number of items per page */\n pageSize: number;\n /** Stale time in ms (defaults to 10 minutes) */\n staleTime?: number;\n /** GC time in ms (defaults to 30 minutes) */\n gcTime?: number;\n enabled?: boolean;\n}\n\n/**\n * Prefetch adjacent pages on hover for instant pagination.\n * Accepts a generic queryFn so it works with any paginated resource.\n */\nexport const usePaginationPrefetch = ({\n queryKey,\n queryFn,\n pageSize,\n staleTime = 10 * 60 * 1000,\n gcTime = 30 * 60 * 1000,\n enabled = true,\n}: UsePaginationPrefetchOptions) => {\n const queryClient = useQueryClient();\n\n const prefetchPage = useCallback(\n async (page: number) => {\n if (!enabled) return;\n\n const offset = (page - 1) * pageSize;\n\n try {\n await queryClient.prefetchQuery({\n queryKey: [...queryKey, offset],\n queryFn: () => queryFn(offset),\n staleTime,\n gcTime,\n });\n } catch (error) {\n console.warn(`Error prefetching page ${page}:`, error);\n }\n },\n [queryKey, queryFn, pageSize, staleTime, gcTime, queryClient, enabled],\n );\n\n const handlePaginationHover = useCallback(\n (page: number) => {\n const timeoutId = setTimeout(() => prefetchPage(page), 150);\n return () => clearTimeout(timeoutId);\n },\n [prefetchPage],\n );\n\n return {\n prefetchPage,\n handlePaginationHover,\n };\n};\n","import { useInfiniteQuery } from \"@tanstack/react-query\";\nimport {\n CACHE_CONFIG,\n type TItemsFilters,\n type TProductItem,\n} from \"@simpleapps-com/augur-utils\";\nimport { useAugurApi } from \"../provider\";\n\ninterface CategoryItemsInfiniteResponse {\n data: TProductItem[];\n total: number;\n nextCursor?: number;\n}\n\ninterface UseCategoryItemsInfiniteOptions {\n enabled?: boolean;\n}\n\nexport const getCategoryItemsInfiniteKey = (\n itemCategoryUid: number,\n itemsFilters: TItemsFilters,\n) => {\n return [\n \"categoryItemsInfinite\",\n itemCategoryUid,\n JSON.stringify(itemsFilters),\n ] as const;\n};\n\n/**\n * Infinite scroll for category product listings.\n * Fetches pages of products via the augur-api SDK.\n */\nexport function useCategoryItemsInfinite(\n itemCategoryUid: number,\n itemsFilters: TItemsFilters,\n options: UseCategoryItemsInfiniteOptions = {},\n) {\n const api = useAugurApi();\n const { enabled = true } = options;\n\n return useInfiniteQuery<CategoryItemsInfiniteResponse>({\n queryKey: getCategoryItemsInfiniteKey(itemCategoryUid, itemsFilters),\n queryFn: async ({ pageParam = 0 }) => {\n const response = await api.openSearch.itemSearch.list({\n q: itemsFilters.q || \"\",\n searchType: \"query\",\n size: itemsFilters.limit,\n from: pageParam as number,\n classId5List: String(itemCategoryUid),\n filters: itemsFilters.filters?.length\n ? JSON.stringify(itemsFilters.filters)\n : undefined,\n });\n const items: TProductItem[] = response.data?.items ?? [];\n const total: number = response.data?.totalResults ?? 0;\n const nextOffset = (pageParam as number) + itemsFilters.limit;\n return {\n data: items,\n total,\n nextCursor: nextOffset < total ? nextOffset : undefined,\n };\n },\n initialPageParam: 0,\n getNextPageParam: (lastPage) => lastPage.nextCursor,\n ...CACHE_CONFIG.SEMI_STATIC,\n enabled: enabled && !!itemCategoryUid,\n });\n}\n","import { useInfiniteQuery } from \"@tanstack/react-query\";\nimport {\n CACHE_CONFIG,\n type TItemsFilters,\n type TProductItem,\n} from \"@simpleapps-com/augur-utils\";\nimport { useAugurApi } from \"../provider\";\n\ninterface ItemSearchInfiniteResponse {\n data: TProductItem[];\n total: number;\n nextCursor?: number;\n}\n\ninterface UseItemSearchInfiniteOptions {\n enabled?: boolean;\n}\n\nexport const getItemSearchInfiniteKey = (\n itemsFilters: TItemsFilters,\n itemCategoryUid?: number | string,\n) => {\n return [\n \"itemSearchInfinite\",\n JSON.stringify(itemsFilters),\n itemCategoryUid,\n ] as const;\n};\n\n/**\n * Infinite scroll for search results.\n * Fetches pages of products via the augur-api SDK OpenSearch endpoint.\n */\nexport function useItemSearchInfinite(\n itemsFilters: TItemsFilters,\n itemCategoryUid?: number | string,\n options: UseItemSearchInfiniteOptions = {},\n) {\n const api = useAugurApi();\n const { enabled = true } = options;\n\n return useInfiniteQuery<ItemSearchInfiniteResponse>({\n queryKey: getItemSearchInfiniteKey(itemsFilters, itemCategoryUid),\n queryFn: async ({ pageParam = 0 }) => {\n const response = await api.openSearch.itemSearch.list({\n q: itemsFilters.q,\n searchType: \"query\",\n size: itemsFilters.limit,\n from: pageParam as number,\n classId5List: itemCategoryUid\n ? String(itemCategoryUid)\n : undefined,\n filters: itemsFilters.filters?.length\n ? JSON.stringify(itemsFilters.filters)\n : undefined,\n });\n const items: TProductItem[] = response.data?.items ?? [];\n const total: number = response.data?.totalResults ?? 0;\n const nextOffset = (pageParam as number) + itemsFilters.limit;\n return {\n data: items,\n total,\n nextCursor: nextOffset < total ? nextOffset : undefined,\n };\n },\n initialPageParam: 0,\n getNextPageParam: (lastPage) => lastPage.nextCursor,\n ...CACHE_CONFIG.SEMI_STATIC,\n enabled: enabled && !!itemsFilters.q,\n meta: { persist: true },\n });\n}\n"],"mappings":";AAAA,SAAS,eAAe,kBAAkC;AA+BtD;AAhBJ,IAAM,kBAAkB,cAAqC,IAAI;AAc1D,SAAS,mBAAmB,EAAE,KAAK,SAAS,GAA4B;AAC7E,SACE,oBAAC,gBAAgB,UAAhB,EAAyB,OAAO,KAAM,UAAS;AAEpD;AAMO,SAAS,cAA8B;AAC5C,QAAM,MAAM,WAAW,eAAe;AACtC,MAAI,CAAC,KAAK;AACR,UAAM,IAAI;AAAA,MACR;AAAA,IAEF;AAAA,EACF;AACA,SAAO;AACT;;;AChDA,SAAS,cAAc;AACvB,SAAS,gBAAgB;AAWlB,IAAM,eAAe,OAAkB;AAAA,EAC5C;AAAA,IACE,CAAC,SAAS;AAAA,MAC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W,MAAM,IAAI,WAAW,WAAW,KAAK;AAAA,QACpD,GAAG,aAAa;AAAA,QAChB,YAAY;AAAA,QACZ,MAAM,aAAa;AAAA,QACnB,MAAM;AAAA,QACN,cAAc,kBACV,OAAO,eAAe,IACtB;AAAA,QACJ,SAAS,aAAa,SAAS,SAC3B,KAAK,UAAU,aAAa,OAAO,IACnC;AAAA,MACN,CAAC;AACD,YAAM,QAAwB,SAAS,MAAM,SAAS,CAAC;AACvD,YAAM,QAAgB,SAAS,MAAM,gBAAgB;AACrD,YAAM,aAAc,YAAuB,aAAa;AACxD,aAAO;AAAA,QACL,MAAM;AAAA,QACN;AAAA,QACA,YAAY,aAAa,QAAQ,aAAa;AAAA,MAChD;AAAA,IACF;AAAA,IACA,kBAAkB;AAAA,IAClB,kBAAkB,CAAC,aAAa,SAAS;AAAA,IACzC,GAAGC,eAAa;AAAA,IAChB,SAAS,WAAW,CAAC,CAAC,aAAa;AAAA,IACnC,MAAM,EAAE,SAAS,KAAK;AAAA,EACxB,CAAC;AACH;","names":["create","devtools","useQuery","CACHE_CONFIG","CACHE_CONFIG","useQuery","useQuery","CACHE_CONFIG","CACHE_CONFIG","useQuery","useQuery","CACHE_CONFIG","CACHE_CONFIG","useQuery","useQuery","CACHE_CONFIG","CACHE_CONFIG","useQuery","useQuery","CACHE_CONFIG","CACHE_CONFIG","useQuery","useQuery","CACHE_CONFIG","CACHE_CONFIG","useQuery","useQuery","CACHE_CONFIG","CACHE_CONFIG","useQuery","useQuery","CACHE_CONFIG","CACHE_CONFIG","useQuery","useQuery","CACHE_CONFIG","CACHE_CONFIG","useQuery","useEffect","useQuery","CACHE_CONFIG","useEffect","useQuery","CACHE_CONFIG","useQueryClient","useCallback","CACHE_CONFIG","CACHE_CONFIG","useInfiniteQuery","CACHE_CONFIG","useInfiniteQuery","CACHE_CONFIG"]}
|