@wbsuite/react-hooks 1.0.210 → 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 (300) 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 -0
  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/useArticles/index.d.ts +0 -5
  70. package/cjs/hooks/useArticles/index.js +0 -45
  71. package/cjs/hooks/useAttributes/index.d.ts +0 -2
  72. package/cjs/hooks/useAttributes/index.js +0 -52
  73. package/cjs/hooks/useAttributesGroups/index.d.ts +0 -3
  74. package/cjs/hooks/useAttributesGroups/index.js +0 -47
  75. package/cjs/hooks/useAutomations/index.d.ts +0 -2
  76. package/cjs/hooks/useAutomations/index.js +0 -32
  77. package/cjs/hooks/useBackend/get.d.ts +0 -2
  78. package/cjs/hooks/useBackend/get.js +0 -52
  79. package/cjs/hooks/useBackend/index.d.ts +0 -17
  80. package/cjs/hooks/useBackend/index.js +0 -22
  81. package/cjs/hooks/useBackend/list.d.ts +0 -2
  82. package/cjs/hooks/useBackend/list.js +0 -55
  83. package/cjs/hooks/useBackend/post.d.ts +0 -2
  84. package/cjs/hooks/useBackend/post.js +0 -52
  85. package/cjs/hooks/useBackend/put.d.ts +0 -2
  86. package/cjs/hooks/useBackend/put.js +0 -52
  87. package/cjs/hooks/useCampaigns/index.d.ts +0 -2
  88. package/cjs/hooks/useCampaigns/index.js +0 -35
  89. package/cjs/hooks/useCategories/index.d.ts +0 -3
  90. package/cjs/hooks/useCategories/index.js +0 -9
  91. package/cjs/hooks/useChats/index.d.ts +0 -3
  92. package/cjs/hooks/useChats/index.js +0 -37
  93. package/cjs/hooks/useContactGroups/index.d.ts +0 -3
  94. package/cjs/hooks/useContactGroups/index.js +0 -57
  95. package/cjs/hooks/useContacts/index.d.ts +0 -3
  96. package/cjs/hooks/useContacts/index.js +0 -52
  97. package/cjs/hooks/useCurrencies/index.d.ts +0 -3
  98. package/cjs/hooks/useCurrencies/index.js +0 -37
  99. package/cjs/hooks/useCustomers/index.d.ts +0 -3
  100. package/cjs/hooks/useCustomers/index.js +0 -52
  101. package/cjs/hooks/useDocuments/index.d.ts +0 -10
  102. package/cjs/hooks/useDocuments/index.js +0 -145
  103. package/cjs/hooks/useDomains/index.d.ts +0 -2
  104. package/cjs/hooks/useDomains/index.js +0 -32
  105. package/cjs/hooks/useEmailTemplates/index.d.ts +0 -2
  106. package/cjs/hooks/useEmailTemplates/index.js +0 -37
  107. package/cjs/hooks/useEntityStatuses/index.d.ts +0 -2
  108. package/cjs/hooks/useEntityStatuses/index.js +0 -34
  109. package/cjs/hooks/useForms/index.d.ts +0 -2
  110. package/cjs/hooks/useForms/index.js +0 -37
  111. package/cjs/hooks/useIntegrations/index.d.ts +0 -2
  112. package/cjs/hooks/useIntegrations/index.js +0 -39
  113. package/cjs/hooks/useInvites/index.d.ts +0 -2
  114. package/cjs/hooks/useInvites/index.js +0 -47
  115. package/cjs/hooks/useLabels/index.d.ts +0 -3
  116. package/cjs/hooks/useLabels/index.js +0 -32
  117. package/cjs/hooks/useLanguages/index.d.ts +0 -5
  118. package/cjs/hooks/useLanguages/index.js +0 -39
  119. package/cjs/hooks/useLeads/index.d.ts +0 -30
  120. package/cjs/hooks/useLeads/index.js +0 -113
  121. package/cjs/hooks/useMedia/index.d.ts +0 -2
  122. package/cjs/hooks/useMedia/index.js +0 -34
  123. package/cjs/hooks/useOrders/index.d.ts +0 -2
  124. package/cjs/hooks/useOrders/index.js +0 -76
  125. package/cjs/hooks/usePaths/index.d.ts +0 -2
  126. package/cjs/hooks/usePaths/index.js +0 -37
  127. package/cjs/hooks/usePermissions/index.d.ts +0 -2
  128. package/cjs/hooks/usePermissions/index.js +0 -47
  129. package/cjs/hooks/useProducts/index.d.ts +0 -2
  130. package/cjs/hooks/useProducts/index.js +0 -52
  131. package/cjs/hooks/useProfile/index.d.ts +0 -3
  132. package/cjs/hooks/useProfile/index.js +0 -57
  133. package/cjs/hooks/useRenting/index.d.ts +0 -47
  134. package/cjs/hooks/useRenting/index.js +0 -52
  135. package/cjs/hooks/useRoles/index.d.ts +0 -2
  136. package/cjs/hooks/useRoles/index.js +0 -32
  137. package/cjs/hooks/useRoom/index.d.ts +0 -3
  138. package/cjs/hooks/useRoom/index.js +0 -55
  139. package/cjs/hooks/useRotations/index.d.ts +0 -2
  140. package/cjs/hooks/useRotations/index.js +0 -37
  141. package/cjs/hooks/useSiteConfig/index.d.ts +0 -5
  142. package/cjs/hooks/useSiteConfig/index.js +0 -33
  143. package/cjs/hooks/useStatuses/index.d.ts +0 -2
  144. package/cjs/hooks/useStatuses/index.js +0 -32
  145. package/cjs/hooks/useStock/index.d.ts +0 -20
  146. package/cjs/hooks/useStock/index.js +0 -51
  147. package/cjs/hooks/useStores/index.d.ts +0 -3
  148. package/cjs/hooks/useStores/index.js +0 -62
  149. package/cjs/hooks/useSubscriptions/index.d.ts +0 -2
  150. package/cjs/hooks/useSubscriptions/index.js +0 -37
  151. package/cjs/hooks/useTable/index.d.ts +0 -3
  152. package/cjs/hooks/useTable/index.js +0 -34
  153. package/cjs/hooks/useTeams/index.d.ts +0 -5
  154. package/cjs/hooks/useTeams/index.js +0 -52
  155. package/cjs/hooks/useTickets/index.d.ts +0 -3
  156. package/cjs/hooks/useTickets/index.js +0 -47
  157. package/cjs/hooks/useTransactions/index.d.ts +0 -8
  158. package/cjs/hooks/useTransactions/index.js +0 -61
  159. package/cjs/hooks/useTranslations/index.d.ts +0 -5
  160. package/cjs/hooks/useTranslations/index.js +0 -42
  161. package/cjs/hooks/useUserConnections/index.d.ts +0 -2
  162. package/cjs/hooks/useUserConnections/index.js +0 -53
  163. package/cjs/hooks/useUserSubscriptions/index.d.ts +0 -6
  164. package/cjs/hooks/useUserSubscriptions/index.js +0 -47
  165. package/cjs/hooks/useUsers/index.d.ts +0 -17
  166. package/cjs/hooks/useUsers/index.js +0 -141
  167. package/cjs/hooks/useWBSuite/index.d.ts +0 -2
  168. package/cjs/hooks/useWBSuite/index.js +0 -39
  169. package/cjs/hooks/useWebsites/index.d.ts +0 -2
  170. package/cjs/hooks/useWebsites/index.js +0 -72
  171. package/cjs/index.d.ts +0 -49
  172. package/cjs/index.js +0 -115
  173. package/cjs/models/Requestor.d.ts +0 -24
  174. package/cjs/models/Requestor.js +0 -53
  175. package/cjs/next/utils/index.js +0 -6
  176. package/cjs/next/utils/wrapAsync.d.ts +0 -1
  177. package/cjs/next/utils/wrapAsync.js +0 -54
  178. package/cjs/utils/authWithApiKey.d.ts +0 -4
  179. package/cjs/utils/authWithApiKey.js +0 -8
  180. package/cjs/utils/authWithToken.d.ts +0 -4
  181. package/cjs/utils/authWithToken.js +0 -8
  182. package/cjs/utils/index.d.ts +0 -11
  183. package/cjs/utils/index.js +0 -19
  184. package/esm/hooks/useAgents/index.d.ts +0 -2
  185. package/esm/hooks/useAgents/index.js +0 -28
  186. package/esm/hooks/useArticles/index.d.ts +0 -5
  187. package/esm/hooks/useArticles/index.js +0 -40
  188. package/esm/hooks/useAttributes/index.d.ts +0 -2
  189. package/esm/hooks/useAttributes/index.js +0 -48
  190. package/esm/hooks/useAttributesGroups/index.d.ts +0 -3
  191. package/esm/hooks/useAttributesGroups/index.js +0 -43
  192. package/esm/hooks/useAutomations/index.d.ts +0 -2
  193. package/esm/hooks/useAutomations/index.js +0 -28
  194. package/esm/hooks/useBackend/get.d.ts +0 -2
  195. package/esm/hooks/useBackend/get.js +0 -48
  196. package/esm/hooks/useBackend/index.d.ts +0 -17
  197. package/esm/hooks/useBackend/index.js +0 -18
  198. package/esm/hooks/useBackend/list.d.ts +0 -2
  199. package/esm/hooks/useBackend/list.js +0 -51
  200. package/esm/hooks/useBackend/post.d.ts +0 -2
  201. package/esm/hooks/useBackend/post.js +0 -48
  202. package/esm/hooks/useBackend/put.d.ts +0 -2
  203. package/esm/hooks/useBackend/put.js +0 -48
  204. package/esm/hooks/useCampaigns/index.d.ts +0 -2
  205. package/esm/hooks/useCampaigns/index.js +0 -31
  206. package/esm/hooks/useCategories/index.d.ts +0 -3
  207. package/esm/hooks/useCategories/index.js +0 -5
  208. package/esm/hooks/useChats/index.d.ts +0 -3
  209. package/esm/hooks/useChats/index.js +0 -33
  210. package/esm/hooks/useContactGroups/index.d.ts +0 -3
  211. package/esm/hooks/useContactGroups/index.js +0 -53
  212. package/esm/hooks/useContacts/index.d.ts +0 -3
  213. package/esm/hooks/useContacts/index.js +0 -48
  214. package/esm/hooks/useCurrencies/index.d.ts +0 -3
  215. package/esm/hooks/useCurrencies/index.js +0 -33
  216. package/esm/hooks/useCustomers/index.d.ts +0 -3
  217. package/esm/hooks/useCustomers/index.js +0 -48
  218. package/esm/hooks/useDocuments/index.d.ts +0 -10
  219. package/esm/hooks/useDocuments/index.js +0 -141
  220. package/esm/hooks/useDomains/index.d.ts +0 -2
  221. package/esm/hooks/useDomains/index.js +0 -28
  222. package/esm/hooks/useEmailTemplates/index.d.ts +0 -2
  223. package/esm/hooks/useEmailTemplates/index.js +0 -33
  224. package/esm/hooks/useEntityStatuses/index.d.ts +0 -2
  225. package/esm/hooks/useEntityStatuses/index.js +0 -30
  226. package/esm/hooks/useForms/index.d.ts +0 -2
  227. package/esm/hooks/useForms/index.js +0 -33
  228. package/esm/hooks/useIntegrations/index.d.ts +0 -2
  229. package/esm/hooks/useIntegrations/index.js +0 -35
  230. package/esm/hooks/useInvites/index.d.ts +0 -2
  231. package/esm/hooks/useInvites/index.js +0 -43
  232. package/esm/hooks/useLabels/index.d.ts +0 -3
  233. package/esm/hooks/useLabels/index.js +0 -28
  234. package/esm/hooks/useLanguages/index.d.ts +0 -5
  235. package/esm/hooks/useLanguages/index.js +0 -35
  236. package/esm/hooks/useLeads/index.d.ts +0 -30
  237. package/esm/hooks/useLeads/index.js +0 -109
  238. package/esm/hooks/useMedia/index.d.ts +0 -2
  239. package/esm/hooks/useMedia/index.js +0 -30
  240. package/esm/hooks/useOrders/index.d.ts +0 -2
  241. package/esm/hooks/useOrders/index.js +0 -72
  242. package/esm/hooks/usePaths/index.d.ts +0 -2
  243. package/esm/hooks/usePaths/index.js +0 -33
  244. package/esm/hooks/usePermissions/index.d.ts +0 -2
  245. package/esm/hooks/usePermissions/index.js +0 -43
  246. package/esm/hooks/useProducts/index.d.ts +0 -2
  247. package/esm/hooks/useProducts/index.js +0 -48
  248. package/esm/hooks/useProfile/index.d.ts +0 -3
  249. package/esm/hooks/useProfile/index.js +0 -53
  250. package/esm/hooks/useRenting/index.d.ts +0 -47
  251. package/esm/hooks/useRenting/index.js +0 -48
  252. package/esm/hooks/useRoles/index.d.ts +0 -2
  253. package/esm/hooks/useRoles/index.js +0 -28
  254. package/esm/hooks/useRoom/index.d.ts +0 -3
  255. package/esm/hooks/useRoom/index.js +0 -51
  256. package/esm/hooks/useRotations/index.d.ts +0 -2
  257. package/esm/hooks/useRotations/index.js +0 -33
  258. package/esm/hooks/useSiteConfig/index.d.ts +0 -5
  259. package/esm/hooks/useSiteConfig/index.js +0 -29
  260. package/esm/hooks/useStatuses/index.d.ts +0 -2
  261. package/esm/hooks/useStatuses/index.js +0 -28
  262. package/esm/hooks/useStock/index.d.ts +0 -20
  263. package/esm/hooks/useStock/index.js +0 -47
  264. package/esm/hooks/useStores/index.d.ts +0 -3
  265. package/esm/hooks/useStores/index.js +0 -58
  266. package/esm/hooks/useSubscriptions/index.d.ts +0 -2
  267. package/esm/hooks/useSubscriptions/index.js +0 -33
  268. package/esm/hooks/useTable/index.d.ts +0 -3
  269. package/esm/hooks/useTable/index.js +0 -30
  270. package/esm/hooks/useTeams/index.d.ts +0 -5
  271. package/esm/hooks/useTeams/index.js +0 -48
  272. package/esm/hooks/useTickets/index.d.ts +0 -3
  273. package/esm/hooks/useTickets/index.js +0 -43
  274. package/esm/hooks/useTransactions/index.d.ts +0 -8
  275. package/esm/hooks/useTransactions/index.js +0 -57
  276. package/esm/hooks/useTranslations/index.d.ts +0 -5
  277. package/esm/hooks/useTranslations/index.js +0 -38
  278. package/esm/hooks/useUserConnections/index.d.ts +0 -2
  279. package/esm/hooks/useUserConnections/index.js +0 -49
  280. package/esm/hooks/useUserSubscriptions/index.d.ts +0 -6
  281. package/esm/hooks/useUserSubscriptions/index.js +0 -43
  282. package/esm/hooks/useUsers/index.d.ts +0 -17
  283. package/esm/hooks/useUsers/index.js +0 -137
  284. package/esm/hooks/useWBSuite/index.d.ts +0 -2
  285. package/esm/hooks/useWBSuite/index.js +0 -35
  286. package/esm/hooks/useWebsites/index.d.ts +0 -2
  287. package/esm/hooks/useWebsites/index.js +0 -68
  288. package/esm/index.js +0 -50
  289. package/esm/models/Requestor.d.ts +0 -24
  290. package/esm/models/Requestor.js +0 -47
  291. package/esm/next/utils/index.d.ts +0 -2
  292. package/esm/next/utils/index.js +0 -3
  293. package/esm/next/utils/wrapAsync.d.ts +0 -1
  294. package/esm/next/utils/wrapAsync.js +0 -50
  295. package/esm/utils/authWithApiKey.d.ts +0 -4
  296. package/esm/utils/authWithApiKey.js +0 -4
  297. package/esm/utils/authWithToken.d.ts +0 -4
  298. package/esm/utils/authWithToken.js +0 -4
  299. package/esm/utils/index.d.ts +0 -11
  300. package/esm/utils/index.js +0 -3
@@ -0,0 +1,19 @@
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
+ };
@@ -0,0 +1,13 @@
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
+ };
@@ -0,0 +1,16 @@
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
+ };
@@ -0,0 +1,149 @@
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
+ };
@@ -0,0 +1,13 @@
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
+ };
@@ -0,0 +1,74 @@
1
+ import { RequestorOptions } from 'models/Requestor';
2
+ import { BackendHook, useBackend } from '../useBackend';
3
+
4
+ export const useOrders: BackendHook<any> = (auth?: RequestorOptions['auth']) => {
5
+ const { requestor, ...endpoints } = useBackend(`orders`, { auth });
6
+
7
+ return {
8
+ requestor,
9
+ ...endpoints,
10
+ createManual: (order: any) => {
11
+ return requestor.makeRequest.post(`orders/manual`, order).then((r) => r.data);
12
+ },
13
+ get: (orderId: string, skipProductDetails: boolean = true) => {
14
+ return requestor.makeRequest.get(`orders/${orderId}?skipProductDetails=${skipProductDetails}`).then((r) => r.data);
15
+ },
16
+ addLog: (orderId: string, log: { text: string; extra?: Record<string, unknown> }) => {
17
+ return requestor.makeRequest.post(`orders/${orderId}/notes`, log).then((r) => r.data);
18
+ },
19
+ logHistory: (orderId: string, limit?: number) => {
20
+ return requestor.makeRequest.get(`orders/${orderId}/log/history`, { params: { limit } }).then((r) => r.data);
21
+ },
22
+ deleteLog: (orderId: string, logId: string) => {
23
+ return requestor.makeRequest.delete(`orders/${orderId}/notes/${logId}`).then((r) => r.data);
24
+ },
25
+ commentsHistory: (orderId: string, limit?: number) => {
26
+ return requestor.makeRequest.get(`orders/${orderId}/notes`, { params: { limit } }).then((r) => r.data);
27
+ },
28
+ paymentHistory: (orderId: string, limit?: number) => {
29
+ return requestor.makeRequest.get(`orders/${orderId}/payment/history`, { params: { limit } }).then((r) => r.data);
30
+ },
31
+ getAvailableStock: (orderId: string, productId: string) => {
32
+ return requestor.makeRequest.get(`orders/${orderId}/stock/${productId}/available`).then((r) => r.data);
33
+ },
34
+ assignStock: (orderId: string, productId: string, stockId: string) => {
35
+ return requestor.makeRequest.post(`orders/${orderId}/stock/${productId}/assign/${stockId}`).then((r) => r.data);
36
+ },
37
+ unassignStock: (orderId: string, productId: string, stockId: string) => {
38
+ return requestor.makeRequest.post(`orders/${orderId}/stock/${productId}/unassign/${stockId}`).then((r) => r.data);
39
+ },
40
+ replaceStock: (orderId: string, productId: string, stockId: string, newStockId: string) => {
41
+ return requestor.makeRequest.post(`orders/${orderId}/stock/${productId}/replace/${stockId}/${newStockId}`).then((r) => r.data);
42
+ },
43
+ convertToDraft: (orderId: string) =>{
44
+ return requestor.makeRequest.post(`orders/${orderId}/draft`).then((r) => r.data);
45
+ },
46
+ convertToUndraft: (orderId: string) =>{
47
+ return requestor.makeRequest.post(`orders/${orderId}/undraft`).then((r) => r.data);
48
+ },
49
+ changeOrderStatus: (orderId: string, request: { newStatus: string, reason?: string }) =>{
50
+ return requestor.makeRequest.put(`orders/${orderId}/status`, request).then((r) => r.data);
51
+ },
52
+ closeOrder: (orderId: string, request: { reason?: string }) =>{
53
+ return requestor.makeRequest.post(`orders/${orderId}/close`, request).then((r) => r.data);
54
+ },
55
+ cancelOrder: (orderId: string, request: { reason?: string }) =>{
56
+ return requestor.makeRequest.post(`orders/${orderId}/cancel`, request).then((r) => r.data);
57
+ },
58
+ approveOrder: (orderId: string) =>{
59
+ return requestor.makeRequest.post(`orders/${orderId}/approve`).then((r) => r.data);
60
+ },
61
+ rejectOrder: (orderId: string) =>{
62
+ return requestor.makeRequest.post(`orders/${orderId}/reject`).then((r) => r.data);
63
+ },
64
+ reevaluateOrderStatus: (orderId: string) =>{
65
+ return requestor.makeRequest.post(`orders/${orderId}/reevaluate/status`).then((r) => r.data);
66
+ },
67
+ getPublic: (orderId: string) => {
68
+ return requestor.makeRequest.get(`orders/${orderId}/public`).then((r) => r.data);
69
+ },
70
+ getReport: (filters: Record<string, unknown>, options: Partial<{ sendEmail: boolean, email?: string; format?: 'csv' | 'xlsx' }> = {}) => {
71
+ return requestor.makeRequest.post(`orders/report/request`, { filters, options }).then((r) => r.data);
72
+ },
73
+ };
74
+ };
@@ -0,0 +1,16 @@
1
+ import { RequestorOptions } from 'models/Requestor';
2
+ import { BackendHook, useBackend } from '../useBackend';
3
+
4
+ export const usePaths: BackendHook<
5
+ Record<string, string>,
6
+ undefined
7
+ > = (auth?: RequestorOptions['auth']) => {
8
+ const { requestor, ...rest } = useBackend('paths', { auth });
9
+ return {
10
+ ...rest,
11
+ requestor,
12
+ getByKey: (key: string) => {
13
+ return requestor.makeRequest.get(`paths/${key}`).then(({ data }) => data);
14
+ }
15
+ };
16
+ };
@@ -0,0 +1,16 @@
1
+ import { BackendHook, useBackend } from '../useBackend';
2
+ import { RequestorOptions } from 'models/Requestor';
3
+
4
+ export const usePermissions: BackendHook = (auth?: RequestorOptions['auth']) => {
5
+ const { requestor, ...endpoints } = useBackend('permissions', { auth });
6
+ return {
7
+ requestor,
8
+ ...endpoints,
9
+ create: (data) =>
10
+ requestor.makeRequest.post(`permissions`, data).then(({ data }) => data),
11
+ update: (id: any, data: any) =>
12
+ requestor.makeRequest.put(`permissions/${id}`, data).then(({ data }) => data),
13
+ delete: (id: string) =>
14
+ requestor.makeRequest.delete(`permissions/${id}`).then(({ data }) => data),
15
+ };
16
+ };
@@ -0,0 +1,18 @@
1
+ import { BackendHook, useBackend } from '../useBackend';
2
+ import { RequestorOptions } from 'models/Requestor';
3
+
4
+ export const useProducts: BackendHook = (auth?: RequestorOptions['auth']) => {
5
+ const { requestor, ...endpoints } = useBackend('products', { auth });
6
+ return {
7
+ requestor,
8
+ ...endpoints,
9
+ create: (data) =>
10
+ requestor.makeRequest.post(`products`, data).then(({ data }) => data),
11
+ update: (id: any, data: any) =>
12
+ requestor.makeRequest.put(`products/${id}`, data).then(({ data }) => data),
13
+ delete: (id: string) =>
14
+ requestor.makeRequest.delete(`products/${id}`).then(({ data }) => data),
15
+ import: (userConnectionId: string, storeId: string | null) =>
16
+ requestor.makeRequest.post(`products/import`, { userConnectionId, storeId }).then(({ data }) => data),
17
+ };
18
+ };
@@ -0,0 +1,20 @@
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 useProfile: BackendHook<Chat> = (auth?: RequestorOptions['auth']) => {
6
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
7
+ const { requestor, ...endpoints } = useBackend('users/profile', { auth });
8
+ return {
9
+ requestor,
10
+ ...endpoints,
11
+ updateProfile: (profile: { name: string }) => requestor.makeRequest.put(`users/profile`, profile).then(({ data }) => data),
12
+ requestPasswordChange: () => requestor.makeRequest.post(`users/profile/request-password-change`).then(({ data }) => data),
13
+ requestEmailChange: () => requestor.makeRequest.post(`users/profile/request-email-change`).then(({ data }) => data),
14
+ requestEmailVerification: () => requestor.makeRequest.post(`users/profile/request-email-verification`).then(({ data }) => data),
15
+ passwordRecovery: (emailOrUsername: string) => requestor.makeRequest.post(`users/profile/recover-password`, { emailOrUsername }).then(({ data }) => data),
16
+ changeEmail: (token: string, newEmail: string) => requestor.makeRequest.post(`users/profile/change-email`, { token, newEmail }).then(({ data }) => data),
17
+ changePassword: (token: string, newPassword: string) => requestor.makeRequest.post(`users/profile/change-password`, { token, newPassword }).then(({ data }) => data),
18
+ verifyEmail: (token: string) => requestor.makeRequest.post(`users/profile/verify-email`, { token }).then(({ data }) => data),
19
+ };
20
+ };
@@ -0,0 +1,57 @@
1
+ import { RequestorOptions } from 'models/Requestor';
2
+ import { BackendHook, useBackend } from '../useBackend';
3
+
4
+ type RentingDetails = {
5
+ startsAt: string,
6
+ endsAt: string,
7
+ pickUpStore?: string;
8
+ dropOffStore?: string;
9
+ }
10
+
11
+ type ListAvailableRentingDetails = RentingDetails & {
12
+ categories: string[];
13
+ }
14
+
15
+ type GetBugdetRentingDetails = RentingDetails & {
16
+ products: { product: string, variant?: { variant: string, orderedQty?: number }[], orderedQty?: number }[];
17
+ }
18
+
19
+ type PlaceRentRentingDetails = GetBugdetRentingDetails & {
20
+ customer: {
21
+ name: string,
22
+ email: string
23
+ }
24
+ }
25
+
26
+ export const useRenting: BackendHook<any, any, {
27
+ listAvailable: (storeId: string, rentingDetails: ListAvailableRentingDetails) => Promise<RentingDetails>,
28
+ getBudget: (storeId: string, rentingDetails: GetBugdetRentingDetails) => Promise<{
29
+ price: number;
30
+ priceBeforeDiscounts: number;
31
+ priceInBase: number;
32
+ priceInBaseBeforeDiscounts: number;
33
+ endsAt: string;
34
+ startsAt: string;
35
+ pickUpStore: { store: string, name: Record<string, string> };
36
+ dropOffStore: { store: string, name: Record<string, string> };
37
+ }>,
38
+ rent: (storeId: string, rentingDetails: PlaceRentRentingDetails) => Promise<Record<string, unknown>>
39
+ }> = (auth?: RequestorOptions['auth']) => {
40
+ const { requestor, ...rest } = useBackend('rentings', { auth });
41
+ return {
42
+ requestor,
43
+ ...rest,
44
+ listAvailable: (storeId: string, rentingDetails: ListAvailableRentingDetails) => {
45
+ return requestor.makeRequest.post(`rentings/available/${storeId}`, rentingDetails).then(({ data }) => data)
46
+ },
47
+ getBudget: (storeId: string, rentingDetails: GetBugdetRentingDetails) => {
48
+ return requestor.makeRequest.post(`rentings/getPrice/${storeId}`, rentingDetails).then(({ data }) => data)
49
+ },
50
+ rent: (storeId: string, rentingDetails: PlaceRentRentingDetails) => {
51
+ return requestor.makeRequest.post(`rentings/${storeId}`, rentingDetails).then(({ data }) => data)
52
+ },
53
+ getPublic: (rentingId: string) => {
54
+ return requestor.makeRequest.get(`rentings/${rentingId}/public`).then(({ data }) => data);
55
+ },
56
+ };
57
+ };
@@ -0,0 +1,10 @@
1
+ import { BackendHook, useBackend } from '../useBackend';
2
+ import { RequestorOptions } from 'models/Requestor';
3
+
4
+ export const useRoles: BackendHook<Record<string, string>, any> = (auth?: RequestorOptions['auth']) => {
5
+ const { requestor, ...rest } = useBackend('roles', { auth });
6
+ return {
7
+ ...rest,
8
+ requestor,
9
+ };
10
+ };
@@ -0,0 +1,20 @@
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 useRooms: BackendHook<Chat> = (auth?: RequestorOptions['auth']) => {
6
+ const { requestor, ...endpoints } = useBackend('rooms', { auth });
7
+ return {
8
+ requestor,
9
+ ...endpoints,
10
+ createRoom: (chatId: string) =>
11
+ requestor.makeRequest.post(`rooms/${chatId}`).then(({ data }) => data),
12
+ message: (roomId: string, message: any) =>
13
+ requestor.makeRequest.post(`rooms/reply/${roomId}`, message).then(({ data }) => data),
14
+ reset: (roomId: string) => requestor.makeRequest.post(`rooms/${roomId}/reset`).then(({ data }) => data),
15
+ createRoomForUserConnection: (userConnectionId: string, identityId:string) =>
16
+ requestor.makeRequest.post(`rooms/${userConnectionId}/${identityId}`).then(({ data }) => data),
17
+ comment: (roomId: string, message: any) =>
18
+ requestor.makeRequest.post(`rooms/${roomId}/comment`, message).then(({ data }) => data),
19
+ };
20
+ };
@@ -0,0 +1,13 @@
1
+ import { RequestorOptions } from 'models/Requestor';
2
+ import { BackendHook, useBackend } from '../useBackend';
3
+
4
+ export const useRotations: BackendHook<any, any> = (auth?: RequestorOptions['auth']) => {
5
+ const { requestor, ...rest } = useBackend('rotations', { auth });
6
+ return {
7
+ ...rest,
8
+ requestor,
9
+ makeDefault: (rotationId: string) => {
10
+ return requestor.makeRequest.post(`rotations/${rotationId}/makeDefault`).then(({ data }) => data);
11
+ },
12
+ };
13
+ };
@@ -0,0 +1,13 @@
1
+ import { CustomResponse } from '@wb/types/custom-response/custom-response.model';
2
+ import { BackendHook, useBackend } from '../useBackend';
3
+ import { RequestorOptions } from 'models/Requestor';
4
+
5
+ export const useSiteConfig: BackendHook<any, any, { getForSession: () => Promise<CustomResponse> }> = (auth?: RequestorOptions['auth']) => {
6
+ // eslint-disable-next-line
7
+ const { requestor, ...rest } = useBackend('app-configs', { auth });
8
+ return {
9
+ requestor,
10
+ ...rest,
11
+ getForSession: () => requestor.makeRequest.get('app-configs').then(r => r.data)
12
+ };
13
+ };
@@ -0,0 +1,10 @@
1
+ import { RequestorOptions } from 'models/Requestor';
2
+ import { BackendHook, useBackend } from '../useBackend';
3
+
4
+ export const useStatuses: BackendHook<any, any> = (auth?: RequestorOptions['auth']) => {
5
+ const { requestor, ...rest } = useBackend('statuses', { auth });
6
+ return {
7
+ ...rest,
8
+ requestor,
9
+ };
10
+ };
@@ -0,0 +1,48 @@
1
+ import { RequestorOptions } from 'models/Requestor';
2
+ import { BackendHook, useBackend } from '../useBackend';
3
+ import { IProductStock } from '@wb/types/products/products.model';
4
+
5
+ export const useStock: BackendHook<IProductStock, undefined, {
6
+ getStatus: (unitId: string) => Promise<IProductStock>;
7
+ addNote: (unitId: string, { text, extra }: { text: string; extra?: Record<string, unknown> }) => Promise<IProductStock>;
8
+ delete: (unitId: string) => Promise<boolean>;
9
+ logHistory: (unitId: string, limit?: number) => Promise<IProductStock>;
10
+ commentsHistory: (unitId: string, limit?: number) => Promise<IProductStock>;
11
+ changeStockStatus: (unitId: string, request: { newStatus: string, reason?: string }) => Promise<IProductStock>;
12
+ reevaluateStockStatus: (unitId: string) => Promise<IProductStock>;
13
+ markReceived: (unitId: string, request: { comment?: string }) => Promise<IProductStock>;
14
+ }> = (auth?: RequestorOptions['auth']) => {
15
+ const { requestor, ...endpoints } = useBackend('products/stock', { auth });
16
+
17
+ return {
18
+ requestor,
19
+ ...endpoints,
20
+ delete: (unitId: string) => {
21
+ return requestor.makeRequest.delete(`products/stock/${unitId}`).then((r) => r.data);
22
+ },
23
+ getStatus: (unitId: string) => {
24
+ return requestor.makeRequest.get(`products/stock/status/${unitId}`).then((r) => r.data);
25
+ },
26
+ addNote: (unitId: string, { text, extra }: { text: string; extra?: Record<string, unknown> }) => {
27
+ return requestor.makeRequest.post(`products/stock/${unitId}/notes`, { text, extra }).then((r) => r.data);
28
+ },
29
+ logHistory: (unitId: string, limit?: number) => {
30
+ return requestor.makeRequest.get(`products/stock/${unitId}/log/history`, { params: { limit } }).then((r) => r.data);
31
+ },
32
+ commentsHistory: (unitId: string, limit?: number) => {
33
+ return requestor.makeRequest.get(`products/stock/${unitId}/comment/history`, { params: { limit } }).then((r) => r.data);
34
+ },
35
+ changeStockStatus: (unitId: string, request: { newStatus: string, reason?: string }) =>{
36
+ return requestor.makeRequest.put(`products/stock/${unitId}/status`, request).then((r) => r.data);
37
+ },
38
+ reevaluateStockStatus: (unitId: string) =>{
39
+ return requestor.makeRequest.post(`products/stock/${unitId}/reevaluate/status`).then((r) => r.data);
40
+ },
41
+ markReceived: (unitId: string, request: { comment?: string }) =>{
42
+ return requestor.makeRequest.post(`products/stock/${unitId}/mark-received`, request).then((r) => r.data);
43
+ },
44
+ bulkMarkReceived: (stockIds: string[], request: { comment?: string }) => {
45
+ return requestor.makeRequest.put(`products/stock/bulk/mark-received`, { unitIds: stockIds, ...request }).then((r) => r.data);
46
+ },
47
+ };
48
+ };
@@ -0,0 +1,23 @@
1
+ import { RequestorOptions } from 'models/Requestor';
2
+ import { BackendHook, useBackend } from '../useBackend';
3
+ import { IStore } from '@wb/types/store/store.model';
4
+
5
+ export const useStores: BackendHook<IStore> = (auth?: RequestorOptions['auth']) => {
6
+ const { requestor, ...rest } = useBackend<IStore>('stores', { auth });
7
+ return {
8
+ ...rest,
9
+ requestor,
10
+ delete: (id: string) =>
11
+ requestor.makeRequest.delete(`stores/${id}`).then(({ data }) => data),
12
+ delegate: (id: string, data: { userId: string } | { teamId: string }) =>
13
+ requestor.makeRequest.post(`stores/${id}/delegate`, data).then(({ data }) => data),
14
+ undelegate: (id: string, reason?: string) =>
15
+ requestor.makeRequest.post(`stores/${id}/undelegate`, { reason }).then(({ data }) => data),
16
+ inviteToManage: (storeId: string, data: { userEmail: string }) =>
17
+ requestor.makeRequest.post(`stores/${storeId}/invite-to-manage`, data).then(({ data }) => data),
18
+ acceptManagement: (requestToken: string) =>
19
+ requestor.makeRequest.post(`stores/accept-manage`, { requestToken }).then(({ data }) => data),
20
+ rejectManagement: (requestToken: string) =>
21
+ requestor.makeRequest.post(`stores/reject-manage`, { requestToken }).then(({ data }) => data),
22
+ };
23
+ };
@@ -0,0 +1,17 @@
1
+
2
+ import { BackendHook, useBackend } from '../useBackend';
3
+ import { RequestorOptions } from 'models/Requestor';
4
+
5
+ export const useSubscriptions: BackendHook<
6
+ Record<string, string>,
7
+ any
8
+ > = (auth?: RequestorOptions['auth']) => {
9
+ const { requestor, ...rest } = useBackend('subscriptions', { auth });
10
+ return {
11
+ ...rest,
12
+ requestor,
13
+ listPaymentMethods: () => {
14
+ return requestor.makeRequest.get(`subscriptions/payment-methods`).then(({ data }) => data);
15
+ },
16
+ };
17
+ };
@@ -0,0 +1,15 @@
1
+ import { RequestorOptions } from 'models/Requestor';
2
+ import { BackendHook, useBackend } from '../useBackend';
3
+ import { IStore } from '@wb/types/store/store.model';
4
+
5
+ export const useTables: BackendHook<IStore> = (auth?: RequestorOptions['auth']) => {
6
+ const { requestor, ...endpoints } = useBackend('tables', { auth });
7
+
8
+ return {
9
+ requestor,
10
+ ...endpoints,
11
+ list: () => {
12
+ return requestor.makeRequest.get(`tables/list`).then((r) => r.data);
13
+ },
14
+ };
15
+ };
@@ -0,0 +1,29 @@
1
+ import { RequestorOptions } from 'models/Requestor';
2
+ import { BackendHook, useBackend } from '../useBackend';
3
+
4
+ export const useTeams: BackendHook<
5
+ Record<string, string>,
6
+ undefined,
7
+ {
8
+ getTeamInfo: (teamId: string) => Promise<void>;
9
+ updateTeamName: (teamId: string, name: string) => Promise<void>;
10
+ }
11
+ > = (auth?: RequestorOptions['auth']) => {
12
+ const { requestor, ...rest } = useBackend('teams', { auth });
13
+ return {
14
+ ...rest,
15
+ requestor,
16
+ updateTeamName: (teamId: string, name: string) => {
17
+ return requestor.makeRequest.put(`teams/${teamId}`, { name }).then(({ data }) => data);
18
+ },
19
+ getTeamInfo: (teamId: string) => {
20
+ return requestor.makeRequest.get(`teams/${teamId}`).then(({ data }) => data);
21
+ },
22
+ inviteToTeam: (invitation: { email: string; roles: string[]; store: string[] }) => {
23
+ return requestor.makeRequest.post(`teams/invite`, invitation).then(({ data }) => data);
24
+ },
25
+ subscriptionStatus: () => {
26
+ return requestor.makeRequest.get(`teams/subscription-status`).then(({ data }) => data);
27
+ },
28
+ };
29
+ };