@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.
- package/cjs/hooks/useAgents/index.d.ts +2 -0
- package/cjs/hooks/useAgents/index.js +32 -0
- package/cjs/hooks/useApps/index.d.ts +2 -0
- package/cjs/hooks/useApps/index.js +32 -0
- package/cjs/hooks/useArticles/index.d.ts +5 -0
- package/cjs/hooks/useArticles/index.js +45 -0
- package/cjs/hooks/useAttributes/index.d.ts +2 -0
- package/cjs/hooks/useAttributes/index.js +52 -0
- package/cjs/hooks/useAttributesGroups/index.d.ts +3 -0
- package/cjs/hooks/useAttributesGroups/index.js +47 -0
- package/cjs/hooks/useAutomations/index.d.ts +2 -0
- package/cjs/hooks/useAutomations/index.js +32 -0
- package/cjs/hooks/useBackend/get.d.ts +2 -0
- package/cjs/hooks/useBackend/get.js +52 -0
- package/cjs/hooks/useBackend/index.d.ts +17 -0
- package/cjs/hooks/useBackend/index.js +22 -0
- package/cjs/hooks/useBackend/list.d.ts +2 -0
- package/cjs/hooks/useBackend/list.js +55 -0
- package/cjs/hooks/useBackend/post.d.ts +2 -0
- package/cjs/hooks/useBackend/post.js +52 -0
- package/cjs/hooks/useBackend/put.d.ts +2 -0
- package/cjs/hooks/useBackend/put.js +52 -0
- package/cjs/hooks/useCampaigns/index.d.ts +2 -0
- package/cjs/hooks/useCampaigns/index.js +35 -0
- package/cjs/hooks/useCategories/index.d.ts +3 -0
- package/cjs/hooks/useCategories/index.js +9 -0
- package/cjs/hooks/useChats/index.d.ts +3 -0
- package/cjs/hooks/useChats/index.js +37 -0
- package/cjs/hooks/useContactGroups/index.d.ts +3 -0
- package/cjs/hooks/useContactGroups/index.js +57 -0
- package/cjs/hooks/useContacts/index.d.ts +3 -0
- package/cjs/hooks/useContacts/index.js +52 -0
- package/cjs/hooks/useCurrencies/index.d.ts +3 -0
- package/cjs/hooks/useCurrencies/index.js +37 -0
- package/cjs/hooks/useCustomers/index.d.ts +3 -0
- package/cjs/hooks/useCustomers/index.js +52 -0
- package/cjs/hooks/useDocuments/index.d.ts +10 -0
- package/cjs/hooks/useDocuments/index.js +145 -0
- package/cjs/hooks/useDomains/index.d.ts +2 -0
- package/cjs/hooks/useDomains/index.js +32 -0
- package/cjs/hooks/useEmailTemplates/index.d.ts +2 -0
- package/cjs/hooks/useEmailTemplates/index.js +37 -0
- package/cjs/hooks/useEntityStatuses/index.d.ts +2 -0
- package/cjs/hooks/useEntityStatuses/index.js +34 -0
- package/cjs/hooks/useForms/index.d.ts +2 -0
- package/cjs/hooks/useForms/index.js +37 -0
- package/cjs/hooks/useIntegrations/index.d.ts +2 -0
- package/cjs/hooks/useIntegrations/index.js +39 -0
- package/cjs/hooks/useInvites/index.d.ts +2 -0
- package/cjs/hooks/useInvites/index.js +47 -0
- package/cjs/hooks/useLabels/index.d.ts +3 -0
- package/cjs/hooks/useLabels/index.js +32 -0
- package/cjs/hooks/useLanguages/index.d.ts +5 -0
- package/cjs/hooks/useLanguages/index.js +39 -0
- package/cjs/hooks/useLeads/index.d.ts +30 -0
- package/cjs/hooks/useLeads/index.js +113 -0
- package/cjs/hooks/useMedia/index.d.ts +2 -0
- package/cjs/hooks/useMedia/index.js +34 -0
- package/cjs/hooks/useOrders/index.d.ts +2 -0
- package/cjs/hooks/useOrders/index.js +76 -0
- package/cjs/hooks/usePaths/index.d.ts +2 -0
- package/cjs/hooks/usePaths/index.js +37 -0
- package/cjs/hooks/usePermissions/index.d.ts +2 -0
- package/cjs/hooks/usePermissions/index.js +47 -0
- package/cjs/hooks/useProducts/index.d.ts +2 -0
- package/cjs/hooks/useProducts/index.js +52 -0
- package/cjs/hooks/useProfile/index.d.ts +3 -0
- package/cjs/hooks/useProfile/index.js +57 -0
- package/cjs/hooks/useRenting/index.d.ts +47 -0
- package/cjs/hooks/useRenting/index.js +52 -0
- package/cjs/hooks/useRoles/index.d.ts +2 -0
- package/cjs/hooks/useRoles/index.js +32 -0
- package/cjs/hooks/useRoom/index.d.ts +3 -0
- package/cjs/hooks/useRoom/index.js +55 -0
- package/cjs/hooks/useRotations/index.d.ts +2 -0
- package/cjs/hooks/useRotations/index.js +37 -0
- package/cjs/hooks/useSiteConfig/index.d.ts +5 -0
- package/cjs/hooks/useSiteConfig/index.js +33 -0
- package/cjs/hooks/useStatuses/index.d.ts +2 -0
- package/cjs/hooks/useStatuses/index.js +32 -0
- package/cjs/hooks/useStock/index.d.ts +20 -0
- package/cjs/hooks/useStock/index.js +51 -0
- package/cjs/hooks/useStores/index.d.ts +3 -0
- package/cjs/hooks/useStores/index.js +62 -0
- package/cjs/hooks/useSubscriptions/index.d.ts +2 -0
- package/cjs/hooks/useSubscriptions/index.js +37 -0
- package/cjs/hooks/useTable/index.d.ts +3 -0
- package/cjs/hooks/useTable/index.js +34 -0
- package/cjs/hooks/useTeams/index.d.ts +5 -0
- package/cjs/hooks/useTeams/index.js +52 -0
- package/cjs/hooks/useTickets/index.d.ts +3 -0
- package/cjs/hooks/useTickets/index.js +47 -0
- package/cjs/hooks/useTransactions/index.d.ts +8 -0
- package/cjs/hooks/useTransactions/index.js +61 -0
- package/cjs/hooks/useTranslations/index.d.ts +5 -0
- package/cjs/hooks/useTranslations/index.js +42 -0
- package/cjs/hooks/useUserConnections/index.d.ts +2 -0
- package/cjs/hooks/useUserConnections/index.js +53 -0
- package/cjs/hooks/useUserSubscriptions/index.d.ts +6 -0
- package/cjs/hooks/useUserSubscriptions/index.js +47 -0
- package/cjs/hooks/useUsers/index.d.ts +17 -0
- package/cjs/hooks/useUsers/index.js +141 -0
- package/cjs/hooks/useWBSuite/index.d.ts +2 -0
- package/cjs/hooks/useWBSuite/index.js +39 -0
- package/cjs/hooks/useWebsites/index.d.ts +2 -0
- package/cjs/hooks/useWebsites/index.js +72 -0
- package/{src/index.ts → cjs/index.d.ts} +2 -1
- package/cjs/index.js +117 -0
- package/cjs/models/Requestor.d.ts +24 -0
- package/cjs/models/Requestor.js +53 -0
- package/{src/next/utils/index.ts → cjs/next/utils/index.d.ts} +1 -1
- package/cjs/next/utils/index.js +6 -0
- package/cjs/next/utils/wrapAsync.d.ts +1 -0
- package/cjs/next/utils/wrapAsync.js +54 -0
- package/cjs/utils/authWithApiKey.d.ts +4 -0
- package/cjs/utils/authWithApiKey.js +8 -0
- package/cjs/utils/authWithToken.d.ts +4 -0
- package/cjs/utils/authWithToken.js +8 -0
- package/cjs/utils/index.d.ts +11 -0
- package/cjs/utils/index.js +19 -0
- package/esm/hooks/useAgents/index.d.ts +2 -0
- package/esm/hooks/useAgents/index.js +28 -0
- package/esm/hooks/useApps/index.d.ts +2 -0
- package/esm/hooks/useApps/index.js +28 -0
- package/esm/hooks/useArticles/index.d.ts +5 -0
- package/esm/hooks/useArticles/index.js +40 -0
- package/esm/hooks/useAttributes/index.d.ts +2 -0
- package/esm/hooks/useAttributes/index.js +48 -0
- package/esm/hooks/useAttributesGroups/index.d.ts +3 -0
- package/esm/hooks/useAttributesGroups/index.js +43 -0
- package/esm/hooks/useAutomations/index.d.ts +2 -0
- package/esm/hooks/useAutomations/index.js +28 -0
- package/esm/hooks/useBackend/get.d.ts +2 -0
- package/esm/hooks/useBackend/get.js +48 -0
- package/esm/hooks/useBackend/index.d.ts +17 -0
- package/esm/hooks/useBackend/index.js +18 -0
- package/esm/hooks/useBackend/list.d.ts +2 -0
- package/esm/hooks/useBackend/list.js +51 -0
- package/esm/hooks/useBackend/post.d.ts +2 -0
- package/esm/hooks/useBackend/post.js +48 -0
- package/esm/hooks/useBackend/put.d.ts +2 -0
- package/esm/hooks/useBackend/put.js +48 -0
- package/esm/hooks/useCampaigns/index.d.ts +2 -0
- package/esm/hooks/useCampaigns/index.js +31 -0
- package/esm/hooks/useCategories/index.d.ts +3 -0
- package/esm/hooks/useCategories/index.js +5 -0
- package/esm/hooks/useChats/index.d.ts +3 -0
- package/esm/hooks/useChats/index.js +33 -0
- package/esm/hooks/useContactGroups/index.d.ts +3 -0
- package/esm/hooks/useContactGroups/index.js +53 -0
- package/esm/hooks/useContacts/index.d.ts +3 -0
- package/esm/hooks/useContacts/index.js +48 -0
- package/esm/hooks/useCurrencies/index.d.ts +3 -0
- package/esm/hooks/useCurrencies/index.js +33 -0
- package/esm/hooks/useCustomers/index.d.ts +3 -0
- package/esm/hooks/useCustomers/index.js +48 -0
- package/esm/hooks/useDocuments/index.d.ts +10 -0
- package/esm/hooks/useDocuments/index.js +141 -0
- package/esm/hooks/useDomains/index.d.ts +2 -0
- package/esm/hooks/useDomains/index.js +28 -0
- package/esm/hooks/useEmailTemplates/index.d.ts +2 -0
- package/esm/hooks/useEmailTemplates/index.js +33 -0
- package/esm/hooks/useEntityStatuses/index.d.ts +2 -0
- package/esm/hooks/useEntityStatuses/index.js +30 -0
- package/esm/hooks/useForms/index.d.ts +2 -0
- package/esm/hooks/useForms/index.js +33 -0
- package/esm/hooks/useIntegrations/index.d.ts +2 -0
- package/esm/hooks/useIntegrations/index.js +35 -0
- package/esm/hooks/useInvites/index.d.ts +2 -0
- package/esm/hooks/useInvites/index.js +43 -0
- package/esm/hooks/useLabels/index.d.ts +3 -0
- package/esm/hooks/useLabels/index.js +28 -0
- package/esm/hooks/useLanguages/index.d.ts +5 -0
- package/esm/hooks/useLanguages/index.js +35 -0
- package/esm/hooks/useLeads/index.d.ts +30 -0
- package/esm/hooks/useLeads/index.js +109 -0
- package/esm/hooks/useMedia/index.d.ts +2 -0
- package/esm/hooks/useMedia/index.js +30 -0
- package/esm/hooks/useOrders/index.d.ts +2 -0
- package/esm/hooks/useOrders/index.js +72 -0
- package/esm/hooks/usePaths/index.d.ts +2 -0
- package/esm/hooks/usePaths/index.js +33 -0
- package/esm/hooks/usePermissions/index.d.ts +2 -0
- package/esm/hooks/usePermissions/index.js +43 -0
- package/esm/hooks/useProducts/index.d.ts +2 -0
- package/esm/hooks/useProducts/index.js +48 -0
- package/esm/hooks/useProfile/index.d.ts +3 -0
- package/esm/hooks/useProfile/index.js +53 -0
- package/esm/hooks/useRenting/index.d.ts +47 -0
- package/esm/hooks/useRenting/index.js +48 -0
- package/esm/hooks/useRoles/index.d.ts +2 -0
- package/esm/hooks/useRoles/index.js +28 -0
- package/esm/hooks/useRoom/index.d.ts +3 -0
- package/esm/hooks/useRoom/index.js +51 -0
- package/esm/hooks/useRotations/index.d.ts +2 -0
- package/esm/hooks/useRotations/index.js +33 -0
- package/esm/hooks/useSiteConfig/index.d.ts +5 -0
- package/esm/hooks/useSiteConfig/index.js +29 -0
- package/esm/hooks/useStatuses/index.d.ts +2 -0
- package/esm/hooks/useStatuses/index.js +28 -0
- package/esm/hooks/useStock/index.d.ts +20 -0
- package/esm/hooks/useStock/index.js +47 -0
- package/esm/hooks/useStores/index.d.ts +3 -0
- package/esm/hooks/useStores/index.js +58 -0
- package/esm/hooks/useSubscriptions/index.d.ts +2 -0
- package/esm/hooks/useSubscriptions/index.js +33 -0
- package/esm/hooks/useTable/index.d.ts +3 -0
- package/esm/hooks/useTable/index.js +30 -0
- package/esm/hooks/useTeams/index.d.ts +5 -0
- package/esm/hooks/useTeams/index.js +48 -0
- package/esm/hooks/useTickets/index.d.ts +3 -0
- package/esm/hooks/useTickets/index.js +43 -0
- package/esm/hooks/useTransactions/index.d.ts +8 -0
- package/esm/hooks/useTransactions/index.js +57 -0
- package/esm/hooks/useTranslations/index.d.ts +5 -0
- package/esm/hooks/useTranslations/index.js +38 -0
- package/esm/hooks/useUserConnections/index.d.ts +2 -0
- package/esm/hooks/useUserConnections/index.js +49 -0
- package/esm/hooks/useUserSubscriptions/index.d.ts +6 -0
- package/esm/hooks/useUserSubscriptions/index.js +43 -0
- package/esm/hooks/useUsers/index.d.ts +17 -0
- package/esm/hooks/useUsers/index.js +137 -0
- package/esm/hooks/useWBSuite/index.d.ts +2 -0
- package/esm/hooks/useWBSuite/index.js +35 -0
- package/esm/hooks/useWebsites/index.d.ts +2 -0
- package/esm/hooks/useWebsites/index.js +68 -0
- package/esm/index.d.ts +50 -0
- package/esm/index.js +51 -0
- package/esm/models/Requestor.d.ts +24 -0
- package/esm/models/Requestor.js +47 -0
- package/esm/next/utils/index.d.ts +2 -0
- package/esm/next/utils/index.js +3 -0
- package/esm/next/utils/wrapAsync.d.ts +1 -0
- package/esm/next/utils/wrapAsync.js +50 -0
- package/esm/utils/authWithApiKey.d.ts +4 -0
- package/esm/utils/authWithApiKey.js +4 -0
- package/esm/utils/authWithToken.d.ts +4 -0
- package/esm/utils/authWithToken.js +4 -0
- package/esm/utils/index.d.ts +11 -0
- package/esm/utils/index.js +3 -0
- package/package.json +1 -1
- package/README.md +0 -66
- package/docs/USAGE.md +0 -107
- package/eslint.config.js +0 -12
- package/src/hooks/useAgents/index.ts +0 -10
- package/src/hooks/useArticles/index.ts +0 -18
- package/src/hooks/useAttributes/index.ts +0 -18
- package/src/hooks/useAttributesGroups/index.ts +0 -17
- package/src/hooks/useAutomations/index.ts +0 -10
- package/src/hooks/useBackend/get.ts +0 -6
- package/src/hooks/useBackend/index.ts +0 -40
- package/src/hooks/useBackend/list.ts +0 -6
- package/src/hooks/useBackend/post.ts +0 -6
- package/src/hooks/useBackend/put.ts +0 -6
- package/src/hooks/useCampaigns/index.ts +0 -11
- package/src/hooks/useCategories/index.ts +0 -7
- package/src/hooks/useChats/index.ts +0 -13
- package/src/hooks/useContactGroups/index.ts +0 -28
- package/src/hooks/useContacts/index.ts +0 -21
- package/src/hooks/useCurrencies/index.ts +0 -14
- package/src/hooks/useCustomers/index.ts +0 -21
- package/src/hooks/useDocuments/index.ts +0 -86
- package/src/hooks/useDomains/index.ts +0 -10
- package/src/hooks/useEmailTemplates/index.ts +0 -13
- package/src/hooks/useEntityStatuses/index.ts +0 -13
- package/src/hooks/useForms/index.ts +0 -16
- package/src/hooks/useIntegrations/index.ts +0 -15
- package/src/hooks/useInvites/index.ts +0 -19
- package/src/hooks/useLabels/index.ts +0 -13
- package/src/hooks/useLanguages/index.ts +0 -16
- package/src/hooks/useLeads/index.ts +0 -149
- package/src/hooks/useMedia/index.ts +0 -13
- package/src/hooks/useOrders/index.ts +0 -74
- package/src/hooks/usePaths/index.ts +0 -16
- package/src/hooks/usePermissions/index.ts +0 -16
- package/src/hooks/useProducts/index.ts +0 -18
- package/src/hooks/useProfile/index.ts +0 -20
- package/src/hooks/useRenting/index.ts +0 -57
- package/src/hooks/useRoles/index.ts +0 -10
- package/src/hooks/useRoom/index.ts +0 -20
- package/src/hooks/useRotations/index.ts +0 -13
- package/src/hooks/useSiteConfig/index.ts +0 -13
- package/src/hooks/useStatuses/index.ts +0 -10
- package/src/hooks/useStock/index.ts +0 -48
- package/src/hooks/useStores/index.ts +0 -23
- package/src/hooks/useSubscriptions/index.ts +0 -17
- package/src/hooks/useTable/index.ts +0 -15
- package/src/hooks/useTeams/index.ts +0 -29
- package/src/hooks/useTickets/index.ts +0 -17
- package/src/hooks/useTransactions/index.ts +0 -43
- package/src/hooks/useTranslations/index.ts +0 -20
- package/src/hooks/useUserConnections/index.ts +0 -18
- package/src/hooks/useUserSubscriptions/index.ts +0 -28
- package/src/hooks/useUsers/index.ts +0 -57
- package/src/hooks/useWBSuite/index.ts +0 -29
- package/src/hooks/useWebsites/index.ts +0 -34
- package/src/models/Requestor.ts +0 -67
- package/src/next/utils/wrapAsync.ts +0 -2
- package/src/utils/authWithApiKey.ts +0 -3
- package/src/utils/authWithToken.ts +0 -3
- package/src/utils/index.ts +0 -7
- package/tsconfig.json +0 -20
|
@@ -1,74 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,16 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,16 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,18 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,20 +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 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
|
-
};
|
|
@@ -1,57 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,20 +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 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
|
-
};
|
|
@@ -1,13 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,13 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,48 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,23 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,17 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,15 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,29 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,17 +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 useTickets: BackendHook<Chat> = (auth?: RequestorOptions['auth']) => {
|
|
6
|
-
const { requestor, ...endpoints } = useBackend('tickets', { auth });
|
|
7
|
-
return {
|
|
8
|
-
requestor,
|
|
9
|
-
...endpoints,
|
|
10
|
-
resolve: (ticketId: string) =>
|
|
11
|
-
requestor.makeRequest.post(`tickets/${ticketId}/resolve`).then(({ data }) => data),
|
|
12
|
-
addComment: (ticketId: string, note: { text: string, extra: Record<string, unknown> }) =>
|
|
13
|
-
requestor.makeRequest.post(`tickets/${ticketId}/comment`, note).then(({ data }) => data),
|
|
14
|
-
commentHistory: (ticketId: string) =>
|
|
15
|
-
requestor.makeRequest.post(`tickets/${ticketId}/comment/history`).then(({ data }) => data),
|
|
16
|
-
};
|
|
17
|
-
};
|
|
@@ -1,43 +0,0 @@
|
|
|
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
|
-
type EntityTypes = 'renting' | 'order';
|
|
6
|
-
|
|
7
|
-
export const useTransactions: BackendHook<
|
|
8
|
-
Record<string, string>,
|
|
9
|
-
any,
|
|
10
|
-
{
|
|
11
|
-
listPaymentMethods: () => Promise<CustomResponse<Record<string, unknown>[]>>;
|
|
12
|
-
getPublicPayment: (
|
|
13
|
-
entity: EntityTypes,
|
|
14
|
-
entityId: string,
|
|
15
|
-
method: string
|
|
16
|
-
) => Promise<CustomResponse<Record<string, unknown>[]>>;
|
|
17
|
-
}
|
|
18
|
-
> = (auth?: RequestorOptions['auth']) => {
|
|
19
|
-
const { requestor, ...rest } = useBackend('transactions', { auth });
|
|
20
|
-
return {
|
|
21
|
-
...rest,
|
|
22
|
-
requestor,
|
|
23
|
-
listPaymentMethods: () => {
|
|
24
|
-
return requestor.makeRequest.get(`transactions/methods`).then(({ data }) => data);
|
|
25
|
-
},
|
|
26
|
-
getPayment: (entity: EntityTypes, entityId: string, method: string, amount?: number) => {
|
|
27
|
-
return requestor.makeRequest
|
|
28
|
-
.post(`transactions/${method}/${entity}/${entityId}`, { amount })
|
|
29
|
-
.then(({ data }) => data);
|
|
30
|
-
},
|
|
31
|
-
getPublicPayment: (entity: EntityTypes, entityId: string, method: string, amount?: number) => {
|
|
32
|
-
return requestor.makeRequest
|
|
33
|
-
.post(`transactions/public/${method}/${entity}/${entityId}`, { amount })
|
|
34
|
-
.then(({ data }) => data);
|
|
35
|
-
},
|
|
36
|
-
cancelPayment: (transactionId: string) => {
|
|
37
|
-
return requestor.makeRequest.post(`transactions/cancel/${transactionId}`).then(({ data }) => data);
|
|
38
|
-
},
|
|
39
|
-
completePayment: (transactionId: string) => {
|
|
40
|
-
return requestor.makeRequest.post(`transactions/complete/${transactionId}`).then(({ data }) => data);
|
|
41
|
-
},
|
|
42
|
-
};
|
|
43
|
-
};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { RequestorOptions } from 'models/Requestor';
|
|
2
|
-
import { BackendHook, useBackend } from '../useBackend';
|
|
3
|
-
|
|
4
|
-
export const useTranslations: BackendHook<
|
|
5
|
-
Record<string, string>,
|
|
6
|
-
any,
|
|
7
|
-
{ getJson: () => Promise<Record<string, unknown>>; getProductJson: () => Promise<Record<string, unknown>> }
|
|
8
|
-
> = (auth?: RequestorOptions['auth']) => {
|
|
9
|
-
const { requestor, ...rest } = useBackend('translations', { auth });
|
|
10
|
-
return {
|
|
11
|
-
...rest,
|
|
12
|
-
requestor,
|
|
13
|
-
getJson: () => {
|
|
14
|
-
return requestor.makeRequest.get(`translations/getAll`).then(({ data }) => data);
|
|
15
|
-
},
|
|
16
|
-
getProductJson: () => {
|
|
17
|
-
return requestor.makeRequest.get(`translations/product/getAll`).then(({ data }) => data);
|
|
18
|
-
},
|
|
19
|
-
};
|
|
20
|
-
};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { BackendHook, useBackend } from '../useBackend';
|
|
2
|
-
import { RequestorOptions } from 'models/Requestor';
|
|
3
|
-
|
|
4
|
-
export const useUserConnection: BackendHook = (auth?: RequestorOptions['auth']) => {
|
|
5
|
-
const { requestor, ...endpoints } = useBackend('user-connections', { auth });
|
|
6
|
-
return {
|
|
7
|
-
requestor,
|
|
8
|
-
...endpoints,
|
|
9
|
-
create: (data) =>
|
|
10
|
-
requestor.makeRequest.post(`user-connections`, data).then(({ data }) => data),
|
|
11
|
-
update: (id: any, data: any) =>
|
|
12
|
-
requestor.makeRequest.put(`user-connections/${id}`, data).then(({ data }) => data),
|
|
13
|
-
delete: (id: string) =>
|
|
14
|
-
requestor.makeRequest.delete(`user-connections/${id}`).then(({ data }) => data),
|
|
15
|
-
searchContactExternalId: (searchValue: string, { userConnectionIds }: { userConnectionIds?: string[] }) =>
|
|
16
|
-
requestor.makeRequest.get(`user-connections/search/contact/${searchValue}`, { params: { userConnectionIds } }).then(({ data }) => data),
|
|
17
|
-
};
|
|
18
|
-
};
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { BackendHook, useBackend } from '../useBackend';
|
|
3
|
-
import { RequestorOptions } from 'models/Requestor';
|
|
4
|
-
|
|
5
|
-
export const useUserSubscriptions: BackendHook<
|
|
6
|
-
Record<string, string>,
|
|
7
|
-
any,
|
|
8
|
-
{
|
|
9
|
-
subscribe: (subscriptionId: string, subscriptionDetails: Record<string, unknown>) => Promise<void>;
|
|
10
|
-
requestPayment: (userSubscriptionId: string, data: Record<string, unknown>) => Promise<void>;
|
|
11
|
-
cancel: (userSubscriptionId: string) => Promise<void>;
|
|
12
|
-
}
|
|
13
|
-
> = (auth?: RequestorOptions['auth']) => {
|
|
14
|
-
const { requestor, ...rest } = useBackend('user-subscriptions', { auth });
|
|
15
|
-
return {
|
|
16
|
-
...rest,
|
|
17
|
-
requestor,
|
|
18
|
-
subscribe: (subscriptionId: string, subscriptionDetails: Record<string, unknown>) => {
|
|
19
|
-
return requestor.makeRequest.post(`user-subscriptions/${subscriptionId}`, subscriptionDetails).then(({ data }) => data);
|
|
20
|
-
},
|
|
21
|
-
requestPayment: (userSubscriptionId: string, data: Record<string, unknown>) => {
|
|
22
|
-
return requestor.makeRequest.post(`user-subscriptions/payment/request/${userSubscriptionId}`, data).then(({ data }) => data);
|
|
23
|
-
},
|
|
24
|
-
cancel: (userSubscriptionId: string) => {
|
|
25
|
-
return requestor.makeRequest.post(`user-subscriptions/${userSubscriptionId}/cancel`).then(({ data }) => data);
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
};
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { BackendHook, useBackend } from '../useBackend';
|
|
2
|
-
import { CustomResponse } from '@wb/types/custom-response/custom-response.model';
|
|
3
|
-
import { RequestorOptions } from 'models/Requestor';
|
|
4
|
-
|
|
5
|
-
type LoginResponse = CustomResponse<{ user: unknown; token: { access_token: string; expires_in: number; token_type: string } }>;
|
|
6
|
-
type LoginFunction = (
|
|
7
|
-
username: string,
|
|
8
|
-
password: string
|
|
9
|
-
) => Promise<LoginResponse>;
|
|
10
|
-
|
|
11
|
-
export const useUsers: BackendHook<
|
|
12
|
-
any,
|
|
13
|
-
any,
|
|
14
|
-
{
|
|
15
|
-
login: LoginFunction;
|
|
16
|
-
getSession: () => Promise<LoginResponse>
|
|
17
|
-
restartSession: (token: string) => Promise<LoginResponse> | Promise<CustomResponse>
|
|
18
|
-
}
|
|
19
|
-
> = (auth?: RequestorOptions['auth']) => {
|
|
20
|
-
const { requestor, ...endpoints } = useBackend('users', { auth });
|
|
21
|
-
return {
|
|
22
|
-
...endpoints,
|
|
23
|
-
requestor,
|
|
24
|
-
login: async (username: string, password: string) => {
|
|
25
|
-
const { data: response } = await requestor.makeRequest.post<LoginResponse>('users/login', { username, password });
|
|
26
|
-
return response;
|
|
27
|
-
},
|
|
28
|
-
getSession: async () => {
|
|
29
|
-
const { data: response } = await requestor.makeRequest.get<LoginResponse>('users/login');
|
|
30
|
-
return response;
|
|
31
|
-
},
|
|
32
|
-
restartSession: async () => {
|
|
33
|
-
try {
|
|
34
|
-
const { data: response } = await requestor.makeRequest.get<LoginResponse>('users/login')
|
|
35
|
-
return response;
|
|
36
|
-
} catch(err) {
|
|
37
|
-
return { success: false, data: null };
|
|
38
|
-
}
|
|
39
|
-
},
|
|
40
|
-
getPermissions: async () => {
|
|
41
|
-
return requestor.makeRequest.get<LoginResponse>('users/permissions').then(({ data }) => data);
|
|
42
|
-
},
|
|
43
|
-
getUserSummary: async (userId: string) => {
|
|
44
|
-
const { data: response } = await requestor.makeRequest.get<LoginResponse>(`users/${userId}/profile`).then(({ data }) => data);
|
|
45
|
-
return response;
|
|
46
|
-
},
|
|
47
|
-
logout: async () => {
|
|
48
|
-
return requestor.makeRequest.post<LoginResponse>('users/logout').then(({ data }) => data);
|
|
49
|
-
},
|
|
50
|
-
updateStore: (userId: string, stores: string[]) => {
|
|
51
|
-
return requestor.makeRequest.put(`users/${userId}/stores`, { stores }).then(({ data }) => data);
|
|
52
|
-
},
|
|
53
|
-
updateRoles: (userId: string, roles: string[]) => {
|
|
54
|
-
return requestor.makeRequest.put(`users/${userId}/roles`, { roles }).then(({ data }) => data);
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
};
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { WBBackendConfig } from '@wb/types/backendConfig/backendConfig';
|
|
2
|
-
|
|
3
|
-
const process = globalThis.process || {};
|
|
4
|
-
|
|
5
|
-
const DEFAULTS = {
|
|
6
|
-
apiURL: process?.env?.WB_API_URL || 'https://api.wbsuite.app/api/v2',
|
|
7
|
-
publicURL: process?.env?.WB_PUBLIC_URL || 'https://api.wbsuite.app/public',
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
(globalThis as any).WBSUITE_CONFIG;
|
|
11
|
-
(globalThis as any).initialized = false;
|
|
12
|
-
|
|
13
|
-
export const useWBSuite = (wbsuiteConfiguration: Partial<WBBackendConfig> = {}) => {
|
|
14
|
-
if (!(globalThis as any).initialized) {
|
|
15
|
-
(globalThis as any).initialized = true;
|
|
16
|
-
(globalThis as any).WBSUITE_CONFIG = {
|
|
17
|
-
...DEFAULTS,
|
|
18
|
-
...Object.fromEntries(
|
|
19
|
-
Object.entries({
|
|
20
|
-
...wbsuiteConfiguration,
|
|
21
|
-
}).filter(([, value]) => value !== undefined && value !== null)
|
|
22
|
-
),
|
|
23
|
-
};
|
|
24
|
-
return true;
|
|
25
|
-
} else {
|
|
26
|
-
console.warn('Configuration skipped since it was already configured');
|
|
27
|
-
return false;
|
|
28
|
-
}
|
|
29
|
-
};
|