@wbsuite/react-hooks 1.0.209 → 1.0.211

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 (302) hide show
  1. package/cjs/hooks/useAgents/index.d.ts +2 -0
  2. package/cjs/hooks/useAgents/index.js +32 -0
  3. package/cjs/hooks/useApps/index.d.ts +2 -0
  4. package/cjs/hooks/useApps/index.js +32 -0
  5. package/cjs/hooks/useArticles/index.d.ts +5 -0
  6. package/cjs/hooks/useArticles/index.js +45 -0
  7. package/cjs/hooks/useAttributes/index.d.ts +2 -0
  8. package/cjs/hooks/useAttributes/index.js +52 -0
  9. package/cjs/hooks/useAttributesGroups/index.d.ts +3 -0
  10. package/cjs/hooks/useAttributesGroups/index.js +47 -0
  11. package/cjs/hooks/useAutomations/index.d.ts +2 -0
  12. package/cjs/hooks/useAutomations/index.js +32 -0
  13. package/cjs/hooks/useBackend/get.d.ts +2 -0
  14. package/cjs/hooks/useBackend/get.js +52 -0
  15. package/cjs/hooks/useBackend/index.d.ts +17 -0
  16. package/cjs/hooks/useBackend/index.js +22 -0
  17. package/cjs/hooks/useBackend/list.d.ts +2 -0
  18. package/cjs/hooks/useBackend/list.js +55 -0
  19. package/cjs/hooks/useBackend/post.d.ts +2 -0
  20. package/cjs/hooks/useBackend/post.js +52 -0
  21. package/cjs/hooks/useBackend/put.d.ts +2 -0
  22. package/cjs/hooks/useBackend/put.js +52 -0
  23. package/cjs/hooks/useCampaigns/index.d.ts +2 -0
  24. package/cjs/hooks/useCampaigns/index.js +35 -0
  25. package/cjs/hooks/useCategories/index.d.ts +3 -0
  26. package/cjs/hooks/useCategories/index.js +9 -0
  27. package/cjs/hooks/useChats/index.d.ts +3 -0
  28. package/cjs/hooks/useChats/index.js +37 -0
  29. package/cjs/hooks/useContactGroups/index.d.ts +3 -0
  30. package/cjs/hooks/useContactGroups/index.js +57 -0
  31. package/cjs/hooks/useContacts/index.d.ts +3 -0
  32. package/cjs/hooks/useContacts/index.js +52 -0
  33. package/cjs/hooks/useCurrencies/index.d.ts +3 -0
  34. package/cjs/hooks/useCurrencies/index.js +37 -0
  35. package/cjs/hooks/useCustomers/index.d.ts +3 -0
  36. package/cjs/hooks/useCustomers/index.js +52 -0
  37. package/cjs/hooks/useDocuments/index.d.ts +10 -0
  38. package/cjs/hooks/useDocuments/index.js +145 -0
  39. package/cjs/hooks/useDomains/index.d.ts +2 -0
  40. package/cjs/hooks/useDomains/index.js +32 -0
  41. package/cjs/hooks/useEmailTemplates/index.d.ts +2 -0
  42. package/cjs/hooks/useEmailTemplates/index.js +37 -0
  43. package/cjs/hooks/useEntityStatuses/index.d.ts +2 -0
  44. package/cjs/hooks/useEntityStatuses/index.js +34 -0
  45. package/cjs/hooks/useForms/index.d.ts +2 -0
  46. package/cjs/hooks/useForms/index.js +37 -0
  47. package/cjs/hooks/useIntegrations/index.d.ts +2 -0
  48. package/cjs/hooks/useIntegrations/index.js +39 -0
  49. package/cjs/hooks/useInvites/index.d.ts +2 -0
  50. package/cjs/hooks/useInvites/index.js +47 -0
  51. package/cjs/hooks/useLabels/index.d.ts +3 -0
  52. package/cjs/hooks/useLabels/index.js +32 -0
  53. package/cjs/hooks/useLanguages/index.d.ts +5 -0
  54. package/cjs/hooks/useLanguages/index.js +39 -0
  55. package/cjs/hooks/useLeads/index.d.ts +30 -0
  56. package/cjs/hooks/useLeads/index.js +113 -0
  57. package/cjs/hooks/useMedia/index.d.ts +2 -0
  58. package/cjs/hooks/useMedia/index.js +34 -0
  59. package/cjs/hooks/useOrders/index.d.ts +2 -0
  60. package/cjs/hooks/useOrders/index.js +76 -0
  61. package/cjs/hooks/usePaths/index.d.ts +2 -0
  62. package/cjs/hooks/usePaths/index.js +37 -0
  63. package/cjs/hooks/usePermissions/index.d.ts +2 -0
  64. package/cjs/hooks/usePermissions/index.js +47 -0
  65. package/cjs/hooks/useProducts/index.d.ts +2 -0
  66. package/cjs/hooks/useProducts/index.js +52 -0
  67. package/cjs/hooks/useProfile/index.d.ts +3 -0
  68. package/cjs/hooks/useProfile/index.js +57 -0
  69. package/cjs/hooks/useRenting/index.d.ts +47 -0
  70. package/cjs/hooks/useRenting/index.js +52 -0
  71. package/cjs/hooks/useRoles/index.d.ts +2 -0
  72. package/cjs/hooks/useRoles/index.js +32 -0
  73. package/cjs/hooks/useRoom/index.d.ts +3 -0
  74. package/cjs/hooks/useRoom/index.js +55 -0
  75. package/cjs/hooks/useRotations/index.d.ts +2 -0
  76. package/cjs/hooks/useRotations/index.js +37 -0
  77. package/cjs/hooks/useSiteConfig/index.d.ts +5 -0
  78. package/cjs/hooks/useSiteConfig/index.js +33 -0
  79. package/cjs/hooks/useStatuses/index.d.ts +2 -0
  80. package/cjs/hooks/useStatuses/index.js +32 -0
  81. package/cjs/hooks/useStock/index.d.ts +20 -0
  82. package/cjs/hooks/useStock/index.js +51 -0
  83. package/cjs/hooks/useStores/index.d.ts +3 -0
  84. package/cjs/hooks/useStores/index.js +62 -0
  85. package/cjs/hooks/useSubscriptions/index.d.ts +2 -0
  86. package/cjs/hooks/useSubscriptions/index.js +37 -0
  87. package/cjs/hooks/useTable/index.d.ts +3 -0
  88. package/cjs/hooks/useTable/index.js +34 -0
  89. package/cjs/hooks/useTeams/index.d.ts +5 -0
  90. package/cjs/hooks/useTeams/index.js +52 -0
  91. package/cjs/hooks/useTickets/index.d.ts +3 -0
  92. package/cjs/hooks/useTickets/index.js +47 -0
  93. package/cjs/hooks/useTransactions/index.d.ts +8 -0
  94. package/cjs/hooks/useTransactions/index.js +61 -0
  95. package/cjs/hooks/useTranslations/index.d.ts +5 -0
  96. package/cjs/hooks/useTranslations/index.js +42 -0
  97. package/cjs/hooks/useUserConnections/index.d.ts +2 -0
  98. package/cjs/hooks/useUserConnections/index.js +53 -0
  99. package/cjs/hooks/useUserSubscriptions/index.d.ts +6 -0
  100. package/cjs/hooks/useUserSubscriptions/index.js +47 -0
  101. package/cjs/hooks/useUsers/index.d.ts +17 -0
  102. package/cjs/hooks/useUsers/index.js +141 -0
  103. package/cjs/hooks/useWBSuite/index.d.ts +2 -0
  104. package/cjs/hooks/useWBSuite/index.js +39 -0
  105. package/cjs/hooks/useWebsites/index.d.ts +2 -0
  106. package/cjs/hooks/useWebsites/index.js +72 -0
  107. package/{src/index.ts → cjs/index.d.ts} +2 -1
  108. package/cjs/index.js +117 -0
  109. package/cjs/models/Requestor.d.ts +24 -0
  110. package/cjs/models/Requestor.js +53 -0
  111. package/{src/next/utils/index.ts → cjs/next/utils/index.d.ts} +1 -1
  112. package/cjs/next/utils/index.js +6 -0
  113. package/cjs/next/utils/wrapAsync.d.ts +1 -0
  114. package/cjs/next/utils/wrapAsync.js +54 -0
  115. package/cjs/utils/authWithApiKey.d.ts +4 -0
  116. package/cjs/utils/authWithApiKey.js +8 -0
  117. package/cjs/utils/authWithToken.d.ts +4 -0
  118. package/cjs/utils/authWithToken.js +8 -0
  119. package/cjs/utils/index.d.ts +11 -0
  120. package/cjs/utils/index.js +19 -0
  121. package/esm/hooks/useAgents/index.d.ts +2 -0
  122. package/esm/hooks/useAgents/index.js +28 -0
  123. package/esm/hooks/useApps/index.d.ts +2 -0
  124. package/esm/hooks/useApps/index.js +28 -0
  125. package/esm/hooks/useArticles/index.d.ts +5 -0
  126. package/esm/hooks/useArticles/index.js +40 -0
  127. package/esm/hooks/useAttributes/index.d.ts +2 -0
  128. package/esm/hooks/useAttributes/index.js +48 -0
  129. package/esm/hooks/useAttributesGroups/index.d.ts +3 -0
  130. package/esm/hooks/useAttributesGroups/index.js +43 -0
  131. package/esm/hooks/useAutomations/index.d.ts +2 -0
  132. package/esm/hooks/useAutomations/index.js +28 -0
  133. package/esm/hooks/useBackend/get.d.ts +2 -0
  134. package/esm/hooks/useBackend/get.js +48 -0
  135. package/esm/hooks/useBackend/index.d.ts +17 -0
  136. package/esm/hooks/useBackend/index.js +18 -0
  137. package/esm/hooks/useBackend/list.d.ts +2 -0
  138. package/esm/hooks/useBackend/list.js +51 -0
  139. package/esm/hooks/useBackend/post.d.ts +2 -0
  140. package/esm/hooks/useBackend/post.js +48 -0
  141. package/esm/hooks/useBackend/put.d.ts +2 -0
  142. package/esm/hooks/useBackend/put.js +48 -0
  143. package/esm/hooks/useCampaigns/index.d.ts +2 -0
  144. package/esm/hooks/useCampaigns/index.js +31 -0
  145. package/esm/hooks/useCategories/index.d.ts +3 -0
  146. package/esm/hooks/useCategories/index.js +5 -0
  147. package/esm/hooks/useChats/index.d.ts +3 -0
  148. package/esm/hooks/useChats/index.js +33 -0
  149. package/esm/hooks/useContactGroups/index.d.ts +3 -0
  150. package/esm/hooks/useContactGroups/index.js +53 -0
  151. package/esm/hooks/useContacts/index.d.ts +3 -0
  152. package/esm/hooks/useContacts/index.js +48 -0
  153. package/esm/hooks/useCurrencies/index.d.ts +3 -0
  154. package/esm/hooks/useCurrencies/index.js +33 -0
  155. package/esm/hooks/useCustomers/index.d.ts +3 -0
  156. package/esm/hooks/useCustomers/index.js +48 -0
  157. package/esm/hooks/useDocuments/index.d.ts +10 -0
  158. package/esm/hooks/useDocuments/index.js +141 -0
  159. package/esm/hooks/useDomains/index.d.ts +2 -0
  160. package/esm/hooks/useDomains/index.js +28 -0
  161. package/esm/hooks/useEmailTemplates/index.d.ts +2 -0
  162. package/esm/hooks/useEmailTemplates/index.js +33 -0
  163. package/esm/hooks/useEntityStatuses/index.d.ts +2 -0
  164. package/esm/hooks/useEntityStatuses/index.js +30 -0
  165. package/esm/hooks/useForms/index.d.ts +2 -0
  166. package/esm/hooks/useForms/index.js +33 -0
  167. package/esm/hooks/useIntegrations/index.d.ts +2 -0
  168. package/esm/hooks/useIntegrations/index.js +35 -0
  169. package/esm/hooks/useInvites/index.d.ts +2 -0
  170. package/esm/hooks/useInvites/index.js +43 -0
  171. package/esm/hooks/useLabels/index.d.ts +3 -0
  172. package/esm/hooks/useLabels/index.js +28 -0
  173. package/esm/hooks/useLanguages/index.d.ts +5 -0
  174. package/esm/hooks/useLanguages/index.js +35 -0
  175. package/esm/hooks/useLeads/index.d.ts +30 -0
  176. package/esm/hooks/useLeads/index.js +109 -0
  177. package/esm/hooks/useMedia/index.d.ts +2 -0
  178. package/esm/hooks/useMedia/index.js +30 -0
  179. package/esm/hooks/useOrders/index.d.ts +2 -0
  180. package/esm/hooks/useOrders/index.js +72 -0
  181. package/esm/hooks/usePaths/index.d.ts +2 -0
  182. package/esm/hooks/usePaths/index.js +33 -0
  183. package/esm/hooks/usePermissions/index.d.ts +2 -0
  184. package/esm/hooks/usePermissions/index.js +43 -0
  185. package/esm/hooks/useProducts/index.d.ts +2 -0
  186. package/esm/hooks/useProducts/index.js +48 -0
  187. package/esm/hooks/useProfile/index.d.ts +3 -0
  188. package/esm/hooks/useProfile/index.js +53 -0
  189. package/esm/hooks/useRenting/index.d.ts +47 -0
  190. package/esm/hooks/useRenting/index.js +48 -0
  191. package/esm/hooks/useRoles/index.d.ts +2 -0
  192. package/esm/hooks/useRoles/index.js +28 -0
  193. package/esm/hooks/useRoom/index.d.ts +3 -0
  194. package/esm/hooks/useRoom/index.js +51 -0
  195. package/esm/hooks/useRotations/index.d.ts +2 -0
  196. package/esm/hooks/useRotations/index.js +33 -0
  197. package/esm/hooks/useSiteConfig/index.d.ts +5 -0
  198. package/esm/hooks/useSiteConfig/index.js +29 -0
  199. package/esm/hooks/useStatuses/index.d.ts +2 -0
  200. package/esm/hooks/useStatuses/index.js +28 -0
  201. package/esm/hooks/useStock/index.d.ts +20 -0
  202. package/esm/hooks/useStock/index.js +47 -0
  203. package/esm/hooks/useStores/index.d.ts +3 -0
  204. package/esm/hooks/useStores/index.js +58 -0
  205. package/esm/hooks/useSubscriptions/index.d.ts +2 -0
  206. package/esm/hooks/useSubscriptions/index.js +33 -0
  207. package/esm/hooks/useTable/index.d.ts +3 -0
  208. package/esm/hooks/useTable/index.js +30 -0
  209. package/esm/hooks/useTeams/index.d.ts +5 -0
  210. package/esm/hooks/useTeams/index.js +48 -0
  211. package/esm/hooks/useTickets/index.d.ts +3 -0
  212. package/esm/hooks/useTickets/index.js +43 -0
  213. package/esm/hooks/useTransactions/index.d.ts +8 -0
  214. package/esm/hooks/useTransactions/index.js +57 -0
  215. package/esm/hooks/useTranslations/index.d.ts +5 -0
  216. package/esm/hooks/useTranslations/index.js +38 -0
  217. package/esm/hooks/useUserConnections/index.d.ts +2 -0
  218. package/esm/hooks/useUserConnections/index.js +49 -0
  219. package/esm/hooks/useUserSubscriptions/index.d.ts +6 -0
  220. package/esm/hooks/useUserSubscriptions/index.js +43 -0
  221. package/esm/hooks/useUsers/index.d.ts +17 -0
  222. package/esm/hooks/useUsers/index.js +137 -0
  223. package/esm/hooks/useWBSuite/index.d.ts +2 -0
  224. package/esm/hooks/useWBSuite/index.js +35 -0
  225. package/esm/hooks/useWebsites/index.d.ts +2 -0
  226. package/esm/hooks/useWebsites/index.js +68 -0
  227. package/esm/index.d.ts +50 -0
  228. package/esm/index.js +51 -0
  229. package/esm/models/Requestor.d.ts +24 -0
  230. package/esm/models/Requestor.js +47 -0
  231. package/esm/next/utils/index.d.ts +2 -0
  232. package/esm/next/utils/index.js +3 -0
  233. package/esm/next/utils/wrapAsync.d.ts +1 -0
  234. package/esm/next/utils/wrapAsync.js +50 -0
  235. package/esm/utils/authWithApiKey.d.ts +4 -0
  236. package/esm/utils/authWithApiKey.js +4 -0
  237. package/esm/utils/authWithToken.d.ts +4 -0
  238. package/esm/utils/authWithToken.js +4 -0
  239. package/esm/utils/index.d.ts +11 -0
  240. package/esm/utils/index.js +3 -0
  241. package/package.json +1 -1
  242. package/README.md +0 -66
  243. package/docs/USAGE.md +0 -107
  244. package/eslint.config.js +0 -12
  245. package/src/hooks/useAgents/index.ts +0 -10
  246. package/src/hooks/useArticles/index.ts +0 -18
  247. package/src/hooks/useAttributes/index.ts +0 -18
  248. package/src/hooks/useAttributesGroups/index.ts +0 -17
  249. package/src/hooks/useAutomations/index.ts +0 -10
  250. package/src/hooks/useBackend/get.ts +0 -6
  251. package/src/hooks/useBackend/index.ts +0 -40
  252. package/src/hooks/useBackend/list.ts +0 -6
  253. package/src/hooks/useBackend/post.ts +0 -6
  254. package/src/hooks/useBackend/put.ts +0 -6
  255. package/src/hooks/useCampaigns/index.ts +0 -11
  256. package/src/hooks/useCategories/index.ts +0 -7
  257. package/src/hooks/useChats/index.ts +0 -13
  258. package/src/hooks/useContactGroups/index.ts +0 -28
  259. package/src/hooks/useContacts/index.ts +0 -21
  260. package/src/hooks/useCurrencies/index.ts +0 -14
  261. package/src/hooks/useCustomers/index.ts +0 -21
  262. package/src/hooks/useDocuments/index.ts +0 -86
  263. package/src/hooks/useDomains/index.ts +0 -10
  264. package/src/hooks/useEmailTemplates/index.ts +0 -13
  265. package/src/hooks/useEntityStatuses/index.ts +0 -13
  266. package/src/hooks/useForms/index.ts +0 -16
  267. package/src/hooks/useIntegrations/index.ts +0 -15
  268. package/src/hooks/useInvites/index.ts +0 -19
  269. package/src/hooks/useLabels/index.ts +0 -13
  270. package/src/hooks/useLanguages/index.ts +0 -16
  271. package/src/hooks/useLeads/index.ts +0 -149
  272. package/src/hooks/useMedia/index.ts +0 -13
  273. package/src/hooks/useOrders/index.ts +0 -74
  274. package/src/hooks/usePaths/index.ts +0 -16
  275. package/src/hooks/usePermissions/index.ts +0 -16
  276. package/src/hooks/useProducts/index.ts +0 -18
  277. package/src/hooks/useProfile/index.ts +0 -20
  278. package/src/hooks/useRenting/index.ts +0 -57
  279. package/src/hooks/useRoles/index.ts +0 -10
  280. package/src/hooks/useRoom/index.ts +0 -20
  281. package/src/hooks/useRotations/index.ts +0 -13
  282. package/src/hooks/useSiteConfig/index.ts +0 -13
  283. package/src/hooks/useStatuses/index.ts +0 -10
  284. package/src/hooks/useStock/index.ts +0 -48
  285. package/src/hooks/useStores/index.ts +0 -23
  286. package/src/hooks/useSubscriptions/index.ts +0 -17
  287. package/src/hooks/useTable/index.ts +0 -15
  288. package/src/hooks/useTeams/index.ts +0 -29
  289. package/src/hooks/useTickets/index.ts +0 -17
  290. package/src/hooks/useTransactions/index.ts +0 -43
  291. package/src/hooks/useTranslations/index.ts +0 -20
  292. package/src/hooks/useUserConnections/index.ts +0 -18
  293. package/src/hooks/useUserSubscriptions/index.ts +0 -28
  294. package/src/hooks/useUsers/index.ts +0 -57
  295. package/src/hooks/useWBSuite/index.ts +0 -29
  296. package/src/hooks/useWebsites/index.ts +0 -34
  297. package/src/models/Requestor.ts +0 -67
  298. package/src/next/utils/wrapAsync.ts +0 -2
  299. package/src/utils/authWithApiKey.ts +0 -3
  300. package/src/utils/authWithToken.ts +0 -3
  301. package/src/utils/index.ts +0 -7
  302. package/tsconfig.json +0 -20
@@ -1,17 +0,0 @@
1
- import { BackendHook, useBackend } from '../useBackend';
2
- import { RequestorOptions } from 'models/Requestor';
3
- import { IAttributeGroup } from '@wb/types/products/attributeGroup.model';
4
-
5
- export const useAttributesGroups: BackendHook<IAttributeGroup> = (auth?: RequestorOptions['auth']) => {
6
- const { requestor, ...endpoints } = useBackend('attribute/groups', { auth });
7
- return {
8
- requestor,
9
- ...endpoints,
10
- create: (data) =>
11
- requestor.makeRequest.post(`attribute/groups`, data).then(({ data }) => data),
12
- update: (id, data) =>
13
- requestor.makeRequest.put(`attribute/groups/${id}`, data).then(({ data }) => data),
14
- delete: (id: string) =>
15
- requestor.makeRequest.delete(`attribute/groups/${id}`).then(({ data }) => data),
16
- };
17
- };
@@ -1,10 +0,0 @@
1
- import { RequestorOptions } from 'models/Requestor';
2
- import { BackendHook, useBackend } from '../useBackend';
3
-
4
- export const useAutomations: BackendHook<any, undefined> = (auth?: RequestorOptions['auth']) => {
5
- const { requestor, ...rest } = useBackend('automations', { auth });
6
- return {
7
- ...rest,
8
- requestor,
9
- };
10
- };
@@ -1,6 +0,0 @@
1
- import { Requestor } from '../../models/Requestor';
2
-
3
- export const get = async (requestor: Requestor, path: string, id: string) => {
4
- const { data } = await requestor.makeRequest.get(`${path}/${id}`);
5
- return data;
6
- };
@@ -1,40 +0,0 @@
1
- import { list } from './list';
2
- import { get } from './get';
3
- import { Requestor, RequestorOptions } from '../../models/Requestor';
4
- import { post } from './post';
5
- import { CustomResponse } from '@wb/types/custom-response/custom-response.model';
6
- import { put } from './put';
7
-
8
- type OtherMethods<T> = (Record<string, (...args: any[]) => Promise<CustomResponse<T[]> | CustomResponse<T>>>) | Record<'requestor', Requestor>;
9
-
10
- // Base methods that cannot be overridden
11
- type BaseMethods<T> = {
12
- requestor: Requestor;
13
- list: (filters?: Partial<T>) => Promise<CustomResponse<T[]>>,
14
- get: (id: string) => Promise<CustomResponse<T>>,
15
- };
16
-
17
- // Default overridable methods
18
- type DefaultOverridableMethods<T> = {
19
- create: (param: Partial<T>) => Promise<CustomResponse<T>>,
20
- };
21
-
22
- // If OM contains any keys that overlap with DefaultOverridableMethods, those will take precedence
23
- // Example: Backend<MyType, { create: (data: MyType) => Promise<MyType> }>
24
- // will use the custom create method instead of the default one
25
- export type Backend<T = any, OM = OtherMethods<T>> = BaseMethods<T> &
26
- Omit<DefaultOverridableMethods<T>, keyof OM> &
27
- OM;
28
-
29
- export type BackendHook<T = any, A = any, OM = OtherMethods<T>> = (auth?: RequestorOptions['auth'], ...args: A[]) => Backend<T, OM>;
30
-
31
- export const useBackend = <T = any>(path: string, opts: Partial<{ auth: RequestorOptions['auth'] }> = {}): Backend<T> => {
32
- const requestor = new Requestor((globalThis as any).WBSUITE_CONFIG, undefined, opts);
33
- return {
34
- requestor,
35
- list: list.bind(this, requestor, path),
36
- get: get.bind(this, requestor, path),
37
- create: post.bind(this, requestor, path),
38
- update: put.bind(this, requestor, path),
39
- }
40
- };
@@ -1,6 +0,0 @@
1
- import { Requestor } from '../../models/Requestor';
2
-
3
- export const list = async (requestor: Requestor, path: string, filters: any = {}) => {
4
- const { data } = await requestor.makeRequest.get(`${path}?${new URLSearchParams(filters).toString()}`);
5
- return data;
6
- };
@@ -1,6 +0,0 @@
1
- import { Requestor } from '../../models/Requestor';
2
-
3
- export const post = async (requestor: Requestor, path: string, data: any) => {
4
- const { data: result } = await requestor.makeRequest.post(path, data);
5
- return result;
6
- };
@@ -1,6 +0,0 @@
1
- import { Requestor } from '../../models/Requestor';
2
-
3
- export const put = async (requestor: Requestor, path: string, resourceId: string, data: any) => {
4
- const { data: result } = await requestor.makeRequest.put(`${path}/${resourceId}`, data);
5
- return result;
6
- };
@@ -1,11 +0,0 @@
1
- import { BackendHook, useBackend } from '../useBackend';
2
- import { RequestorOptions } from 'models/Requestor';
3
-
4
- export const useCampaigns: BackendHook = (auth?: RequestorOptions['auth']) => {
5
- const { requestor, ...endpoints } = useBackend('campaigns', { auth });
6
- return {
7
- requestor,
8
- ...endpoints,
9
- delete: (id: string) => requestor.makeRequest.delete(`campaigns/${id}`).then(({ data }) => data)
10
- };
11
- };
@@ -1,7 +0,0 @@
1
- import { BackendHook, useBackend } from '../useBackend';
2
- import { RequestorOptions } from 'models/Requestor';
3
- import { ICategory } from '@wb/types/category/category.model'
4
-
5
- export const useCategories: BackendHook<ICategory> = (auth?: RequestorOptions['auth']) => {
6
- return useBackend('categories', { auth });
7
- };
@@ -1,13 +0,0 @@
1
- import { BackendHook, useBackend } from '../useBackend';
2
- import { Chat } from '@wb/types/chats/chats.model';
3
- import { RequestorOptions } from 'models/Requestor';
4
-
5
- export const useChats: BackendHook<Chat> = (auth?: RequestorOptions['auth']) => {
6
- const { requestor, ...endpoints } = useBackend('chats', { auth });
7
- return {
8
- requestor,
9
- ...endpoints,
10
- metadata: (chatId: string) =>
11
- requestor.makeRequest.get(`chats/${chatId}/metadata`).then(({ data }) => data),
12
- };
13
- };
@@ -1,28 +0,0 @@
1
-
2
- import { RequestorOptions } from 'models/Requestor';
3
- import { BackendHook, useBackend } from '../useBackend';
4
-
5
- export type ICustomer = Record<string, unknown>;
6
-
7
- export const useContactGroups: BackendHook<ICustomer> = (auth?: RequestorOptions['auth']) => {
8
- const { requestor, ...endpoints } = useBackend<ICustomer>('identities', { auth });
9
- return {
10
- requestor,
11
- ...endpoints,
12
- addIdentity: (groupId: string, identityId: string) => {
13
- return requestor.makeRequest.post(`contact-groups/${groupId}/identities`, { identityId }).then(({ data }) => data);
14
- },
15
- addIdentities: (groupId: string, identities: string[]) => {
16
- return requestor.makeRequest.post(`contact-groups/${groupId}/identities`, { identities }).then(({ data }) => data);
17
- },
18
- updateGroupIdentities: (groupId: string, identities: string[]) => {
19
- return requestor.makeRequest.post(`contact-groups/${groupId}/identities`, { identities }).then(({ data }) => data);
20
- },
21
- removeIdentity: (groupId: string, identityId: string) => {
22
- return requestor.makeRequest.delete(`contact-groups/${groupId}/identities/${identityId}`).then(({ data }) => data);
23
- },
24
- removeIdentities: (groupId: string, identities: string[]) => {
25
- return requestor.makeRequest.post(`contact-groups/${groupId}/identities/bulk/remove`, { identities }).then(({ data }) => data);
26
- },
27
- };
28
- };
@@ -1,21 +0,0 @@
1
-
2
- import { RequestorOptions } from 'models/Requestor';
3
- import { BackendHook, useBackend } from '../useBackend';
4
-
5
- export type ICustomer = Record<string, unknown>;
6
-
7
- export const useContacts: BackendHook<ICustomer> = (auth?: RequestorOptions['auth']) => {
8
- const { requestor, ...endpoints } = useBackend<ICustomer>('identities', { auth });
9
- return {
10
- requestor,
11
- ...endpoints,
12
- get: (id: string) =>
13
- requestor.makeRequest.get(`identities/${id}`).then(({ data }) => data),
14
- create: (data) =>
15
- requestor.makeRequest.post(`identities`, data).then(({ data }) => data),
16
- update: (id: any, data: any) =>
17
- requestor.makeRequest.put(`identities/${id}`, data).then(({ data }) => data),
18
- delete: (id: string) =>
19
- requestor.makeRequest.delete(`identities/${id}`).then(({ data }) => data),
20
- };
21
- };
@@ -1,14 +0,0 @@
1
- import { ICurrency } from '@wb/types/currency/currency.model';
2
- import { RequestorOptions } from 'models/Requestor';
3
- import { BackendHook, useBackend } from '../useBackend';
4
-
5
- export const useCurrencies: BackendHook<ICurrency> = (auth?: RequestorOptions['auth']) => {
6
- const { requestor, ...rest } = useBackend('currencies', { auth });
7
- return {
8
- ...rest,
9
- requestor,
10
- toggleStatus: (id: string) => {
11
- return requestor.makeRequest.put(`currencies/${id}/toggle-status`).then(({ data }) => data);
12
- },
13
- };
14
- };
@@ -1,21 +0,0 @@
1
-
2
- import { RequestorOptions } from 'models/Requestor';
3
- import { BackendHook, useBackend } from '../useBackend';
4
-
5
- export type ICustomer = Record<string, unknown>;
6
-
7
- export const useCustomers: BackendHook<ICustomer> = (auth?: RequestorOptions['auth']) => {
8
- const { requestor, ...endpoints } = useBackend<ICustomer>('customers', { auth });
9
- return {
10
- requestor,
11
- ...endpoints,
12
- get: (id: string) =>
13
- requestor.makeRequest.get(`customers/${id}`).then(({ data }) => data),
14
- create: (data) =>
15
- requestor.makeRequest.post(`customers`, data).then(({ data }) => data),
16
- update: (id: any, data: any) =>
17
- requestor.makeRequest.put(`customers/${id}`, data).then(({ data }) => data),
18
- delete: (id: string) =>
19
- requestor.makeRequest.delete(`customers/${id}`).then(({ data }) => data),
20
- };
21
- };
@@ -1,86 +0,0 @@
1
- import { CustomResponse } from '@wb/types/custom-response/custom-response.model';
2
- import { BackendHook, useBackend } from '../useBackend';
3
- import { IDocument } from '@wb/types/document/documents.model';
4
- import { RequestorOptions } from 'models/Requestor';
5
-
6
- const getPublicUrl = (document: any) =>
7
- document?.file?.filename ? `${(globalThis as any).WBSUITE_CONFIG?.publicURL}/${document.file.filename}` : '';
8
- const getDescription = (document: any, lang: string = 'es', defaultLang: string = 'es') =>
9
- document.description?.[lang] || document.description?.[defaultLang] || '';
10
- const getTitle = (document: any, lang: string = 'es', defaultLang: string = 'es') =>
11
- document.name?.[lang] || document.name?.[defaultLang] || '';
12
-
13
- export const useDocuments: BackendHook<
14
- IDocument,
15
- any,
16
- {
17
- create: (document: IDocument) => Promise<CustomResponse<IDocument>>;
18
- uploadFile: (id: string | undefined, file: File) => Promise<CustomResponse<any>>;
19
- getPublicUrl: (document: any, lang?: string, defaultLang?: string) => string | undefined;
20
- getDescription: (document: any, lang?: string, defaultLang?: string) => string | undefined;
21
- getTitle: (document: any, lang?: string, defaultLang?: string) => string | undefined;
22
- }
23
- > = (auth?: RequestorOptions['auth']) => {
24
- const { requestor, ...backend } = useBackend('documents', { auth });
25
- const uploadFile = (id: string | undefined, file: File, options?: { convertTo?: string, height?: number, width?: number }) => {
26
- const formData = new FormData();
27
- formData.append('document', file);
28
- if (options) {
29
- formData.append('convertTo', options.convertTo || '');
30
- formData.append('height', options.height?.toString() || '');
31
- formData.append('width', options.width?.toString() || '');
32
- }
33
- if (id) {
34
- return requestor.makeRequest
35
- .put<CustomResponse<IDocument>>(`/documents/upload/${id}`, formData, {
36
- headers: {
37
- 'Content-Type': 'multipart/form-data',
38
- },
39
- })
40
- .then((res) => res.data);
41
- } else {
42
- return requestor.makeRequest
43
- .post<CustomResponse<IDocument>>('/documents/upload', formData, {
44
- headers: {
45
- 'Content-Type': 'multipart/form-data',
46
- },
47
- })
48
- .then((res) => res.data);
49
- }
50
- };
51
- return {
52
- requestor,
53
- ...backend,
54
- create: async (document: IDocument) => {
55
- const { file, convertTo, height, width, ...rest } = document as any;
56
- const { data } = await uploadFile(undefined, file as any, { convertTo, height, width });
57
- return requestor.makeRequest
58
- .post<CustomResponse<IDocument>>('/documents', {
59
- ...rest,
60
- _id: data?._id,
61
- })
62
- .then((res) => res.data);
63
- },
64
- update: async (id: string, document: IDocument) => {
65
- const { file, convertTo, height, width, ...rest } = document as any;
66
- if (file) {
67
- await uploadFile(id, file as any, { convertTo, height, width });
68
- }
69
- return requestor.makeRequest
70
- .put<CustomResponse<IDocument>>(`/documents/${id}`, {
71
- ...rest,
72
- _id: id,
73
- })
74
- .then((res) => res.data);
75
- },
76
- uploadFile,
77
- getPublicUrl,
78
- getDescription,
79
- getTitle,
80
- delete: async (id: string) => {
81
- return requestor.makeRequest
82
- .delete<CustomResponse<IDocument>>(`/documents/${id}`)
83
- .then((res) => res.data);
84
- },
85
- };
86
- };
@@ -1,10 +0,0 @@
1
- import { RequestorOptions } from 'models/Requestor';
2
- import { BackendHook, useBackend } from '../useBackend';
3
-
4
- export const useDomains: BackendHook = (auth?: RequestorOptions['auth']) => {
5
- const { requestor, ...rest } = useBackend('domains', { auth });
6
- return {
7
- ...rest,
8
- requestor,
9
- };
10
- };
@@ -1,13 +0,0 @@
1
- import { RequestorOptions } from 'models/Requestor';
2
- import { BackendHook, useBackend } from '../useBackend';
3
-
4
- export const useEmailTemplates: BackendHook = (auth?: RequestorOptions['auth']) => {
5
- const { requestor, ...rest } = useBackend('user-email-templates', { auth });
6
- return {
7
- ...rest,
8
- requestor,
9
- duplicate: (templateId: string) => {
10
- return requestor.makeRequest.post(`user-email-templates/${templateId}/duplicate`).then(({ data }) => data);
11
- },
12
- };
13
- };
@@ -1,13 +0,0 @@
1
- import { RequestorOptions } from 'models/Requestor';
2
- import { BackendHook, useBackend } from '../useBackend';
3
-
4
- export const useEntityStatuses: BackendHook<any, any> = (auth?: RequestorOptions['auth']) => {
5
- const { requestor, ...rest } = useBackend('statuses', { auth });
6
- return {
7
- ...rest,
8
- requestor,
9
- getByEntity: (entity: string) => {
10
- return requestor.makeRequest.get(`statuses/entity/${entity}`).then((r: { data: any }) => r.data);
11
- },
12
- };
13
- };
@@ -1,16 +0,0 @@
1
- import { RequestorOptions } from 'models/Requestor';
2
- import { BackendHook, useBackend } from '../useBackend';
3
-
4
- export const useForms: BackendHook<
5
- Record<string, string>,
6
- undefined
7
- > = (auth?: RequestorOptions['auth']) => {
8
- const { requestor, ...rest } = useBackend('forms', { auth });
9
- return {
10
- ...rest,
11
- requestor,
12
- submit: (formId: string, data: any) => {
13
- return requestor.makeRequest.post(`form-submissions/${formId}`, data).then(({ data }) => data);
14
- }
15
- };
16
- };
@@ -1,15 +0,0 @@
1
- import { BackendHook, useBackend } from '../useBackend';
2
- import { RequestorOptions } from 'models/Requestor';
3
-
4
- export const useIntegrations: BackendHook = (auth?: RequestorOptions['auth']) => {
5
- const { requestor, ...endpoints } = useBackend('integrations', { auth });
6
- return {
7
- requestor,
8
- ...endpoints,
9
- authenticate: (integrationName: string, config?: Record<string, any>) => {
10
- return requestor.makeRequest
11
- .get(`integrations/${integrationName}/auth`, { params: config })
12
- .then(({ data }) => data);
13
- },
14
- };
15
- };
@@ -1,19 +0,0 @@
1
- import { RequestorOptions } from 'models/Requestor';
2
- import { BackendHook, useBackend } from '../useBackend';
3
-
4
- export const useInvites: BackendHook<any> = (auth?: RequestorOptions['auth']) => {
5
- const { requestor, ...endpoints } = useBackend<any>('invites', { auth });
6
- return {
7
- requestor,
8
- ...endpoints,
9
- validate: (invite: string) => {
10
- return requestor.makeRequest.post(`invites/validate`, { invite }).then(({ data }) => data);
11
- },
12
- accept: (invite: string) => {
13
- return requestor.makeRequest.post(`invites/accept`, { invite }).then(({ data }) => data);
14
- },
15
- reject: (invite: string) => {
16
- return requestor.makeRequest.post(`invites/reject`, { invite }).then(({ data }) => data);
17
- }
18
- };
19
- };
@@ -1,13 +0,0 @@
1
-
2
- import { RequestorOptions } from 'models/Requestor';
3
- import { BackendHook, useBackend } from '../useBackend';
4
-
5
- export type ILabel = Record<string, unknown>;
6
-
7
- export const useLabels: BackendHook<ILabel> = (auth?: RequestorOptions['auth']) => {
8
- const { requestor, ...endpoints } = useBackend<ILabel>('labels', { auth });
9
- return {
10
- requestor,
11
- ...endpoints,
12
- };
13
- };
@@ -1,16 +0,0 @@
1
- import { RequestorOptions } from 'models/Requestor';
2
- import { BackendHook, useBackend } from '../useBackend';
3
- import { ILang } from '@wb/types/lang/lang.model';
4
-
5
- export const useLanguages: BackendHook<ILang, any, { getProductLanguages: () => Promise<ILang[]> }> = (auth?: RequestorOptions['auth']) => {
6
- const { requestor, ...rest } = useBackend('languages', { auth });
7
- return {
8
- ...rest,
9
- requestor,
10
- getProductLanguages: () => {
11
- return requestor.makeRequest
12
- .get(`languages/product`)
13
- .then(({ data }) => data);
14
- },
15
- };
16
- };
@@ -1,149 +0,0 @@
1
- import { BackendHook, useBackend } from '../useBackend';
2
- import { RequestorOptions } from 'models/Requestor';
3
-
4
- export type LeadStatus = 'new' | 'contacted' | 'closed' | 'bad' | 'lost';
5
- export enum LeadGradeValues {
6
- BAD = -1,
7
- NEUTRAL = 0,
8
- GOOD = 1,
9
- }
10
-
11
- export const useLeads: BackendHook<
12
- any,
13
- any,
14
- {
15
- createLead: (campaignId: string, lead: any) => Promise<any>;
16
- getLeadSummary: (filter: Record<string, unknown>) => Promise<any>;
17
- getAvailableAsignees: (leadId: string) => Promise<any>;
18
- assign: (leadId: string, userId: string) => Promise<any>;
19
- archive: (leadId: string) => Promise<any>;
20
- addLog: (leadId: string, log: { text: string; extra?: Record<string, unknown> }) => Promise<any>;
21
- logHistory: (leadId: string, limit?: number) => Promise<any>;
22
- assignmentHistory: (leadId: string, limit?: number) => Promise<any>;
23
- actionHistory: (leadId: string, limit?: number) => Promise<any>;
24
- commentsHistory: (leadId: string, limit?: number) => Promise<any>;
25
- addAction: (leadId: string, action: Record<string, unknown>) => Promise<any>;
26
- editAction: (leadId: string, actionId: string, action: Record<string, unknown>) => Promise<any>;
27
- deleteAction: (leadId: string, actionId: string) => Promise<any>;
28
- completeAction: (leadId: string, actionId: string, completed: boolean) => Promise<any>;
29
- grade: (leadId: string, grade: { assessment: LeadGradeValues; description?: string }) => Promise<any>;
30
- }
31
- > = (auth?: RequestorOptions['auth']) => {
32
- const { requestor, ...endpoints } = useBackend(`leads`, { auth });
33
-
34
- return {
35
- requestor,
36
- ...endpoints,
37
- createLead: (campaignId: string, lead: any) => {
38
- return requestor.makeRequest.post(`leads/${campaignId}`, lead).then((r: { data: any }) => r.data);
39
- },
40
- getLeadSummary: (filter: Record<string, unknown> = {}) => {
41
- return requestor.makeRequest.get('leads/summary', { params: filter }).then((r: { data: any }) => r.data);
42
- },
43
- getAvailableAsignees: (leadId: string) => {
44
- return requestor.makeRequest.get(`leads/${leadId}/available-assignees`).then((r: { data: any }) => r.data);
45
- },
46
- assign: (leadId: string, userId: string) => {
47
- return requestor.makeRequest.post(`leads/${leadId}/assign/${userId}`, {}).then((r: { data: any }) => r.data);
48
- },
49
- manualAssign: (leadId: string, userId: string) => {
50
- return requestor.makeRequest.post(`leads/${leadId}/assign/manual/${userId}`, {}).then((r: { data: any }) => r.data);
51
- },
52
- archive: (leadId: string) => {
53
- return requestor.makeRequest.post(`leads/${leadId}/archive`).then((r: { data: any }) => r.data);
54
- },
55
- addLog: (leadId: string, log: { text: string; extra?: Record<string, unknown> }) => {
56
- return requestor.makeRequest.post(`leads/${leadId}/log`, log).then((r) => r.data);
57
- },
58
- logHistory: (leadId: string, limit?: number) => {
59
- return requestor.makeRequest.get(`leads/${leadId}/log/history`, { params: { limit } }).then((r) => r.data);
60
- },
61
- assignmentHistory: (leadId: string, limit?: number) => {
62
- return requestor.makeRequest.get(`leads/${leadId}/assignment/history`, { params: { limit } }).then((r) => r.data);
63
- },
64
- actionHistory: (leadId: string, limit?: number) => {
65
- return requestor.makeRequest.get(`leads/${leadId}/action/history`, { params: { limit } }).then((r) => r.data);
66
- },
67
- commentsHistory: (leadId: string, limit?: number) => {
68
- return requestor.makeRequest.get(`leads/${leadId}/comment/history`, { params: { limit } }).then((r) => r.data);
69
- },
70
- addAction: (leadId: string, action: Record<string, unknown>) => {
71
- return requestor.makeRequest.post(`leads/${leadId}/action`, action).then((r: { data: any }) => r.data);
72
- },
73
- editAction: (leadId: string, actionId: string, action: Record<string, unknown>) => {
74
- return requestor.makeRequest.put(`leads/${leadId}/action/${actionId}`, action).then((r: { data: any }) => r.data);
75
- },
76
- deleteAction: (leadId: string, actionId: string) => {
77
- return requestor.makeRequest.delete(`leads/${leadId}/action/${actionId}`).then((r: { data: any }) => r.data);
78
- },
79
- completeAction: (leadId: string, actionId: string, completed: boolean) => {
80
- return requestor.makeRequest
81
- .post(`leads/${leadId}/action/${actionId}/complete`, {
82
- completed,
83
- })
84
- .then((r: { data: any }) => r.data);
85
- },
86
- grade: (
87
- leadId: string,
88
- grade: {
89
- assessment: (typeof LeadGradeValues)[keyof typeof LeadGradeValues];
90
- description?: string;
91
- }
92
- ) => {
93
- return requestor.makeRequest.post(`leads/${leadId}/grade`, { ...grade }).then((r: { data: any }) => r.data);
94
- },
95
- createQuote: (leadId: string, quote: Record<string, unknown>) => {
96
- return requestor.makeRequest.post(`leads/${leadId}/quote`, quote).then((r: { data: any }) => r.data);
97
- },
98
- createManualQuote: (leadId: string, quote: Record<string, unknown>) => {
99
- return requestor.makeRequest.post(`leads/${leadId}/quote/manual`, quote).then((r: { data: any }) => r.data);
100
- },
101
- acceptQuote: (leadId: string, quoteId: string) => {
102
- return requestor.makeRequest.post(`leads/${leadId}/quote/${quoteId}/accept`).then((r: { data: any }) => r.data);
103
- },
104
- linkToCustomer: (leadId: string, customerId: string) => {
105
- return requestor.makeRequest
106
- .post(`leads/${leadId}/link/customer/${customerId}`)
107
- .then((r: { data: any }) => r.data);
108
- },
109
- changeLeadStatus: (leadId: string, request: { newStatus: string; reason?: string }) => {
110
- return requestor.makeRequest.put(`leads/${leadId}/status`, request).then((r) => r.data);
111
- },
112
- closeLead: (leadId: string, request: { reason?: string }) => {
113
- return requestor.makeRequest.post(`leads/${leadId}/close`, request).then((r) => r.data);
114
- },
115
- cancelLead: (leadId: string, request: { reason?: string }) => {
116
- return requestor.makeRequest.post(`leads/${leadId}/cancel`, request).then((r) => r.data);
117
- },
118
- reevaluateLeadStatus: (leadId: string) => {
119
- return requestor.makeRequest.post(`leads/${leadId}/reevaluate/status`).then((r) => r.data);
120
- },
121
- relocate: (leadId: string, { campaign, store }: { campaign?: string; store?: string }) => {
122
- return requestor.makeRequest.put(`leads/${leadId}/relocate`, { campaign, store }).then((r) => r.data);
123
- },
124
- unassign: (leadId: string) => {
125
- return requestor.makeRequest.post(`leads/${leadId}/unassign`).then((r) => r.data);
126
- },
127
- updateStore: (leadId: string, storeId: string) => {
128
- return requestor.makeRequest.put(`leads/${leadId}/store/${storeId}`).then((r) => r.data);
129
- },
130
- bulkUpdateStore: (leadIds: string[], storeId: string) => {
131
- return requestor.makeRequest.put(`leads/bulk/store/${storeId}`, { leadIds }).then((r) => r.data);
132
- },
133
- updateRotation: (leadId: string, rotationId: string) => {
134
- return requestor.makeRequest.put(`leads/${leadId}/rotation/${rotationId}`).then((r) => r.data);
135
- },
136
- bulkUpdateRotation: (leadIds: string[], rotationId: string) => {
137
- return requestor.makeRequest.put(`leads/bulk/rotation/${rotationId}`, { leadIds }).then((r) => r.data);
138
- },
139
- bulkAssign: (leadIds: string[], userId: string) => {
140
- return requestor.makeRequest.put(`leads/bulk/assign/${userId}`, { leadIds }).then((r) => r.data);
141
- },
142
- bulkClose: (leadIds: string[], reason?: string) => {
143
- return requestor.makeRequest.put(`leads/bulk/close`, { leadIds, reason }).then((r) => r.data);
144
- },
145
- getReport: (filters: Record<string, unknown>, options: Partial<{ sendEmail: boolean, email: string; format: 'csv' | 'xlsx' }> = {}) => {
146
- return requestor.makeRequest.post(`leads/report/request`, { filters, options }).then((r) => r.data);
147
- },
148
- };
149
- };
@@ -1,13 +0,0 @@
1
- import { RequestorOptions } from 'models/Requestor';
2
- import { BackendHook, useBackend } from '../useBackend';
3
-
4
- export const useMedia: BackendHook<any, any> = (auth?: RequestorOptions['auth']) => {
5
- const { requestor, ...rest } = useBackend('media', { auth });
6
- return {
7
- ...rest,
8
- requestor,
9
- getShareableLink: (entity: string, entityId: string) => {
10
- return requestor.makeRequest.post(`media/share`, { entity, entityId }).then((r: { data: any }) => r.data);
11
- },
12
- };
13
- };