@wbsuite/react-hooks 1.0.214 → 1.0.216
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 +37 -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/useFormSubmissions/index.d.ts +2 -0
- package/cjs/hooks/useFormSubmissions/index.js +9 -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 +77 -0
- package/{src/index.ts → cjs/index.d.ts} +1 -1
- package/cjs/index.js +119 -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 +33 -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/useFormSubmissions/index.d.ts +2 -0
- package/esm/hooks/useFormSubmissions/index.js +5 -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 +73 -0
- package/esm/index.d.ts +51 -0
- package/esm/index.js +52 -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/useApps/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 -13
- 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/useFormSubmissions/index.ts +0 -6
- 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
package/README.md
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
## Installing wbsuite react hooks library
|
|
2
|
-
1. Install dependency in your proyect by running `npm i @wbsuite/react-hooks`
|
|
3
|
-
|
|
4
|
-
## How to use
|
|
5
|
-
1. Set up wbsuite by running the `useWBSuite` hook with the api key you were given.
|
|
6
|
-
|
|
7
|
-
```
|
|
8
|
-
function App() {
|
|
9
|
-
useWBSuite({ apiKey: '<your-api-key>' });
|
|
10
|
-
return <></>
|
|
11
|
-
}
|
|
12
|
-
```
|
|
13
|
-
|
|
14
|
-
2. You're ready to start using the hooks you need. This library version contains:
|
|
15
|
-
- useStores -- lists available stores for your team
|
|
16
|
-
- useProducts -- lists products available for your team
|
|
17
|
-
- useCategories -- lists categories available for your team
|
|
18
|
-
- useRenting -- renting utils
|
|
19
|
-
- useDocuments -- document / images utils
|
|
20
|
-
- useLeads -- create leads for your campaigns
|
|
21
|
-
|
|
22
|
-
### useCategories
|
|
23
|
-
This hook is used to list, get or create categories. In order to use it consider:
|
|
24
|
-
|
|
25
|
-
```
|
|
26
|
-
const { list: listCategories } = useCategories();
|
|
27
|
-
|
|
28
|
-
useEffect(() => {
|
|
29
|
-
listCategories().then(categoryList => {
|
|
30
|
-
// Do what you need with the categoryList
|
|
31
|
-
});
|
|
32
|
-
}, []);
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
### useProducts
|
|
36
|
-
This hook is used to list, get or create products. In order to use it consider:
|
|
37
|
-
|
|
38
|
-
```
|
|
39
|
-
const { list: listProducts } = useProducts();
|
|
40
|
-
|
|
41
|
-
useEffect(() => {
|
|
42
|
-
/** filters needs to be an object with any valid property of the product schema.
|
|
43
|
-
* for example to get the products from a category you need to pass in an object like:
|
|
44
|
-
* { categories: <categoryId>[] }
|
|
45
|
-
*
|
|
46
|
-
* { categories: ['some-category-id', 'other-category-id'] }
|
|
47
|
-
*
|
|
48
|
-
* The categoryId can be retrieved from the useCategories hook explained above.
|
|
49
|
-
**/
|
|
50
|
-
listProducts(filters ?? {}).then(filteredProductList => {
|
|
51
|
-
// Do what you need with the filteredProductList
|
|
52
|
-
});
|
|
53
|
-
}, []);
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
## Permissions
|
|
57
|
-
Even if the hooks are available in the library the `apiKey` limits the permissions you have
|
|
58
|
-
access to.
|
|
59
|
-
|
|
60
|
-
Which means, that you won't be able to use all of our features unless you were given access to.
|
|
61
|
-
|
|
62
|
-
If, you find yourself in need of using a non-accessible util, please reach out to the provider.
|
|
63
|
-
|
|
64
|
-
## Additional documentation
|
|
65
|
-
|
|
66
|
-
For a complete walkthrough that covers configuration, authentication, available hooks, and extended examples, see [`docs/USAGE.md`](docs/USAGE.md).
|
package/docs/USAGE.md
DELETED
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
# Using the `@wbsuite/react-hooks` library
|
|
2
|
-
|
|
3
|
-
This guide walks through installing the package, configuring the WBSuite client, and using the provided hooks to call the API.
|
|
4
|
-
|
|
5
|
-
## Installation
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
npm install @wbsuite/react-hooks
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
## Configure WBSuite once
|
|
12
|
-
|
|
13
|
-
Initialize the client near the root of your app (for example in `_app.tsx` or your main layout component):
|
|
14
|
-
|
|
15
|
-
```tsx
|
|
16
|
-
import { useWBSuite } from '@wbsuite/react-hooks';
|
|
17
|
-
|
|
18
|
-
function App() {
|
|
19
|
-
useWBSuite({
|
|
20
|
-
apiKey: '<your-api-key>',
|
|
21
|
-
// optional overrides:
|
|
22
|
-
// apiURL: 'https://api.wbsuite.app/api/v2',
|
|
23
|
-
// publicURL: 'https://api.wbsuite.app/public',
|
|
24
|
-
// environment: 'development',
|
|
25
|
-
});
|
|
26
|
-
return <YourRoutes />;
|
|
27
|
-
}
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
- The first call stores the configuration globally; subsequent calls no-op and log a warning so you only need to run it once during app bootstrap.
|
|
31
|
-
- `apiURL` and `publicURL` default to the hosted endpoints shown above.
|
|
32
|
-
- Setting `environment: 'development'` enables verbose request/response logging for troubleshooting.
|
|
33
|
-
|
|
34
|
-
## Authenticating requests
|
|
35
|
-
|
|
36
|
-
Most hooks accept an optional `auth` argument so you can decide per call how to authenticate:
|
|
37
|
-
|
|
38
|
-
```tsx
|
|
39
|
-
const products = useProducts({ type: 'apiKey', apiKey: '<key>' });
|
|
40
|
-
const secureProducts = useProducts({ type: 'token', token: '<jwt>' });
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
- When `type` is `apiKey`, the requestor sends `x-api-key` headers. If you configured an `apiKey` in `useWBSuite`, you can omit the `auth` argument and that key will be used automatically.
|
|
44
|
-
- When `type` is `token`, the requestor swaps to a `Bearer` `Authorization` header.
|
|
45
|
-
|
|
46
|
-
## Working with backend hooks
|
|
47
|
-
|
|
48
|
-
Most exported hooks are thin wrappers around the shared `useBackend` helper. They expose a common shape:
|
|
49
|
-
|
|
50
|
-
- `list(filters?)` – fetch a filtered collection (filters mirror the entity fields where supported).
|
|
51
|
-
- `get(id)` – retrieve one entity.
|
|
52
|
-
- `create(data)` – create an entity (overridable by hooks that need custom logic).
|
|
53
|
-
- `update(id, data)` – update an entity (overridable by hooks that need custom logic).
|
|
54
|
-
- `requestor` – the underlying Axios instance if you need lower-level control.
|
|
55
|
-
|
|
56
|
-
Example using categories:
|
|
57
|
-
|
|
58
|
-
```tsx
|
|
59
|
-
import { useCategories } from '@wbsuite/react-hooks';
|
|
60
|
-
|
|
61
|
-
const { list, create, update } = useCategories();
|
|
62
|
-
|
|
63
|
-
useEffect(() => {
|
|
64
|
-
list({ name: 'Vehicles' }).then(({ data }) => {
|
|
65
|
-
// work with filtered categories
|
|
66
|
-
});
|
|
67
|
-
}, [list]);
|
|
68
|
-
|
|
69
|
-
const addCategory = async () => {
|
|
70
|
-
const result = await create({ name: 'New Category' });
|
|
71
|
-
console.log(result.data);
|
|
72
|
-
};
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
## Product-specific helpers
|
|
76
|
-
|
|
77
|
-
Some hooks extend the base methods with extra endpoints. For example, `useProducts` adds custom `create`, `update`, and `delete` helpers that call the product-specific routes directly:
|
|
78
|
-
|
|
79
|
-
```tsx
|
|
80
|
-
import { useProducts } from '@wbsuite/react-hooks';
|
|
81
|
-
|
|
82
|
-
const { list, create, update, delete: remove } = useProducts();
|
|
83
|
-
|
|
84
|
-
const refresh = async () => {
|
|
85
|
-
const response = await list({ categories: ['category-id'] });
|
|
86
|
-
console.log(response.data);
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
const saveProduct = async () => {
|
|
90
|
-
const created = await create({ name: 'My product' });
|
|
91
|
-
const updated = await update(created.data.id, { price: 999 });
|
|
92
|
-
await remove(updated.data.id);
|
|
93
|
-
};
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
## Available hooks
|
|
97
|
-
|
|
98
|
-
All hooks live under `react-hooks/src/hooks/` and follow the same configuration approach:
|
|
99
|
-
|
|
100
|
-
- Content & catalog: `useArticles`, `useAttributes`, `useAttributesGroups`, `useCategories`, `useDocuments`, `useEntityStatuses`, `useMedia`, `useProducts`, `useRenting`, `useRoom`, `useStock`, `useTable`, `useTransactions`.
|
|
101
|
-
- Commerce & orders: `useOrders`, `useRotations`.
|
|
102
|
-
- Customers & contacts: `useCampaigns`, `useCustomers`, `useLeads`.
|
|
103
|
-
- Accounts & permissions: `useBackend`, `useInvites`, `usePermissions`, `useProfile`, `useRoles`, `useStatuses`, `useTeams`, `useUserConnections`, `useUsers`, `useWBSuite`.
|
|
104
|
-
- Localization & communication: `useChats`, `useCurrencies`, `useEmailTemplates`, `useLanguages`, `useSiteConfig`, `useTranslations`.
|
|
105
|
-
- Platform configuration: `useBackend`, `useDomains`, `useStores`, `useWebsites`.
|
|
106
|
-
|
|
107
|
-
Use the lists above as a starting point when exploring the package; each hook mirrors a WBSuite API resource and uses the same initialization and authentication rules described earlier.
|
package/eslint.config.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
const eslint = require('@eslint/js');
|
|
2
|
-
const tseslint = require('typescript-eslint');
|
|
3
|
-
|
|
4
|
-
module.exports = tseslint.config(
|
|
5
|
-
eslint.configs.recommended,
|
|
6
|
-
...tseslint.configs.recommended,
|
|
7
|
-
{
|
|
8
|
-
'rules': {
|
|
9
|
-
'@typescript-eslint/no-explicit-any': 'warn'
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
);
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { RequestorOptions } from 'models/Requestor';
|
|
2
|
-
import { BackendHook, useBackend } from '../useBackend';
|
|
3
|
-
|
|
4
|
-
export const useAgents: BackendHook<any, undefined> = (auth?: RequestorOptions['auth']) => {
|
|
5
|
-
const { requestor, ...rest } = useBackend('agents', { auth });
|
|
6
|
-
return {
|
|
7
|
-
...rest,
|
|
8
|
-
requestor,
|
|
9
|
-
};
|
|
10
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { RequestorOptions } from 'models/Requestor';
|
|
2
|
-
import { BackendHook, useBackend } from '../useBackend';
|
|
3
|
-
|
|
4
|
-
export const useApps: BackendHook<any, undefined> = (auth?: RequestorOptions['auth']) => {
|
|
5
|
-
const { requestor, ...rest } = useBackend('apps', { auth });
|
|
6
|
-
return {
|
|
7
|
-
...rest,
|
|
8
|
-
requestor,
|
|
9
|
-
};
|
|
10
|
-
};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { slateToHtml } from '@slate-serializers/html';
|
|
2
|
-
import { BackendHook, useBackend } from '../useBackend';
|
|
3
|
-
import { RequestorOptions } from 'models/Requestor';
|
|
4
|
-
|
|
5
|
-
export const deserialize = (content: string) => {
|
|
6
|
-
try {
|
|
7
|
-
const deserializedContent = JSON.parse(content);
|
|
8
|
-
if(Array.isArray(deserializedContent)) return slateToHtml(deserializedContent);
|
|
9
|
-
return deserializedContent;
|
|
10
|
-
} catch (e) {
|
|
11
|
-
return content;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export const useArticles: BackendHook<any, any, { deserialize: (content: string) => string }> = (auth?: RequestorOptions['auth']) => {
|
|
16
|
-
const { ...endpoints } = useBackend('articles', { auth });
|
|
17
|
-
return { ...endpoints, deserialize };
|
|
18
|
-
};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { BackendHook, useBackend } from '../useBackend';
|
|
2
|
-
import { RequestorOptions } from 'models/Requestor';
|
|
3
|
-
|
|
4
|
-
export const useAttributes: BackendHook = (auth?: RequestorOptions['auth']) => {
|
|
5
|
-
const { requestor, ...endpoints } = useBackend('attributes', { auth });
|
|
6
|
-
return {
|
|
7
|
-
requestor,
|
|
8
|
-
...endpoints,
|
|
9
|
-
create: (data) =>
|
|
10
|
-
requestor.makeRequest.post(`attributes`, data).then(({ data }) => data),
|
|
11
|
-
update: (id: any, data: any) =>
|
|
12
|
-
requestor.makeRequest.put(`attributes/${id}`, data).then(({ data }) => data),
|
|
13
|
-
delete: (id: string) =>
|
|
14
|
-
requestor.makeRequest.delete(`attributes/${id}`).then(({ data }) => data),
|
|
15
|
-
getGrouped: () =>
|
|
16
|
-
requestor.makeRequest.get(`attributes/grouped`).then(({ data }) => data),
|
|
17
|
-
};
|
|
18
|
-
};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { BackendHook, useBackend } from '../useBackend';
|
|
2
|
-
import { RequestorOptions } from 'models/Requestor';
|
|
3
|
-
import { IAttributeGroup } from '@wb/types/products/attributeGroup.model';
|
|
4
|
-
|
|
5
|
-
export const useAttributesGroups: BackendHook<IAttributeGroup> = (auth?: RequestorOptions['auth']) => {
|
|
6
|
-
const { requestor, ...endpoints } = useBackend('attribute/groups', { auth });
|
|
7
|
-
return {
|
|
8
|
-
requestor,
|
|
9
|
-
...endpoints,
|
|
10
|
-
create: (data) =>
|
|
11
|
-
requestor.makeRequest.post(`attribute/groups`, data).then(({ data }) => data),
|
|
12
|
-
update: (id, data) =>
|
|
13
|
-
requestor.makeRequest.put(`attribute/groups/${id}`, data).then(({ data }) => data),
|
|
14
|
-
delete: (id: string) =>
|
|
15
|
-
requestor.makeRequest.delete(`attribute/groups/${id}`).then(({ data }) => data),
|
|
16
|
-
};
|
|
17
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { RequestorOptions } from 'models/Requestor';
|
|
2
|
-
import { BackendHook, useBackend } from '../useBackend';
|
|
3
|
-
|
|
4
|
-
export const useAutomations: BackendHook<any, undefined> = (auth?: RequestorOptions['auth']) => {
|
|
5
|
-
const { requestor, ...rest } = useBackend('automations', { auth });
|
|
6
|
-
return {
|
|
7
|
-
...rest,
|
|
8
|
-
requestor,
|
|
9
|
-
};
|
|
10
|
-
};
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { list } from './list';
|
|
2
|
-
import { get } from './get';
|
|
3
|
-
import { Requestor, RequestorOptions } from '../../models/Requestor';
|
|
4
|
-
import { post } from './post';
|
|
5
|
-
import { CustomResponse } from '@wb/types/custom-response/custom-response.model';
|
|
6
|
-
import { put } from './put';
|
|
7
|
-
|
|
8
|
-
type OtherMethods<T> = (Record<string, (...args: any[]) => Promise<CustomResponse<T[]> | CustomResponse<T>>>) | Record<'requestor', Requestor>;
|
|
9
|
-
|
|
10
|
-
// Base methods that cannot be overridden
|
|
11
|
-
type BaseMethods<T> = {
|
|
12
|
-
requestor: Requestor;
|
|
13
|
-
list: (filters?: Partial<T>) => Promise<CustomResponse<T[]>>,
|
|
14
|
-
get: (id: string) => Promise<CustomResponse<T>>,
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
// Default overridable methods
|
|
18
|
-
type DefaultOverridableMethods<T> = {
|
|
19
|
-
create: (param: Partial<T>) => Promise<CustomResponse<T>>,
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
// If OM contains any keys that overlap with DefaultOverridableMethods, those will take precedence
|
|
23
|
-
// Example: Backend<MyType, { create: (data: MyType) => Promise<MyType> }>
|
|
24
|
-
// will use the custom create method instead of the default one
|
|
25
|
-
export type Backend<T = any, OM = OtherMethods<T>> = BaseMethods<T> &
|
|
26
|
-
Omit<DefaultOverridableMethods<T>, keyof OM> &
|
|
27
|
-
OM;
|
|
28
|
-
|
|
29
|
-
export type BackendHook<T = any, A = any, OM = OtherMethods<T>> = (auth?: RequestorOptions['auth'], ...args: A[]) => Backend<T, OM>;
|
|
30
|
-
|
|
31
|
-
export const useBackend = <T = any>(path: string, opts: Partial<{ auth: RequestorOptions['auth'] }> = {}): Backend<T> => {
|
|
32
|
-
const requestor = new Requestor((globalThis as any).WBSUITE_CONFIG, undefined, opts);
|
|
33
|
-
return {
|
|
34
|
-
requestor,
|
|
35
|
-
list: list.bind(this, requestor, path),
|
|
36
|
-
get: get.bind(this, requestor, path),
|
|
37
|
-
create: post.bind(this, requestor, path),
|
|
38
|
-
update: put.bind(this, requestor, path),
|
|
39
|
-
}
|
|
40
|
-
};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { BackendHook, useBackend } from '../useBackend';
|
|
2
|
-
import { RequestorOptions } from 'models/Requestor';
|
|
3
|
-
|
|
4
|
-
export const useCampaigns: BackendHook = (auth?: RequestorOptions['auth']) => {
|
|
5
|
-
const { requestor, ...endpoints } = useBackend('campaigns', { auth });
|
|
6
|
-
return {
|
|
7
|
-
requestor,
|
|
8
|
-
...endpoints,
|
|
9
|
-
delete: (id: string) => requestor.makeRequest.delete(`campaigns/${id}`).then(({ data }) => data)
|
|
10
|
-
};
|
|
11
|
-
};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { BackendHook, useBackend } from '../useBackend';
|
|
2
|
-
import { RequestorOptions } from 'models/Requestor';
|
|
3
|
-
import { ICategory } from '@wb/types/category/category.model'
|
|
4
|
-
|
|
5
|
-
export const useCategories: BackendHook<ICategory> = (auth?: RequestorOptions['auth']) => {
|
|
6
|
-
const { requestor, ...rest } = useBackend<ICategory>('categories', { auth });
|
|
7
|
-
return {
|
|
8
|
-
...rest,
|
|
9
|
-
requestor,
|
|
10
|
-
delete: (id: string) =>
|
|
11
|
-
requestor.makeRequest.delete(`categories/${id}`).then(({ data }) => data),
|
|
12
|
-
};
|
|
13
|
-
};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { BackendHook, useBackend } from '../useBackend';
|
|
2
|
-
import { Chat } from '@wb/types/chats/chats.model';
|
|
3
|
-
import { RequestorOptions } from 'models/Requestor';
|
|
4
|
-
|
|
5
|
-
export const useChats: BackendHook<Chat> = (auth?: RequestorOptions['auth']) => {
|
|
6
|
-
const { requestor, ...endpoints } = useBackend('chats', { auth });
|
|
7
|
-
return {
|
|
8
|
-
requestor,
|
|
9
|
-
...endpoints,
|
|
10
|
-
metadata: (chatId: string) =>
|
|
11
|
-
requestor.makeRequest.get(`chats/${chatId}/metadata`).then(({ data }) => data),
|
|
12
|
-
};
|
|
13
|
-
};
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { RequestorOptions } from 'models/Requestor';
|
|
3
|
-
import { BackendHook, useBackend } from '../useBackend';
|
|
4
|
-
|
|
5
|
-
export type ICustomer = Record<string, unknown>;
|
|
6
|
-
|
|
7
|
-
export const useContactGroups: BackendHook<ICustomer> = (auth?: RequestorOptions['auth']) => {
|
|
8
|
-
const { requestor, ...endpoints } = useBackend<ICustomer>('identities', { auth });
|
|
9
|
-
return {
|
|
10
|
-
requestor,
|
|
11
|
-
...endpoints,
|
|
12
|
-
addIdentity: (groupId: string, identityId: string) => {
|
|
13
|
-
return requestor.makeRequest.post(`contact-groups/${groupId}/identities`, { identityId }).then(({ data }) => data);
|
|
14
|
-
},
|
|
15
|
-
addIdentities: (groupId: string, identities: string[]) => {
|
|
16
|
-
return requestor.makeRequest.post(`contact-groups/${groupId}/identities`, { identities }).then(({ data }) => data);
|
|
17
|
-
},
|
|
18
|
-
updateGroupIdentities: (groupId: string, identities: string[]) => {
|
|
19
|
-
return requestor.makeRequest.post(`contact-groups/${groupId}/identities`, { identities }).then(({ data }) => data);
|
|
20
|
-
},
|
|
21
|
-
removeIdentity: (groupId: string, identityId: string) => {
|
|
22
|
-
return requestor.makeRequest.delete(`contact-groups/${groupId}/identities/${identityId}`).then(({ data }) => data);
|
|
23
|
-
},
|
|
24
|
-
removeIdentities: (groupId: string, identities: string[]) => {
|
|
25
|
-
return requestor.makeRequest.post(`contact-groups/${groupId}/identities/bulk/remove`, { identities }).then(({ data }) => data);
|
|
26
|
-
},
|
|
27
|
-
};
|
|
28
|
-
};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { RequestorOptions } from 'models/Requestor';
|
|
3
|
-
import { BackendHook, useBackend } from '../useBackend';
|
|
4
|
-
|
|
5
|
-
export type ICustomer = Record<string, unknown>;
|
|
6
|
-
|
|
7
|
-
export const useContacts: BackendHook<ICustomer> = (auth?: RequestorOptions['auth']) => {
|
|
8
|
-
const { requestor, ...endpoints } = useBackend<ICustomer>('identities', { auth });
|
|
9
|
-
return {
|
|
10
|
-
requestor,
|
|
11
|
-
...endpoints,
|
|
12
|
-
get: (id: string) =>
|
|
13
|
-
requestor.makeRequest.get(`identities/${id}`).then(({ data }) => data),
|
|
14
|
-
create: (data) =>
|
|
15
|
-
requestor.makeRequest.post(`identities`, data).then(({ data }) => data),
|
|
16
|
-
update: (id: any, data: any) =>
|
|
17
|
-
requestor.makeRequest.put(`identities/${id}`, data).then(({ data }) => data),
|
|
18
|
-
delete: (id: string) =>
|
|
19
|
-
requestor.makeRequest.delete(`identities/${id}`).then(({ data }) => data),
|
|
20
|
-
};
|
|
21
|
-
};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { ICurrency } from '@wb/types/currency/currency.model';
|
|
2
|
-
import { RequestorOptions } from 'models/Requestor';
|
|
3
|
-
import { BackendHook, useBackend } from '../useBackend';
|
|
4
|
-
|
|
5
|
-
export const useCurrencies: BackendHook<ICurrency> = (auth?: RequestorOptions['auth']) => {
|
|
6
|
-
const { requestor, ...rest } = useBackend('currencies', { auth });
|
|
7
|
-
return {
|
|
8
|
-
...rest,
|
|
9
|
-
requestor,
|
|
10
|
-
toggleStatus: (id: string) => {
|
|
11
|
-
return requestor.makeRequest.put(`currencies/${id}/toggle-status`).then(({ data }) => data);
|
|
12
|
-
},
|
|
13
|
-
};
|
|
14
|
-
};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { RequestorOptions } from 'models/Requestor';
|
|
3
|
-
import { BackendHook, useBackend } from '../useBackend';
|
|
4
|
-
|
|
5
|
-
export type ICustomer = Record<string, unknown>;
|
|
6
|
-
|
|
7
|
-
export const useCustomers: BackendHook<ICustomer> = (auth?: RequestorOptions['auth']) => {
|
|
8
|
-
const { requestor, ...endpoints } = useBackend<ICustomer>('customers', { auth });
|
|
9
|
-
return {
|
|
10
|
-
requestor,
|
|
11
|
-
...endpoints,
|
|
12
|
-
get: (id: string) =>
|
|
13
|
-
requestor.makeRequest.get(`customers/${id}`).then(({ data }) => data),
|
|
14
|
-
create: (data) =>
|
|
15
|
-
requestor.makeRequest.post(`customers`, data).then(({ data }) => data),
|
|
16
|
-
update: (id: any, data: any) =>
|
|
17
|
-
requestor.makeRequest.put(`customers/${id}`, data).then(({ data }) => data),
|
|
18
|
-
delete: (id: string) =>
|
|
19
|
-
requestor.makeRequest.delete(`customers/${id}`).then(({ data }) => data),
|
|
20
|
-
};
|
|
21
|
-
};
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import { CustomResponse } from '@wb/types/custom-response/custom-response.model';
|
|
2
|
-
import { BackendHook, useBackend } from '../useBackend';
|
|
3
|
-
import { IDocument } from '@wb/types/document/documents.model';
|
|
4
|
-
import { RequestorOptions } from 'models/Requestor';
|
|
5
|
-
|
|
6
|
-
const getPublicUrl = (document: any) =>
|
|
7
|
-
document?.file?.filename ? `${(globalThis as any).WBSUITE_CONFIG?.publicURL}/${document.file.filename}` : '';
|
|
8
|
-
const getDescription = (document: any, lang: string = 'es', defaultLang: string = 'es') =>
|
|
9
|
-
document.description?.[lang] || document.description?.[defaultLang] || '';
|
|
10
|
-
const getTitle = (document: any, lang: string = 'es', defaultLang: string = 'es') =>
|
|
11
|
-
document.name?.[lang] || document.name?.[defaultLang] || '';
|
|
12
|
-
|
|
13
|
-
export const useDocuments: BackendHook<
|
|
14
|
-
IDocument,
|
|
15
|
-
any,
|
|
16
|
-
{
|
|
17
|
-
create: (document: IDocument) => Promise<CustomResponse<IDocument>>;
|
|
18
|
-
uploadFile: (id: string | undefined, file: File) => Promise<CustomResponse<any>>;
|
|
19
|
-
getPublicUrl: (document: any, lang?: string, defaultLang?: string) => string | undefined;
|
|
20
|
-
getDescription: (document: any, lang?: string, defaultLang?: string) => string | undefined;
|
|
21
|
-
getTitle: (document: any, lang?: string, defaultLang?: string) => string | undefined;
|
|
22
|
-
}
|
|
23
|
-
> = (auth?: RequestorOptions['auth']) => {
|
|
24
|
-
const { requestor, ...backend } = useBackend('documents', { auth });
|
|
25
|
-
const uploadFile = (id: string | undefined, file: File, options?: { convertTo?: string, height?: number, width?: number }) => {
|
|
26
|
-
const formData = new FormData();
|
|
27
|
-
formData.append('document', file);
|
|
28
|
-
if (options) {
|
|
29
|
-
formData.append('convertTo', options.convertTo || '');
|
|
30
|
-
formData.append('height', options.height?.toString() || '');
|
|
31
|
-
formData.append('width', options.width?.toString() || '');
|
|
32
|
-
}
|
|
33
|
-
if (id) {
|
|
34
|
-
return requestor.makeRequest
|
|
35
|
-
.put<CustomResponse<IDocument>>(`/documents/upload/${id}`, formData, {
|
|
36
|
-
headers: {
|
|
37
|
-
'Content-Type': 'multipart/form-data',
|
|
38
|
-
},
|
|
39
|
-
})
|
|
40
|
-
.then((res) => res.data);
|
|
41
|
-
} else {
|
|
42
|
-
return requestor.makeRequest
|
|
43
|
-
.post<CustomResponse<IDocument>>('/documents/upload', formData, {
|
|
44
|
-
headers: {
|
|
45
|
-
'Content-Type': 'multipart/form-data',
|
|
46
|
-
},
|
|
47
|
-
})
|
|
48
|
-
.then((res) => res.data);
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
return {
|
|
52
|
-
requestor,
|
|
53
|
-
...backend,
|
|
54
|
-
create: async (document: IDocument) => {
|
|
55
|
-
const { file, convertTo, height, width, ...rest } = document as any;
|
|
56
|
-
const { data } = await uploadFile(undefined, file as any, { convertTo, height, width });
|
|
57
|
-
return requestor.makeRequest
|
|
58
|
-
.post<CustomResponse<IDocument>>('/documents', {
|
|
59
|
-
...rest,
|
|
60
|
-
_id: data?._id,
|
|
61
|
-
})
|
|
62
|
-
.then((res) => res.data);
|
|
63
|
-
},
|
|
64
|
-
update: async (id: string, document: IDocument) => {
|
|
65
|
-
const { file, convertTo, height, width, ...rest } = document as any;
|
|
66
|
-
if (file) {
|
|
67
|
-
await uploadFile(id, file as any, { convertTo, height, width });
|
|
68
|
-
}
|
|
69
|
-
return requestor.makeRequest
|
|
70
|
-
.put<CustomResponse<IDocument>>(`/documents/${id}`, {
|
|
71
|
-
...rest,
|
|
72
|
-
_id: id,
|
|
73
|
-
})
|
|
74
|
-
.then((res) => res.data);
|
|
75
|
-
},
|
|
76
|
-
uploadFile,
|
|
77
|
-
getPublicUrl,
|
|
78
|
-
getDescription,
|
|
79
|
-
getTitle,
|
|
80
|
-
delete: async (id: string) => {
|
|
81
|
-
return requestor.makeRequest
|
|
82
|
-
.delete<CustomResponse<IDocument>>(`/documents/${id}`)
|
|
83
|
-
.then((res) => res.data);
|
|
84
|
-
},
|
|
85
|
-
};
|
|
86
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { RequestorOptions } from 'models/Requestor';
|
|
2
|
-
import { BackendHook, useBackend } from '../useBackend';
|
|
3
|
-
|
|
4
|
-
export const useDomains: BackendHook = (auth?: RequestorOptions['auth']) => {
|
|
5
|
-
const { requestor, ...rest } = useBackend('domains', { auth });
|
|
6
|
-
return {
|
|
7
|
-
...rest,
|
|
8
|
-
requestor,
|
|
9
|
-
};
|
|
10
|
-
};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { RequestorOptions } from 'models/Requestor';
|
|
2
|
-
import { BackendHook, useBackend } from '../useBackend';
|
|
3
|
-
|
|
4
|
-
export const useEmailTemplates: BackendHook = (auth?: RequestorOptions['auth']) => {
|
|
5
|
-
const { requestor, ...rest } = useBackend('user-email-templates', { auth });
|
|
6
|
-
return {
|
|
7
|
-
...rest,
|
|
8
|
-
requestor,
|
|
9
|
-
duplicate: (templateId: string) => {
|
|
10
|
-
return requestor.makeRequest.post(`user-email-templates/${templateId}/duplicate`).then(({ data }) => data);
|
|
11
|
-
},
|
|
12
|
-
};
|
|
13
|
-
};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { RequestorOptions } from 'models/Requestor';
|
|
2
|
-
import { BackendHook, useBackend } from '../useBackend';
|
|
3
|
-
|
|
4
|
-
export const useEntityStatuses: BackendHook<any, any> = (auth?: RequestorOptions['auth']) => {
|
|
5
|
-
const { requestor, ...rest } = useBackend('statuses', { auth });
|
|
6
|
-
return {
|
|
7
|
-
...rest,
|
|
8
|
-
requestor,
|
|
9
|
-
getByEntity: (entity: string) => {
|
|
10
|
-
return requestor.makeRequest.get(`statuses/entity/${entity}`).then((r: { data: any }) => r.data);
|
|
11
|
-
},
|
|
12
|
-
};
|
|
13
|
-
};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { RequestorOptions } from 'models/Requestor';
|
|
2
|
-
import { BackendHook, useBackend } from '../useBackend';
|
|
3
|
-
|
|
4
|
-
export const useForms: BackendHook<
|
|
5
|
-
Record<string, string>,
|
|
6
|
-
undefined
|
|
7
|
-
> = (auth?: RequestorOptions['auth']) => {
|
|
8
|
-
const { requestor, ...rest } = useBackend('forms', { auth });
|
|
9
|
-
return {
|
|
10
|
-
...rest,
|
|
11
|
-
requestor,
|
|
12
|
-
submit: (formId: string, data: any) => {
|
|
13
|
-
return requestor.makeRequest.post(`form-submissions/${formId}`, data).then(({ data }) => data);
|
|
14
|
-
}
|
|
15
|
-
};
|
|
16
|
-
};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { BackendHook, useBackend } from '../useBackend';
|
|
2
|
-
import { RequestorOptions } from 'models/Requestor';
|
|
3
|
-
|
|
4
|
-
export const useIntegrations: BackendHook = (auth?: RequestorOptions['auth']) => {
|
|
5
|
-
const { requestor, ...endpoints } = useBackend('integrations', { auth });
|
|
6
|
-
return {
|
|
7
|
-
requestor,
|
|
8
|
-
...endpoints,
|
|
9
|
-
authenticate: (integrationName: string, config?: Record<string, any>) => {
|
|
10
|
-
return requestor.makeRequest
|
|
11
|
-
.get(`integrations/${integrationName}/auth`, { params: config })
|
|
12
|
-
.then(({ data }) => data);
|
|
13
|
-
},
|
|
14
|
-
};
|
|
15
|
-
};
|