@ventlio/tanstack-query 0.2.47 → 0.2.49

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.mjs CHANGED
@@ -117,7 +117,15 @@ const buildFormData = (body) => {
117
117
  const formData = new FormData();
118
118
  const bodyKeys = Object.keys(body);
119
119
  bodyKeys.forEach((key) => {
120
- formData.append(key, body[key]);
120
+ const inputValue = body[key];
121
+ if (inputValue instanceof Array) {
122
+ for (const value of inputValue) {
123
+ formData.append(key, value);
124
+ }
125
+ }
126
+ else {
127
+ formData.append(key, inputValue);
128
+ }
121
129
  });
122
130
  return formData;
123
131
  };
@@ -304,10 +312,9 @@ const useGetRequest = ({ path, load = false, queryOptions, keyTracker, baseUrl,
304
312
  }
305
313
  };
306
314
  const constructPaginationLink = (link, pageNumber) => {
307
- const oldParams = new URLSearchParams(link);
308
- const oldPage = Number(oldParams.get('page'));
309
- const [pathname, queryStrings] = link.split('?', 1);
310
- const queryParams = new URLSearchParams(queryStrings ?? '');
315
+ const [pathname, queryString] = link.split('?');
316
+ const queryParams = new URLSearchParams(queryString);
317
+ const oldPage = Number(queryParams.get('page'));
311
318
  queryParams.set('page', pageNumber);
312
319
  link = pathname + '?' + queryParams.toString();
313
320
  // only update page when pagination number changed
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,7 +1,7 @@
1
1
  import type { UseQueryOptions } from '@tanstack/react-query';
2
2
  import type { IRequestError, IRequestSuccess } from '../request';
3
3
  import type { DefaultRequestOptions } from './queries.interface';
4
- export declare const useDeleteRequest: <TResponse>(deleteOptions: DefaultRequestOptions | undefined) => {
4
+ export declare const useDeleteRequest: <TResponse>(deleteOptions?: DefaultRequestOptions) => {
5
5
  data: IRequestSuccess<TResponse>;
6
6
  error: any;
7
7
  isError: true;
@@ -71,10 +71,9 @@ const useGetRequest = ({ path, load = false, queryOptions, keyTracker, baseUrl,
71
71
  }
72
72
  };
73
73
  const constructPaginationLink = (link, pageNumber) => {
74
- const oldParams = new URLSearchParams(link);
75
- const oldPage = Number(oldParams.get('page'));
76
- const [pathname, queryStrings] = link.split('?', 1);
77
- const queryParams = new URLSearchParams(queryStrings ?? '');
74
+ const [pathname, queryString] = link.split('?');
75
+ const queryParams = new URLSearchParams(queryString);
76
+ const oldPage = Number(queryParams.get('page'));
78
77
  queryParams.set('page', pageNumber);
79
78
  link = pathname + '?' + queryParams.toString();
80
79
  // only update page when pagination number changed
@@ -1 +1 @@
1
- {"version":3,"file":"useGetRequest.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"useGetRequest.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -4,7 +4,15 @@ const buildFormData = (body) => {
4
4
  const formData = new FormData();
5
5
  const bodyKeys = Object.keys(body);
6
6
  bodyKeys.forEach((key) => {
7
- formData.append(key, body[key]);
7
+ const inputValue = body[key];
8
+ if (inputValue instanceof Array) {
9
+ for (const value of inputValue) {
10
+ formData.append(key, value);
11
+ }
12
+ }
13
+ else {
14
+ formData.append(key, inputValue);
15
+ }
8
16
  });
9
17
  return formData;
10
18
  };
@@ -1 +1 @@
1
- {"version":3,"file":"buildFormData.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;"}
1
+ {"version":3,"file":"buildFormData.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ventlio/tanstack-query",
3
- "version": "0.2.47",
3
+ "version": "0.2.49",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "contributors": [
@@ -8,7 +8,7 @@ import { HttpMethod, makeRequest } from '../request';
8
8
  import type { DefaultRequestOptions } from './queries.interface';
9
9
 
10
10
  export const useDeleteRequest = <TResponse>(
11
- deleteOptions: DefaultRequestOptions | undefined
11
+ deleteOptions?: DefaultRequestOptions
12
12
  ) => {
13
13
  const { baseUrl, headers } = deleteOptions ?? {};
14
14
  const [requestPath, updateDeletePath] = useState<string>('');
@@ -119,11 +119,10 @@ export const useGetRequest = <TResponse extends Record<string, any>>({
119
119
  };
120
120
 
121
121
  const constructPaginationLink = (link: string, pageNumber: number) => {
122
- const oldParams = new URLSearchParams(link);
123
- const oldPage = Number(oldParams.get('page'));
122
+ const [pathname, queryString] = link.split('?');
123
+ const queryParams = new URLSearchParams(queryString);
124
124
 
125
- const [pathname, queryStrings] = link.split('?', 1);
126
- const queryParams = new URLSearchParams(queryStrings ?? '');
125
+ const oldPage = Number(queryParams.get('page'));
127
126
 
128
127
  queryParams.set('page', pageNumber as any);
129
128
 
@@ -4,7 +4,14 @@ export const buildFormData = (body: Record<string, any>) => {
4
4
  const bodyKeys = Object.keys(body);
5
5
 
6
6
  bodyKeys.forEach((key) => {
7
- formData.append(key, body[key]);
7
+ const inputValue = body[key];
8
+ if (inputValue instanceof Array) {
9
+ for (const value of inputValue) {
10
+ formData.append(key, value);
11
+ }
12
+ } else {
13
+ formData.append(key, inputValue);
14
+ }
8
15
  });
9
16
 
10
17
  return formData;