@omniumretail/shared-resources 0.0.25 → 0.0.26

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.
Files changed (191) hide show
  1. package/.eslintrc.json +31 -31
  2. package/README.md +44 -44
  3. package/dist/bundle.js +244 -211
  4. package/dist/types/components/BottomDrawer/index.d.ts +9 -9
  5. package/dist/types/components/Button/index.d.ts +2 -2
  6. package/dist/types/components/Footer/index.d.ts +3 -3
  7. package/dist/types/components/Form/FormInputField/index.d.ts +8 -8
  8. package/dist/types/components/Form/FormSelectField/index.d.ts +9 -9
  9. package/dist/types/components/Form/index.d.ts +2 -2
  10. package/dist/types/components/Header/index.d.ts +4 -4
  11. package/dist/types/components/Link/index.d.ts +6 -6
  12. package/dist/types/components/Navigation/index.d.ts +8 -8
  13. package/dist/types/components/Page/index.d.ts +13 -13
  14. package/dist/types/components/SharedContextProvider/index.d.ts +7 -7
  15. package/dist/types/components/index.d.ts +9 -9
  16. package/dist/types/constants/Icons.d.ts +15 -15
  17. package/dist/types/constants/QueryClient.d.ts +2 -2
  18. package/dist/types/constants/index.d.ts +2 -2
  19. package/dist/types/contexts/useStore.d.ts +8 -8
  20. package/dist/types/hooks/activateEvaluationCycleQuery.hook.d.ts +2 -2
  21. package/dist/types/hooks/activateQuestionnaireQuery.hook.d.ts +2 -2
  22. package/dist/types/hooks/cancelEvaluationCycleQuery.hook.d.ts +2 -2
  23. package/dist/types/hooks/cancelQuestionnaireQuery.hook.d.ts +2 -2
  24. package/dist/types/hooks/deleteEvaluationCycleQuery.hook.d.ts +2 -2
  25. package/dist/types/hooks/deleteQuestionnaireQuery.hook.d.ts +2 -2
  26. package/dist/types/hooks/duplicateQuestionnaireQuery.hook.d.ts +2 -2
  27. package/dist/types/hooks/finishEvaluationCycleQuery.hook.d.ts +2 -2
  28. package/dist/types/hooks/finishQuestionnaireQuery.hook.d.ts +2 -2
  29. package/dist/types/hooks/index.d.ts +44 -42
  30. package/dist/types/hooks/useAllRolesQuery.hook.d.ts +11 -11
  31. package/dist/types/hooks/useAllStoreQuery.hook.d.ts +13 -13
  32. package/dist/types/hooks/useAnalyticsEvaluationCyclesQuery.hook.d.ts +7 -7
  33. package/dist/types/hooks/useAnalyticsQuestionsQuery.hook.d.ts +9 -9
  34. package/dist/types/hooks/useAnalyticsSideBarQuery.hook.d.ts +7 -7
  35. package/dist/types/hooks/useAnalyticsUserIdQuery.hook.d.ts +9 -9
  36. package/dist/types/hooks/useAnalyticsUserQuery.hook.d.ts +9 -9
  37. package/dist/types/hooks/useAnswerIdQuery.hook.d.ts +2 -2
  38. package/dist/types/hooks/useAnswerMutateQuery.hook.d.ts +9 -9
  39. package/dist/types/hooks/useAnswersUserSupervisorQuery.hook.d.ts +7 -7
  40. package/dist/types/hooks/useApplicationDataQuery.hook.d.ts +2 -2
  41. package/dist/types/hooks/useContractStatesQuery.hook.d.ts +7 -7
  42. package/dist/types/hooks/useCountriesQuery.hook.d.ts +7 -7
  43. package/dist/types/hooks/useCustomersQuery.hook.d.ts +138 -138
  44. package/dist/types/hooks/useEvaluationCycleIdQuery.hook.d.ts +2 -2
  45. package/dist/types/hooks/useEvaluationCycleMutateQuery.hook.d.ts +2 -2
  46. package/dist/types/hooks/useEvaluationCycleQuery.hook.d.ts +8 -8
  47. package/dist/types/hooks/useExpUsersAnswersQuery.hook.d.ts +8 -0
  48. package/dist/types/hooks/useJobTitlesQuery.hook.d.ts +7 -7
  49. package/dist/types/hooks/useProductHierarchies.hook.d.ts +7 -7
  50. package/dist/types/hooks/useProductsQuery.hook.d.ts +138 -138
  51. package/dist/types/hooks/useQuestionnaireIdQuery.hook.d.ts +2 -2
  52. package/dist/types/hooks/useQuestionnaireMutateQuery.hook.d.ts +2 -2
  53. package/dist/types/hooks/useQuestionnaireQuery.hook.d.ts +9 -9
  54. package/dist/types/hooks/useSingleUserIdMutateQuery.hook.d.ts +2 -2
  55. package/dist/types/hooks/useSingleUserIdQuery.hook.d.ts +2 -2
  56. package/dist/types/hooks/useSingleUserResetPassword.hook.d.ts +2 -2
  57. package/dist/types/hooks/useStoreQuery.d.ts +7 -7
  58. package/dist/types/hooks/useTermNotificationQuery.hook.d.ts +2 -2
  59. package/dist/types/hooks/useUpdateSupervisorMutateQuery.hook.d.ts +8 -0
  60. package/dist/types/hooks/useUserBlockQuery.hook.d.ts +2 -2
  61. package/dist/types/hooks/useUserEmailVerifQuery.hook.d.ts +2 -2
  62. package/dist/types/hooks/useUserIdQuery.hook.d.ts +2 -2
  63. package/dist/types/hooks/useUserListQuery.hook.d.ts +8 -8
  64. package/dist/types/hooks/useUserQuery.hook.d.ts +10 -10
  65. package/dist/types/index.d.ts +7 -7
  66. package/dist/types/interfaces/AnalyticsEvaluationCycle.d.ts +19 -19
  67. package/dist/types/interfaces/AnalyticsUserId.d.ts +12 -11
  68. package/dist/types/interfaces/Answer.d.ts +12 -12
  69. package/dist/types/interfaces/AnswersUserSupervisor.d.ts +42 -42
  70. package/dist/types/interfaces/ApplicationsByCategory.d.ts +16 -16
  71. package/dist/types/interfaces/Brand.d.ts +4 -4
  72. package/dist/types/interfaces/Cart.d.ts +10 -10
  73. package/dist/types/interfaces/Configuration.d.ts +6 -6
  74. package/dist/types/interfaces/ContractStates.d.ts +7 -7
  75. package/dist/types/interfaces/Countries.d.ts +10 -10
  76. package/dist/types/interfaces/Customer.d.ts +21 -21
  77. package/dist/types/interfaces/EvaluationCycle.d.ts +32 -32
  78. package/dist/types/interfaces/ExpUsersAnswers.d.ts +15 -0
  79. package/dist/types/interfaces/JobTitles.d.ts +7 -7
  80. package/dist/types/interfaces/Product.d.ts +15 -15
  81. package/dist/types/interfaces/ProductsHierarchies.d.ts +5 -5
  82. package/dist/types/interfaces/Questionnaire.d.ts +36 -36
  83. package/dist/types/interfaces/ResponseList.d.ts +5 -5
  84. package/dist/types/interfaces/Roles.d.ts +5 -5
  85. package/dist/types/interfaces/Store.d.ts +7 -7
  86. package/dist/types/interfaces/TermNotification.d.ts +5 -5
  87. package/dist/types/interfaces/User.d.ts +65 -65
  88. package/dist/types/interfaces/index.d.ts +22 -21
  89. package/dist/types/services/ApiService/index.d.ts +9 -9
  90. package/dist/types/services/InitService/index.d.ts +3 -3
  91. package/dist/types/services/index.d.ts +2 -2
  92. package/package.json +54 -54
  93. package/src/assets/sitoo.svg +9 -9
  94. package/src/components/BottomDrawer/index.tsx +32 -32
  95. package/src/components/BottomDrawer/styles.module.scss +59 -59
  96. package/src/components/Button/index.tsx +7 -7
  97. package/src/components/Footer/index.tsx +44 -44
  98. package/src/components/Footer/styles.module.scss +33 -33
  99. package/src/components/Form/FormInputField/index.tsx +18 -18
  100. package/src/components/Form/FormSelectField/index.tsx +16 -16
  101. package/src/components/Form/index.ts +2 -2
  102. package/src/components/Header/index.tsx +20 -20
  103. package/src/components/Header/styles.module.scss +16 -16
  104. package/src/components/Link/index.tsx +21 -21
  105. package/src/components/Link/styles.module.scss +24 -24
  106. package/src/components/Navigation/index.tsx +30 -30
  107. package/src/components/Navigation/styles.module.scss +34 -34
  108. package/src/components/Page/index.tsx +35 -35
  109. package/src/components/Page/styles.module.scss +26 -26
  110. package/src/components/SharedContextProvider/index.tsx +30 -30
  111. package/src/components/index.ts +9 -9
  112. package/src/constants/Icons.ts +23 -23
  113. package/src/constants/QueryClient.ts +10 -10
  114. package/src/constants/index.ts +2 -2
  115. package/src/contexts/useStore.tsx +20 -20
  116. package/src/global.scss +124 -124
  117. package/src/hooks/activateEvaluationCycleQuery.hook.ts +15 -15
  118. package/src/hooks/activateQuestionnaireQuery.hook.ts +15 -15
  119. package/src/hooks/cancelEvaluationCycleQuery.hook.ts +15 -15
  120. package/src/hooks/cancelQuestionnaireQuery.hook.ts +15 -15
  121. package/src/hooks/deleteEvaluationCycleQuery.hook.ts +15 -15
  122. package/src/hooks/deleteQuestionnaireQuery.hook.ts +15 -15
  123. package/src/hooks/duplicateQuestionnaireQuery.hook.ts +14 -14
  124. package/src/hooks/finishEvaluationCycleQuery.hook.ts +15 -15
  125. package/src/hooks/finishQuestionnaireQuery.hook.ts +15 -15
  126. package/src/hooks/index.ts +44 -42
  127. package/src/hooks/useAllRolesQuery.hook.ts +21 -21
  128. package/src/hooks/useAllStoreQuery.hook.ts +39 -39
  129. package/src/hooks/useAnalyticsEvaluationCyclesQuery.hook.ts +21 -21
  130. package/src/hooks/useAnalyticsQuestionsQuery.hook.ts +22 -22
  131. package/src/hooks/useAnalyticsSideBarQuery.hook.ts +21 -21
  132. package/src/hooks/useAnalyticsUserIdQuery.hook.ts +24 -24
  133. package/src/hooks/useAnalyticsUserQuery.hook.ts +27 -27
  134. package/src/hooks/useAnswerIdQuery.hook.ts +13 -13
  135. package/src/hooks/useAnswerMutateQuery.hook.ts +31 -31
  136. package/src/hooks/useAnswersUserSupervisorQuery.hook.tsx +21 -21
  137. package/src/hooks/useApplicationDataQuery.hook.ts +10 -10
  138. package/src/hooks/useContractStatesQuery.hook.ts +14 -14
  139. package/src/hooks/useCountriesQuery.hook.ts +14 -14
  140. package/src/hooks/useCustomersQuery.hook.ts +30 -30
  141. package/src/hooks/useEvaluationCycleIdQuery.hook.ts +13 -13
  142. package/src/hooks/useEvaluationCycleMutateQuery.hook.ts +17 -17
  143. package/src/hooks/useEvaluationCycleQuery.hook.ts +25 -25
  144. package/src/hooks/useExpUsersAnswersQuery.hook.ts +25 -0
  145. package/src/hooks/useJobTitlesQuery.hook.ts +14 -14
  146. package/src/hooks/useProductHierarchies.hook.ts +12 -12
  147. package/src/hooks/useProductsQuery.hook.ts +30 -30
  148. package/src/hooks/useQuestionnaireIdQuery.hook.ts +13 -13
  149. package/src/hooks/useQuestionnaireMutateQuery.hook.ts +17 -17
  150. package/src/hooks/useQuestionnaireQuery.hook.ts +27 -27
  151. package/src/hooks/useSingleUserIdMutateQuery.hook.ts +18 -18
  152. package/src/hooks/useSingleUserIdQuery.hook.ts +14 -14
  153. package/src/hooks/useSingleUserResetPassword.hook.ts +15 -15
  154. package/src/hooks/useStoreQuery.ts +13 -13
  155. package/src/hooks/useTermNotificationQuery.hook.ts +11 -11
  156. package/src/hooks/useUpdateSupervisorMutateQuery.hook.ts +27 -0
  157. package/src/hooks/useUserBlockQuery.hook.ts +15 -15
  158. package/src/hooks/useUserEmailVerifQuery.hook.ts +15 -15
  159. package/src/hooks/useUserIdQuery.hook.ts +14 -14
  160. package/src/hooks/useUserListQuery.hook.ts +25 -25
  161. package/src/hooks/useUserQuery.hook.ts +29 -29
  162. package/src/index.ts +9 -9
  163. package/src/interfaces/AnalyticsEvaluationCycle.ts +24 -24
  164. package/src/interfaces/AnalyticsUserId.ts +13 -12
  165. package/src/interfaces/Answer.ts +13 -13
  166. package/src/interfaces/AnswersUserSupervisor.ts +45 -45
  167. package/src/interfaces/ApplicationsByCategory.ts +19 -19
  168. package/src/interfaces/Brand.ts +4 -4
  169. package/src/interfaces/Cart.ts +13 -13
  170. package/src/interfaces/Configuration.ts +7 -7
  171. package/src/interfaces/ContractStates.ts +7 -7
  172. package/src/interfaces/Countries.ts +10 -10
  173. package/src/interfaces/Customer.ts +23 -23
  174. package/src/interfaces/EvaluationCycle.ts +32 -32
  175. package/src/interfaces/ExpUsersAnswers.ts +16 -0
  176. package/src/interfaces/JobTitles.ts +7 -7
  177. package/src/interfaces/Product.ts +17 -17
  178. package/src/interfaces/ProductsHierarchies.ts +6 -6
  179. package/src/interfaces/Questionnaire.ts +38 -38
  180. package/src/interfaces/ResponseList.ts +6 -6
  181. package/src/interfaces/Roles.ts +5 -5
  182. package/src/interfaces/Store.ts +8 -8
  183. package/src/interfaces/TermNotification.ts +5 -5
  184. package/src/interfaces/User.ts +69 -69
  185. package/src/interfaces/index.ts +22 -21
  186. package/src/services/ApiService/index.ts +125 -125
  187. package/src/services/InitService/index.ts +7 -7
  188. package/src/services/index.ts +3 -3
  189. package/src/types/Global.d.ts +4 -4
  190. package/tsconfig.json +27 -27
  191. package/webpack.config.js +48 -48
@@ -1,6 +1,6 @@
1
-
2
- export interface ProductsHierarchies {
3
- Id: string;
4
- Name: string;
5
- SubCategory?: ProductsHierarchies[];
6
- }
1
+
2
+ export interface ProductsHierarchies {
3
+ Id: string;
4
+ Name: string;
5
+ SubCategory?: ProductsHierarchies[];
6
+ }
@@ -1,39 +1,39 @@
1
-
2
- export interface Questionnaire {
3
- Id: string;
4
- Name: string;
5
- Type: number;
6
- NrLevel: number;
7
- Level: number;
8
- State: string;
9
- Categories: Categories[];
10
- }
11
-
12
- export interface Categories {
13
- Id: string;
14
- Title: string;
15
- Key: string;
16
- Data: {
17
- Id: string;
18
- CategoryId: string;
19
- CategoryName: string;
20
- OpenAnswer: boolean;
21
- Grade: number;
22
- GeneralEvaluationLevel: number;
23
- Description: string;
24
- Score: string;
25
- Questions: Questions[];
26
- };
27
- Children: Categories[];
28
- }
29
-
30
- export interface Questions {
31
- Id: string;
32
- Question: string;
33
- Info: string;
34
- Grade: number;
35
- QuestionId: string;
36
- Subject: string;
37
- Description: string;
38
- Answer: string;
1
+
2
+ export interface Questionnaire {
3
+ Id: string;
4
+ Name: string;
5
+ Type: number;
6
+ NrLevel: number;
7
+ Level: number;
8
+ State: string;
9
+ Categories: Categories[];
10
+ }
11
+
12
+ export interface Categories {
13
+ Id: string;
14
+ Title: string;
15
+ Key: string;
16
+ Data: {
17
+ Id: string;
18
+ CategoryId: string;
19
+ CategoryName: string;
20
+ OpenAnswer: boolean;
21
+ Grade: number;
22
+ GeneralEvaluationLevel: number;
23
+ Description: string;
24
+ Score: string;
25
+ Questions: Questions[];
26
+ };
27
+ Children: Categories[];
28
+ }
29
+
30
+ export interface Questions {
31
+ Id: string;
32
+ Question: string;
33
+ Info: string;
34
+ Grade: number;
35
+ QuestionId: string;
36
+ Subject: string;
37
+ Description: string;
38
+ Answer: string;
39
39
  }
@@ -1,6 +1,6 @@
1
-
2
- export type ResponseList<K extends string, T> = {
3
- [key in K]: T[];
4
- } & {
5
- Count: number;
6
- };
1
+
2
+ export type ResponseList<K extends string, T> = {
3
+ [key in K]: T[];
4
+ } & {
5
+ Count: number;
6
+ };
@@ -1,5 +1,5 @@
1
- export interface Roles {
2
- ApplicationName: string;
3
- RoleId: string;
4
- RoleName: string;
5
- }
1
+ export interface Roles {
2
+ ApplicationName: string;
3
+ RoleId: string;
4
+ RoleName: string;
5
+ }
@@ -1,8 +1,8 @@
1
-
2
- export interface Store {
3
- Id: string;
4
- Name: string;
5
- Address: string;
6
- City: string;
7
- ZipCode: string;
8
- }
1
+
2
+ export interface Store {
3
+ Id: string;
4
+ Name: string;
5
+ Address: string;
6
+ City: string;
7
+ ZipCode: string;
8
+ }
@@ -1,6 +1,6 @@
1
-
2
- export interface TermNotification {
3
- Id: string;
4
- Value: string;
5
- Label: string;
1
+
2
+ export interface TermNotification {
3
+ Id: string;
4
+ Value: string;
5
+ Label: string;
6
6
  }
@@ -1,69 +1,69 @@
1
-
2
- export interface User {
3
- UserId: string;
4
- DisplayName: string;
5
- Code: string;
6
- Store: string[];
7
- JobTitleId: string;
8
- JobTitleName: string;
9
- ContractStateId: string;
10
- ContractStateName: string;
11
- IsSelected: boolean;
12
- UserScore: number;
13
- SupervisorScore: number;
14
- Date: number;
15
- Supervisor: string;
16
- TypeOfContract: string;
17
- Team: string;
18
- UserName: string;
19
- }
20
-
21
- interface JobTitle {
22
- Id: string;
23
- Name: string;
24
- }
25
-
26
- interface ContractState {
27
- Id: string;
28
- Name: string;
29
- }
30
-
31
- interface Roles {
32
- Id: string;
33
- Name: string;
34
- }
35
-
36
- export interface SingleUser {
37
- UserId: string;
38
- FullName: string;
39
- Email: string;
40
- DisplayName: string;
41
- PhoneNumber: number;
42
- Code: string;
43
- Birthday: number;
44
- AdmissionData: number;
45
- ResignDate: number;
46
- Address: string;
47
- ZipCode: string;
48
- City: string;
49
- CountryIso02: string;
50
- JobTitle: JobTitle;
51
- ContractState: ContractState;
52
- Stores: string[];
53
- SupervisorId: string;
54
- ImageUrl: string;
55
- Tags: string[];
56
- Roles: Roles;
57
- IdentityCardNumber: number | string;
58
- IdentityCardExpirationDate: number | string;
59
- PlaceOfBirth: string;
60
- MaritalStatus: string;
61
- NumberOfChildren: number;
62
- Qualifications: string;
63
- TaxNumber: string;
64
- SocialSecurityNumber: string;
65
- IBAN: string;
66
- CreateDate: number;
67
- UpdateDate: string
68
- ContractStatusId: string;
69
- }
1
+
2
+ export interface User {
3
+ UserId: string;
4
+ DisplayName: string;
5
+ Code: string;
6
+ Store: string[];
7
+ JobTitleId: string;
8
+ JobTitleName: string;
9
+ ContractStateId: string;
10
+ ContractStateName: string;
11
+ IsSelected: boolean;
12
+ UserScore: number;
13
+ SupervisorScore: number;
14
+ Date: number;
15
+ Supervisor: string;
16
+ TypeOfContract: string;
17
+ Team: string;
18
+ UserName: string;
19
+ }
20
+
21
+ interface JobTitle {
22
+ Id: string;
23
+ Name: string;
24
+ }
25
+
26
+ interface ContractState {
27
+ Id: string;
28
+ Name: string;
29
+ }
30
+
31
+ interface Roles {
32
+ Id: string;
33
+ Name: string;
34
+ }
35
+
36
+ export interface SingleUser {
37
+ UserId: string;
38
+ FullName: string;
39
+ Email: string;
40
+ DisplayName: string;
41
+ PhoneNumber: number;
42
+ Code: string;
43
+ Birthday: number;
44
+ AdmissionData: number;
45
+ ResignDate: number;
46
+ Address: string;
47
+ ZipCode: string;
48
+ City: string;
49
+ CountryIso02: string;
50
+ JobTitle: JobTitle;
51
+ ContractState: ContractState;
52
+ Stores: string[];
53
+ SupervisorId: string;
54
+ ImageUrl: string;
55
+ Tags: string[];
56
+ Roles: Roles;
57
+ IdentityCardNumber: number | string;
58
+ IdentityCardExpirationDate: number | string;
59
+ PlaceOfBirth: string;
60
+ MaritalStatus: string;
61
+ NumberOfChildren: number;
62
+ Qualifications: string;
63
+ TaxNumber: string;
64
+ SocialSecurityNumber: string;
65
+ IBAN: string;
66
+ CreateDate: number;
67
+ UpdateDate: string
68
+ ContractStatusId: string;
69
+ }
@@ -1,21 +1,22 @@
1
- export * from './ResponseList';
2
- export * from './Configuration';
3
- export * from './Store';
4
- export * from './Product';
5
- export * from './Customer';
6
- export * from './ApplicationsByCategory';
7
- export * from './EvaluationCycle';
8
- export * from './User';
9
- export * from './Questionnaire';
10
- export * from './AnalyticsEvaluationCycle';
11
- export * from './Answer';
12
- export * from './AnalyticsUserId';
13
- export * from './Cart';
14
- export * from './ProductsHierarchies';
15
- export * from './Brand';
16
- export * from './Countries';
17
- export * from './Roles';
18
- export * from './AnswersUserSupervisor';
19
- export * from './TermNotification';
20
- export * from './JobTitles';
21
- export * from './ContractStates';
1
+ export * from './ResponseList';
2
+ export * from './Configuration';
3
+ export * from './Store';
4
+ export * from './Product';
5
+ export * from './Customer';
6
+ export * from './ApplicationsByCategory';
7
+ export * from './EvaluationCycle';
8
+ export * from './User';
9
+ export * from './Questionnaire';
10
+ export * from './AnalyticsEvaluationCycle';
11
+ export * from './Answer';
12
+ export * from './AnalyticsUserId';
13
+ export * from './Cart';
14
+ export * from './ProductsHierarchies';
15
+ export * from './Brand';
16
+ export * from './Countries';
17
+ export * from './Roles';
18
+ export * from './AnswersUserSupervisor';
19
+ export * from './TermNotification';
20
+ export * from './JobTitles';
21
+ export * from './ContractStates';
22
+ export * from './ExpUsersAnswers';
@@ -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
+ }
@@ -1,3 +1,3 @@
1
-
2
- export * from './InitService';
3
- export * from './ApiService';
1
+
2
+ export * from './InitService';
3
+ export * from './ApiService';
@@ -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
+ }