@wbsuite/react-hooks 1.0.211 → 1.0.212

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 (304) hide show
  1. package/README.md +66 -0
  2. package/docs/USAGE.md +107 -0
  3. package/eslint.config.js +12 -0
  4. package/package.json +1 -1
  5. package/src/hooks/useAgents/index.ts +10 -0
  6. package/src/hooks/useApps/index.ts +10 -0
  7. package/src/hooks/useArticles/index.ts +18 -0
  8. package/src/hooks/useAttributes/index.ts +18 -0
  9. package/src/hooks/useAttributesGroups/index.ts +17 -0
  10. package/src/hooks/useAutomations/index.ts +10 -0
  11. package/src/hooks/useBackend/get.ts +6 -0
  12. package/src/hooks/useBackend/index.ts +40 -0
  13. package/src/hooks/useBackend/list.ts +6 -0
  14. package/src/hooks/useBackend/post.ts +6 -0
  15. package/src/hooks/useBackend/put.ts +6 -0
  16. package/src/hooks/useCampaigns/index.ts +11 -0
  17. package/src/hooks/useCategories/index.ts +7 -0
  18. package/src/hooks/useChats/index.ts +13 -0
  19. package/src/hooks/useContactGroups/index.ts +28 -0
  20. package/src/hooks/useContacts/index.ts +21 -0
  21. package/src/hooks/useCurrencies/index.ts +14 -0
  22. package/src/hooks/useCustomers/index.ts +21 -0
  23. package/src/hooks/useDocuments/index.ts +86 -0
  24. package/src/hooks/useDomains/index.ts +10 -0
  25. package/src/hooks/useEmailTemplates/index.ts +13 -0
  26. package/src/hooks/useEntityStatuses/index.ts +13 -0
  27. package/src/hooks/useFormSubmissions/index.ts +6 -0
  28. package/src/hooks/useForms/index.ts +16 -0
  29. package/src/hooks/useIntegrations/index.ts +15 -0
  30. package/src/hooks/useInvites/index.ts +19 -0
  31. package/src/hooks/useLabels/index.ts +13 -0
  32. package/src/hooks/useLanguages/index.ts +16 -0
  33. package/src/hooks/useLeads/index.ts +149 -0
  34. package/src/hooks/useMedia/index.ts +13 -0
  35. package/src/hooks/useOrders/index.ts +74 -0
  36. package/src/hooks/usePaths/index.ts +16 -0
  37. package/src/hooks/usePermissions/index.ts +16 -0
  38. package/src/hooks/useProducts/index.ts +18 -0
  39. package/src/hooks/useProfile/index.ts +20 -0
  40. package/src/hooks/useRenting/index.ts +57 -0
  41. package/src/hooks/useRoles/index.ts +10 -0
  42. package/src/hooks/useRoom/index.ts +20 -0
  43. package/src/hooks/useRotations/index.ts +13 -0
  44. package/src/hooks/useSiteConfig/index.ts +13 -0
  45. package/src/hooks/useStatuses/index.ts +10 -0
  46. package/src/hooks/useStock/index.ts +48 -0
  47. package/src/hooks/useStores/index.ts +23 -0
  48. package/src/hooks/useSubscriptions/index.ts +17 -0
  49. package/src/hooks/useTable/index.ts +15 -0
  50. package/src/hooks/useTeams/index.ts +29 -0
  51. package/src/hooks/useTickets/index.ts +17 -0
  52. package/src/hooks/useTransactions/index.ts +43 -0
  53. package/src/hooks/useTranslations/index.ts +20 -0
  54. package/src/hooks/useUserConnections/index.ts +18 -0
  55. package/src/hooks/useUserSubscriptions/index.ts +28 -0
  56. package/src/hooks/useUsers/index.ts +57 -0
  57. package/src/hooks/useWBSuite/index.ts +29 -0
  58. package/src/hooks/useWebsites/index.ts +34 -0
  59. package/{esm/index.d.ts → src/index.ts} +2 -1
  60. package/src/models/Requestor.ts +67 -0
  61. package/{cjs/next/utils/index.d.ts → src/next/utils/index.ts} +1 -1
  62. package/src/next/utils/wrapAsync.ts +2 -0
  63. package/src/utils/authWithApiKey.ts +3 -0
  64. package/src/utils/authWithToken.ts +3 -0
  65. package/src/utils/index.ts +7 -0
  66. package/tsconfig.json +20 -0
  67. package/cjs/hooks/useAgents/index.d.ts +0 -2
  68. package/cjs/hooks/useAgents/index.js +0 -32
  69. package/cjs/hooks/useApps/index.d.ts +0 -2
  70. package/cjs/hooks/useApps/index.js +0 -32
  71. package/cjs/hooks/useArticles/index.d.ts +0 -5
  72. package/cjs/hooks/useArticles/index.js +0 -45
  73. package/cjs/hooks/useAttributes/index.d.ts +0 -2
  74. package/cjs/hooks/useAttributes/index.js +0 -52
  75. package/cjs/hooks/useAttributesGroups/index.d.ts +0 -3
  76. package/cjs/hooks/useAttributesGroups/index.js +0 -47
  77. package/cjs/hooks/useAutomations/index.d.ts +0 -2
  78. package/cjs/hooks/useAutomations/index.js +0 -32
  79. package/cjs/hooks/useBackend/get.d.ts +0 -2
  80. package/cjs/hooks/useBackend/get.js +0 -52
  81. package/cjs/hooks/useBackend/index.d.ts +0 -17
  82. package/cjs/hooks/useBackend/index.js +0 -22
  83. package/cjs/hooks/useBackend/list.d.ts +0 -2
  84. package/cjs/hooks/useBackend/list.js +0 -55
  85. package/cjs/hooks/useBackend/post.d.ts +0 -2
  86. package/cjs/hooks/useBackend/post.js +0 -52
  87. package/cjs/hooks/useBackend/put.d.ts +0 -2
  88. package/cjs/hooks/useBackend/put.js +0 -52
  89. package/cjs/hooks/useCampaigns/index.d.ts +0 -2
  90. package/cjs/hooks/useCampaigns/index.js +0 -35
  91. package/cjs/hooks/useCategories/index.d.ts +0 -3
  92. package/cjs/hooks/useCategories/index.js +0 -9
  93. package/cjs/hooks/useChats/index.d.ts +0 -3
  94. package/cjs/hooks/useChats/index.js +0 -37
  95. package/cjs/hooks/useContactGroups/index.d.ts +0 -3
  96. package/cjs/hooks/useContactGroups/index.js +0 -57
  97. package/cjs/hooks/useContacts/index.d.ts +0 -3
  98. package/cjs/hooks/useContacts/index.js +0 -52
  99. package/cjs/hooks/useCurrencies/index.d.ts +0 -3
  100. package/cjs/hooks/useCurrencies/index.js +0 -37
  101. package/cjs/hooks/useCustomers/index.d.ts +0 -3
  102. package/cjs/hooks/useCustomers/index.js +0 -52
  103. package/cjs/hooks/useDocuments/index.d.ts +0 -10
  104. package/cjs/hooks/useDocuments/index.js +0 -145
  105. package/cjs/hooks/useDomains/index.d.ts +0 -2
  106. package/cjs/hooks/useDomains/index.js +0 -32
  107. package/cjs/hooks/useEmailTemplates/index.d.ts +0 -2
  108. package/cjs/hooks/useEmailTemplates/index.js +0 -37
  109. package/cjs/hooks/useEntityStatuses/index.d.ts +0 -2
  110. package/cjs/hooks/useEntityStatuses/index.js +0 -34
  111. package/cjs/hooks/useForms/index.d.ts +0 -2
  112. package/cjs/hooks/useForms/index.js +0 -37
  113. package/cjs/hooks/useIntegrations/index.d.ts +0 -2
  114. package/cjs/hooks/useIntegrations/index.js +0 -39
  115. package/cjs/hooks/useInvites/index.d.ts +0 -2
  116. package/cjs/hooks/useInvites/index.js +0 -47
  117. package/cjs/hooks/useLabels/index.d.ts +0 -3
  118. package/cjs/hooks/useLabels/index.js +0 -32
  119. package/cjs/hooks/useLanguages/index.d.ts +0 -5
  120. package/cjs/hooks/useLanguages/index.js +0 -39
  121. package/cjs/hooks/useLeads/index.d.ts +0 -30
  122. package/cjs/hooks/useLeads/index.js +0 -113
  123. package/cjs/hooks/useMedia/index.d.ts +0 -2
  124. package/cjs/hooks/useMedia/index.js +0 -34
  125. package/cjs/hooks/useOrders/index.d.ts +0 -2
  126. package/cjs/hooks/useOrders/index.js +0 -76
  127. package/cjs/hooks/usePaths/index.d.ts +0 -2
  128. package/cjs/hooks/usePaths/index.js +0 -37
  129. package/cjs/hooks/usePermissions/index.d.ts +0 -2
  130. package/cjs/hooks/usePermissions/index.js +0 -47
  131. package/cjs/hooks/useProducts/index.d.ts +0 -2
  132. package/cjs/hooks/useProducts/index.js +0 -52
  133. package/cjs/hooks/useProfile/index.d.ts +0 -3
  134. package/cjs/hooks/useProfile/index.js +0 -57
  135. package/cjs/hooks/useRenting/index.d.ts +0 -47
  136. package/cjs/hooks/useRenting/index.js +0 -52
  137. package/cjs/hooks/useRoles/index.d.ts +0 -2
  138. package/cjs/hooks/useRoles/index.js +0 -32
  139. package/cjs/hooks/useRoom/index.d.ts +0 -3
  140. package/cjs/hooks/useRoom/index.js +0 -55
  141. package/cjs/hooks/useRotations/index.d.ts +0 -2
  142. package/cjs/hooks/useRotations/index.js +0 -37
  143. package/cjs/hooks/useSiteConfig/index.d.ts +0 -5
  144. package/cjs/hooks/useSiteConfig/index.js +0 -33
  145. package/cjs/hooks/useStatuses/index.d.ts +0 -2
  146. package/cjs/hooks/useStatuses/index.js +0 -32
  147. package/cjs/hooks/useStock/index.d.ts +0 -20
  148. package/cjs/hooks/useStock/index.js +0 -51
  149. package/cjs/hooks/useStores/index.d.ts +0 -3
  150. package/cjs/hooks/useStores/index.js +0 -62
  151. package/cjs/hooks/useSubscriptions/index.d.ts +0 -2
  152. package/cjs/hooks/useSubscriptions/index.js +0 -37
  153. package/cjs/hooks/useTable/index.d.ts +0 -3
  154. package/cjs/hooks/useTable/index.js +0 -34
  155. package/cjs/hooks/useTeams/index.d.ts +0 -5
  156. package/cjs/hooks/useTeams/index.js +0 -52
  157. package/cjs/hooks/useTickets/index.d.ts +0 -3
  158. package/cjs/hooks/useTickets/index.js +0 -47
  159. package/cjs/hooks/useTransactions/index.d.ts +0 -8
  160. package/cjs/hooks/useTransactions/index.js +0 -61
  161. package/cjs/hooks/useTranslations/index.d.ts +0 -5
  162. package/cjs/hooks/useTranslations/index.js +0 -42
  163. package/cjs/hooks/useUserConnections/index.d.ts +0 -2
  164. package/cjs/hooks/useUserConnections/index.js +0 -53
  165. package/cjs/hooks/useUserSubscriptions/index.d.ts +0 -6
  166. package/cjs/hooks/useUserSubscriptions/index.js +0 -47
  167. package/cjs/hooks/useUsers/index.d.ts +0 -17
  168. package/cjs/hooks/useUsers/index.js +0 -141
  169. package/cjs/hooks/useWBSuite/index.d.ts +0 -2
  170. package/cjs/hooks/useWBSuite/index.js +0 -39
  171. package/cjs/hooks/useWebsites/index.d.ts +0 -2
  172. package/cjs/hooks/useWebsites/index.js +0 -72
  173. package/cjs/index.d.ts +0 -50
  174. package/cjs/index.js +0 -117
  175. package/cjs/models/Requestor.d.ts +0 -24
  176. package/cjs/models/Requestor.js +0 -53
  177. package/cjs/next/utils/index.js +0 -6
  178. package/cjs/next/utils/wrapAsync.d.ts +0 -1
  179. package/cjs/next/utils/wrapAsync.js +0 -54
  180. package/cjs/utils/authWithApiKey.d.ts +0 -4
  181. package/cjs/utils/authWithApiKey.js +0 -8
  182. package/cjs/utils/authWithToken.d.ts +0 -4
  183. package/cjs/utils/authWithToken.js +0 -8
  184. package/cjs/utils/index.d.ts +0 -11
  185. package/cjs/utils/index.js +0 -19
  186. package/esm/hooks/useAgents/index.d.ts +0 -2
  187. package/esm/hooks/useAgents/index.js +0 -28
  188. package/esm/hooks/useApps/index.d.ts +0 -2
  189. package/esm/hooks/useApps/index.js +0 -28
  190. package/esm/hooks/useArticles/index.d.ts +0 -5
  191. package/esm/hooks/useArticles/index.js +0 -40
  192. package/esm/hooks/useAttributes/index.d.ts +0 -2
  193. package/esm/hooks/useAttributes/index.js +0 -48
  194. package/esm/hooks/useAttributesGroups/index.d.ts +0 -3
  195. package/esm/hooks/useAttributesGroups/index.js +0 -43
  196. package/esm/hooks/useAutomations/index.d.ts +0 -2
  197. package/esm/hooks/useAutomations/index.js +0 -28
  198. package/esm/hooks/useBackend/get.d.ts +0 -2
  199. package/esm/hooks/useBackend/get.js +0 -48
  200. package/esm/hooks/useBackend/index.d.ts +0 -17
  201. package/esm/hooks/useBackend/index.js +0 -18
  202. package/esm/hooks/useBackend/list.d.ts +0 -2
  203. package/esm/hooks/useBackend/list.js +0 -51
  204. package/esm/hooks/useBackend/post.d.ts +0 -2
  205. package/esm/hooks/useBackend/post.js +0 -48
  206. package/esm/hooks/useBackend/put.d.ts +0 -2
  207. package/esm/hooks/useBackend/put.js +0 -48
  208. package/esm/hooks/useCampaigns/index.d.ts +0 -2
  209. package/esm/hooks/useCampaigns/index.js +0 -31
  210. package/esm/hooks/useCategories/index.d.ts +0 -3
  211. package/esm/hooks/useCategories/index.js +0 -5
  212. package/esm/hooks/useChats/index.d.ts +0 -3
  213. package/esm/hooks/useChats/index.js +0 -33
  214. package/esm/hooks/useContactGroups/index.d.ts +0 -3
  215. package/esm/hooks/useContactGroups/index.js +0 -53
  216. package/esm/hooks/useContacts/index.d.ts +0 -3
  217. package/esm/hooks/useContacts/index.js +0 -48
  218. package/esm/hooks/useCurrencies/index.d.ts +0 -3
  219. package/esm/hooks/useCurrencies/index.js +0 -33
  220. package/esm/hooks/useCustomers/index.d.ts +0 -3
  221. package/esm/hooks/useCustomers/index.js +0 -48
  222. package/esm/hooks/useDocuments/index.d.ts +0 -10
  223. package/esm/hooks/useDocuments/index.js +0 -141
  224. package/esm/hooks/useDomains/index.d.ts +0 -2
  225. package/esm/hooks/useDomains/index.js +0 -28
  226. package/esm/hooks/useEmailTemplates/index.d.ts +0 -2
  227. package/esm/hooks/useEmailTemplates/index.js +0 -33
  228. package/esm/hooks/useEntityStatuses/index.d.ts +0 -2
  229. package/esm/hooks/useEntityStatuses/index.js +0 -30
  230. package/esm/hooks/useForms/index.d.ts +0 -2
  231. package/esm/hooks/useForms/index.js +0 -33
  232. package/esm/hooks/useIntegrations/index.d.ts +0 -2
  233. package/esm/hooks/useIntegrations/index.js +0 -35
  234. package/esm/hooks/useInvites/index.d.ts +0 -2
  235. package/esm/hooks/useInvites/index.js +0 -43
  236. package/esm/hooks/useLabels/index.d.ts +0 -3
  237. package/esm/hooks/useLabels/index.js +0 -28
  238. package/esm/hooks/useLanguages/index.d.ts +0 -5
  239. package/esm/hooks/useLanguages/index.js +0 -35
  240. package/esm/hooks/useLeads/index.d.ts +0 -30
  241. package/esm/hooks/useLeads/index.js +0 -109
  242. package/esm/hooks/useMedia/index.d.ts +0 -2
  243. package/esm/hooks/useMedia/index.js +0 -30
  244. package/esm/hooks/useOrders/index.d.ts +0 -2
  245. package/esm/hooks/useOrders/index.js +0 -72
  246. package/esm/hooks/usePaths/index.d.ts +0 -2
  247. package/esm/hooks/usePaths/index.js +0 -33
  248. package/esm/hooks/usePermissions/index.d.ts +0 -2
  249. package/esm/hooks/usePermissions/index.js +0 -43
  250. package/esm/hooks/useProducts/index.d.ts +0 -2
  251. package/esm/hooks/useProducts/index.js +0 -48
  252. package/esm/hooks/useProfile/index.d.ts +0 -3
  253. package/esm/hooks/useProfile/index.js +0 -53
  254. package/esm/hooks/useRenting/index.d.ts +0 -47
  255. package/esm/hooks/useRenting/index.js +0 -48
  256. package/esm/hooks/useRoles/index.d.ts +0 -2
  257. package/esm/hooks/useRoles/index.js +0 -28
  258. package/esm/hooks/useRoom/index.d.ts +0 -3
  259. package/esm/hooks/useRoom/index.js +0 -51
  260. package/esm/hooks/useRotations/index.d.ts +0 -2
  261. package/esm/hooks/useRotations/index.js +0 -33
  262. package/esm/hooks/useSiteConfig/index.d.ts +0 -5
  263. package/esm/hooks/useSiteConfig/index.js +0 -29
  264. package/esm/hooks/useStatuses/index.d.ts +0 -2
  265. package/esm/hooks/useStatuses/index.js +0 -28
  266. package/esm/hooks/useStock/index.d.ts +0 -20
  267. package/esm/hooks/useStock/index.js +0 -47
  268. package/esm/hooks/useStores/index.d.ts +0 -3
  269. package/esm/hooks/useStores/index.js +0 -58
  270. package/esm/hooks/useSubscriptions/index.d.ts +0 -2
  271. package/esm/hooks/useSubscriptions/index.js +0 -33
  272. package/esm/hooks/useTable/index.d.ts +0 -3
  273. package/esm/hooks/useTable/index.js +0 -30
  274. package/esm/hooks/useTeams/index.d.ts +0 -5
  275. package/esm/hooks/useTeams/index.js +0 -48
  276. package/esm/hooks/useTickets/index.d.ts +0 -3
  277. package/esm/hooks/useTickets/index.js +0 -43
  278. package/esm/hooks/useTransactions/index.d.ts +0 -8
  279. package/esm/hooks/useTransactions/index.js +0 -57
  280. package/esm/hooks/useTranslations/index.d.ts +0 -5
  281. package/esm/hooks/useTranslations/index.js +0 -38
  282. package/esm/hooks/useUserConnections/index.d.ts +0 -2
  283. package/esm/hooks/useUserConnections/index.js +0 -49
  284. package/esm/hooks/useUserSubscriptions/index.d.ts +0 -6
  285. package/esm/hooks/useUserSubscriptions/index.js +0 -43
  286. package/esm/hooks/useUsers/index.d.ts +0 -17
  287. package/esm/hooks/useUsers/index.js +0 -137
  288. package/esm/hooks/useWBSuite/index.d.ts +0 -2
  289. package/esm/hooks/useWBSuite/index.js +0 -35
  290. package/esm/hooks/useWebsites/index.d.ts +0 -2
  291. package/esm/hooks/useWebsites/index.js +0 -68
  292. package/esm/index.js +0 -51
  293. package/esm/models/Requestor.d.ts +0 -24
  294. package/esm/models/Requestor.js +0 -47
  295. package/esm/next/utils/index.d.ts +0 -2
  296. package/esm/next/utils/index.js +0 -3
  297. package/esm/next/utils/wrapAsync.d.ts +0 -1
  298. package/esm/next/utils/wrapAsync.js +0 -50
  299. package/esm/utils/authWithApiKey.d.ts +0 -4
  300. package/esm/utils/authWithApiKey.js +0 -4
  301. package/esm/utils/authWithToken.d.ts +0 -4
  302. package/esm/utils/authWithToken.js +0 -4
  303. package/esm/utils/index.d.ts +0 -11
  304. package/esm/utils/index.js +0 -3
package/README.md ADDED
@@ -0,0 +1,66 @@
1
+ ## Installing wbsuite react hooks library
2
+ 1. Install dependency in your proyect by running `npm i @wbsuite/react-hooks`
3
+
4
+ ## How to use
5
+ 1. Set up wbsuite by running the `useWBSuite` hook with the api key you were given.
6
+
7
+ ```
8
+ function App() {
9
+ useWBSuite({ apiKey: '<your-api-key>' });
10
+ return <></>
11
+ }
12
+ ```
13
+
14
+ 2. You're ready to start using the hooks you need. This library version contains:
15
+ - useStores -- lists available stores for your team
16
+ - useProducts -- lists products available for your team
17
+ - useCategories -- lists categories available for your team
18
+ - useRenting -- renting utils
19
+ - useDocuments -- document / images utils
20
+ - useLeads -- create leads for your campaigns
21
+
22
+ ### useCategories
23
+ This hook is used to list, get or create categories. In order to use it consider:
24
+
25
+ ```
26
+ const { list: listCategories } = useCategories();
27
+
28
+ useEffect(() => {
29
+ listCategories().then(categoryList => {
30
+ // Do what you need with the categoryList
31
+ });
32
+ }, []);
33
+ ```
34
+
35
+ ### useProducts
36
+ This hook is used to list, get or create products. In order to use it consider:
37
+
38
+ ```
39
+ const { list: listProducts } = useProducts();
40
+
41
+ useEffect(() => {
42
+ /** filters needs to be an object with any valid property of the product schema.
43
+ * for example to get the products from a category you need to pass in an object like:
44
+ * { categories: <categoryId>[] }
45
+ *
46
+ * { categories: ['some-category-id', 'other-category-id'] }
47
+ *
48
+ * The categoryId can be retrieved from the useCategories hook explained above.
49
+ **/
50
+ listProducts(filters ?? {}).then(filteredProductList => {
51
+ // Do what you need with the filteredProductList
52
+ });
53
+ }, []);
54
+ ```
55
+
56
+ ## Permissions
57
+ Even if the hooks are available in the library the `apiKey` limits the permissions you have
58
+ access to.
59
+
60
+ Which means, that you won't be able to use all of our features unless you were given access to.
61
+
62
+ If, you find yourself in need of using a non-accessible util, please reach out to the provider.
63
+
64
+ ## Additional documentation
65
+
66
+ For a complete walkthrough that covers configuration, authentication, available hooks, and extended examples, see [`docs/USAGE.md`](docs/USAGE.md).
package/docs/USAGE.md ADDED
@@ -0,0 +1,107 @@
1
+ # Using the `@wbsuite/react-hooks` library
2
+
3
+ This guide walks through installing the package, configuring the WBSuite client, and using the provided hooks to call the API.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @wbsuite/react-hooks
9
+ ```
10
+
11
+ ## Configure WBSuite once
12
+
13
+ Initialize the client near the root of your app (for example in `_app.tsx` or your main layout component):
14
+
15
+ ```tsx
16
+ import { useWBSuite } from '@wbsuite/react-hooks';
17
+
18
+ function App() {
19
+ useWBSuite({
20
+ apiKey: '<your-api-key>',
21
+ // optional overrides:
22
+ // apiURL: 'https://api.wbsuite.app/api/v2',
23
+ // publicURL: 'https://api.wbsuite.app/public',
24
+ // environment: 'development',
25
+ });
26
+ return <YourRoutes />;
27
+ }
28
+ ```
29
+
30
+ - The first call stores the configuration globally; subsequent calls no-op and log a warning so you only need to run it once during app bootstrap.
31
+ - `apiURL` and `publicURL` default to the hosted endpoints shown above.
32
+ - Setting `environment: 'development'` enables verbose request/response logging for troubleshooting.
33
+
34
+ ## Authenticating requests
35
+
36
+ Most hooks accept an optional `auth` argument so you can decide per call how to authenticate:
37
+
38
+ ```tsx
39
+ const products = useProducts({ type: 'apiKey', apiKey: '<key>' });
40
+ const secureProducts = useProducts({ type: 'token', token: '<jwt>' });
41
+ ```
42
+
43
+ - When `type` is `apiKey`, the requestor sends `x-api-key` headers. If you configured an `apiKey` in `useWBSuite`, you can omit the `auth` argument and that key will be used automatically.
44
+ - When `type` is `token`, the requestor swaps to a `Bearer` `Authorization` header.
45
+
46
+ ## Working with backend hooks
47
+
48
+ Most exported hooks are thin wrappers around the shared `useBackend` helper. They expose a common shape:
49
+
50
+ - `list(filters?)` – fetch a filtered collection (filters mirror the entity fields where supported).
51
+ - `get(id)` – retrieve one entity.
52
+ - `create(data)` – create an entity (overridable by hooks that need custom logic).
53
+ - `update(id, data)` – update an entity (overridable by hooks that need custom logic).
54
+ - `requestor` – the underlying Axios instance if you need lower-level control.
55
+
56
+ Example using categories:
57
+
58
+ ```tsx
59
+ import { useCategories } from '@wbsuite/react-hooks';
60
+
61
+ const { list, create, update } = useCategories();
62
+
63
+ useEffect(() => {
64
+ list({ name: 'Vehicles' }).then(({ data }) => {
65
+ // work with filtered categories
66
+ });
67
+ }, [list]);
68
+
69
+ const addCategory = async () => {
70
+ const result = await create({ name: 'New Category' });
71
+ console.log(result.data);
72
+ };
73
+ ```
74
+
75
+ ## Product-specific helpers
76
+
77
+ Some hooks extend the base methods with extra endpoints. For example, `useProducts` adds custom `create`, `update`, and `delete` helpers that call the product-specific routes directly:
78
+
79
+ ```tsx
80
+ import { useProducts } from '@wbsuite/react-hooks';
81
+
82
+ const { list, create, update, delete: remove } = useProducts();
83
+
84
+ const refresh = async () => {
85
+ const response = await list({ categories: ['category-id'] });
86
+ console.log(response.data);
87
+ };
88
+
89
+ const saveProduct = async () => {
90
+ const created = await create({ name: 'My product' });
91
+ const updated = await update(created.data.id, { price: 999 });
92
+ await remove(updated.data.id);
93
+ };
94
+ ```
95
+
96
+ ## Available hooks
97
+
98
+ All hooks live under `react-hooks/src/hooks/` and follow the same configuration approach:
99
+
100
+ - Content & catalog: `useArticles`, `useAttributes`, `useAttributesGroups`, `useCategories`, `useDocuments`, `useEntityStatuses`, `useMedia`, `useProducts`, `useRenting`, `useRoom`, `useStock`, `useTable`, `useTransactions`.
101
+ - Commerce & orders: `useOrders`, `useRotations`.
102
+ - Customers & contacts: `useCampaigns`, `useCustomers`, `useLeads`.
103
+ - Accounts & permissions: `useBackend`, `useInvites`, `usePermissions`, `useProfile`, `useRoles`, `useStatuses`, `useTeams`, `useUserConnections`, `useUsers`, `useWBSuite`.
104
+ - Localization & communication: `useChats`, `useCurrencies`, `useEmailTemplates`, `useLanguages`, `useSiteConfig`, `useTranslations`.
105
+ - Platform configuration: `useBackend`, `useDomains`, `useStores`, `useWebsites`.
106
+
107
+ Use the lists above as a starting point when exploring the package; each hook mirrors a WBSuite API resource and uses the same initialization and authentication rules described earlier.
@@ -0,0 +1,12 @@
1
+ const eslint = require('@eslint/js');
2
+ const tseslint = require('typescript-eslint');
3
+
4
+ module.exports = tseslint.config(
5
+ eslint.configs.recommended,
6
+ ...tseslint.configs.recommended,
7
+ {
8
+ 'rules': {
9
+ '@typescript-eslint/no-explicit-any': 'warn'
10
+ }
11
+ }
12
+ );
package/package.json CHANGED
@@ -1 +1 @@
1
- {"name":"@wbsuite/react-hooks","version":"1.0.211","description":"","main":"cjs/index.js","module":"esm/index.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1","lint":"npx eslint src/**","build":"npm run build:esm && npm run build:cjs","build:esm":"tsc","build:cjs":"tsc --module commonjs --outDir dist/react-hooks/cjs","pre-publish":"npm run lint && rm -rf dist && npm run build && cp package*.json dist/react-hooks","publish-to-npm":"cd dist/react-hooks && npm publish --access public --registry=https://registry.npmjs.org/"},"author":"faluma@webbuilders.com.ar","license":"ISC","devDependencies":{"@eslint/js":"^8.57.0","@wb/types":"^2.0.34","eslint":"^8.57.0","typescript":"^5.3.3","typescript-eslint":"^7.0.2"},"dependencies":{"@slate-serializers/html":"^2.2.3","axios":"^1.6.7"}}
1
+ {"name":"@wbsuite/react-hooks","version":"1.0.212","description":"","main":"cjs/index.js","module":"esm/index.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1","lint":"npx eslint src/**","build":"npm run build:esm && npm run build:cjs","build:esm":"tsc","build:cjs":"tsc --module commonjs --outDir dist/react-hooks/cjs","pre-publish":"npm run lint && rm -rf dist && npm run build && cp package*.json dist/react-hooks","publish-to-npm":"cd dist/react-hooks && npm publish --access public --registry=https://registry.npmjs.org/"},"author":"faluma@webbuilders.com.ar","license":"ISC","devDependencies":{"@eslint/js":"^8.57.0","@wb/types":"^2.0.34","eslint":"^8.57.0","typescript":"^5.3.3","typescript-eslint":"^7.0.2"},"dependencies":{"@slate-serializers/html":"^2.2.3","axios":"^1.6.7"}}
@@ -0,0 +1,10 @@
1
+ import { RequestorOptions } from 'models/Requestor';
2
+ import { BackendHook, useBackend } from '../useBackend';
3
+
4
+ export const useAgents: BackendHook<any, undefined> = (auth?: RequestorOptions['auth']) => {
5
+ const { requestor, ...rest } = useBackend('agents', { auth });
6
+ return {
7
+ ...rest,
8
+ requestor,
9
+ };
10
+ };
@@ -0,0 +1,10 @@
1
+ import { RequestorOptions } from 'models/Requestor';
2
+ import { BackendHook, useBackend } from '../useBackend';
3
+
4
+ export const useApps: BackendHook<any, undefined> = (auth?: RequestorOptions['auth']) => {
5
+ const { requestor, ...rest } = useBackend('apps', { auth });
6
+ return {
7
+ ...rest,
8
+ requestor,
9
+ };
10
+ };
@@ -0,0 +1,18 @@
1
+ import { slateToHtml } from '@slate-serializers/html';
2
+ import { BackendHook, useBackend } from '../useBackend';
3
+ import { RequestorOptions } from 'models/Requestor';
4
+
5
+ export const deserialize = (content: string) => {
6
+ try {
7
+ const deserializedContent = JSON.parse(content);
8
+ if(Array.isArray(deserializedContent)) return slateToHtml(deserializedContent);
9
+ return deserializedContent;
10
+ } catch (e) {
11
+ return content;
12
+ }
13
+ }
14
+
15
+ export const useArticles: BackendHook<any, any, { deserialize: (content: string) => string }> = (auth?: RequestorOptions['auth']) => {
16
+ const { ...endpoints } = useBackend('articles', { auth });
17
+ return { ...endpoints, deserialize };
18
+ };
@@ -0,0 +1,18 @@
1
+ import { BackendHook, useBackend } from '../useBackend';
2
+ import { RequestorOptions } from 'models/Requestor';
3
+
4
+ export const useAttributes: BackendHook = (auth?: RequestorOptions['auth']) => {
5
+ const { requestor, ...endpoints } = useBackend('attributes', { auth });
6
+ return {
7
+ requestor,
8
+ ...endpoints,
9
+ create: (data) =>
10
+ requestor.makeRequest.post(`attributes`, data).then(({ data }) => data),
11
+ update: (id: any, data: any) =>
12
+ requestor.makeRequest.put(`attributes/${id}`, data).then(({ data }) => data),
13
+ delete: (id: string) =>
14
+ requestor.makeRequest.delete(`attributes/${id}`).then(({ data }) => data),
15
+ getGrouped: () =>
16
+ requestor.makeRequest.get(`attributes/grouped`).then(({ data }) => data),
17
+ };
18
+ };
@@ -0,0 +1,17 @@
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
+ };
@@ -0,0 +1,10 @@
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
+ };
@@ -0,0 +1,6 @@
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
+ };
@@ -0,0 +1,40 @@
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
+ };
@@ -0,0 +1,6 @@
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
+ };
@@ -0,0 +1,6 @@
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
+ };
@@ -0,0 +1,6 @@
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
+ };
@@ -0,0 +1,11 @@
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
+ };
@@ -0,0 +1,7 @@
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
+ };
@@ -0,0 +1,13 @@
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
+ };
@@ -0,0 +1,28 @@
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
+ };
@@ -0,0 +1,21 @@
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
+ };
@@ -0,0 +1,14 @@
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
+ };
@@ -0,0 +1,21 @@
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
+ };
@@ -0,0 +1,86 @@
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
+ };
@@ -0,0 +1,10 @@
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
+ };
@@ -0,0 +1,13 @@
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
+ };
@@ -0,0 +1,13 @@
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
+ };
@@ -0,0 +1,6 @@
1
+ import { RequestorOptions } from 'models/Requestor';
2
+ import { BackendHook, useBackend } from '../useBackend';
3
+
4
+ export const useFormSubmissions: BackendHook<any> = (auth?: RequestorOptions['auth']) => {
5
+ return useBackend('form-submissions', { auth });
6
+ };
@@ -0,0 +1,16 @@
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
+ };
@@ -0,0 +1,15 @@
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
+ };