@greatapps/common 1.1.87 → 1.1.90
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/hooks/useDebounceState.ts"],"sourcesContent":["'use client';\n\nimport { useState } from 'react';\nimport { useDebounce } from './useDebounce';\n\nexport function useDebounceState<T>(initialValue: T, delay: number = 400): [T,
|
|
1
|
+
{"version":3,"sources":["../../src/hooks/useDebounceState.ts"],"sourcesContent":["'use client';\n\nimport { useState } from 'react';\nimport type React from 'react';\nimport { useDebounce } from './useDebounce';\n\nexport function useDebounceState<T>(initialValue: T, delay: number = 400): [T, React.Dispatch<React.SetStateAction<T>>] {\n const [rawValue, setRawValue] = useState<T>(initialValue);\n const debouncedValue = useDebounce(rawValue, delay);\n return [debouncedValue, setRawValue];\n}\n"],"mappings":";AAEA,SAAS,gBAAgB;AAEzB,SAAS,mBAAmB;AAErB,SAAS,iBAAoB,cAAiB,QAAgB,KAAmD;AACtH,QAAM,CAAC,UAAU,WAAW,IAAI,SAAY,YAAY;AACxD,QAAM,iBAAiB,YAAY,UAAU,KAAK;AAClD,SAAO,CAAC,gBAAgB,WAAW;AACrC;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import { useState } from 'react';
|
|
4
|
+
import type React from 'react';
|
|
4
5
|
import { useDebounce } from './useDebounce';
|
|
5
6
|
|
|
6
|
-
export function useDebounceState<T>(initialValue: T, delay: number = 400): [T,
|
|
7
|
+
export function useDebounceState<T>(initialValue: T, delay: number = 400): [T, React.Dispatch<React.SetStateAction<T>>] {
|
|
7
8
|
const [rawValue, setRawValue] = useState<T>(initialValue);
|
|
8
9
|
const debouncedValue = useDebounce(rawValue, delay);
|
|
9
10
|
return [debouncedValue, setRawValue];
|
package/src/infra/api/client.ts
CHANGED
|
@@ -25,16 +25,19 @@ class ApiClient {
|
|
|
25
25
|
return url;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
private async getDefaultHeaders(token: string): Promise<HeadersInit> {
|
|
28
|
+
private async getDefaultHeaders(token: string, isFormData = false): Promise<HeadersInit> {
|
|
29
29
|
console.log('[ApiClient] getDefaultHeaders', {
|
|
30
30
|
token: token.substring(0, 20) + '...',
|
|
31
31
|
});
|
|
32
32
|
|
|
33
33
|
const headers: HeadersInit = {
|
|
34
|
-
'Content-Type': 'application/json',
|
|
35
34
|
authorization: token,
|
|
36
35
|
};
|
|
37
36
|
|
|
37
|
+
if (!isFormData) {
|
|
38
|
+
headers['Content-Type'] = 'application/json';
|
|
39
|
+
}
|
|
40
|
+
|
|
38
41
|
return headers;
|
|
39
42
|
}
|
|
40
43
|
|
|
@@ -53,7 +56,7 @@ class ApiClient {
|
|
|
53
56
|
|
|
54
57
|
const [url, defaultHeaders] = await Promise.all([
|
|
55
58
|
this.buildUrl(endpoint, id),
|
|
56
|
-
this.getDefaultHeaders(token),
|
|
59
|
+
this.getDefaultHeaders(token, fetchConfig.body instanceof FormData),
|
|
57
60
|
]);
|
|
58
61
|
|
|
59
62
|
console.log('[ApiClient] Fetching', {
|
|
@@ -118,6 +121,10 @@ class ApiClient {
|
|
|
118
121
|
});
|
|
119
122
|
}
|
|
120
123
|
|
|
124
|
+
async postFormData<T>(endpoint: string, data: FormData, config?: RequestConfig): Promise<T> {
|
|
125
|
+
return this.request<T>(endpoint, { ...config, method: 'POST', body: data });
|
|
126
|
+
}
|
|
127
|
+
|
|
121
128
|
async put<T>(endpoint: string, data?: unknown, config?: RequestConfig): Promise<T> {
|
|
122
129
|
return this.request<T>(endpoint, {
|
|
123
130
|
...config,
|