@omniumretail/shared-resources 0.1.13 → 0.1.15
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/bundle.js +1 -1
- package/dist/types/hooks/AprProduct/get/useProductHierarchies.hook.d.ts +7 -0
- package/dist/types/hooks/AprProduct/get/useProductRecommendations.hook.d.ts +10 -0
- package/dist/types/hooks/AprProduct/get/useProductsByRefQuery.hook.d.ts +2 -0
- package/dist/types/hooks/AprProduct/get/useProductsQuery.hook.d.ts +144 -0
- package/dist/types/hooks/Checkouts/mutate/postCheckoutsMutateQuery.hook.d.ts +2 -0
- package/dist/types/hooks/index.d.ts +4 -2
- package/dist/types/interfaces/Product.d.ts +1 -0
- package/dist/types/interfaces/ProductsHierarchies.d.ts +1 -1
- package/package.json +1 -1
- package/src/hooks/AprProduct/get/useProductHierarchies.hook.ts +19 -0
- package/src/hooks/AprProduct/get/useProductRecommendations.hook.ts +25 -0
- package/src/hooks/AprProduct/get/useProductsByRefQuery.hook.ts +10 -0
- package/src/hooks/AprProduct/get/useProductsQuery.hook.ts +46 -0
- package/src/hooks/Checkouts/mutate/postCheckoutsMutateQuery.hook.ts +15 -0
- package/src/hooks/index.ts +5 -3
- package/src/interfaces/Product.ts +1 -0
- package/src/interfaces/ProductsHierarchies.ts +1 -1
- package/src/hooks/Product/get/useProductHierarchies.hook.ts +0 -12
- package/src/hooks/Product/get/useProductsQuery.hook.ts +0 -30
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ProductsHierarchies, ResponseList } from '../../../';
|
|
2
|
+
import { UseQueryOptions } from '@tanstack/react-query';
|
|
3
|
+
export interface useProductsHierarchiesQueryHook extends UseQueryOptions<ResponseList<"Categories", ProductsHierarchies>> {
|
|
4
|
+
terms?: string;
|
|
5
|
+
query?: string;
|
|
6
|
+
}
|
|
7
|
+
export declare const useProductsHierarchiesQueryHook: ({ terms, query, ...options }: useProductsHierarchiesQueryHook) => import("@tanstack/react-query").UseQueryResult<ResponseList<"Categories", ProductsHierarchies>, unknown>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Product, ResponseList } from '../../..';
|
|
2
|
+
import { UseQueryOptions } from '@tanstack/react-query';
|
|
3
|
+
export interface useProductsRecommendationsQueryHook extends UseQueryOptions<ResponseList<"Products", Product>> {
|
|
4
|
+
sortBy?: string;
|
|
5
|
+
sortDirection?: string;
|
|
6
|
+
reference?: string;
|
|
7
|
+
category?: string;
|
|
8
|
+
type?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare const useProductRecommendationsHook: ({ sortBy, sortDirection, reference, category, type }: useProductsRecommendationsQueryHook) => import("@tanstack/react-query").UseQueryResult<ResponseList<"Products", Product>, unknown>;
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { Product, ResponseList } from '../../../';
|
|
2
|
+
import { UseQueryOptions } from '@tanstack/react-query';
|
|
3
|
+
export interface ProductsQuery extends UseQueryOptions<ResponseList<"Products", Product>> {
|
|
4
|
+
page?: number;
|
|
5
|
+
records?: number;
|
|
6
|
+
sortBy?: string;
|
|
7
|
+
sortDirection?: string;
|
|
8
|
+
terms?: string;
|
|
9
|
+
query?: string;
|
|
10
|
+
}
|
|
11
|
+
export declare const useProductsQueryHook: ({ page, records, sortBy, sortDirection, terms, query, ...options }: ProductsQuery) => import("@tanstack/react-query").UseQueryResult<ResponseList<"Products", Product>, unknown>;
|
|
12
|
+
export declare const useProductInfiniteQueryHook: ({ sortBy, sortDirection, terms, query }?: Omit<ProductsQuery, 'page' | 'records'>) => {
|
|
13
|
+
count: number;
|
|
14
|
+
data: Product[];
|
|
15
|
+
error: unknown;
|
|
16
|
+
isError: true;
|
|
17
|
+
isLoading: false;
|
|
18
|
+
isLoadingError: true;
|
|
19
|
+
isRefetchError: false;
|
|
20
|
+
isSuccess: false;
|
|
21
|
+
status: "error";
|
|
22
|
+
fetchNextPage: (options?: import("@tanstack/react-query").FetchNextPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<ResponseList<"Products", Product>, unknown>>;
|
|
23
|
+
fetchPreviousPage: (options?: import("@tanstack/react-query").FetchPreviousPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<ResponseList<"Products", Product>, unknown>>;
|
|
24
|
+
hasNextPage?: boolean;
|
|
25
|
+
hasPreviousPage?: boolean;
|
|
26
|
+
isFetchingNextPage: boolean;
|
|
27
|
+
isFetchingPreviousPage: boolean;
|
|
28
|
+
dataUpdatedAt: number;
|
|
29
|
+
errorUpdatedAt: number;
|
|
30
|
+
failureCount: number;
|
|
31
|
+
failureReason: unknown;
|
|
32
|
+
errorUpdateCount: number;
|
|
33
|
+
isFetched: boolean;
|
|
34
|
+
isFetchedAfterMount: boolean;
|
|
35
|
+
isFetching: boolean;
|
|
36
|
+
isInitialLoading: boolean;
|
|
37
|
+
isPaused: boolean;
|
|
38
|
+
isPlaceholderData: boolean;
|
|
39
|
+
isPreviousData: boolean;
|
|
40
|
+
isRefetching: boolean;
|
|
41
|
+
isStale: boolean;
|
|
42
|
+
refetch: <TPageData>(options?: import("@tanstack/react-query").RefetchOptions & import("@tanstack/react-query").RefetchQueryFilters<TPageData>) => Promise<import("@tanstack/react-query").QueryObserverResult<import("@tanstack/react-query").InfiniteData<ResponseList<"Products", Product>>, unknown>>;
|
|
43
|
+
remove: () => void;
|
|
44
|
+
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
45
|
+
} | {
|
|
46
|
+
count: number;
|
|
47
|
+
data: Product[];
|
|
48
|
+
error: null;
|
|
49
|
+
isError: false;
|
|
50
|
+
isLoading: true;
|
|
51
|
+
isLoadingError: false;
|
|
52
|
+
isRefetchError: false;
|
|
53
|
+
isSuccess: false;
|
|
54
|
+
status: "loading";
|
|
55
|
+
fetchNextPage: (options?: import("@tanstack/react-query").FetchNextPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<ResponseList<"Products", Product>, unknown>>;
|
|
56
|
+
fetchPreviousPage: (options?: import("@tanstack/react-query").FetchPreviousPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<ResponseList<"Products", Product>, unknown>>;
|
|
57
|
+
hasNextPage?: boolean;
|
|
58
|
+
hasPreviousPage?: boolean;
|
|
59
|
+
isFetchingNextPage: boolean;
|
|
60
|
+
isFetchingPreviousPage: boolean;
|
|
61
|
+
dataUpdatedAt: number;
|
|
62
|
+
errorUpdatedAt: number;
|
|
63
|
+
failureCount: number;
|
|
64
|
+
failureReason: unknown;
|
|
65
|
+
errorUpdateCount: number;
|
|
66
|
+
isFetched: boolean;
|
|
67
|
+
isFetchedAfterMount: boolean;
|
|
68
|
+
isFetching: boolean;
|
|
69
|
+
isInitialLoading: boolean;
|
|
70
|
+
isPaused: boolean;
|
|
71
|
+
isPlaceholderData: boolean;
|
|
72
|
+
isPreviousData: boolean;
|
|
73
|
+
isRefetching: boolean;
|
|
74
|
+
isStale: boolean;
|
|
75
|
+
refetch: <TPageData>(options?: import("@tanstack/react-query").RefetchOptions & import("@tanstack/react-query").RefetchQueryFilters<TPageData>) => Promise<import("@tanstack/react-query").QueryObserverResult<import("@tanstack/react-query").InfiniteData<ResponseList<"Products", Product>>, unknown>>;
|
|
76
|
+
remove: () => void;
|
|
77
|
+
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
78
|
+
} | {
|
|
79
|
+
count: number;
|
|
80
|
+
data: Product[];
|
|
81
|
+
error: unknown;
|
|
82
|
+
isError: true;
|
|
83
|
+
isLoading: false;
|
|
84
|
+
isLoadingError: false;
|
|
85
|
+
isRefetchError: true;
|
|
86
|
+
isSuccess: false;
|
|
87
|
+
status: "error";
|
|
88
|
+
fetchNextPage: (options?: import("@tanstack/react-query").FetchNextPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<ResponseList<"Products", Product>, unknown>>;
|
|
89
|
+
fetchPreviousPage: (options?: import("@tanstack/react-query").FetchPreviousPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<ResponseList<"Products", Product>, unknown>>;
|
|
90
|
+
hasNextPage?: boolean;
|
|
91
|
+
hasPreviousPage?: boolean;
|
|
92
|
+
isFetchingNextPage: boolean;
|
|
93
|
+
isFetchingPreviousPage: boolean;
|
|
94
|
+
dataUpdatedAt: number;
|
|
95
|
+
errorUpdatedAt: number;
|
|
96
|
+
failureCount: number;
|
|
97
|
+
failureReason: unknown;
|
|
98
|
+
errorUpdateCount: number;
|
|
99
|
+
isFetched: boolean;
|
|
100
|
+
isFetchedAfterMount: boolean;
|
|
101
|
+
isFetching: boolean;
|
|
102
|
+
isInitialLoading: boolean;
|
|
103
|
+
isPaused: boolean;
|
|
104
|
+
isPlaceholderData: boolean;
|
|
105
|
+
isPreviousData: boolean;
|
|
106
|
+
isRefetching: boolean;
|
|
107
|
+
isStale: boolean;
|
|
108
|
+
refetch: <TPageData>(options?: import("@tanstack/react-query").RefetchOptions & import("@tanstack/react-query").RefetchQueryFilters<TPageData>) => Promise<import("@tanstack/react-query").QueryObserverResult<import("@tanstack/react-query").InfiniteData<ResponseList<"Products", Product>>, unknown>>;
|
|
109
|
+
remove: () => void;
|
|
110
|
+
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
111
|
+
} | {
|
|
112
|
+
count: number;
|
|
113
|
+
data: Product[];
|
|
114
|
+
error: null;
|
|
115
|
+
isError: false;
|
|
116
|
+
isLoading: false;
|
|
117
|
+
isLoadingError: false;
|
|
118
|
+
isRefetchError: false;
|
|
119
|
+
isSuccess: true;
|
|
120
|
+
status: "success";
|
|
121
|
+
fetchNextPage: (options?: import("@tanstack/react-query").FetchNextPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<ResponseList<"Products", Product>, unknown>>;
|
|
122
|
+
fetchPreviousPage: (options?: import("@tanstack/react-query").FetchPreviousPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<ResponseList<"Products", Product>, unknown>>;
|
|
123
|
+
hasNextPage?: boolean;
|
|
124
|
+
hasPreviousPage?: boolean;
|
|
125
|
+
isFetchingNextPage: boolean;
|
|
126
|
+
isFetchingPreviousPage: boolean;
|
|
127
|
+
dataUpdatedAt: number;
|
|
128
|
+
errorUpdatedAt: number;
|
|
129
|
+
failureCount: number;
|
|
130
|
+
failureReason: unknown;
|
|
131
|
+
errorUpdateCount: number;
|
|
132
|
+
isFetched: boolean;
|
|
133
|
+
isFetchedAfterMount: boolean;
|
|
134
|
+
isFetching: boolean;
|
|
135
|
+
isInitialLoading: boolean;
|
|
136
|
+
isPaused: boolean;
|
|
137
|
+
isPlaceholderData: boolean;
|
|
138
|
+
isPreviousData: boolean;
|
|
139
|
+
isRefetching: boolean;
|
|
140
|
+
isStale: boolean;
|
|
141
|
+
refetch: <TPageData>(options?: import("@tanstack/react-query").RefetchOptions & import("@tanstack/react-query").RefetchQueryFilters<TPageData>) => Promise<import("@tanstack/react-query").QueryObserverResult<import("@tanstack/react-query").InfiniteData<ResponseList<"Products", Product>>, unknown>>;
|
|
142
|
+
remove: () => void;
|
|
143
|
+
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
144
|
+
};
|
|
@@ -34,8 +34,10 @@ export * from './Analytics/get/useAnalyticsUserQuery.hook';
|
|
|
34
34
|
export * from './Answer/get/useAnswerIdQuery.hook';
|
|
35
35
|
export * from './Answer/mutate/useAnswerMutateQuery.hook';
|
|
36
36
|
export * from './Answer/get/useAnswersUserSupervisorQuery.hook';
|
|
37
|
-
export * from './
|
|
38
|
-
export * from './
|
|
37
|
+
export * from './AprProduct/get/useProductsQuery.hook';
|
|
38
|
+
export * from './AprProduct/get/useProductHierarchies.hook';
|
|
39
|
+
export * from './AprProduct/get/useProductRecommendations.hook';
|
|
40
|
+
export * from './AprProduct/get/useProductsByRefQuery.hook';
|
|
39
41
|
export * from './Roles/get/useAllStoreQuery.hook';
|
|
40
42
|
export * from './Roles/get/useAllRolesQuery.hook';
|
|
41
43
|
export * from './AsvProduct/get/getProductsByRefQuery.hook';
|
package/package.json
CHANGED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { get, ProductsHierarchies, ResponseList } from '../../../';
|
|
2
|
+
import { useQuery, UseQueryOptions } from '@tanstack/react-query';
|
|
3
|
+
|
|
4
|
+
export interface useProductsHierarchiesQueryHook extends UseQueryOptions<ResponseList<"Categories", ProductsHierarchies>> {
|
|
5
|
+
terms?: string;
|
|
6
|
+
query?: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const useProductsHierarchiesQueryHook = ({ terms, query, ...options }: useProductsHierarchiesQueryHook) => {
|
|
10
|
+
return useQuery(
|
|
11
|
+
['PRODUCT_CATEGORIES', terms, query],
|
|
12
|
+
() => get<ResponseList<"Categories", ProductsHierarchies>>('/Recommendations/Categories', {
|
|
13
|
+
pTerms: terms,
|
|
14
|
+
pQuery: query
|
|
15
|
+
}),
|
|
16
|
+
options
|
|
17
|
+
);
|
|
18
|
+
};
|
|
19
|
+
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { get, Product, ResponseList } from '../../..';
|
|
2
|
+
import { useQuery, UseQueryOptions } from '@tanstack/react-query';
|
|
3
|
+
|
|
4
|
+
export interface useProductsRecommendationsQueryHook extends UseQueryOptions<ResponseList<"Products", Product>> {
|
|
5
|
+
sortBy?: string;
|
|
6
|
+
sortDirection?: string;
|
|
7
|
+
reference?: string;
|
|
8
|
+
category?: string;
|
|
9
|
+
type?: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const useProductRecommendationsHook = ({ sortBy, sortDirection, reference, category, type }: useProductsRecommendationsQueryHook) => {
|
|
13
|
+
return useQuery(
|
|
14
|
+
['PRODUCT_RECOMMENDATIONS', sortBy, sortDirection, reference, category, type],
|
|
15
|
+
() => get<ResponseList<"Products", Product>>('/Recommendations/Products/Recommendations', {
|
|
16
|
+
pSortBy: sortBy,
|
|
17
|
+
pSortDirection: sortDirection,
|
|
18
|
+
pReferences: reference,
|
|
19
|
+
pProductHierarchyId: category,
|
|
20
|
+
pType: type
|
|
21
|
+
|
|
22
|
+
}),
|
|
23
|
+
);
|
|
24
|
+
};
|
|
25
|
+
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { get, Product, ResponseList } from '../../../';
|
|
2
|
+
import { useQuery } from '@tanstack/react-query';
|
|
3
|
+
|
|
4
|
+
export const useProductsByRefQueryHook = (productRef: string) => {
|
|
5
|
+
return useQuery(
|
|
6
|
+
['PRODUCT_BY_REF', productRef],
|
|
7
|
+
() => get<ResponseList<"Products", Product>>(`/Recommendations/Products/${productRef}`)
|
|
8
|
+
);
|
|
9
|
+
};
|
|
10
|
+
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { get, Product, ResponseList } from '../../../';
|
|
2
|
+
import { useInfiniteQuery, useQuery, UseQueryOptions } from '@tanstack/react-query';
|
|
3
|
+
|
|
4
|
+
export interface ProductsQuery extends UseQueryOptions<ResponseList<"Products", Product>> {
|
|
5
|
+
page?: number;
|
|
6
|
+
records?: number;
|
|
7
|
+
sortBy?: string;
|
|
8
|
+
sortDirection?: string;
|
|
9
|
+
terms?: string;
|
|
10
|
+
query?: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const useProductsQueryHook = ({ page, records, sortBy, sortDirection, terms, query, ...options }: ProductsQuery) => {
|
|
14
|
+
return useQuery<ResponseList<"Products", Product>>(['PRODUCTS', page, records, sortBy, sortDirection, terms, query], () =>
|
|
15
|
+
get('/Recommendations/Products', {
|
|
16
|
+
pPage: page,
|
|
17
|
+
pRecords: records || 50,
|
|
18
|
+
pSortBy: sortBy,
|
|
19
|
+
pSortDirection: sortDirection,
|
|
20
|
+
pTerms: terms,
|
|
21
|
+
pQuery: query
|
|
22
|
+
}),
|
|
23
|
+
options
|
|
24
|
+
);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export const useProductInfiniteQueryHook = ({ sortBy, sortDirection, terms, query }: Omit<ProductsQuery, 'page' | 'records'> = {}) => {
|
|
28
|
+
const infiniteQuery = useInfiniteQuery(['PRODUCTS_INFINITE', sortBy, sortDirection, terms, query], ({ pageParam = 1 }) =>
|
|
29
|
+
get<ResponseList<"Products", Product>>('/Recommendations/Products', {
|
|
30
|
+
pPage: pageParam,
|
|
31
|
+
pRecords: 50,
|
|
32
|
+
pSortBy: sortBy,
|
|
33
|
+
pSortDirection: sortDirection,
|
|
34
|
+
pTerms: terms,
|
|
35
|
+
pQuery: query
|
|
36
|
+
}));
|
|
37
|
+
|
|
38
|
+
const pagesMulti = infiniteQuery.data?.pages?.map((page) => (page.Products as Product[]) || []) || [];
|
|
39
|
+
const allDataGrouped = ([] as Product[]).concat(...pagesMulti);
|
|
40
|
+
|
|
41
|
+
return {
|
|
42
|
+
...infiniteQuery,
|
|
43
|
+
count: infiniteQuery.data?.pages?.[0].Count || 0,
|
|
44
|
+
data: allDataGrouped,
|
|
45
|
+
}
|
|
46
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
|
2
|
+
import { Product } from '../../../interfaces';
|
|
3
|
+
import { post } from '../../../services/ApiService';
|
|
4
|
+
|
|
5
|
+
export const postCheckoutsMutateQueryHook = () => {
|
|
6
|
+
const queryClient = useQueryClient();
|
|
7
|
+
return useMutation<Product, unknown, Product>((data: Product) => {
|
|
8
|
+
return post('/Recommendations/Checkouts', data);
|
|
9
|
+
}, {
|
|
10
|
+
onSuccess: (data: Product) => {
|
|
11
|
+
queryClient.setQueryData(
|
|
12
|
+
['CHECKOUT'], data);
|
|
13
|
+
},
|
|
14
|
+
});
|
|
15
|
+
}
|
package/src/hooks/index.ts
CHANGED
|
@@ -46,9 +46,11 @@ export * from './Answer/get/useAnswerIdQuery.hook';
|
|
|
46
46
|
export * from './Answer/mutate/useAnswerMutateQuery.hook';
|
|
47
47
|
export * from './Answer/get/useAnswersUserSupervisorQuery.hook';
|
|
48
48
|
|
|
49
|
-
//
|
|
50
|
-
export * from './
|
|
51
|
-
export * from './
|
|
49
|
+
//AprProducts
|
|
50
|
+
export * from './AprProduct/get/useProductsQuery.hook';
|
|
51
|
+
export * from './AprProduct/get/useProductHierarchies.hook';
|
|
52
|
+
export * from './AprProduct/get/useProductRecommendations.hook';
|
|
53
|
+
export * from './AprProduct/get/useProductsByRefQuery.hook';
|
|
52
54
|
|
|
53
55
|
//Roles
|
|
54
56
|
export * from './Roles/get/useAllStoreQuery.hook';
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { get, ProductsHierarchies, ResponseList } from '../../../';
|
|
2
|
-
import { useQuery, UseQueryOptions } from '@tanstack/react-query';
|
|
3
|
-
|
|
4
|
-
export interface useProductsHierarchiesQueryHook extends UseQueryOptions<ResponseList<"Hierarchies", ProductsHierarchies>> {
|
|
5
|
-
page?: number;
|
|
6
|
-
limit?: number;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export const useProductsHierarchiesQueryHook = ({ page, limit, ...options }: useProductsHierarchiesQueryHook) => {
|
|
10
|
-
return useQuery<ResponseList<"Hierarchies", ProductsHierarchies>>(['HIERARCHIES', page, limit], () =>
|
|
11
|
-
get('/Product/ProductHierarchies', { pPage: page, pRecords: limit || 50 }), options);
|
|
12
|
-
};
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { get, Product, ResponseList } from '../../../';
|
|
2
|
-
import { useInfiniteQuery, useQuery, UseQueryOptions } from '@tanstack/react-query';
|
|
3
|
-
|
|
4
|
-
export interface ProductsQuery extends UseQueryOptions<ResponseList<"Products", Product>> {
|
|
5
|
-
page?: number;
|
|
6
|
-
limit?: number;
|
|
7
|
-
filterBy?: string;
|
|
8
|
-
search?: string;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export const useProductsQueryHook = ({ page, limit, ...options }: ProductsQuery) => {
|
|
12
|
-
return useQuery<ResponseList<"Products", Product>>(['PRODUCTS', page, limit], () =>
|
|
13
|
-
get('/Product/Products', { pPage: page, pRecords: limit || 50 }), options);
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export const useProductInfiniteQueryHook = ({ filterBy, search }: Omit<ProductsQuery, 'page' | 'limit' > = {}) => {
|
|
17
|
-
const infiniteQuery = useInfiniteQuery(['PRODUCTS_INFINITE', filterBy, search], ({ pageParam = 1 }) =>
|
|
18
|
-
get<ResponseList<"Products", Product>>('/Product/Products', {
|
|
19
|
-
pPage: pageParam, pRecords: 50,
|
|
20
|
-
}));
|
|
21
|
-
|
|
22
|
-
const pagesMulti = infiniteQuery.data?.pages?.map((page) => (page.Products as Product[]) || []) || [];
|
|
23
|
-
const allDataGrouped = ([] as Product[]).concat(...pagesMulti);
|
|
24
|
-
|
|
25
|
-
return {
|
|
26
|
-
...infiniteQuery,
|
|
27
|
-
count: infiniteQuery.data?.pages?.[0].Count || 0,
|
|
28
|
-
data: allDataGrouped,
|
|
29
|
-
}
|
|
30
|
-
};
|