@wbsuite/react-hooks 1.0.211 → 1.0.212
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +66 -0
- package/docs/USAGE.md +107 -0
- package/eslint.config.js +12 -0
- package/package.json +1 -1
- package/src/hooks/useAgents/index.ts +10 -0
- package/src/hooks/useApps/index.ts +10 -0
- package/src/hooks/useArticles/index.ts +18 -0
- package/src/hooks/useAttributes/index.ts +18 -0
- package/src/hooks/useAttributesGroups/index.ts +17 -0
- package/src/hooks/useAutomations/index.ts +10 -0
- package/src/hooks/useBackend/get.ts +6 -0
- package/src/hooks/useBackend/index.ts +40 -0
- package/src/hooks/useBackend/list.ts +6 -0
- package/src/hooks/useBackend/post.ts +6 -0
- package/src/hooks/useBackend/put.ts +6 -0
- package/src/hooks/useCampaigns/index.ts +11 -0
- package/src/hooks/useCategories/index.ts +7 -0
- package/src/hooks/useChats/index.ts +13 -0
- package/src/hooks/useContactGroups/index.ts +28 -0
- package/src/hooks/useContacts/index.ts +21 -0
- package/src/hooks/useCurrencies/index.ts +14 -0
- package/src/hooks/useCustomers/index.ts +21 -0
- package/src/hooks/useDocuments/index.ts +86 -0
- package/src/hooks/useDomains/index.ts +10 -0
- package/src/hooks/useEmailTemplates/index.ts +13 -0
- package/src/hooks/useEntityStatuses/index.ts +13 -0
- package/src/hooks/useFormSubmissions/index.ts +6 -0
- package/src/hooks/useForms/index.ts +16 -0
- package/src/hooks/useIntegrations/index.ts +15 -0
- package/src/hooks/useInvites/index.ts +19 -0
- package/src/hooks/useLabels/index.ts +13 -0
- package/src/hooks/useLanguages/index.ts +16 -0
- package/src/hooks/useLeads/index.ts +149 -0
- package/src/hooks/useMedia/index.ts +13 -0
- package/src/hooks/useOrders/index.ts +74 -0
- package/src/hooks/usePaths/index.ts +16 -0
- package/src/hooks/usePermissions/index.ts +16 -0
- package/src/hooks/useProducts/index.ts +18 -0
- package/src/hooks/useProfile/index.ts +20 -0
- package/src/hooks/useRenting/index.ts +57 -0
- package/src/hooks/useRoles/index.ts +10 -0
- package/src/hooks/useRoom/index.ts +20 -0
- package/src/hooks/useRotations/index.ts +13 -0
- package/src/hooks/useSiteConfig/index.ts +13 -0
- package/src/hooks/useStatuses/index.ts +10 -0
- package/src/hooks/useStock/index.ts +48 -0
- package/src/hooks/useStores/index.ts +23 -0
- package/src/hooks/useSubscriptions/index.ts +17 -0
- package/src/hooks/useTable/index.ts +15 -0
- package/src/hooks/useTeams/index.ts +29 -0
- package/src/hooks/useTickets/index.ts +17 -0
- package/src/hooks/useTransactions/index.ts +43 -0
- package/src/hooks/useTranslations/index.ts +20 -0
- package/src/hooks/useUserConnections/index.ts +18 -0
- package/src/hooks/useUserSubscriptions/index.ts +28 -0
- package/src/hooks/useUsers/index.ts +57 -0
- package/src/hooks/useWBSuite/index.ts +29 -0
- package/src/hooks/useWebsites/index.ts +34 -0
- package/{esm/index.d.ts → src/index.ts} +2 -1
- package/src/models/Requestor.ts +67 -0
- package/{cjs/next/utils/index.d.ts → src/next/utils/index.ts} +1 -1
- package/src/next/utils/wrapAsync.ts +2 -0
- package/src/utils/authWithApiKey.ts +3 -0
- package/src/utils/authWithToken.ts +3 -0
- package/src/utils/index.ts +7 -0
- package/tsconfig.json +20 -0
- package/cjs/hooks/useAgents/index.d.ts +0 -2
- package/cjs/hooks/useAgents/index.js +0 -32
- package/cjs/hooks/useApps/index.d.ts +0 -2
- package/cjs/hooks/useApps/index.js +0 -32
- package/cjs/hooks/useArticles/index.d.ts +0 -5
- package/cjs/hooks/useArticles/index.js +0 -45
- package/cjs/hooks/useAttributes/index.d.ts +0 -2
- package/cjs/hooks/useAttributes/index.js +0 -52
- package/cjs/hooks/useAttributesGroups/index.d.ts +0 -3
- package/cjs/hooks/useAttributesGroups/index.js +0 -47
- package/cjs/hooks/useAutomations/index.d.ts +0 -2
- package/cjs/hooks/useAutomations/index.js +0 -32
- package/cjs/hooks/useBackend/get.d.ts +0 -2
- package/cjs/hooks/useBackend/get.js +0 -52
- package/cjs/hooks/useBackend/index.d.ts +0 -17
- package/cjs/hooks/useBackend/index.js +0 -22
- package/cjs/hooks/useBackend/list.d.ts +0 -2
- package/cjs/hooks/useBackend/list.js +0 -55
- package/cjs/hooks/useBackend/post.d.ts +0 -2
- package/cjs/hooks/useBackend/post.js +0 -52
- package/cjs/hooks/useBackend/put.d.ts +0 -2
- package/cjs/hooks/useBackend/put.js +0 -52
- package/cjs/hooks/useCampaigns/index.d.ts +0 -2
- package/cjs/hooks/useCampaigns/index.js +0 -35
- package/cjs/hooks/useCategories/index.d.ts +0 -3
- package/cjs/hooks/useCategories/index.js +0 -9
- package/cjs/hooks/useChats/index.d.ts +0 -3
- package/cjs/hooks/useChats/index.js +0 -37
- package/cjs/hooks/useContactGroups/index.d.ts +0 -3
- package/cjs/hooks/useContactGroups/index.js +0 -57
- package/cjs/hooks/useContacts/index.d.ts +0 -3
- package/cjs/hooks/useContacts/index.js +0 -52
- package/cjs/hooks/useCurrencies/index.d.ts +0 -3
- package/cjs/hooks/useCurrencies/index.js +0 -37
- package/cjs/hooks/useCustomers/index.d.ts +0 -3
- package/cjs/hooks/useCustomers/index.js +0 -52
- package/cjs/hooks/useDocuments/index.d.ts +0 -10
- package/cjs/hooks/useDocuments/index.js +0 -145
- package/cjs/hooks/useDomains/index.d.ts +0 -2
- package/cjs/hooks/useDomains/index.js +0 -32
- package/cjs/hooks/useEmailTemplates/index.d.ts +0 -2
- package/cjs/hooks/useEmailTemplates/index.js +0 -37
- package/cjs/hooks/useEntityStatuses/index.d.ts +0 -2
- package/cjs/hooks/useEntityStatuses/index.js +0 -34
- package/cjs/hooks/useForms/index.d.ts +0 -2
- package/cjs/hooks/useForms/index.js +0 -37
- package/cjs/hooks/useIntegrations/index.d.ts +0 -2
- package/cjs/hooks/useIntegrations/index.js +0 -39
- package/cjs/hooks/useInvites/index.d.ts +0 -2
- package/cjs/hooks/useInvites/index.js +0 -47
- package/cjs/hooks/useLabels/index.d.ts +0 -3
- package/cjs/hooks/useLabels/index.js +0 -32
- package/cjs/hooks/useLanguages/index.d.ts +0 -5
- package/cjs/hooks/useLanguages/index.js +0 -39
- package/cjs/hooks/useLeads/index.d.ts +0 -30
- package/cjs/hooks/useLeads/index.js +0 -113
- package/cjs/hooks/useMedia/index.d.ts +0 -2
- package/cjs/hooks/useMedia/index.js +0 -34
- package/cjs/hooks/useOrders/index.d.ts +0 -2
- package/cjs/hooks/useOrders/index.js +0 -76
- package/cjs/hooks/usePaths/index.d.ts +0 -2
- package/cjs/hooks/usePaths/index.js +0 -37
- package/cjs/hooks/usePermissions/index.d.ts +0 -2
- package/cjs/hooks/usePermissions/index.js +0 -47
- package/cjs/hooks/useProducts/index.d.ts +0 -2
- package/cjs/hooks/useProducts/index.js +0 -52
- package/cjs/hooks/useProfile/index.d.ts +0 -3
- package/cjs/hooks/useProfile/index.js +0 -57
- package/cjs/hooks/useRenting/index.d.ts +0 -47
- package/cjs/hooks/useRenting/index.js +0 -52
- package/cjs/hooks/useRoles/index.d.ts +0 -2
- package/cjs/hooks/useRoles/index.js +0 -32
- package/cjs/hooks/useRoom/index.d.ts +0 -3
- package/cjs/hooks/useRoom/index.js +0 -55
- package/cjs/hooks/useRotations/index.d.ts +0 -2
- package/cjs/hooks/useRotations/index.js +0 -37
- package/cjs/hooks/useSiteConfig/index.d.ts +0 -5
- package/cjs/hooks/useSiteConfig/index.js +0 -33
- package/cjs/hooks/useStatuses/index.d.ts +0 -2
- package/cjs/hooks/useStatuses/index.js +0 -32
- package/cjs/hooks/useStock/index.d.ts +0 -20
- package/cjs/hooks/useStock/index.js +0 -51
- package/cjs/hooks/useStores/index.d.ts +0 -3
- package/cjs/hooks/useStores/index.js +0 -62
- package/cjs/hooks/useSubscriptions/index.d.ts +0 -2
- package/cjs/hooks/useSubscriptions/index.js +0 -37
- package/cjs/hooks/useTable/index.d.ts +0 -3
- package/cjs/hooks/useTable/index.js +0 -34
- package/cjs/hooks/useTeams/index.d.ts +0 -5
- package/cjs/hooks/useTeams/index.js +0 -52
- package/cjs/hooks/useTickets/index.d.ts +0 -3
- package/cjs/hooks/useTickets/index.js +0 -47
- package/cjs/hooks/useTransactions/index.d.ts +0 -8
- package/cjs/hooks/useTransactions/index.js +0 -61
- package/cjs/hooks/useTranslations/index.d.ts +0 -5
- package/cjs/hooks/useTranslations/index.js +0 -42
- package/cjs/hooks/useUserConnections/index.d.ts +0 -2
- package/cjs/hooks/useUserConnections/index.js +0 -53
- package/cjs/hooks/useUserSubscriptions/index.d.ts +0 -6
- package/cjs/hooks/useUserSubscriptions/index.js +0 -47
- package/cjs/hooks/useUsers/index.d.ts +0 -17
- package/cjs/hooks/useUsers/index.js +0 -141
- package/cjs/hooks/useWBSuite/index.d.ts +0 -2
- package/cjs/hooks/useWBSuite/index.js +0 -39
- package/cjs/hooks/useWebsites/index.d.ts +0 -2
- package/cjs/hooks/useWebsites/index.js +0 -72
- package/cjs/index.d.ts +0 -50
- package/cjs/index.js +0 -117
- package/cjs/models/Requestor.d.ts +0 -24
- package/cjs/models/Requestor.js +0 -53
- package/cjs/next/utils/index.js +0 -6
- package/cjs/next/utils/wrapAsync.d.ts +0 -1
- package/cjs/next/utils/wrapAsync.js +0 -54
- package/cjs/utils/authWithApiKey.d.ts +0 -4
- package/cjs/utils/authWithApiKey.js +0 -8
- package/cjs/utils/authWithToken.d.ts +0 -4
- package/cjs/utils/authWithToken.js +0 -8
- package/cjs/utils/index.d.ts +0 -11
- package/cjs/utils/index.js +0 -19
- package/esm/hooks/useAgents/index.d.ts +0 -2
- package/esm/hooks/useAgents/index.js +0 -28
- package/esm/hooks/useApps/index.d.ts +0 -2
- package/esm/hooks/useApps/index.js +0 -28
- package/esm/hooks/useArticles/index.d.ts +0 -5
- package/esm/hooks/useArticles/index.js +0 -40
- package/esm/hooks/useAttributes/index.d.ts +0 -2
- package/esm/hooks/useAttributes/index.js +0 -48
- package/esm/hooks/useAttributesGroups/index.d.ts +0 -3
- package/esm/hooks/useAttributesGroups/index.js +0 -43
- package/esm/hooks/useAutomations/index.d.ts +0 -2
- package/esm/hooks/useAutomations/index.js +0 -28
- package/esm/hooks/useBackend/get.d.ts +0 -2
- package/esm/hooks/useBackend/get.js +0 -48
- package/esm/hooks/useBackend/index.d.ts +0 -17
- package/esm/hooks/useBackend/index.js +0 -18
- package/esm/hooks/useBackend/list.d.ts +0 -2
- package/esm/hooks/useBackend/list.js +0 -51
- package/esm/hooks/useBackend/post.d.ts +0 -2
- package/esm/hooks/useBackend/post.js +0 -48
- package/esm/hooks/useBackend/put.d.ts +0 -2
- package/esm/hooks/useBackend/put.js +0 -48
- package/esm/hooks/useCampaigns/index.d.ts +0 -2
- package/esm/hooks/useCampaigns/index.js +0 -31
- package/esm/hooks/useCategories/index.d.ts +0 -3
- package/esm/hooks/useCategories/index.js +0 -5
- package/esm/hooks/useChats/index.d.ts +0 -3
- package/esm/hooks/useChats/index.js +0 -33
- package/esm/hooks/useContactGroups/index.d.ts +0 -3
- package/esm/hooks/useContactGroups/index.js +0 -53
- package/esm/hooks/useContacts/index.d.ts +0 -3
- package/esm/hooks/useContacts/index.js +0 -48
- package/esm/hooks/useCurrencies/index.d.ts +0 -3
- package/esm/hooks/useCurrencies/index.js +0 -33
- package/esm/hooks/useCustomers/index.d.ts +0 -3
- package/esm/hooks/useCustomers/index.js +0 -48
- package/esm/hooks/useDocuments/index.d.ts +0 -10
- package/esm/hooks/useDocuments/index.js +0 -141
- package/esm/hooks/useDomains/index.d.ts +0 -2
- package/esm/hooks/useDomains/index.js +0 -28
- package/esm/hooks/useEmailTemplates/index.d.ts +0 -2
- package/esm/hooks/useEmailTemplates/index.js +0 -33
- package/esm/hooks/useEntityStatuses/index.d.ts +0 -2
- package/esm/hooks/useEntityStatuses/index.js +0 -30
- package/esm/hooks/useForms/index.d.ts +0 -2
- package/esm/hooks/useForms/index.js +0 -33
- package/esm/hooks/useIntegrations/index.d.ts +0 -2
- package/esm/hooks/useIntegrations/index.js +0 -35
- package/esm/hooks/useInvites/index.d.ts +0 -2
- package/esm/hooks/useInvites/index.js +0 -43
- package/esm/hooks/useLabels/index.d.ts +0 -3
- package/esm/hooks/useLabels/index.js +0 -28
- package/esm/hooks/useLanguages/index.d.ts +0 -5
- package/esm/hooks/useLanguages/index.js +0 -35
- package/esm/hooks/useLeads/index.d.ts +0 -30
- package/esm/hooks/useLeads/index.js +0 -109
- package/esm/hooks/useMedia/index.d.ts +0 -2
- package/esm/hooks/useMedia/index.js +0 -30
- package/esm/hooks/useOrders/index.d.ts +0 -2
- package/esm/hooks/useOrders/index.js +0 -72
- package/esm/hooks/usePaths/index.d.ts +0 -2
- package/esm/hooks/usePaths/index.js +0 -33
- package/esm/hooks/usePermissions/index.d.ts +0 -2
- package/esm/hooks/usePermissions/index.js +0 -43
- package/esm/hooks/useProducts/index.d.ts +0 -2
- package/esm/hooks/useProducts/index.js +0 -48
- package/esm/hooks/useProfile/index.d.ts +0 -3
- package/esm/hooks/useProfile/index.js +0 -53
- package/esm/hooks/useRenting/index.d.ts +0 -47
- package/esm/hooks/useRenting/index.js +0 -48
- package/esm/hooks/useRoles/index.d.ts +0 -2
- package/esm/hooks/useRoles/index.js +0 -28
- package/esm/hooks/useRoom/index.d.ts +0 -3
- package/esm/hooks/useRoom/index.js +0 -51
- package/esm/hooks/useRotations/index.d.ts +0 -2
- package/esm/hooks/useRotations/index.js +0 -33
- package/esm/hooks/useSiteConfig/index.d.ts +0 -5
- package/esm/hooks/useSiteConfig/index.js +0 -29
- package/esm/hooks/useStatuses/index.d.ts +0 -2
- package/esm/hooks/useStatuses/index.js +0 -28
- package/esm/hooks/useStock/index.d.ts +0 -20
- package/esm/hooks/useStock/index.js +0 -47
- package/esm/hooks/useStores/index.d.ts +0 -3
- package/esm/hooks/useStores/index.js +0 -58
- package/esm/hooks/useSubscriptions/index.d.ts +0 -2
- package/esm/hooks/useSubscriptions/index.js +0 -33
- package/esm/hooks/useTable/index.d.ts +0 -3
- package/esm/hooks/useTable/index.js +0 -30
- package/esm/hooks/useTeams/index.d.ts +0 -5
- package/esm/hooks/useTeams/index.js +0 -48
- package/esm/hooks/useTickets/index.d.ts +0 -3
- package/esm/hooks/useTickets/index.js +0 -43
- package/esm/hooks/useTransactions/index.d.ts +0 -8
- package/esm/hooks/useTransactions/index.js +0 -57
- package/esm/hooks/useTranslations/index.d.ts +0 -5
- package/esm/hooks/useTranslations/index.js +0 -38
- package/esm/hooks/useUserConnections/index.d.ts +0 -2
- package/esm/hooks/useUserConnections/index.js +0 -49
- package/esm/hooks/useUserSubscriptions/index.d.ts +0 -6
- package/esm/hooks/useUserSubscriptions/index.js +0 -43
- package/esm/hooks/useUsers/index.d.ts +0 -17
- package/esm/hooks/useUsers/index.js +0 -137
- package/esm/hooks/useWBSuite/index.d.ts +0 -2
- package/esm/hooks/useWBSuite/index.js +0 -35
- package/esm/hooks/useWebsites/index.d.ts +0 -2
- package/esm/hooks/useWebsites/index.js +0 -68
- package/esm/index.js +0 -51
- package/esm/models/Requestor.d.ts +0 -24
- package/esm/models/Requestor.js +0 -47
- package/esm/next/utils/index.d.ts +0 -2
- package/esm/next/utils/index.js +0 -3
- package/esm/next/utils/wrapAsync.d.ts +0 -1
- package/esm/next/utils/wrapAsync.js +0 -50
- package/esm/utils/authWithApiKey.d.ts +0 -4
- package/esm/utils/authWithApiKey.js +0 -4
- package/esm/utils/authWithToken.d.ts +0 -4
- package/esm/utils/authWithToken.js +0 -4
- package/esm/utils/index.d.ts +0 -11
- 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
|
+
};
|