@bit.rhplus/data 0.0.7 → 0.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -327
- package/dist/index.js +2 -41
- package/dist/index.js.map +1 -1
- package/dist/reactQuery.d.ts +327 -0
- package/dist/reactQuery.js +39 -0
- package/dist/reactQuery.js.map +1 -0
- package/index.js +4 -45
- package/package.json +2 -2
- package/reactQuery.js +44 -0
- /package/dist/{preview-1744710139233.js → preview-1744714889120.js} +0 -0
package/dist/index.d.ts
CHANGED
|
@@ -3,331 +3,5 @@ export default function useData(): {
|
|
|
3
3
|
fetchDataUIAsync: (api: any, data: any) => Promise<any>;
|
|
4
4
|
getFileURL: (content: any, type: any) => string;
|
|
5
5
|
downloadFileURL: (content: any, type: any, fileName: any) => void;
|
|
6
|
-
useApiQuerySilence: (key: any, api: any, params: {} | undefined, returnFn: any) => {
|
|
7
|
-
updateData: (updateFn: any) => void;
|
|
8
|
-
data: any;
|
|
9
|
-
error: Error;
|
|
10
|
-
isError: true;
|
|
11
|
-
isPending: false;
|
|
12
|
-
isLoading: false;
|
|
13
|
-
isLoadingError: false;
|
|
14
|
-
isRefetchError: true;
|
|
15
|
-
isSuccess: false;
|
|
16
|
-
isPlaceholderData: false;
|
|
17
|
-
status: "error";
|
|
18
|
-
dataUpdatedAt: number;
|
|
19
|
-
errorUpdatedAt: number;
|
|
20
|
-
failureCount: number;
|
|
21
|
-
failureReason: Error | null;
|
|
22
|
-
errorUpdateCount: number;
|
|
23
|
-
isFetched: boolean;
|
|
24
|
-
isFetchedAfterMount: boolean;
|
|
25
|
-
isFetching: boolean;
|
|
26
|
-
isInitialLoading: boolean;
|
|
27
|
-
isPaused: boolean;
|
|
28
|
-
isRefetching: boolean;
|
|
29
|
-
isStale: boolean;
|
|
30
|
-
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<any, Error>>;
|
|
31
|
-
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
32
|
-
promise: Promise<any>;
|
|
33
|
-
} | {
|
|
34
|
-
updateData: (updateFn: any) => void;
|
|
35
|
-
data: any;
|
|
36
|
-
error: null;
|
|
37
|
-
isError: false;
|
|
38
|
-
isPending: false;
|
|
39
|
-
isLoading: false;
|
|
40
|
-
isLoadingError: false;
|
|
41
|
-
isRefetchError: false;
|
|
42
|
-
isSuccess: true;
|
|
43
|
-
isPlaceholderData: false;
|
|
44
|
-
status: "success";
|
|
45
|
-
dataUpdatedAt: number;
|
|
46
|
-
errorUpdatedAt: number;
|
|
47
|
-
failureCount: number;
|
|
48
|
-
failureReason: Error | null;
|
|
49
|
-
errorUpdateCount: number;
|
|
50
|
-
isFetched: boolean;
|
|
51
|
-
isFetchedAfterMount: boolean;
|
|
52
|
-
isFetching: boolean;
|
|
53
|
-
isInitialLoading: boolean;
|
|
54
|
-
isPaused: boolean;
|
|
55
|
-
isRefetching: boolean;
|
|
56
|
-
isStale: boolean;
|
|
57
|
-
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<any, Error>>;
|
|
58
|
-
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
59
|
-
promise: Promise<any>;
|
|
60
|
-
} | {
|
|
61
|
-
updateData: (updateFn: any) => void;
|
|
62
|
-
data: undefined;
|
|
63
|
-
error: Error;
|
|
64
|
-
isError: true;
|
|
65
|
-
isPending: false;
|
|
66
|
-
isLoading: false;
|
|
67
|
-
isLoadingError: true;
|
|
68
|
-
isRefetchError: false;
|
|
69
|
-
isSuccess: false;
|
|
70
|
-
isPlaceholderData: false;
|
|
71
|
-
status: "error";
|
|
72
|
-
dataUpdatedAt: number;
|
|
73
|
-
errorUpdatedAt: number;
|
|
74
|
-
failureCount: number;
|
|
75
|
-
failureReason: Error | null;
|
|
76
|
-
errorUpdateCount: number;
|
|
77
|
-
isFetched: boolean;
|
|
78
|
-
isFetchedAfterMount: boolean;
|
|
79
|
-
isFetching: boolean;
|
|
80
|
-
isInitialLoading: boolean;
|
|
81
|
-
isPaused: boolean;
|
|
82
|
-
isRefetching: boolean;
|
|
83
|
-
isStale: boolean;
|
|
84
|
-
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<any, Error>>;
|
|
85
|
-
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
86
|
-
promise: Promise<any>;
|
|
87
|
-
} | {
|
|
88
|
-
updateData: (updateFn: any) => void;
|
|
89
|
-
data: undefined;
|
|
90
|
-
error: null;
|
|
91
|
-
isError: false;
|
|
92
|
-
isPending: true;
|
|
93
|
-
isLoading: true;
|
|
94
|
-
isLoadingError: false;
|
|
95
|
-
isRefetchError: false;
|
|
96
|
-
isSuccess: false;
|
|
97
|
-
isPlaceholderData: false;
|
|
98
|
-
status: "pending";
|
|
99
|
-
dataUpdatedAt: number;
|
|
100
|
-
errorUpdatedAt: number;
|
|
101
|
-
failureCount: number;
|
|
102
|
-
failureReason: Error | null;
|
|
103
|
-
errorUpdateCount: number;
|
|
104
|
-
isFetched: boolean;
|
|
105
|
-
isFetchedAfterMount: boolean;
|
|
106
|
-
isFetching: boolean;
|
|
107
|
-
isInitialLoading: boolean;
|
|
108
|
-
isPaused: boolean;
|
|
109
|
-
isRefetching: boolean;
|
|
110
|
-
isStale: boolean;
|
|
111
|
-
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<any, Error>>;
|
|
112
|
-
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
113
|
-
promise: Promise<any>;
|
|
114
|
-
} | {
|
|
115
|
-
updateData: (updateFn: any) => void;
|
|
116
|
-
data: undefined;
|
|
117
|
-
error: null;
|
|
118
|
-
isError: false;
|
|
119
|
-
isPending: true;
|
|
120
|
-
isLoadingError: false;
|
|
121
|
-
isRefetchError: false;
|
|
122
|
-
isSuccess: false;
|
|
123
|
-
isPlaceholderData: false;
|
|
124
|
-
status: "pending";
|
|
125
|
-
dataUpdatedAt: number;
|
|
126
|
-
errorUpdatedAt: number;
|
|
127
|
-
failureCount: number;
|
|
128
|
-
failureReason: Error | null;
|
|
129
|
-
errorUpdateCount: number;
|
|
130
|
-
isFetched: boolean;
|
|
131
|
-
isFetchedAfterMount: boolean;
|
|
132
|
-
isFetching: boolean;
|
|
133
|
-
isLoading: boolean;
|
|
134
|
-
isInitialLoading: boolean;
|
|
135
|
-
isPaused: boolean;
|
|
136
|
-
isRefetching: boolean;
|
|
137
|
-
isStale: boolean;
|
|
138
|
-
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<any, Error>>;
|
|
139
|
-
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
140
|
-
promise: Promise<any>;
|
|
141
|
-
} | {
|
|
142
|
-
updateData: (updateFn: any) => void;
|
|
143
|
-
data: any;
|
|
144
|
-
isError: false;
|
|
145
|
-
error: null;
|
|
146
|
-
isPending: false;
|
|
147
|
-
isLoading: false;
|
|
148
|
-
isLoadingError: false;
|
|
149
|
-
isRefetchError: false;
|
|
150
|
-
isSuccess: true;
|
|
151
|
-
isPlaceholderData: true;
|
|
152
|
-
status: "success";
|
|
153
|
-
dataUpdatedAt: number;
|
|
154
|
-
errorUpdatedAt: number;
|
|
155
|
-
failureCount: number;
|
|
156
|
-
failureReason: Error | null;
|
|
157
|
-
errorUpdateCount: number;
|
|
158
|
-
isFetched: boolean;
|
|
159
|
-
isFetchedAfterMount: boolean;
|
|
160
|
-
isFetching: boolean;
|
|
161
|
-
isInitialLoading: boolean;
|
|
162
|
-
isPaused: boolean;
|
|
163
|
-
isRefetching: boolean;
|
|
164
|
-
isStale: boolean;
|
|
165
|
-
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<any, Error>>;
|
|
166
|
-
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
167
|
-
promise: Promise<any>;
|
|
168
|
-
};
|
|
169
|
-
useApiQuery: (key: any, api: any, params: {} | undefined, returnFn: any, ui?: boolean) => {
|
|
170
|
-
updateData: (updateFn: any) => void;
|
|
171
|
-
data: any;
|
|
172
|
-
error: Error;
|
|
173
|
-
isError: true;
|
|
174
|
-
isPending: false;
|
|
175
|
-
isLoading: false;
|
|
176
|
-
isLoadingError: false;
|
|
177
|
-
isRefetchError: true;
|
|
178
|
-
isSuccess: false;
|
|
179
|
-
isPlaceholderData: false;
|
|
180
|
-
status: "error";
|
|
181
|
-
dataUpdatedAt: number;
|
|
182
|
-
errorUpdatedAt: number;
|
|
183
|
-
failureCount: number;
|
|
184
|
-
failureReason: Error | null;
|
|
185
|
-
errorUpdateCount: number;
|
|
186
|
-
isFetched: boolean;
|
|
187
|
-
isFetchedAfterMount: boolean;
|
|
188
|
-
isFetching: boolean;
|
|
189
|
-
isInitialLoading: boolean;
|
|
190
|
-
isPaused: boolean;
|
|
191
|
-
isRefetching: boolean;
|
|
192
|
-
isStale: boolean;
|
|
193
|
-
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<any, Error>>;
|
|
194
|
-
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
195
|
-
promise: Promise<any>;
|
|
196
|
-
} | {
|
|
197
|
-
updateData: (updateFn: any) => void;
|
|
198
|
-
data: any;
|
|
199
|
-
error: null;
|
|
200
|
-
isError: false;
|
|
201
|
-
isPending: false;
|
|
202
|
-
isLoading: false;
|
|
203
|
-
isLoadingError: false;
|
|
204
|
-
isRefetchError: false;
|
|
205
|
-
isSuccess: true;
|
|
206
|
-
isPlaceholderData: false;
|
|
207
|
-
status: "success";
|
|
208
|
-
dataUpdatedAt: number;
|
|
209
|
-
errorUpdatedAt: number;
|
|
210
|
-
failureCount: number;
|
|
211
|
-
failureReason: Error | null;
|
|
212
|
-
errorUpdateCount: number;
|
|
213
|
-
isFetched: boolean;
|
|
214
|
-
isFetchedAfterMount: boolean;
|
|
215
|
-
isFetching: boolean;
|
|
216
|
-
isInitialLoading: boolean;
|
|
217
|
-
isPaused: boolean;
|
|
218
|
-
isRefetching: boolean;
|
|
219
|
-
isStale: boolean;
|
|
220
|
-
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<any, Error>>;
|
|
221
|
-
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
222
|
-
promise: Promise<any>;
|
|
223
|
-
} | {
|
|
224
|
-
updateData: (updateFn: any) => void;
|
|
225
|
-
data: undefined;
|
|
226
|
-
error: Error;
|
|
227
|
-
isError: true;
|
|
228
|
-
isPending: false;
|
|
229
|
-
isLoading: false;
|
|
230
|
-
isLoadingError: true;
|
|
231
|
-
isRefetchError: false;
|
|
232
|
-
isSuccess: false;
|
|
233
|
-
isPlaceholderData: false;
|
|
234
|
-
status: "error";
|
|
235
|
-
dataUpdatedAt: number;
|
|
236
|
-
errorUpdatedAt: number;
|
|
237
|
-
failureCount: number;
|
|
238
|
-
failureReason: Error | null;
|
|
239
|
-
errorUpdateCount: number;
|
|
240
|
-
isFetched: boolean;
|
|
241
|
-
isFetchedAfterMount: boolean;
|
|
242
|
-
isFetching: boolean;
|
|
243
|
-
isInitialLoading: boolean;
|
|
244
|
-
isPaused: boolean;
|
|
245
|
-
isRefetching: boolean;
|
|
246
|
-
isStale: boolean;
|
|
247
|
-
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<any, Error>>;
|
|
248
|
-
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
249
|
-
promise: Promise<any>;
|
|
250
|
-
} | {
|
|
251
|
-
updateData: (updateFn: any) => void;
|
|
252
|
-
data: undefined;
|
|
253
|
-
error: null;
|
|
254
|
-
isError: false;
|
|
255
|
-
isPending: true;
|
|
256
|
-
isLoading: true;
|
|
257
|
-
isLoadingError: false;
|
|
258
|
-
isRefetchError: false;
|
|
259
|
-
isSuccess: false;
|
|
260
|
-
isPlaceholderData: false;
|
|
261
|
-
status: "pending";
|
|
262
|
-
dataUpdatedAt: number;
|
|
263
|
-
errorUpdatedAt: number;
|
|
264
|
-
failureCount: number;
|
|
265
|
-
failureReason: Error | null;
|
|
266
|
-
errorUpdateCount: number;
|
|
267
|
-
isFetched: boolean;
|
|
268
|
-
isFetchedAfterMount: boolean;
|
|
269
|
-
isFetching: boolean;
|
|
270
|
-
isInitialLoading: boolean;
|
|
271
|
-
isPaused: boolean;
|
|
272
|
-
isRefetching: boolean;
|
|
273
|
-
isStale: boolean;
|
|
274
|
-
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<any, Error>>;
|
|
275
|
-
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
276
|
-
promise: Promise<any>;
|
|
277
|
-
} | {
|
|
278
|
-
updateData: (updateFn: any) => void;
|
|
279
|
-
data: undefined;
|
|
280
|
-
error: null;
|
|
281
|
-
isError: false;
|
|
282
|
-
isPending: true;
|
|
283
|
-
isLoadingError: false;
|
|
284
|
-
isRefetchError: false;
|
|
285
|
-
isSuccess: false;
|
|
286
|
-
isPlaceholderData: false;
|
|
287
|
-
status: "pending";
|
|
288
|
-
dataUpdatedAt: number;
|
|
289
|
-
errorUpdatedAt: number;
|
|
290
|
-
failureCount: number;
|
|
291
|
-
failureReason: Error | null;
|
|
292
|
-
errorUpdateCount: number;
|
|
293
|
-
isFetched: boolean;
|
|
294
|
-
isFetchedAfterMount: boolean;
|
|
295
|
-
isFetching: boolean;
|
|
296
|
-
isLoading: boolean;
|
|
297
|
-
isInitialLoading: boolean;
|
|
298
|
-
isPaused: boolean;
|
|
299
|
-
isRefetching: boolean;
|
|
300
|
-
isStale: boolean;
|
|
301
|
-
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<any, Error>>;
|
|
302
|
-
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
303
|
-
promise: Promise<any>;
|
|
304
|
-
} | {
|
|
305
|
-
updateData: (updateFn: any) => void;
|
|
306
|
-
data: any;
|
|
307
|
-
isError: false;
|
|
308
|
-
error: null;
|
|
309
|
-
isPending: false;
|
|
310
|
-
isLoading: false;
|
|
311
|
-
isLoadingError: false;
|
|
312
|
-
isRefetchError: false;
|
|
313
|
-
isSuccess: true;
|
|
314
|
-
isPlaceholderData: true;
|
|
315
|
-
status: "success";
|
|
316
|
-
dataUpdatedAt: number;
|
|
317
|
-
errorUpdatedAt: number;
|
|
318
|
-
failureCount: number;
|
|
319
|
-
failureReason: Error | null;
|
|
320
|
-
errorUpdateCount: number;
|
|
321
|
-
isFetched: boolean;
|
|
322
|
-
isFetchedAfterMount: boolean;
|
|
323
|
-
isFetching: boolean;
|
|
324
|
-
isInitialLoading: boolean;
|
|
325
|
-
isPaused: boolean;
|
|
326
|
-
isRefetching: boolean;
|
|
327
|
-
isStale: boolean;
|
|
328
|
-
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<any, Error>>;
|
|
329
|
-
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
330
|
-
promise: Promise<any>;
|
|
331
|
-
};
|
|
332
|
-
useStaticQuery: (key: any, staticData: any) => import("@tanstack/react-query").DefinedUseQueryResult<any, Error>;
|
|
333
6
|
};
|
|
7
|
+
export { useApiQuery, useApiQuerySilence, useStaticQuery } from "./reactQuery";
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { useQuery, useQueryClient } from '@tanstack/react-query';
|
|
2
1
|
import { FetchData, errorNotification } from '@rhplus/wieldy.api';
|
|
3
2
|
import { useOidcAccessToken } from "@axa-fr/react-oidc";
|
|
4
3
|
export default function useData() {
|
|
@@ -51,50 +50,12 @@ export default function useData() {
|
|
|
51
50
|
tempLink.download = fileName;
|
|
52
51
|
tempLink.click();
|
|
53
52
|
};
|
|
54
|
-
const useStaticQuery = (key, staticData) => {
|
|
55
|
-
return useQuery({
|
|
56
|
-
queryKey: [key],
|
|
57
|
-
queryFn: () => Promise.resolve(staticData),
|
|
58
|
-
initialData: staticData,
|
|
59
|
-
staleTime: Infinity,
|
|
60
|
-
});
|
|
61
|
-
};
|
|
62
|
-
const useApiQuery = (key, api, params = {}, returnFn, ui = true) => {
|
|
63
|
-
const queryClient = useQueryClient();
|
|
64
|
-
return {
|
|
65
|
-
...useQuery({
|
|
66
|
-
queryKey: [key],
|
|
67
|
-
queryFn: async () => {
|
|
68
|
-
let response;
|
|
69
|
-
if (ui)
|
|
70
|
-
response = await fetchDataUIAsync(api, params);
|
|
71
|
-
else
|
|
72
|
-
response = await fetchData(api, params);
|
|
73
|
-
if (returnFn) {
|
|
74
|
-
return returnFn(response.data);
|
|
75
|
-
}
|
|
76
|
-
return response.data;
|
|
77
|
-
},
|
|
78
|
-
}),
|
|
79
|
-
// Funkce pro manuální aktualizaci dat
|
|
80
|
-
updateData: (updateFn) => {
|
|
81
|
-
queryClient.setQueryData([key], (oldData) => {
|
|
82
|
-
if (!oldData)
|
|
83
|
-
return oldData;
|
|
84
|
-
return updateFn(oldData);
|
|
85
|
-
});
|
|
86
|
-
},
|
|
87
|
-
};
|
|
88
|
-
};
|
|
89
|
-
const useApiQuerySilence = (key, api, params = {}, returnFn) => useApiQuery(key, api, params, returnFn, false);
|
|
90
53
|
return {
|
|
91
54
|
fetchData,
|
|
92
55
|
fetchDataUIAsync,
|
|
93
56
|
getFileURL,
|
|
94
|
-
downloadFileURL
|
|
95
|
-
useApiQuerySilence,
|
|
96
|
-
useApiQuery,
|
|
97
|
-
useStaticQuery
|
|
57
|
+
downloadFileURL
|
|
98
58
|
};
|
|
99
59
|
}
|
|
60
|
+
export { useApiQuery, useApiQuerySilence, useStaticQuery } from './reactQuery';
|
|
100
61
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAClE,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAExD,MAAM,CAAC,OAAO,UAAU,OAAO;IAC7B,MAAM,EAAE,WAAW,EAAE,GAAG,kBAAkB,EAAE,CAAC;IAC7C,MAAM,SAAS,GAAG,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,CAAC,SAAS,CAAC,GAAG,EAAE,IAAI,EAAE,WAAW,CAAC,CAAC;IAEnE,MAAM,gBAAgB,GAAG,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE;QAC3C,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;YAC1C,OAAO;gBACL,GAAG,MAAM;gBACT,MAAM,EAAE,SAAS;gBACjB,OAAO,EAAE,IAAI;aACd,CAAA;QACH,CAAC;QACD,OAAO,KAAK,EAAE,CAAC;YACb,iBAAiB,CAAC,KAAK,CAAC,CAAC;YACzB,OAAO;gBACL,MAAM,EAAE,MAAM;gBACd,OAAO,EAAE,KAAK;gBACd,KAAK;aACN,CAAA;QACH,CAAC;IACH,CAAC,CAAA;IAED,MAAM,UAAU,GAAG,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE;QACnC,0GAA0G;QAC1G,MAAM,QAAQ,GAAG,OAAO,OAAO,KAAK,QAAQ,IAAI,mBAAmB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAElF,IAAI,SAAS,CAAC;QAEd,IAAI,QAAQ,EAAE,CAAC;YACb,uCAAuC;YACvC,MAAM,cAAc,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC;YACrC,MAAM,WAAW,GAAG,IAAI,KAAK,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;YACrD,uCAAuC;YACvC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,cAAc,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;gBAC/C,WAAW,CAAC,CAAC,CAAC,GAAG,cAAc,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;YAChD,CAAC;YACD,SAAS,GAAG,IAAI,UAAU,CAAC,WAAW,CAAC,CAAC;QAC1C,CAAC;aAAM,CAAC;YACN,0CAA0C;YAC1C,SAAS,GAAG,IAAI,UAAU,CAAC,OAAO,CAAC,CAAC;QACtC,CAAC;QAED,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,CAAC,SAAS,CAAC,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;QAC7C,MAAM,OAAO,GAAG,MAAM,CAAC,GAAG,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;QACjD,OAAO,OAAO,CAAC;IACjB,CAAC,CAAA;IAED,MAAM,eAAe,GAAG,CAAC,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE;QAClD,MAAM,OAAO,GAAG,UAAU,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QAC1C,MAAM,QAAQ,GAAG,QAAQ,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;QAC7C,QAAQ,CAAC,IAAI,GAAG,OAAO,CAAC;QACxB,QAAQ,CAAC,QAAQ,GAAG,QAAQ,CAAC;QAC7B,QAAQ,CAAC,KAAK,EAAE,CAAC;IACnB,CAAC,CAAA;IAED,OAAO;QACL,SAAS;QACT,gBAAgB;QAChB,UAAU;QACV,eAAe;KAChB,CAAA;AACH,CAAC;AAED,OAAO,EAAC,WAAW,EAAE,kBAAkB,EAAE,cAAc,EAAC,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
export function useApiQuery(key: any, api: any, params: {} | undefined, returnFn: any, ui?: boolean): {
|
|
2
|
+
updateData: (updateFn: any) => void;
|
|
3
|
+
data: any;
|
|
4
|
+
error: Error;
|
|
5
|
+
isError: true;
|
|
6
|
+
isPending: false;
|
|
7
|
+
isLoading: false;
|
|
8
|
+
isLoadingError: false;
|
|
9
|
+
isRefetchError: true;
|
|
10
|
+
isSuccess: false;
|
|
11
|
+
isPlaceholderData: false;
|
|
12
|
+
status: "error";
|
|
13
|
+
dataUpdatedAt: number;
|
|
14
|
+
errorUpdatedAt: number;
|
|
15
|
+
failureCount: number;
|
|
16
|
+
failureReason: Error | null;
|
|
17
|
+
errorUpdateCount: number;
|
|
18
|
+
isFetched: boolean;
|
|
19
|
+
isFetchedAfterMount: boolean;
|
|
20
|
+
isFetching: boolean;
|
|
21
|
+
isInitialLoading: boolean;
|
|
22
|
+
isPaused: boolean;
|
|
23
|
+
isRefetching: boolean;
|
|
24
|
+
isStale: boolean;
|
|
25
|
+
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<any, Error>>;
|
|
26
|
+
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
27
|
+
promise: Promise<any>;
|
|
28
|
+
} | {
|
|
29
|
+
updateData: (updateFn: any) => void;
|
|
30
|
+
data: any;
|
|
31
|
+
error: null;
|
|
32
|
+
isError: false;
|
|
33
|
+
isPending: false;
|
|
34
|
+
isLoading: false;
|
|
35
|
+
isLoadingError: false;
|
|
36
|
+
isRefetchError: false;
|
|
37
|
+
isSuccess: true;
|
|
38
|
+
isPlaceholderData: false;
|
|
39
|
+
status: "success";
|
|
40
|
+
dataUpdatedAt: number;
|
|
41
|
+
errorUpdatedAt: number;
|
|
42
|
+
failureCount: number;
|
|
43
|
+
failureReason: Error | null;
|
|
44
|
+
errorUpdateCount: number;
|
|
45
|
+
isFetched: boolean;
|
|
46
|
+
isFetchedAfterMount: boolean;
|
|
47
|
+
isFetching: boolean;
|
|
48
|
+
isInitialLoading: boolean;
|
|
49
|
+
isPaused: boolean;
|
|
50
|
+
isRefetching: boolean;
|
|
51
|
+
isStale: boolean;
|
|
52
|
+
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<any, Error>>;
|
|
53
|
+
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
54
|
+
promise: Promise<any>;
|
|
55
|
+
} | {
|
|
56
|
+
updateData: (updateFn: any) => void;
|
|
57
|
+
data: undefined;
|
|
58
|
+
error: Error;
|
|
59
|
+
isError: true;
|
|
60
|
+
isPending: false;
|
|
61
|
+
isLoading: false;
|
|
62
|
+
isLoadingError: true;
|
|
63
|
+
isRefetchError: false;
|
|
64
|
+
isSuccess: false;
|
|
65
|
+
isPlaceholderData: false;
|
|
66
|
+
status: "error";
|
|
67
|
+
dataUpdatedAt: number;
|
|
68
|
+
errorUpdatedAt: number;
|
|
69
|
+
failureCount: number;
|
|
70
|
+
failureReason: Error | null;
|
|
71
|
+
errorUpdateCount: number;
|
|
72
|
+
isFetched: boolean;
|
|
73
|
+
isFetchedAfterMount: boolean;
|
|
74
|
+
isFetching: boolean;
|
|
75
|
+
isInitialLoading: boolean;
|
|
76
|
+
isPaused: boolean;
|
|
77
|
+
isRefetching: boolean;
|
|
78
|
+
isStale: boolean;
|
|
79
|
+
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<any, Error>>;
|
|
80
|
+
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
81
|
+
promise: Promise<any>;
|
|
82
|
+
} | {
|
|
83
|
+
updateData: (updateFn: any) => void;
|
|
84
|
+
data: undefined;
|
|
85
|
+
error: null;
|
|
86
|
+
isError: false;
|
|
87
|
+
isPending: true;
|
|
88
|
+
isLoading: true;
|
|
89
|
+
isLoadingError: false;
|
|
90
|
+
isRefetchError: false;
|
|
91
|
+
isSuccess: false;
|
|
92
|
+
isPlaceholderData: false;
|
|
93
|
+
status: "pending";
|
|
94
|
+
dataUpdatedAt: number;
|
|
95
|
+
errorUpdatedAt: number;
|
|
96
|
+
failureCount: number;
|
|
97
|
+
failureReason: Error | null;
|
|
98
|
+
errorUpdateCount: number;
|
|
99
|
+
isFetched: boolean;
|
|
100
|
+
isFetchedAfterMount: boolean;
|
|
101
|
+
isFetching: boolean;
|
|
102
|
+
isInitialLoading: boolean;
|
|
103
|
+
isPaused: boolean;
|
|
104
|
+
isRefetching: boolean;
|
|
105
|
+
isStale: boolean;
|
|
106
|
+
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<any, Error>>;
|
|
107
|
+
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
108
|
+
promise: Promise<any>;
|
|
109
|
+
} | {
|
|
110
|
+
updateData: (updateFn: any) => void;
|
|
111
|
+
data: undefined;
|
|
112
|
+
error: null;
|
|
113
|
+
isError: false;
|
|
114
|
+
isPending: true;
|
|
115
|
+
isLoadingError: false;
|
|
116
|
+
isRefetchError: false;
|
|
117
|
+
isSuccess: false;
|
|
118
|
+
isPlaceholderData: false;
|
|
119
|
+
status: "pending";
|
|
120
|
+
dataUpdatedAt: number;
|
|
121
|
+
errorUpdatedAt: number;
|
|
122
|
+
failureCount: number;
|
|
123
|
+
failureReason: Error | null;
|
|
124
|
+
errorUpdateCount: number;
|
|
125
|
+
isFetched: boolean;
|
|
126
|
+
isFetchedAfterMount: boolean;
|
|
127
|
+
isFetching: boolean;
|
|
128
|
+
isLoading: boolean;
|
|
129
|
+
isInitialLoading: boolean;
|
|
130
|
+
isPaused: boolean;
|
|
131
|
+
isRefetching: boolean;
|
|
132
|
+
isStale: boolean;
|
|
133
|
+
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<any, Error>>;
|
|
134
|
+
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
135
|
+
promise: Promise<any>;
|
|
136
|
+
} | {
|
|
137
|
+
updateData: (updateFn: any) => void;
|
|
138
|
+
data: any;
|
|
139
|
+
isError: false;
|
|
140
|
+
error: null;
|
|
141
|
+
isPending: false;
|
|
142
|
+
isLoading: false;
|
|
143
|
+
isLoadingError: false;
|
|
144
|
+
isRefetchError: false;
|
|
145
|
+
isSuccess: true;
|
|
146
|
+
isPlaceholderData: true;
|
|
147
|
+
status: "success";
|
|
148
|
+
dataUpdatedAt: number;
|
|
149
|
+
errorUpdatedAt: number;
|
|
150
|
+
failureCount: number;
|
|
151
|
+
failureReason: Error | null;
|
|
152
|
+
errorUpdateCount: number;
|
|
153
|
+
isFetched: boolean;
|
|
154
|
+
isFetchedAfterMount: boolean;
|
|
155
|
+
isFetching: boolean;
|
|
156
|
+
isInitialLoading: boolean;
|
|
157
|
+
isPaused: boolean;
|
|
158
|
+
isRefetching: boolean;
|
|
159
|
+
isStale: boolean;
|
|
160
|
+
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<any, Error>>;
|
|
161
|
+
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
162
|
+
promise: Promise<any>;
|
|
163
|
+
};
|
|
164
|
+
export function useApiQuerySilence(key: any, api: any, params: {} | undefined, returnFn: any): {
|
|
165
|
+
updateData: (updateFn: any) => void;
|
|
166
|
+
data: any;
|
|
167
|
+
error: Error;
|
|
168
|
+
isError: true;
|
|
169
|
+
isPending: false;
|
|
170
|
+
isLoading: false;
|
|
171
|
+
isLoadingError: false;
|
|
172
|
+
isRefetchError: true;
|
|
173
|
+
isSuccess: false;
|
|
174
|
+
isPlaceholderData: false;
|
|
175
|
+
status: "error";
|
|
176
|
+
dataUpdatedAt: number;
|
|
177
|
+
errorUpdatedAt: number;
|
|
178
|
+
failureCount: number;
|
|
179
|
+
failureReason: Error | null;
|
|
180
|
+
errorUpdateCount: number;
|
|
181
|
+
isFetched: boolean;
|
|
182
|
+
isFetchedAfterMount: boolean;
|
|
183
|
+
isFetching: boolean;
|
|
184
|
+
isInitialLoading: boolean;
|
|
185
|
+
isPaused: boolean;
|
|
186
|
+
isRefetching: boolean;
|
|
187
|
+
isStale: boolean;
|
|
188
|
+
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<any, Error>>;
|
|
189
|
+
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
190
|
+
promise: Promise<any>;
|
|
191
|
+
} | {
|
|
192
|
+
updateData: (updateFn: any) => void;
|
|
193
|
+
data: any;
|
|
194
|
+
error: null;
|
|
195
|
+
isError: false;
|
|
196
|
+
isPending: false;
|
|
197
|
+
isLoading: false;
|
|
198
|
+
isLoadingError: false;
|
|
199
|
+
isRefetchError: false;
|
|
200
|
+
isSuccess: true;
|
|
201
|
+
isPlaceholderData: false;
|
|
202
|
+
status: "success";
|
|
203
|
+
dataUpdatedAt: number;
|
|
204
|
+
errorUpdatedAt: number;
|
|
205
|
+
failureCount: number;
|
|
206
|
+
failureReason: Error | null;
|
|
207
|
+
errorUpdateCount: number;
|
|
208
|
+
isFetched: boolean;
|
|
209
|
+
isFetchedAfterMount: boolean;
|
|
210
|
+
isFetching: boolean;
|
|
211
|
+
isInitialLoading: boolean;
|
|
212
|
+
isPaused: boolean;
|
|
213
|
+
isRefetching: boolean;
|
|
214
|
+
isStale: boolean;
|
|
215
|
+
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<any, Error>>;
|
|
216
|
+
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
217
|
+
promise: Promise<any>;
|
|
218
|
+
} | {
|
|
219
|
+
updateData: (updateFn: any) => void;
|
|
220
|
+
data: undefined;
|
|
221
|
+
error: Error;
|
|
222
|
+
isError: true;
|
|
223
|
+
isPending: false;
|
|
224
|
+
isLoading: false;
|
|
225
|
+
isLoadingError: true;
|
|
226
|
+
isRefetchError: false;
|
|
227
|
+
isSuccess: false;
|
|
228
|
+
isPlaceholderData: false;
|
|
229
|
+
status: "error";
|
|
230
|
+
dataUpdatedAt: number;
|
|
231
|
+
errorUpdatedAt: number;
|
|
232
|
+
failureCount: number;
|
|
233
|
+
failureReason: Error | null;
|
|
234
|
+
errorUpdateCount: number;
|
|
235
|
+
isFetched: boolean;
|
|
236
|
+
isFetchedAfterMount: boolean;
|
|
237
|
+
isFetching: boolean;
|
|
238
|
+
isInitialLoading: boolean;
|
|
239
|
+
isPaused: boolean;
|
|
240
|
+
isRefetching: boolean;
|
|
241
|
+
isStale: boolean;
|
|
242
|
+
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<any, Error>>;
|
|
243
|
+
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
244
|
+
promise: Promise<any>;
|
|
245
|
+
} | {
|
|
246
|
+
updateData: (updateFn: any) => void;
|
|
247
|
+
data: undefined;
|
|
248
|
+
error: null;
|
|
249
|
+
isError: false;
|
|
250
|
+
isPending: true;
|
|
251
|
+
isLoading: true;
|
|
252
|
+
isLoadingError: false;
|
|
253
|
+
isRefetchError: false;
|
|
254
|
+
isSuccess: false;
|
|
255
|
+
isPlaceholderData: false;
|
|
256
|
+
status: "pending";
|
|
257
|
+
dataUpdatedAt: number;
|
|
258
|
+
errorUpdatedAt: number;
|
|
259
|
+
failureCount: number;
|
|
260
|
+
failureReason: Error | null;
|
|
261
|
+
errorUpdateCount: number;
|
|
262
|
+
isFetched: boolean;
|
|
263
|
+
isFetchedAfterMount: boolean;
|
|
264
|
+
isFetching: boolean;
|
|
265
|
+
isInitialLoading: boolean;
|
|
266
|
+
isPaused: boolean;
|
|
267
|
+
isRefetching: boolean;
|
|
268
|
+
isStale: boolean;
|
|
269
|
+
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<any, Error>>;
|
|
270
|
+
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
271
|
+
promise: Promise<any>;
|
|
272
|
+
} | {
|
|
273
|
+
updateData: (updateFn: any) => void;
|
|
274
|
+
data: undefined;
|
|
275
|
+
error: null;
|
|
276
|
+
isError: false;
|
|
277
|
+
isPending: true;
|
|
278
|
+
isLoadingError: false;
|
|
279
|
+
isRefetchError: false;
|
|
280
|
+
isSuccess: false;
|
|
281
|
+
isPlaceholderData: false;
|
|
282
|
+
status: "pending";
|
|
283
|
+
dataUpdatedAt: number;
|
|
284
|
+
errorUpdatedAt: number;
|
|
285
|
+
failureCount: number;
|
|
286
|
+
failureReason: Error | null;
|
|
287
|
+
errorUpdateCount: number;
|
|
288
|
+
isFetched: boolean;
|
|
289
|
+
isFetchedAfterMount: boolean;
|
|
290
|
+
isFetching: boolean;
|
|
291
|
+
isLoading: boolean;
|
|
292
|
+
isInitialLoading: boolean;
|
|
293
|
+
isPaused: boolean;
|
|
294
|
+
isRefetching: boolean;
|
|
295
|
+
isStale: boolean;
|
|
296
|
+
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<any, Error>>;
|
|
297
|
+
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
298
|
+
promise: Promise<any>;
|
|
299
|
+
} | {
|
|
300
|
+
updateData: (updateFn: any) => void;
|
|
301
|
+
data: any;
|
|
302
|
+
isError: false;
|
|
303
|
+
error: null;
|
|
304
|
+
isPending: false;
|
|
305
|
+
isLoading: false;
|
|
306
|
+
isLoadingError: false;
|
|
307
|
+
isRefetchError: false;
|
|
308
|
+
isSuccess: true;
|
|
309
|
+
isPlaceholderData: true;
|
|
310
|
+
status: "success";
|
|
311
|
+
dataUpdatedAt: number;
|
|
312
|
+
errorUpdatedAt: number;
|
|
313
|
+
failureCount: number;
|
|
314
|
+
failureReason: Error | null;
|
|
315
|
+
errorUpdateCount: number;
|
|
316
|
+
isFetched: boolean;
|
|
317
|
+
isFetchedAfterMount: boolean;
|
|
318
|
+
isFetching: boolean;
|
|
319
|
+
isInitialLoading: boolean;
|
|
320
|
+
isPaused: boolean;
|
|
321
|
+
isRefetching: boolean;
|
|
322
|
+
isStale: boolean;
|
|
323
|
+
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<any, Error>>;
|
|
324
|
+
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
325
|
+
promise: Promise<any>;
|
|
326
|
+
};
|
|
327
|
+
export function useStaticQuery(key: any, staticData: any): import("@tanstack/react-query").DefinedUseQueryResult<any, Error>;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { useQuery, useQueryClient } from '@tanstack/react-query';
|
|
2
|
+
import useData from '.';
|
|
3
|
+
export const useApiQuery = (key, api, params = {}, returnFn, ui = true) => {
|
|
4
|
+
const { fetchData, fetchDataUIAsync } = useData();
|
|
5
|
+
const queryClient = useQueryClient();
|
|
6
|
+
return {
|
|
7
|
+
...useQuery({
|
|
8
|
+
queryKey: [key], // Přidáváme params do queryKey
|
|
9
|
+
queryFn: async () => {
|
|
10
|
+
const response = ui
|
|
11
|
+
? await fetchDataUIAsync(api, params)
|
|
12
|
+
: await fetchData(api, params);
|
|
13
|
+
if (returnFn) {
|
|
14
|
+
return returnFn(response.data);
|
|
15
|
+
}
|
|
16
|
+
return response.data;
|
|
17
|
+
},
|
|
18
|
+
}),
|
|
19
|
+
// Funkce pro manuální aktualizaci dat
|
|
20
|
+
updateData: (updateFn) => {
|
|
21
|
+
queryClient.setQueryData([key], (oldData) => {
|
|
22
|
+
// Aktualizace queryKey i zde
|
|
23
|
+
if (!oldData)
|
|
24
|
+
return oldData;
|
|
25
|
+
return updateFn(oldData);
|
|
26
|
+
});
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
export const useApiQuerySilence = (key, api, params = {}, returnFn) => useApiQuery(key, api, params, returnFn, false);
|
|
31
|
+
export const useStaticQuery = (key, staticData) => {
|
|
32
|
+
return useQuery({
|
|
33
|
+
queryKey: [key],
|
|
34
|
+
queryFn: () => Promise.resolve(staticData),
|
|
35
|
+
initialData: staticData,
|
|
36
|
+
staleTime: Infinity,
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
//# sourceMappingURL=reactQuery.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reactQuery.js","sourceRoot":"","sources":["../reactQuery.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,OAAO,MAAM,GAAG,CAAC;AAExB,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,MAAM,GAAG,EAAE,EAAE,QAAQ,EAAE,EAAE,GAAG,IAAI,EAAE,EAAE;IACxE,MAAM,EAAE,SAAS,EAAE,gBAAgB,EAAE,GAAG,OAAO,EAAE,CAAC;IAClD,MAAM,WAAW,GAAG,cAAc,EAAE,CAAC;IAErC,OAAO;QACL,GAAG,QAAQ,CAAC;YACV,QAAQ,EAAE,CAAC,GAAG,CAAC,EAAE,+BAA+B;YAChD,OAAO,EAAE,KAAK,IAAI,EAAE;gBAClB,MAAM,QAAQ,GAAG,EAAE;oBACjB,CAAC,CAAC,MAAM,gBAAgB,CAAC,GAAG,EAAE,MAAM,CAAC;oBACrC,CAAC,CAAC,MAAM,SAAS,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;gBAEjC,IAAI,QAAQ,EAAE,CAAC;oBACb,OAAO,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;gBACjC,CAAC;gBAED,OAAO,QAAQ,CAAC,IAAI,CAAC;YACvB,CAAC;SACF,CAAC;QACF,sCAAsC;QACtC,UAAU,EAAE,CAAC,QAAQ,EAAE,EAAE;YACvB,WAAW,CAAC,YAAY,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE;gBAC1C,6BAA6B;gBAC7B,IAAI,CAAC,OAAO;oBAAE,OAAO,OAAO,CAAC;gBAC7B,OAAO,QAAQ,CAAC,OAAO,CAAC,CAAC;YAC3B,CAAC,CAAC,CAAC;QACL,CAAC;KACF,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,MAAM,GAAG,EAAE,EAAE,QAAQ,EAAE,EAAE,CAClE,WAAW,CAAC,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC;AAEnD,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,GAAG,EAAE,UAAU,EAAE,EAAE;IAChD,OAAO,QAAQ,CAAC;QACd,QAAQ,EAAE,CAAC,GAAG,CAAC;QACf,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC;QAC1C,WAAW,EAAE,UAAU;QACvB,SAAS,EAAE,QAAQ;KACpB,CAAC,CAAC;AACL,CAAC,CAAC"}
|
package/index.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { useQuery, useQueryClient } from '@tanstack/react-query';
|
|
2
1
|
import { FetchData, errorNotification } from '@rhplus/wieldy.api';
|
|
3
2
|
import { useOidcAccessToken } from "@axa-fr/react-oidc";
|
|
4
3
|
|
|
@@ -57,53 +56,13 @@ export default function useData() {
|
|
|
57
56
|
tempLink.download = fileName;
|
|
58
57
|
tempLink.click();
|
|
59
58
|
}
|
|
60
|
-
|
|
61
|
-
const useStaticQuery = (key, staticData) => {
|
|
62
|
-
return useQuery({
|
|
63
|
-
queryKey: [key],
|
|
64
|
-
queryFn: () => Promise.resolve(staticData),
|
|
65
|
-
initialData: staticData,
|
|
66
|
-
staleTime: Infinity,
|
|
67
|
-
});
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
const useApiQuery = (key, api, params = {}, returnFn, ui = true) => {
|
|
71
|
-
const queryClient = useQueryClient();
|
|
72
|
-
|
|
73
|
-
return {
|
|
74
|
-
...useQuery({
|
|
75
|
-
queryKey: [key],
|
|
76
|
-
queryFn: async () => {
|
|
77
|
-
let response;
|
|
78
|
-
if (ui) response = await fetchDataUIAsync(api, params);
|
|
79
|
-
else response = await fetchData(api, params);
|
|
80
|
-
|
|
81
|
-
if (returnFn) {
|
|
82
|
-
return returnFn(response.data);
|
|
83
|
-
}
|
|
84
|
-
return response.data;
|
|
85
|
-
},
|
|
86
|
-
}),
|
|
87
|
-
// Funkce pro manuální aktualizaci dat
|
|
88
|
-
updateData: (updateFn) => {
|
|
89
|
-
queryClient.setQueryData([key], (oldData) => {
|
|
90
|
-
if (!oldData) return oldData;
|
|
91
|
-
return updateFn(oldData);
|
|
92
|
-
});
|
|
93
|
-
},
|
|
94
|
-
};
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
const useApiQuerySilence = (key, api, params = {}, returnFn) =>
|
|
98
|
-
useApiQuery(key, api, params, returnFn, false);
|
|
99
59
|
|
|
100
60
|
return {
|
|
101
61
|
fetchData,
|
|
102
62
|
fetchDataUIAsync,
|
|
103
63
|
getFileURL,
|
|
104
|
-
downloadFileURL
|
|
105
|
-
useApiQuerySilence,
|
|
106
|
-
useApiQuery,
|
|
107
|
-
useStaticQuery
|
|
64
|
+
downloadFileURL
|
|
108
65
|
}
|
|
109
|
-
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export {useApiQuery, useApiQuerySilence, useStaticQuery} from './reactQuery';
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bit.rhplus/data",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.9",
|
|
4
4
|
"homepage": "https://bit.cloud/remote-scope/data",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"componentId": {
|
|
7
7
|
"scope": "remote-scope",
|
|
8
8
|
"name": "data",
|
|
9
|
-
"version": "0.0.
|
|
9
|
+
"version": "0.0.9"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@tanstack/react-query": "^5.66.9",
|
package/reactQuery.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { useQuery, useQueryClient } from '@tanstack/react-query';
|
|
2
|
+
import useData from '.';
|
|
3
|
+
|
|
4
|
+
export const useApiQuery = (key, api, params = {}, returnFn, ui = true) => {
|
|
5
|
+
const { fetchData, fetchDataUIAsync } = useData();
|
|
6
|
+
const queryClient = useQueryClient();
|
|
7
|
+
|
|
8
|
+
return {
|
|
9
|
+
...useQuery({
|
|
10
|
+
queryKey: [key], // Přidáváme params do queryKey
|
|
11
|
+
queryFn: async () => {
|
|
12
|
+
const response = ui
|
|
13
|
+
? await fetchDataUIAsync(api, params)
|
|
14
|
+
: await fetchData(api, params);
|
|
15
|
+
|
|
16
|
+
if (returnFn) {
|
|
17
|
+
return returnFn(response.data);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return response.data;
|
|
21
|
+
},
|
|
22
|
+
}),
|
|
23
|
+
// Funkce pro manuální aktualizaci dat
|
|
24
|
+
updateData: (updateFn) => {
|
|
25
|
+
queryClient.setQueryData([key], (oldData) => {
|
|
26
|
+
// Aktualizace queryKey i zde
|
|
27
|
+
if (!oldData) return oldData;
|
|
28
|
+
return updateFn(oldData);
|
|
29
|
+
});
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export const useApiQuerySilence = (key, api, params = {}, returnFn) =>
|
|
35
|
+
useApiQuery(key, api, params, returnFn, false);
|
|
36
|
+
|
|
37
|
+
export const useStaticQuery = (key, staticData) => {
|
|
38
|
+
return useQuery({
|
|
39
|
+
queryKey: [key],
|
|
40
|
+
queryFn: () => Promise.resolve(staticData),
|
|
41
|
+
initialData: staticData,
|
|
42
|
+
staleTime: Infinity,
|
|
43
|
+
});
|
|
44
|
+
};
|
|
File without changes
|