@omniumretail/shared-resources 0.0.24 → 0.0.25
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/.eslintrc.json +31 -31
- package/README.md +44 -44
- package/dist/bundle.js +259 -193
- package/dist/types/components/BottomDrawer/index.d.ts +9 -9
- package/dist/types/components/Button/index.d.ts +2 -2
- package/dist/types/components/Footer/index.d.ts +3 -3
- package/dist/types/components/Form/FormInputField/index.d.ts +8 -8
- package/dist/types/components/Form/FormSelectField/index.d.ts +9 -9
- package/dist/types/components/Form/index.d.ts +2 -2
- package/dist/types/components/Header/index.d.ts +4 -4
- package/dist/types/components/Link/index.d.ts +6 -6
- package/dist/types/components/Navigation/index.d.ts +8 -8
- package/dist/types/components/Page/index.d.ts +13 -13
- package/dist/types/components/SharedContextProvider/index.d.ts +7 -7
- package/dist/types/components/index.d.ts +9 -9
- package/dist/types/constants/Icons.d.ts +15 -14
- package/dist/types/constants/QueryClient.d.ts +2 -2
- package/dist/types/constants/index.d.ts +2 -2
- package/dist/types/contexts/useStore.d.ts +8 -8
- package/dist/types/hooks/activateEvaluationCycleQuery.hook.d.ts +2 -2
- package/dist/types/hooks/activateQuestionnaireQuery.hook.d.ts +2 -2
- package/dist/types/hooks/cancelEvaluationCycleQuery.hook.d.ts +2 -2
- package/dist/types/hooks/cancelQuestionnaireQuery.hook.d.ts +2 -2
- package/dist/types/hooks/deleteEvaluationCycleQuery.hook.d.ts +2 -2
- package/dist/types/hooks/deleteQuestionnaireQuery.hook.d.ts +2 -2
- package/dist/types/hooks/duplicateQuestionnaireQuery.hook.d.ts +2 -2
- package/dist/types/hooks/finishEvaluationCycleQuery.hook.d.ts +2 -2
- package/dist/types/hooks/finishQuestionnaireQuery.hook.d.ts +2 -2
- package/dist/types/hooks/index.d.ts +42 -39
- package/dist/types/hooks/useAllRolesQuery.hook.d.ts +11 -11
- package/dist/types/hooks/useAllStoreQuery.hook.d.ts +13 -11
- package/dist/types/hooks/useAnalyticsEvaluationCyclesQuery.hook.d.ts +7 -7
- package/dist/types/hooks/useAnalyticsQuestionsQuery.hook.d.ts +9 -9
- package/dist/types/hooks/useAnalyticsSideBarQuery.hook.d.ts +7 -7
- package/dist/types/hooks/useAnalyticsUserIdQuery.hook.d.ts +9 -9
- package/dist/types/hooks/useAnalyticsUserQuery.hook.d.ts +9 -9
- package/dist/types/hooks/useAnswerIdQuery.hook.d.ts +2 -2
- package/dist/types/hooks/useAnswerMutateQuery.hook.d.ts +9 -9
- package/dist/types/hooks/useAnswersUserSupervisorQuery.hook.d.ts +7 -7
- package/dist/types/hooks/useApplicationDataQuery.hook.d.ts +2 -2
- package/dist/types/hooks/useContractStatesQuery.hook.d.ts +7 -7
- package/dist/types/hooks/useCountriesQuery.hook.d.ts +7 -7
- package/dist/types/hooks/useCustomersQuery.hook.d.ts +138 -138
- package/dist/types/hooks/useEvaluationCycleIdQuery.hook.d.ts +2 -2
- package/dist/types/hooks/useEvaluationCycleMutateQuery.hook.d.ts +2 -2
- package/dist/types/hooks/useEvaluationCycleQuery.hook.d.ts +8 -8
- package/dist/types/hooks/useJobTitlesQuery.hook.d.ts +7 -7
- package/dist/types/hooks/useProductHierarchies.hook.d.ts +7 -7
- package/dist/types/hooks/useProductsQuery.hook.d.ts +138 -138
- package/dist/types/hooks/useQuestionnaireIdQuery.hook.d.ts +2 -2
- package/dist/types/hooks/useQuestionnaireMutateQuery.hook.d.ts +2 -2
- package/dist/types/hooks/useQuestionnaireQuery.hook.d.ts +9 -9
- package/dist/types/hooks/useSingleUserIdMutateQuery.hook.d.ts +2 -2
- package/dist/types/hooks/useSingleUserIdQuery.hook.d.ts +2 -2
- package/dist/types/hooks/useSingleUserResetPassword.hook.d.ts +2 -0
- package/dist/types/hooks/useStoreQuery.d.ts +7 -7
- package/dist/types/hooks/useTermNotificationQuery.hook.d.ts +2 -2
- package/dist/types/hooks/useUserBlockQuery.hook.d.ts +2 -2
- package/dist/types/hooks/useUserEmailVerifQuery.hook.d.ts +2 -2
- package/dist/types/hooks/useUserIdQuery.hook.d.ts +2 -2
- package/dist/types/hooks/useUserListQuery.hook.d.ts +8 -8
- package/dist/types/hooks/useUserQuery.hook.d.ts +10 -10
- package/dist/types/index.d.ts +7 -7
- package/dist/types/interfaces/AnalyticsEvaluationCycle.d.ts +19 -19
- package/dist/types/interfaces/AnalyticsUserId.d.ts +11 -11
- package/dist/types/interfaces/Answer.d.ts +12 -12
- package/dist/types/interfaces/AnswersUserSupervisor.d.ts +42 -42
- package/dist/types/interfaces/ApplicationsByCategory.d.ts +16 -16
- package/dist/types/interfaces/Brand.d.ts +4 -4
- package/dist/types/interfaces/Cart.d.ts +10 -9
- package/dist/types/interfaces/Configuration.d.ts +6 -6
- package/dist/types/interfaces/ContractStates.d.ts +7 -7
- package/dist/types/interfaces/Countries.d.ts +10 -10
- package/dist/types/interfaces/Customer.d.ts +21 -21
- package/dist/types/interfaces/EvaluationCycle.d.ts +32 -32
- package/dist/types/interfaces/JobTitles.d.ts +7 -7
- package/dist/types/interfaces/Product.d.ts +15 -16
- package/dist/types/interfaces/ProductsHierarchies.d.ts +5 -5
- package/dist/types/interfaces/Questionnaire.d.ts +36 -36
- package/dist/types/interfaces/ResponseList.d.ts +5 -5
- package/dist/types/interfaces/Roles.d.ts +5 -5
- package/dist/types/interfaces/Store.d.ts +7 -7
- package/dist/types/interfaces/TermNotification.d.ts +5 -5
- package/dist/types/interfaces/User.d.ts +65 -65
- package/dist/types/interfaces/index.d.ts +21 -19
- package/dist/types/services/ApiService/index.d.ts +9 -9
- package/dist/types/services/InitService/index.d.ts +3 -3
- package/dist/types/services/index.d.ts +2 -2
- package/package.json +54 -54
- package/src/assets/sitoo.svg +9 -9
- package/src/components/BottomDrawer/index.tsx +32 -32
- package/src/components/BottomDrawer/styles.module.scss +59 -59
- package/src/components/Button/index.tsx +7 -7
- package/src/components/Footer/index.tsx +44 -44
- package/src/components/Footer/styles.module.scss +33 -33
- package/src/components/Form/FormInputField/index.tsx +18 -18
- package/src/components/Form/FormSelectField/index.tsx +16 -16
- package/src/components/Form/index.ts +2 -2
- package/src/components/Header/index.tsx +20 -20
- package/src/components/Header/styles.module.scss +16 -16
- package/src/components/Link/index.tsx +21 -21
- package/src/components/Link/styles.module.scss +24 -24
- package/src/components/Navigation/index.tsx +30 -30
- package/src/components/Navigation/styles.module.scss +34 -34
- package/src/components/Page/index.tsx +35 -35
- package/src/components/Page/styles.module.scss +26 -26
- package/src/components/SharedContextProvider/index.tsx +30 -30
- package/src/components/index.ts +9 -9
- package/src/constants/Icons.ts +23 -20
- package/src/constants/QueryClient.ts +10 -10
- package/src/constants/index.ts +2 -2
- package/src/contexts/useStore.tsx +20 -20
- package/src/global.scss +124 -124
- package/src/hooks/activateEvaluationCycleQuery.hook.ts +15 -15
- package/src/hooks/activateQuestionnaireQuery.hook.ts +15 -15
- package/src/hooks/cancelEvaluationCycleQuery.hook.ts +15 -15
- package/src/hooks/cancelQuestionnaireQuery.hook.ts +15 -15
- package/src/hooks/deleteEvaluationCycleQuery.hook.ts +15 -15
- package/src/hooks/deleteQuestionnaireQuery.hook.ts +15 -15
- package/src/hooks/duplicateQuestionnaireQuery.hook.ts +14 -14
- package/src/hooks/finishEvaluationCycleQuery.hook.ts +15 -15
- package/src/hooks/finishQuestionnaireQuery.hook.ts +15 -15
- package/src/hooks/index.ts +42 -41
- package/src/hooks/useAllRolesQuery.hook.ts +21 -21
- package/src/hooks/useAllStoreQuery.hook.ts +39 -27
- package/src/hooks/useAnalyticsEvaluationCyclesQuery.hook.ts +21 -21
- package/src/hooks/useAnalyticsQuestionsQuery.hook.ts +22 -22
- package/src/hooks/useAnalyticsSideBarQuery.hook.ts +21 -21
- package/src/hooks/useAnalyticsUserIdQuery.hook.ts +24 -24
- package/src/hooks/useAnalyticsUserQuery.hook.ts +27 -27
- package/src/hooks/useAnswerIdQuery.hook.ts +13 -13
- package/src/hooks/useAnswerMutateQuery.hook.ts +31 -31
- package/src/hooks/useAnswersUserSupervisorQuery.hook.tsx +21 -21
- package/src/hooks/useApplicationDataQuery.hook.ts +10 -10
- package/src/hooks/useContractStatesQuery.hook.ts +14 -14
- package/src/hooks/useCountriesQuery.hook.ts +14 -14
- package/src/hooks/useCustomersQuery.hook.ts +30 -30
- package/src/hooks/useEvaluationCycleIdQuery.hook.ts +13 -13
- package/src/hooks/useEvaluationCycleMutateQuery.hook.ts +17 -17
- package/src/hooks/useEvaluationCycleQuery.hook.ts +25 -25
- package/src/hooks/useJobTitlesQuery.hook.ts +14 -14
- package/src/hooks/useProductHierarchies.hook.ts +12 -12
- package/src/hooks/useProductsQuery.hook.ts +30 -30
- package/src/hooks/useQuestionnaireIdQuery.hook.ts +13 -13
- package/src/hooks/useQuestionnaireMutateQuery.hook.ts +17 -17
- package/src/hooks/useQuestionnaireQuery.hook.ts +27 -27
- package/src/hooks/useSingleUserIdMutateQuery.hook.ts +18 -18
- package/src/hooks/useSingleUserIdQuery.hook.ts +14 -14
- package/src/hooks/useSingleUserResetPassword.hook.ts +15 -0
- package/src/hooks/useStoreQuery.ts +13 -13
- package/src/hooks/useTermNotificationQuery.hook.ts +11 -11
- package/src/hooks/useUserBlockQuery.hook.ts +15 -15
- package/src/hooks/useUserEmailVerifQuery.hook.ts +15 -15
- package/src/hooks/useUserIdQuery.hook.ts +14 -14
- package/src/hooks/useUserListQuery.hook.ts +25 -25
- package/src/hooks/useUserQuery.hook.ts +29 -29
- package/src/index.ts +9 -9
- package/src/interfaces/AnalyticsEvaluationCycle.ts +24 -24
- package/src/interfaces/AnalyticsUserId.ts +12 -12
- package/src/interfaces/Answer.ts +13 -13
- package/src/interfaces/AnswersUserSupervisor.ts +45 -45
- package/src/interfaces/ApplicationsByCategory.ts +19 -19
- package/src/interfaces/Brand.ts +4 -4
- package/src/interfaces/Cart.ts +13 -12
- package/src/interfaces/Configuration.ts +7 -7
- package/src/interfaces/ContractStates.ts +7 -7
- package/src/interfaces/Countries.ts +10 -10
- package/src/interfaces/Customer.ts +23 -23
- package/src/interfaces/EvaluationCycle.ts +32 -32
- package/src/interfaces/JobTitles.ts +7 -7
- package/src/interfaces/Product.ts +17 -18
- package/src/interfaces/ProductsHierarchies.ts +6 -6
- package/src/interfaces/Questionnaire.ts +38 -38
- package/src/interfaces/ResponseList.ts +6 -6
- package/src/interfaces/Roles.ts +5 -5
- package/src/interfaces/Store.ts +8 -8
- package/src/interfaces/TermNotification.ts +5 -5
- package/src/interfaces/User.ts +69 -69
- package/src/interfaces/index.ts +21 -21
- package/src/services/ApiService/index.ts +125 -125
- package/src/services/InitService/index.ts +7 -7
- package/src/services/index.ts +3 -3
- package/src/types/Global.d.ts +4 -4
- package/tsconfig.json +27 -27
- package/webpack.config.js +48 -48
|
@@ -1,125 +1,125 @@
|
|
|
1
|
-
import 'whatwg-fetch';
|
|
2
|
-
import { appConfig } from "../InitService";
|
|
3
|
-
|
|
4
|
-
export const get = <T>(path: string, params?: Record<string, unknown>): Promise<T> => {
|
|
5
|
-
return buildApiRequest<T>(`${path}?${buildParams(params || {})}`, 'GET');
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export const getAuth0 = <T>(path: string, params?: Record<string, unknown>): Promise<T> => {
|
|
9
|
-
return buildApiRequestForAuth0<T>(`${path}?${buildParams(params || {})}`, 'GET');
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export const putAuth0 = <T>(path: string, params?: Record<string, unknown>, body?: unknown, bodyType?: string): Promise<T> => {
|
|
13
|
-
return buildApiRequestForAuth0<T>(`${path}${buildParams(params || {})}`, 'PUT', body, bodyType);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export const postAuth0 = <T>(path: string, params?: Record<string, unknown>, body?: unknown,bodyType?: string): Promise<T> => {
|
|
17
|
-
return buildApiRequestForAuth0<T>(`${path}${buildParams(params || {})}`, 'POST', body, bodyType);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export const toDeleteAuth0 = <T>(path: string, params?: Record<string, unknown>, body?: unknown): Promise<T> => {
|
|
21
|
-
return buildApiRequestForAuth0<T>(`${path}${buildParams(params || {})}`, 'DELETE', body);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export const post = <T>(path: string, body?: unknown): Promise<T> => {
|
|
25
|
-
return buildApiRequest<T>(path, 'POST', body);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export const put = <T>(path: string, body?: unknown): Promise<T> => {
|
|
29
|
-
return buildApiRequest<T>(path, 'PUT', body);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export const toDelete = <T>(path: string, body?: unknown): Promise<T> => {
|
|
33
|
-
return buildApiRequest<T>(path, 'DELETE', body);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
const buildParams = (params: Record<string, unknown>): string => {
|
|
38
|
-
return Object.entries(params).reduce((c, [key, value]) => [...c, `${key}=${value}`], [] as string[]).join('&');
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Build the api request
|
|
43
|
-
* @param path
|
|
44
|
-
* @param method
|
|
45
|
-
* @param data
|
|
46
|
-
* @param bodyType
|
|
47
|
-
* @returns
|
|
48
|
-
*/
|
|
49
|
-
const buildApiRequest = <T>(path: string, method = 'GET', data?: unknown, bodyType?: string): Promise<T> => {
|
|
50
|
-
const requestUri = buildPath(path);
|
|
51
|
-
|
|
52
|
-
const headers: HeadersInit = {
|
|
53
|
-
Authorization: appConfig.token,
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
let body: FormData | string | undefined | any;
|
|
57
|
-
|
|
58
|
-
if (['POST', 'PUT'].includes(method)) {
|
|
59
|
-
if (bodyType === 'formdata') {
|
|
60
|
-
// Não é necessário dar set do contentType porque o fetch faz isso por nós quando usamos o fetch
|
|
61
|
-
body = data;
|
|
62
|
-
} else {
|
|
63
|
-
headers['Content-Type'] = 'application/json';
|
|
64
|
-
body = JSON.stringify(data);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
return fetch(requestUri, {
|
|
69
|
-
method,
|
|
70
|
-
headers,
|
|
71
|
-
body,
|
|
72
|
-
}).then((response) => {
|
|
73
|
-
if (response.status >= 200 && response.status <= 300) {
|
|
74
|
-
return response.json();
|
|
75
|
-
}
|
|
76
|
-
return response.json().then((data) => Promise.reject(data));
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* Build the api request with auth
|
|
82
|
-
* @param path
|
|
83
|
-
* @param method
|
|
84
|
-
* @param data
|
|
85
|
-
* @returns
|
|
86
|
-
*/
|
|
87
|
-
const buildApiRequestForAuth0 = <T>(path: string, method = 'GET', data?: unknown, bodyType?: string): Promise<T> => {
|
|
88
|
-
const requestUri = buildPath(path);
|
|
89
|
-
|
|
90
|
-
const headers: HeadersInit = {
|
|
91
|
-
Authorization: `Bearer ${appConfig.tokenAuth0}`,
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
let body: FormData | string | undefined | any;
|
|
95
|
-
|
|
96
|
-
if (['POST', 'PUT'].includes(method)) {
|
|
97
|
-
if (bodyType === 'formdata') {
|
|
98
|
-
// Não é necessário dar set do contentType porque o fetch faz isso por nós quando usamos o fetch
|
|
99
|
-
body = data;
|
|
100
|
-
} else {
|
|
101
|
-
headers['Content-Type'] = 'application/json';
|
|
102
|
-
body = JSON.stringify(data);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
return fetch(requestUri, {
|
|
107
|
-
method,
|
|
108
|
-
headers,
|
|
109
|
-
body,
|
|
110
|
-
}).then((response) => {
|
|
111
|
-
if (response.status >= 200 && response.status <= 300) {
|
|
112
|
-
return response.json();
|
|
113
|
-
}
|
|
114
|
-
return response.json().then((data) => Promise.reject(data));
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* Builds the path to access the api
|
|
120
|
-
* @param path
|
|
121
|
-
* @returns
|
|
122
|
-
*/
|
|
123
|
-
const buildPath = (path: string): string => {
|
|
124
|
-
return `${appConfig.ApiHost}${appConfig.ApiPath}${path}`;
|
|
125
|
-
};
|
|
1
|
+
import 'whatwg-fetch';
|
|
2
|
+
import { appConfig } from "../InitService";
|
|
3
|
+
|
|
4
|
+
export const get = <T>(path: string, params?: Record<string, unknown>): Promise<T> => {
|
|
5
|
+
return buildApiRequest<T>(`${path}?${buildParams(params || {})}`, 'GET');
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export const getAuth0 = <T>(path: string, params?: Record<string, unknown>): Promise<T> => {
|
|
9
|
+
return buildApiRequestForAuth0<T>(`${path}?${buildParams(params || {})}`, 'GET');
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const putAuth0 = <T>(path: string, params?: Record<string, unknown>, body?: unknown, bodyType?: string): Promise<T> => {
|
|
13
|
+
return buildApiRequestForAuth0<T>(`${path}${buildParams(params || {})}`, 'PUT', body, bodyType);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const postAuth0 = <T>(path: string, params?: Record<string, unknown>, body?: unknown,bodyType?: string): Promise<T> => {
|
|
17
|
+
return buildApiRequestForAuth0<T>(`${path}${buildParams(params || {})}`, 'POST', body, bodyType);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export const toDeleteAuth0 = <T>(path: string, params?: Record<string, unknown>, body?: unknown): Promise<T> => {
|
|
21
|
+
return buildApiRequestForAuth0<T>(`${path}${buildParams(params || {})}`, 'DELETE', body);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export const post = <T>(path: string, body?: unknown): Promise<T> => {
|
|
25
|
+
return buildApiRequest<T>(path, 'POST', body);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export const put = <T>(path: string, body?: unknown): Promise<T> => {
|
|
29
|
+
return buildApiRequest<T>(path, 'PUT', body);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export const toDelete = <T>(path: string, body?: unknown): Promise<T> => {
|
|
33
|
+
return buildApiRequest<T>(path, 'DELETE', body);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
const buildParams = (params: Record<string, unknown>): string => {
|
|
38
|
+
return Object.entries(params).reduce((c, [key, value]) => [...c, `${key}=${value}`], [] as string[]).join('&');
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Build the api request
|
|
43
|
+
* @param path
|
|
44
|
+
* @param method
|
|
45
|
+
* @param data
|
|
46
|
+
* @param bodyType
|
|
47
|
+
* @returns
|
|
48
|
+
*/
|
|
49
|
+
const buildApiRequest = <T>(path: string, method = 'GET', data?: unknown, bodyType?: string): Promise<T> => {
|
|
50
|
+
const requestUri = buildPath(path);
|
|
51
|
+
|
|
52
|
+
const headers: HeadersInit = {
|
|
53
|
+
Authorization: appConfig.token,
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
let body: FormData | string | undefined | any;
|
|
57
|
+
|
|
58
|
+
if (['POST', 'PUT'].includes(method)) {
|
|
59
|
+
if (bodyType === 'formdata') {
|
|
60
|
+
// Não é necessário dar set do contentType porque o fetch faz isso por nós quando usamos o fetch
|
|
61
|
+
body = data;
|
|
62
|
+
} else {
|
|
63
|
+
headers['Content-Type'] = 'application/json';
|
|
64
|
+
body = JSON.stringify(data);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return fetch(requestUri, {
|
|
69
|
+
method,
|
|
70
|
+
headers,
|
|
71
|
+
body,
|
|
72
|
+
}).then((response) => {
|
|
73
|
+
if (response.status >= 200 && response.status <= 300) {
|
|
74
|
+
return response.json();
|
|
75
|
+
}
|
|
76
|
+
return response.json().then((data) => Promise.reject(data));
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Build the api request with auth
|
|
82
|
+
* @param path
|
|
83
|
+
* @param method
|
|
84
|
+
* @param data
|
|
85
|
+
* @returns
|
|
86
|
+
*/
|
|
87
|
+
const buildApiRequestForAuth0 = <T>(path: string, method = 'GET', data?: unknown, bodyType?: string): Promise<T> => {
|
|
88
|
+
const requestUri = buildPath(path);
|
|
89
|
+
|
|
90
|
+
const headers: HeadersInit = {
|
|
91
|
+
Authorization: `Bearer ${appConfig.tokenAuth0}`,
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
let body: FormData | string | undefined | any;
|
|
95
|
+
|
|
96
|
+
if (['POST', 'PUT'].includes(method)) {
|
|
97
|
+
if (bodyType === 'formdata') {
|
|
98
|
+
// Não é necessário dar set do contentType porque o fetch faz isso por nós quando usamos o fetch
|
|
99
|
+
body = data;
|
|
100
|
+
} else {
|
|
101
|
+
headers['Content-Type'] = 'application/json';
|
|
102
|
+
body = JSON.stringify(data);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
return fetch(requestUri, {
|
|
107
|
+
method,
|
|
108
|
+
headers,
|
|
109
|
+
body,
|
|
110
|
+
}).then((response) => {
|
|
111
|
+
if (response.status >= 200 && response.status <= 300) {
|
|
112
|
+
return response.json();
|
|
113
|
+
}
|
|
114
|
+
return response.json().then((data) => Promise.reject(data));
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Builds the path to access the api
|
|
120
|
+
* @param path
|
|
121
|
+
* @returns
|
|
122
|
+
*/
|
|
123
|
+
const buildPath = (path: string): string => {
|
|
124
|
+
return `${appConfig.ApiHost}${appConfig.ApiPath}${path}`;
|
|
125
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Configuration } from "../../interfaces/Configuration";
|
|
2
|
-
|
|
3
|
-
export const appConfig: Partial<Configuration> = {};
|
|
4
|
-
|
|
5
|
-
export const initService = (configuration: Configuration) => {
|
|
6
|
-
Object.assign(appConfig, configuration);
|
|
7
|
-
}
|
|
1
|
+
import { Configuration } from "../../interfaces/Configuration";
|
|
2
|
+
|
|
3
|
+
export const appConfig: Partial<Configuration> = {};
|
|
4
|
+
|
|
5
|
+
export const initService = (configuration: Configuration) => {
|
|
6
|
+
Object.assign(appConfig, configuration);
|
|
7
|
+
}
|
package/src/services/index.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
export * from './InitService';
|
|
3
|
-
export * from './ApiService';
|
|
1
|
+
|
|
2
|
+
export * from './InitService';
|
|
3
|
+
export * from './ApiService';
|
package/src/types/Global.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
declare module "*.module.css";
|
|
2
|
-
declare module "*.module.scss";
|
|
3
|
-
declare module "*.png";
|
|
4
|
-
declare module "*.svg";
|
|
1
|
+
declare module "*.module.css";
|
|
2
|
+
declare module "*.module.scss";
|
|
3
|
+
declare module "*.png";
|
|
4
|
+
declare module "*.svg";
|
package/tsconfig.json
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "es5",
|
|
4
|
-
"outDir": "./dist",
|
|
5
|
-
"lib": ["dom", "dom.iterable", "esnext"],
|
|
6
|
-
"allowJs": true,
|
|
7
|
-
"skipLibCheck": true,
|
|
8
|
-
"esModuleInterop": true,
|
|
9
|
-
"allowSyntheticDefaultImports": true,
|
|
10
|
-
"strict": false,
|
|
11
|
-
"strictNullChecks": false,
|
|
12
|
-
"forceConsistentCasingInFileNames": true,
|
|
13
|
-
"noFallthroughCasesInSwitch": true,
|
|
14
|
-
"module": "esnext",
|
|
15
|
-
"moduleResolution": "node",
|
|
16
|
-
"declaration": true,
|
|
17
|
-
"declarationDir": "./dist/types",
|
|
18
|
-
"resolveJsonModule": true,
|
|
19
|
-
"isolatedModules": true,
|
|
20
|
-
"noEmit": false,
|
|
21
|
-
"sourceMap": true,
|
|
22
|
-
"jsx": "react-jsx",
|
|
23
|
-
"experimentalDecorators": true,
|
|
24
|
-
"downlevelIteration": true,
|
|
25
|
-
},
|
|
26
|
-
"include": ["src"]
|
|
27
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "es5",
|
|
4
|
+
"outDir": "./dist",
|
|
5
|
+
"lib": ["dom", "dom.iterable", "esnext"],
|
|
6
|
+
"allowJs": true,
|
|
7
|
+
"skipLibCheck": true,
|
|
8
|
+
"esModuleInterop": true,
|
|
9
|
+
"allowSyntheticDefaultImports": true,
|
|
10
|
+
"strict": false,
|
|
11
|
+
"strictNullChecks": false,
|
|
12
|
+
"forceConsistentCasingInFileNames": true,
|
|
13
|
+
"noFallthroughCasesInSwitch": true,
|
|
14
|
+
"module": "esnext",
|
|
15
|
+
"moduleResolution": "node",
|
|
16
|
+
"declaration": true,
|
|
17
|
+
"declarationDir": "./dist/types",
|
|
18
|
+
"resolveJsonModule": true,
|
|
19
|
+
"isolatedModules": true,
|
|
20
|
+
"noEmit": false,
|
|
21
|
+
"sourceMap": true,
|
|
22
|
+
"jsx": "react-jsx",
|
|
23
|
+
"experimentalDecorators": true,
|
|
24
|
+
"downlevelIteration": true,
|
|
25
|
+
},
|
|
26
|
+
"include": ["src"]
|
|
27
|
+
}
|
package/webpack.config.js
CHANGED
|
@@ -1,48 +1,48 @@
|
|
|
1
|
-
const path = require('path');
|
|
2
|
-
|
|
3
|
-
module.exports = {
|
|
4
|
-
mode: 'development',
|
|
5
|
-
entry: './src/index.ts',
|
|
6
|
-
devtool: "eval-cheap-source-map",
|
|
7
|
-
output: {
|
|
8
|
-
path: path.resolve(__dirname, 'dist'),
|
|
9
|
-
filename: 'bundle.js',
|
|
10
|
-
libraryTarget: 'umd',
|
|
11
|
-
library: 'lib',
|
|
12
|
-
},
|
|
13
|
-
resolve: {
|
|
14
|
-
extensions: ['.js', '.jsx', '.ts', '.tsx'],
|
|
15
|
-
},
|
|
16
|
-
module: {
|
|
17
|
-
rules: [
|
|
18
|
-
{
|
|
19
|
-
test: /\.s?css$/,
|
|
20
|
-
use: [
|
|
21
|
-
{ loader: 'style-loader' },
|
|
22
|
-
{
|
|
23
|
-
loader: 'css-loader',
|
|
24
|
-
options: {
|
|
25
|
-
modules: true
|
|
26
|
-
}
|
|
27
|
-
},
|
|
28
|
-
{ loader: 'sass-loader' }
|
|
29
|
-
]
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
test: /\.(png|svg|jpg|gif)$/,
|
|
33
|
-
loader: 'url-loader',
|
|
34
|
-
options: {
|
|
35
|
-
limit: Infinity // everything
|
|
36
|
-
}
|
|
37
|
-
},
|
|
38
|
-
{ test: /\.tsx?$/, use: 'ts-loader' },
|
|
39
|
-
],
|
|
40
|
-
},
|
|
41
|
-
externals: {
|
|
42
|
-
react: "react",
|
|
43
|
-
"react-dom": "react-dom",
|
|
44
|
-
"react-router-dom": "react-router-dom",
|
|
45
|
-
// "@tanstack/react-query": "@tanstack/react-query",
|
|
46
|
-
"@tanstack/query-core": "@tanstack/query-core",
|
|
47
|
-
},
|
|
48
|
-
};
|
|
1
|
+
const path = require('path');
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
mode: 'development',
|
|
5
|
+
entry: './src/index.ts',
|
|
6
|
+
devtool: "eval-cheap-source-map",
|
|
7
|
+
output: {
|
|
8
|
+
path: path.resolve(__dirname, 'dist'),
|
|
9
|
+
filename: 'bundle.js',
|
|
10
|
+
libraryTarget: 'umd',
|
|
11
|
+
library: 'lib',
|
|
12
|
+
},
|
|
13
|
+
resolve: {
|
|
14
|
+
extensions: ['.js', '.jsx', '.ts', '.tsx'],
|
|
15
|
+
},
|
|
16
|
+
module: {
|
|
17
|
+
rules: [
|
|
18
|
+
{
|
|
19
|
+
test: /\.s?css$/,
|
|
20
|
+
use: [
|
|
21
|
+
{ loader: 'style-loader' },
|
|
22
|
+
{
|
|
23
|
+
loader: 'css-loader',
|
|
24
|
+
options: {
|
|
25
|
+
modules: true
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
{ loader: 'sass-loader' }
|
|
29
|
+
]
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
test: /\.(png|svg|jpg|gif)$/,
|
|
33
|
+
loader: 'url-loader',
|
|
34
|
+
options: {
|
|
35
|
+
limit: Infinity // everything
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
{ test: /\.tsx?$/, use: 'ts-loader' },
|
|
39
|
+
],
|
|
40
|
+
},
|
|
41
|
+
externals: {
|
|
42
|
+
react: "react",
|
|
43
|
+
"react-dom": "react-dom",
|
|
44
|
+
"react-router-dom": "react-router-dom",
|
|
45
|
+
// "@tanstack/react-query": "@tanstack/react-query",
|
|
46
|
+
"@tanstack/query-core": "@tanstack/query-core",
|
|
47
|
+
},
|
|
48
|
+
};
|