@vonq/hapi-elements-types 1.3.0 → 1.5.0
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/enums.ts +41 -0
- package/package.json +6 -7
- package/src/_window/api.types.ts +59 -0
- package/src/_window/auth.types.ts +11 -0
- package/src/_window/config.types.ts +30 -0
- package/src/_window/events.types.ts +157 -0
- package/src/_window/index.ts +16 -0
- package/src/_window/instances.types.ts +18 -0
- package/src/_window/qa.types.ts +28 -0
- package/src/_window/routing.types.ts +21 -0
- package/src/_window/sdk.types.ts +147 -0
- package/src/_window/service.types.ts +67 -0
- package/src/_window/state.types.ts +112 -0
- package/src/_window/ui.types.ts +13 -0
- package/src/_window/utils.types.ts +34 -0
- package/src/_window/validation.types.ts +43 -0
- package/src/_window/window.ts +56 -0
- package/src/alert/enums.ts +22 -0
- package/src/alert/functions.types.ts +13 -0
- package/src/alert/index.ts +9 -0
- package/src/alert/service.types.ts +15 -0
- package/src/alert/state.initial.ts +16 -0
- package/src/alert/state.types.ts +27 -0
- package/src/alert/state.validations.ts +11 -0
- package/src/alert/types.ts +63 -0
- package/src/ats/api.types.ts +16 -0
- package/src/ats/functions.types.ts +7 -0
- package/src/ats/index.ts +9 -0
- package/src/ats/service.types.ts +17 -0
- package/src/ats/state.initial.ts +5 -0
- package/src/ats/state.types.ts +5 -0
- package/src/ats/state.validations.ts +6 -0
- package/src/ats/types.ts +19 -0
- package/src/basket/consts.ts +1 -0
- package/src/basket/functions.types.ts +40 -0
- package/src/basket/index.ts +12 -0
- package/src/basket/service.types.ts +32 -0
- package/src/basket/state.initial.ts +11 -0
- package/src/basket/state.types.ts +34 -0
- package/src/basket/state.validations.ts +12 -0
- package/src/basket/types.ts +4 -0
- package/src/basket/utils.ts +79 -0
- package/src/basket/utils.types.ts +10 -0
- package/src/basket/validations.types.ts +25 -0
- package/src/campaign/api.types.ts +45 -0
- package/src/campaign/consts.ts +1 -0
- package/src/campaign/enums.ts +17 -0
- package/src/campaign/functions.types.ts +90 -0
- package/src/campaign/index.ts +15 -0
- package/src/campaign/qa.types.ts +12 -0
- package/src/campaign/service.types.ts +48 -0
- package/src/campaign/state.initial.ts +84 -0
- package/src/campaign/state.types.ts +55 -0
- package/src/campaign/state.validations.ts +16 -0
- package/src/campaign/types.ts +237 -0
- package/src/campaign/utils.ts +53 -0
- package/src/campaign/utils.types.ts +59 -0
- package/src/campaign/validations.types.ts +215 -0
- package/src/common/LocalStorage.ts +123 -0
- package/src/common/browser.ts +2 -0
- package/src/common/color.ts +9 -0
- package/src/common/events/EventCommand/enums.ts +49 -0
- package/src/common/events/EventCommand/index.ts +4 -0
- package/src/common/events/EventCommand/types.ts +18 -0
- package/src/common/events/index.ts +4 -0
- package/src/common/events/types.ts +52 -0
- package/src/common/immutable.ts +28 -0
- package/src/common/index.ts +22 -0
- package/src/common/instances/Instance.ts +13 -0
- package/src/common/instances/consts.ts +1 -0
- package/src/common/instances/index.ts +4 -0
- package/src/common/json.ts +25 -0
- package/src/common/logger/Logger.ts +70 -0
- package/src/common/logger/enums.ts +12 -0
- package/src/common/logger/index.ts +5 -0
- package/src/common/logger/types.ts +7 -0
- package/src/common/logger-datadog/LoggerDatadog.ts +42 -0
- package/src/common/logger-datadog/index.ts +3 -0
- package/src/common/misc.ts +114 -0
- package/src/common/promise.ts +161 -0
- package/src/common/proxy.ts +77 -0
- package/src/common/qa.types.ts +9 -0
- package/src/common/regExTest.ts +12 -0
- package/src/common/tree.ts +148 -0
- package/src/common/types.ts +110 -0
- package/src/common/utm.ts +19 -0
- package/src/common/validations.types.ts +89 -0
- package/src/common/validators.ts +21 -0
- package/src/common/webComponents.ts +26 -0
- package/src/config/functions.types.ts +23 -0
- package/src/config/index.ts +5 -0
- package/src/config/state.initial.ts +11 -0
- package/src/config/state.types.ts +15 -0
- package/src/consts.ts +980 -0
- package/src/contract/api.types.ts +47 -0
- package/src/contract/consts.ts +1 -0
- package/src/contract/functions.types.ts +112 -0
- package/src/contract/index.ts +14 -0
- package/src/contract/qa.types.ts +12 -0
- package/src/contract/service.types.ts +54 -0
- package/src/contract/state.initial.ts +39 -0
- package/src/contract/state.types.ts +74 -0
- package/src/contract/state.validations.ts +21 -0
- package/src/contract/types.ts +145 -0
- package/src/contract/utils.ts +36 -0
- package/src/contract/utils.types.ts +11 -0
- package/src/contract/validations.types.ts +104 -0
- package/src/debugging/functions.types.ts +34 -0
- package/src/debugging/index.ts +6 -0
- package/src/debugging/state.initial.ts +10 -0
- package/src/debugging/state.types.ts +18 -0
- package/src/debugging/state.validations.ts +10 -0
- package/src/index.ts +22 -0
- package/src/language/consts.ts +6 -0
- package/src/language/en.ts +530 -0
- package/src/language/functions.types.ts +29 -0
- package/src/language/index.ts +11 -0
- package/src/language/qa.types.ts +19 -0
- package/src/language/state.initial.ts +13 -0
- package/src/language/state.types.ts +25 -0
- package/src/language/state.validations.ts +10 -0
- package/src/language/utils.ts +17 -0
- package/src/language/validations.types.ts +13 -0
- package/src/modal/consts.ts +6 -0
- package/src/modal/enums.ts +14 -0
- package/src/modal/functions.types.ts +22 -0
- package/src/modal/index.ts +11 -0
- package/src/modal/service.types.ts +32 -0
- package/src/modal/state.initial.ts +9 -0
- package/src/modal/state.types.ts +8 -0
- package/src/modal/state.validations.ts +6 -0
- package/src/modal/store.types.ts +5 -0
- package/src/modal/types.ts +44 -0
- package/src/orderJourney/consts.ts +289 -0
- package/src/orderJourney/enums.ts +25 -0
- package/src/orderJourney/functions.types.ts +140 -0
- package/src/orderJourney/index.ts +13 -0
- package/src/orderJourney/qa.types.ts +16 -0
- package/src/orderJourney/state.initial.ts +401 -0
- package/src/orderJourney/state.types.ts +99 -0
- package/src/orderJourney/state.validations.ts +78 -0
- package/src/orderJourney/types.ts +31 -0
- package/src/orderJourney/utils.ts +7 -0
- package/src/orderJourney/utils.types.ts +11 -0
- package/src/orderJourney/validations.types.ts +34 -0
- package/src/product/api.types.ts +62 -0
- package/src/product/consts.ts +1 -0
- package/src/product/enums.ts +11 -0
- package/src/product/functions.types.ts +156 -0
- package/src/product/index.ts +14 -0
- package/src/product/qa.types.ts +11 -0
- package/src/product/service.types.ts +68 -0
- package/src/product/state.initial.ts +28 -0
- package/src/product/state.types.ts +93 -0
- package/src/product/state.validations.ts +25 -0
- package/src/product/types.ts +161 -0
- package/src/product/utils.types.ts +22 -0
- package/src/product/validations.types.ts +189 -0
- package/src/routing/functions.types.ts +48 -0
- package/src/routing/index.ts +5 -0
- package/src/routing/state.initial.ts +10 -0
- package/src/routing/state.types.ts +30 -0
- package/src/theming/consts.ts +7727 -0
- package/src/theming/functions.types.ts +13 -0
- package/src/theming/index.ts +11 -0
- package/src/theming/qa.types.ts +11 -0
- package/src/theming/state.initial.ts +16 -0
- package/src/theming/state.types.ts +6 -0
- package/src/theming/state.validations.ts +8 -0
- package/src/theming/types.ts +123 -0
- package/src/theming/utils.ts +581 -0
- package/src/theming/validations.types.ts +62 -0
- package/src/types.ts +229 -0
- package/src/ui/index.ts +3 -0
- package/src/ui/service.types.ts +26 -0
- package/src/utils.ts +3 -0
- package/src/wallet/api.types.ts +33 -0
- package/src/wallet/consts.ts +3 -0
- package/src/wallet/functions.types.ts +58 -0
- package/src/wallet/index.ts +11 -0
- package/src/wallet/service.types.ts +26 -0
- package/src/wallet/state.initial.ts +18 -0
- package/src/wallet/state.types.ts +58 -0
- package/src/wallet/state.validations.ts +18 -0
- package/src/wallet/types.ts +65 -0
- package/src/wallet/validations.types.ts +18 -0
- package/tsconfig.json +41 -0
@@ -0,0 +1,47 @@
|
|
1
|
+
import { AxiosRequestConfig } from "axios"
|
2
|
+
import {
|
3
|
+
Contract,
|
4
|
+
ContractCreateForm,
|
5
|
+
ContractGroup,
|
6
|
+
ContractGroupCreateForm,
|
7
|
+
} from "./types"
|
8
|
+
import { WindowHapiAPI, WindowHapiAPIModule } from "../_window/api.types"
|
9
|
+
import { PaginatedAPIResponseV1, PaginationLimitOffset } from "../common/types"
|
10
|
+
import { ModuleWithConstructorArgs } from "../types"
|
11
|
+
|
12
|
+
export type WindowHapiAPIContractConfigs = {
|
13
|
+
getContracts: AxiosRequestConfig
|
14
|
+
getContractsByIds: AxiosRequestConfig
|
15
|
+
getContract: AxiosRequestConfig
|
16
|
+
createContract: AxiosRequestConfig
|
17
|
+
removeContract: AxiosRequestConfig
|
18
|
+
getPostingRequirementOptions: AxiosRequestConfig
|
19
|
+
getGroups: AxiosRequestConfig
|
20
|
+
createGroup: AxiosRequestConfig
|
21
|
+
}
|
22
|
+
export type WindowHapiAPIContractRequests = {
|
23
|
+
getContracts: (
|
24
|
+
limitOffset?: PaginationLimitOffset,
|
25
|
+
) => Promise<PaginatedAPIResponseV1<Contract>>
|
26
|
+
getContractsByIds: (
|
27
|
+
contractIds: (string | number)[],
|
28
|
+
limitOffset?: PaginationLimitOffset,
|
29
|
+
) => Promise<PaginatedAPIResponseV1<Contract>>
|
30
|
+
getContract: (contractId: string) => Promise<Contract>
|
31
|
+
createContract: (contract: ContractCreateForm) => Promise<Contract>
|
32
|
+
getPostingRequirementOptions: (
|
33
|
+
contractId: string,
|
34
|
+
fieldName: string,
|
35
|
+
autocompleteRequestOptions: Record<string, string | string[]>,
|
36
|
+
) => Promise<any>
|
37
|
+
getGroups: () => Promise<ContractGroup[]>
|
38
|
+
createGroup: (group: ContractGroupCreateForm) => Promise<ContractGroup>
|
39
|
+
removeContract: (contractId: string) => Promise<Contract>
|
40
|
+
}
|
41
|
+
export type WindowHapiAPIContract = ModuleWithConstructorArgs<
|
42
|
+
WindowHapiAPIModule<
|
43
|
+
WindowHapiAPIContractRequests,
|
44
|
+
WindowHapiAPIContractConfigs
|
45
|
+
>,
|
46
|
+
{ readonly api: WindowHapiAPI }
|
47
|
+
>
|
@@ -0,0 +1 @@
|
|
1
|
+
export const CONTRACT_CREATE_FORM_LOCALSTORAGE_KEY = "createContractForm"
|
@@ -0,0 +1,112 @@
|
|
1
|
+
import { ProductSupportingContractsComplete } from "../product/types"
|
2
|
+
import {
|
3
|
+
Contract,
|
4
|
+
ContractCreateForm,
|
5
|
+
ContractGroup,
|
6
|
+
ContractGroupCreateForm,
|
7
|
+
ContractGroupSelected,
|
8
|
+
} from "./types"
|
9
|
+
import { PaginationResponseV1, RecursivePartial } from "../common/types"
|
10
|
+
|
11
|
+
export type ContractStoreSetContractSelectedHandler = (
|
12
|
+
moc: ProductSupportingContractsComplete | null,
|
13
|
+
) => void
|
14
|
+
export type ContractStoreSetContractSelectedIdHandler = (
|
15
|
+
id: number | null,
|
16
|
+
) => void
|
17
|
+
export type ContractStoreSetContractSelectedIsLoading = (
|
18
|
+
isLoading: boolean,
|
19
|
+
) => void
|
20
|
+
export type ContractStoreSetContractFormHandler = (
|
21
|
+
form: RecursivePartial<ContractCreateForm>,
|
22
|
+
replaceAsIs?: boolean,
|
23
|
+
) => void
|
24
|
+
export type ContractStoreSetContractCreateErrorHandler = (
|
25
|
+
error: Record<string, unknown>,
|
26
|
+
) => void
|
27
|
+
export type ContractStoreSetContractsHandler = (contracts: Contract[]) => void
|
28
|
+
export type ContractStoreSetContractsPaginationMetaHandler = (
|
29
|
+
meta: PaginationResponseV1 | null,
|
30
|
+
) => void
|
31
|
+
export type ContractStoreSetContractsAreLoadingHandler = (
|
32
|
+
isLoading: boolean,
|
33
|
+
) => void
|
34
|
+
export type ContractStoreSetGroupsHandler = (groups: ContractGroup[]) => void
|
35
|
+
export type ContractStoreSetGroupsAreLoadingHandler = (
|
36
|
+
isLoading: boolean,
|
37
|
+
) => void
|
38
|
+
export type ContractStoreSetGroupSelectedHandler = (
|
39
|
+
group: ContractGroupSelected,
|
40
|
+
) => void
|
41
|
+
export type ContractStoreSetGroupIsCreatingHandler = (isSaving: boolean) => void
|
42
|
+
export type ContractStoreSetGroupCreateErrorHandler = (
|
43
|
+
error: string | null,
|
44
|
+
) => void
|
45
|
+
export type ContractStoreSetGroupFormHandler = (
|
46
|
+
form: ContractGroupCreateForm,
|
47
|
+
replaceAsIs?: boolean,
|
48
|
+
) => void
|
49
|
+
|
50
|
+
export type ContractStoreSetActiveTabIndexHandler = (index: number) => void
|
51
|
+
|
52
|
+
export type ContractStoreFunctions = {
|
53
|
+
/* Contracts */
|
54
|
+
/**
|
55
|
+
* The function that sets the value of `contracts`. Refer to [ContractStoreState](/docs/sdk/contracts/#contractstorestate) for more details.
|
56
|
+
*/
|
57
|
+
setContracts: ContractStoreSetContractsHandler
|
58
|
+
/**
|
59
|
+
* The function that sets the value of `contractsPaginationMeta`. Refer to [ContractStoreState](/docs/sdk/contracts/#contractstorestate) for more details.
|
60
|
+
*/
|
61
|
+
setContractsPaginationMeta: ContractStoreSetContractsPaginationMetaHandler
|
62
|
+
/**
|
63
|
+
* The function that sets the value of `contractsAreLoading`. Refer to [ContractStoreState](/docs/sdk/contracts/#contractstorestate) for more details.
|
64
|
+
*/
|
65
|
+
setContractsAreLoading: ContractStoreSetContractsAreLoadingHandler
|
66
|
+
/**
|
67
|
+
* The function that updates the value of `contractSelectedIsLoading`. Refer to [ContractStoreState](/docs/sdk/contracts/#contractstorestate) for more details.
|
68
|
+
*/
|
69
|
+
setContractSelectedIsLoading: ContractStoreSetContractSelectedIsLoading
|
70
|
+
/**
|
71
|
+
* The function that updates the value of `contractForm`. Refer to [ContractStoreState](/docs/sdk/contracts/#contractstorestate) for more details.
|
72
|
+
*/
|
73
|
+
setContractForm: ContractStoreSetContractFormHandler
|
74
|
+
/**
|
75
|
+
* The function that updates the value of `contractCreateError`. Refer to [ContractStoreState](/docs/sdk/contracts/#contractstorestate) for more details.
|
76
|
+
*/
|
77
|
+
setContractCreateError: ContractStoreSetContractCreateErrorHandler
|
78
|
+
/**
|
79
|
+
* The function that updates the value of `contractSelectedId`. Refer to [ContractStoreState](/docs/sdk/contracts/#contractstorestate) for more details.
|
80
|
+
*/
|
81
|
+
setContractSelectedId: ContractStoreSetContractSelectedIdHandler
|
82
|
+
/**
|
83
|
+
* The function that updates the value of `contractSelected`. Refer to [ContractStoreState](/docs/sdk/contracts/#contractstorestate) for more details.
|
84
|
+
*/
|
85
|
+
setContractSelected: ContractStoreSetContractSelectedHandler
|
86
|
+
|
87
|
+
/* Contracts Groups */
|
88
|
+
/**
|
89
|
+
* The function that sets the value of `groups`. Refer to [ContractStoreState](/docs/sdk/contracts/#contractstorestate) for more details.
|
90
|
+
*/
|
91
|
+
setGroups: ContractStoreSetGroupsHandler
|
92
|
+
/**
|
93
|
+
* The function that sets the value of `groupsAreLoading`. Refer to [ContractStoreState](/docs/sdk/contracts/#contractstorestate) for more details.
|
94
|
+
*/
|
95
|
+
setGroupsAreLoading: ContractStoreSetGroupsAreLoadingHandler
|
96
|
+
/**
|
97
|
+
* The function that sets the value of `groupIsCreating`. Refer to [ContractStoreState](/docs/sdk/contracts/#contractstorestate) for more details.
|
98
|
+
*/
|
99
|
+
setGroupIsCreating: ContractStoreSetGroupIsCreatingHandler
|
100
|
+
/**
|
101
|
+
* The function that sets the value of `groupCreateError`. Refer to [ContractStoreState](/docs/sdk/contracts/#contractstorestate) for more details.
|
102
|
+
*/
|
103
|
+
setGroupCreateError: ContractStoreSetGroupCreateErrorHandler
|
104
|
+
/**
|
105
|
+
* The function that sets the value of `groupSelected`. Refer to [ContractStoreState](/docs/sdk/contracts/#contractstorestate) for more details.
|
106
|
+
*/
|
107
|
+
setGroupSelected: ContractStoreSetGroupSelectedHandler
|
108
|
+
/**
|
109
|
+
* The function that updates the value of `groupForm`. Refer to [ContractStoreState](/docs/sdk/contracts/#contractstorestate) for more details.
|
110
|
+
*/
|
111
|
+
setGroupForm: ContractStoreSetGroupFormHandler
|
112
|
+
}
|
@@ -0,0 +1,14 @@
|
|
1
|
+
// created from 'create-ts-index'
|
2
|
+
|
3
|
+
export * from './api.types';
|
4
|
+
export * from './consts';
|
5
|
+
export * from './functions.types';
|
6
|
+
export * from './qa.types';
|
7
|
+
export * from './service.types';
|
8
|
+
export * from './state.initial';
|
9
|
+
export * from './state.types';
|
10
|
+
export * from './state.validations';
|
11
|
+
export * from './types';
|
12
|
+
export * from './utils';
|
13
|
+
export * from './utils.types';
|
14
|
+
export * from './validations.types';
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import { ContractCreateForm, ContractGroupCreateForm } from "./types"
|
2
|
+
import { ModuleWithConstructorArgs } from "../types"
|
3
|
+
import { WindowHapiQA } from "../_window/qa.types"
|
4
|
+
|
5
|
+
export type WindowHapiQAContract = ModuleWithConstructorArgs<
|
6
|
+
{
|
7
|
+
getRandomContractId: () => Promise<string>
|
8
|
+
useMockContractForm: () => ContractCreateForm
|
9
|
+
useMockGroupForm: () => ContractGroupCreateForm
|
10
|
+
},
|
11
|
+
{ readonly qa: WindowHapiQA }
|
12
|
+
>
|
@@ -0,0 +1,54 @@
|
|
1
|
+
import {
|
2
|
+
HapiServiceFunctionWithLifecycleHooks,
|
3
|
+
WindowHapiService,
|
4
|
+
} from "../_window/service.types"
|
5
|
+
import { OrderJourneyStepKey } from "../orderJourney/enums"
|
6
|
+
import {
|
7
|
+
Contract,
|
8
|
+
ContractCredential,
|
9
|
+
ContractGroup,
|
10
|
+
ContractPostingRequirementsAutocompleteRequestOption,
|
11
|
+
} from "./types"
|
12
|
+
import { PaginatedAPIResponseV1 } from "../common/types"
|
13
|
+
import { ModuleWithConstructorArgs } from "../types"
|
14
|
+
|
15
|
+
export type ContractServiceGetContractPostingRequirementOptionsHandler = (
|
16
|
+
contractId: string,
|
17
|
+
fieldName: string,
|
18
|
+
autocompleteRequestOptions: ContractPostingRequirementsAutocompleteRequestOption[],
|
19
|
+
) => Promise<any>
|
20
|
+
export type ContractServiceGetContractsHandler = (
|
21
|
+
offset: number,
|
22
|
+
) => Promise<PaginatedAPIResponseV1<Contract>>
|
23
|
+
export type ContractServiceGetContractGroupsHandler = () => Promise<
|
24
|
+
ContractGroup[]
|
25
|
+
>
|
26
|
+
export type ContractServiceCreateContractHandler = () => Promise<Contract>
|
27
|
+
export type ContractServiceRemoveContractHandler = (
|
28
|
+
contractId: string,
|
29
|
+
) => Promise<void>
|
30
|
+
export type ContractServiceCreateContractGroupHandler =
|
31
|
+
() => Promise<ContractGroup>
|
32
|
+
export type ContractServiceGetContractHandler = (
|
33
|
+
id: string,
|
34
|
+
) => Promise<Contract>
|
35
|
+
|
36
|
+
export type WindowHapiServiceContract = ModuleWithConstructorArgs<
|
37
|
+
{
|
38
|
+
getContractPostingRequirementOptions: HapiServiceFunctionWithLifecycleHooks<ContractServiceGetContractPostingRequirementOptionsHandler>
|
39
|
+
getContracts: HapiServiceFunctionWithLifecycleHooks<ContractServiceGetContractsHandler>
|
40
|
+
getContractGroups: HapiServiceFunctionWithLifecycleHooks<ContractServiceGetContractGroupsHandler>
|
41
|
+
createContract: HapiServiceFunctionWithLifecycleHooks<ContractServiceCreateContractHandler>
|
42
|
+
removeContract: HapiServiceFunctionWithLifecycleHooks<ContractServiceRemoveContractHandler>
|
43
|
+
createContractGroup: HapiServiceFunctionWithLifecycleHooks<ContractServiceCreateContractGroupHandler>
|
44
|
+
getContract: HapiServiceFunctionWithLifecycleHooks<ContractServiceGetContractHandler>
|
45
|
+
initiateOauthLogin: (
|
46
|
+
contractId: string | number,
|
47
|
+
orderJourneyStepActive: OrderJourneyStepKey,
|
48
|
+
credential: ContractCredential,
|
49
|
+
) => void
|
50
|
+
setDefaultContractForm: () => void
|
51
|
+
setDefaultContractGroupForm: () => void
|
52
|
+
},
|
53
|
+
{ readonly service: WindowHapiService }
|
54
|
+
>
|
@@ -0,0 +1,39 @@
|
|
1
|
+
import { ContractStoreState } from "./state.types"
|
2
|
+
|
3
|
+
export const initialContractStoreState: ContractStoreState = {
|
4
|
+
/* Contracts */
|
5
|
+
contractsAreLoading: false,
|
6
|
+
contractsPaginationMeta: {
|
7
|
+
limit: 50,
|
8
|
+
offset: 0,
|
9
|
+
},
|
10
|
+
contracts: [],
|
11
|
+
contractForm: {
|
12
|
+
id: 0,
|
13
|
+
credentials: {},
|
14
|
+
facets: {},
|
15
|
+
expiry_date: null,
|
16
|
+
alias: null,
|
17
|
+
purchase_price: {
|
18
|
+
amount: null,
|
19
|
+
currency: null,
|
20
|
+
},
|
21
|
+
credits: null,
|
22
|
+
followed_instructions: false,
|
23
|
+
allow_renegotiation: false,
|
24
|
+
},
|
25
|
+
contractCreateError: {},
|
26
|
+
contractFormIsValid: null,
|
27
|
+
contractSelected: null,
|
28
|
+
contractSelectedId: null,
|
29
|
+
contractSelectedIsLoading: false,
|
30
|
+
/* Contracts Groups */
|
31
|
+
groupSelected: null,
|
32
|
+
groupIsCreating: false,
|
33
|
+
groupCreateError: null,
|
34
|
+
groupsAreLoading: false,
|
35
|
+
groups: [],
|
36
|
+
groupForm: {
|
37
|
+
name: "",
|
38
|
+
},
|
39
|
+
}
|
@@ -0,0 +1,74 @@
|
|
1
|
+
import { ProductSupportingContractsComplete } from "../product/types"
|
2
|
+
import {
|
3
|
+
Contract,
|
4
|
+
ContractCreateForm,
|
5
|
+
ContractGroup,
|
6
|
+
ContractGroupCreateForm,
|
7
|
+
ContractGroupSelected,
|
8
|
+
} from "./types"
|
9
|
+
import { PaginationResponseV1 } from "../common/types"
|
10
|
+
|
11
|
+
export type ContractStoreState = {
|
12
|
+
/* Contracts */
|
13
|
+
/**
|
14
|
+
* Array of Contracts to be displayed in Contracts Landing or Contracts List widgets.
|
15
|
+
*/
|
16
|
+
contracts: Contract[]
|
17
|
+
/**
|
18
|
+
* An object that holds information like next URL, previous URL and count for pagination purposes
|
19
|
+
*/
|
20
|
+
contractsPaginationMeta: PaginationResponseV1
|
21
|
+
/**
|
22
|
+
* Shows a loading spinner when the Contracts are loading
|
23
|
+
*/
|
24
|
+
contractsAreLoading: boolean
|
25
|
+
/**
|
26
|
+
* Selected Channel ID that will trigger an API request to fetch the data then to populate `contractSelected`
|
27
|
+
*/
|
28
|
+
contractSelectedId: string | number | null
|
29
|
+
/**
|
30
|
+
* Selected Channel that will be part of the Contract when user submits the form
|
31
|
+
*/
|
32
|
+
contractSelected: ProductSupportingContractsComplete | null
|
33
|
+
/**
|
34
|
+
* Shows a loading spinner when the properties required for the Contract are being loaded from the API
|
35
|
+
*/
|
36
|
+
contractSelectedIsLoading: boolean
|
37
|
+
/**
|
38
|
+
* The object that contains details for the new Contract that will be created when user submits the form
|
39
|
+
*/
|
40
|
+
contractForm: ContractCreateForm
|
41
|
+
/**
|
42
|
+
* Error(s) received from the API when user submits the form
|
43
|
+
*/
|
44
|
+
contractCreateError: any
|
45
|
+
/**
|
46
|
+
* Client-side validation result of the `contractForm`. **This value is a computed getter meaning that it cannot be set from outside**
|
47
|
+
*/
|
48
|
+
contractFormIsValid: boolean | null
|
49
|
+
/* Contracts Groups */
|
50
|
+
/**
|
51
|
+
* Array of Contract Groups for user to select during creation of a new Contract.
|
52
|
+
*/
|
53
|
+
groups: ContractGroup[]
|
54
|
+
/**
|
55
|
+
* Selected Contract Group to be saved as part of Contract that will be created when user submits the form
|
56
|
+
*/
|
57
|
+
groupSelected: ContractGroupSelected
|
58
|
+
/**
|
59
|
+
* Shows a loading spinner and disables the Select HTML Element when Contract Groups are loading
|
60
|
+
*/
|
61
|
+
groupsAreLoading: boolean
|
62
|
+
/**
|
63
|
+
* Shows a loading spinner and disables the submit button while a new Contract Group is being created
|
64
|
+
*/
|
65
|
+
groupIsCreating: boolean
|
66
|
+
/**
|
67
|
+
* Error message displayed to the end user when the new Contract Group could not be created
|
68
|
+
*/
|
69
|
+
groupCreateError: string | null
|
70
|
+
/**
|
71
|
+
* The object that contains details for the new Contract Group that will be created when user submits the form
|
72
|
+
*/
|
73
|
+
groupForm: ContractGroupCreateForm
|
74
|
+
}
|
@@ -0,0 +1,21 @@
|
|
1
|
+
import { ContractStoreState } from "./state.types"
|
2
|
+
import { StateValidations } from "../_window/state.types"
|
3
|
+
|
4
|
+
export const contractStoreStateValidations: StateValidations<ContractStoreState> =
|
5
|
+
{
|
6
|
+
contractsAreLoading: "common.genericBoolean",
|
7
|
+
contracts: "contract.contracts",
|
8
|
+
contractsPaginationMeta: "common.paginationMetaV1",
|
9
|
+
contractForm: "contract.contractForm",
|
10
|
+
contractSelectedId: "common.genericNullableStringOrNumber",
|
11
|
+
contractSelected: "contract.contractSelected",
|
12
|
+
contractSelectedIsLoading: "common.genericBoolean",
|
13
|
+
contractCreateError: "common.genericObject",
|
14
|
+
contractFormIsValid: "throwHasNoSetterError",
|
15
|
+
groups: "contract.groups",
|
16
|
+
groupsAreLoading: "common.genericBoolean",
|
17
|
+
groupSelected: "contract.groupSelected",
|
18
|
+
groupIsCreating: "common.genericBoolean",
|
19
|
+
groupCreateError: "common.genericObject",
|
20
|
+
groupForm: "contract.groupForm",
|
21
|
+
}
|
@@ -0,0 +1,145 @@
|
|
1
|
+
import { ProductLogos, ProductType } from "../product/types"
|
2
|
+
|
3
|
+
export type ContractProduct = {
|
4
|
+
product_id: string
|
5
|
+
title: string
|
6
|
+
}
|
7
|
+
|
8
|
+
export type ContractCredential = {
|
9
|
+
description?: string | null
|
10
|
+
label: string
|
11
|
+
name: string
|
12
|
+
sort: string
|
13
|
+
url: string | null
|
14
|
+
options: any[] | null
|
15
|
+
}
|
16
|
+
|
17
|
+
export type ContractFacet = {}
|
18
|
+
|
19
|
+
export type ContractPostingRequirementType =
|
20
|
+
| "SELECT"
|
21
|
+
| "SELECT-MAP_ONLY"
|
22
|
+
| "TEXT"
|
23
|
+
| "MULTIPLE"
|
24
|
+
| "HIER"
|
25
|
+
| "TEXTEXPAND"
|
26
|
+
| "DATE"
|
27
|
+
| "TEXTAREA"
|
28
|
+
| "AUTOCOMPLETE"
|
29
|
+
| "STATISCH"
|
30
|
+
|
31
|
+
export type ContractPostingRequirementRule = {
|
32
|
+
rule: string
|
33
|
+
data: string
|
34
|
+
}
|
35
|
+
|
36
|
+
export type ContractPostingRequirementDisplayRuleShow = {
|
37
|
+
facet: string
|
38
|
+
value: any
|
39
|
+
op: "notempty" | "equal" | "in"
|
40
|
+
}
|
41
|
+
|
42
|
+
export type ContractPostingRequirementDisplayRule = {
|
43
|
+
show: ContractPostingRequirementDisplayRuleShow[]
|
44
|
+
}
|
45
|
+
|
46
|
+
export type ContractPostingRequirementAutocompleteParametersSourceSingle = {
|
47
|
+
field?: string
|
48
|
+
facet?: string
|
49
|
+
}
|
50
|
+
|
51
|
+
export type ContractPostingRequirementAutocompleteParametersSourceMultiple = {
|
52
|
+
[
|
53
|
+
key: string
|
54
|
+
]: ContractPostingRequirementAutocompleteParametersSourceSingle[]
|
55
|
+
}
|
56
|
+
|
57
|
+
export type ContractPostingRequirementParametersSource =
|
58
|
+
| ContractPostingRequirementAutocompleteParametersSourceSingle
|
59
|
+
| ContractPostingRequirementAutocompleteParametersSourceMultiple
|
60
|
+
|
61
|
+
export type ContractPostingRequirementAutocomplete = {
|
62
|
+
required_parameters: string[] | null
|
63
|
+
parameters_source: ContractPostingRequirementParametersSource | null
|
64
|
+
}
|
65
|
+
|
66
|
+
export type ContractPostingRequirement = {
|
67
|
+
name: string
|
68
|
+
label: string
|
69
|
+
description?: string
|
70
|
+
display_rules: ContractPostingRequirementDisplayRule | null
|
71
|
+
autocomplete: ContractPostingRequirementAutocomplete | null
|
72
|
+
options: ContractPostingRequirementOption[] | null
|
73
|
+
required: boolean
|
74
|
+
sort: string
|
75
|
+
type: ContractPostingRequirementType
|
76
|
+
rules?: ContractPostingRequirementRule[] | null
|
77
|
+
}
|
78
|
+
|
79
|
+
export type ContractPostingRequirementOption = {
|
80
|
+
default?: string
|
81
|
+
key: string
|
82
|
+
label: string
|
83
|
+
data?: any[]
|
84
|
+
labels?: Record<"default", string>
|
85
|
+
sort: string
|
86
|
+
parent?: string
|
87
|
+
}
|
88
|
+
|
89
|
+
export type ContractPurchasePrice = {
|
90
|
+
amount: number | null
|
91
|
+
currency: string | null
|
92
|
+
}
|
93
|
+
|
94
|
+
export type ContractCreateFormCredentials = Record<string, string>
|
95
|
+
|
96
|
+
export type ContractCreateForm = {
|
97
|
+
id?: number
|
98
|
+
credentials?: ContractCreateFormCredentials
|
99
|
+
facets?: any
|
100
|
+
expiry_date: string | null
|
101
|
+
alias: string | null
|
102
|
+
purchase_price: ContractPurchasePrice
|
103
|
+
credits: string | null
|
104
|
+
followed_instructions: boolean
|
105
|
+
allow_renegotiation: boolean
|
106
|
+
}
|
107
|
+
|
108
|
+
export type ContractGroupCreateForm = {
|
109
|
+
name: string
|
110
|
+
}
|
111
|
+
|
112
|
+
export type ContractChannel = ProductLogos &
|
113
|
+
ProductType & {
|
114
|
+
id: number
|
115
|
+
name: string
|
116
|
+
url: string
|
117
|
+
}
|
118
|
+
|
119
|
+
export type Contract = {
|
120
|
+
channel?: ContractChannel
|
121
|
+
alias: string
|
122
|
+
channel_id: number
|
123
|
+
class_name: string
|
124
|
+
contract_id: string
|
125
|
+
credits: number | null
|
126
|
+
customer_id: string
|
127
|
+
expiry_date: string | null
|
128
|
+
facets?: any[]
|
129
|
+
product: ContractProduct
|
130
|
+
purchase_price: ContractPurchasePrice | null
|
131
|
+
group: ContractGroup | null
|
132
|
+
}
|
133
|
+
|
134
|
+
export type ContractGroup = {
|
135
|
+
id: string
|
136
|
+
idx: number
|
137
|
+
igb_customer_id: string
|
138
|
+
name: string
|
139
|
+
}
|
140
|
+
|
141
|
+
export type ContractGroupSelected = ContractGroup | "add-new" | null
|
142
|
+
export type ContractPostingRequirementsAutocompleteRequestOption = {
|
143
|
+
key: string
|
144
|
+
value: string | string[]
|
145
|
+
}
|
@@ -0,0 +1,36 @@
|
|
1
|
+
import { isBrowser } from "../common/browser"
|
2
|
+
import { initialContractStoreState } from "./state.initial"
|
3
|
+
import { Contract } from "./types"
|
4
|
+
|
5
|
+
export const setCreateContractFormToLocalStorage = (
|
6
|
+
_form: any,
|
7
|
+
_channelId: number,
|
8
|
+
) => {
|
9
|
+
/*LocalStorage.set(CONTRACT_CREATE_FORM_LOCALSTORAGE_KEY, {
|
10
|
+
...form,
|
11
|
+
id: channelId,
|
12
|
+
})*/
|
13
|
+
}
|
14
|
+
|
15
|
+
export const getInitialContractForm = () => {
|
16
|
+
const form = isBrowser
|
17
|
+
? //LocalStorage.get(CONTRACT_CREATE_FORM_LOCALSTORAGE_KEY) ||
|
18
|
+
initialContractStoreState.contractForm
|
19
|
+
: initialContractStoreState.contractForm
|
20
|
+
return form
|
21
|
+
}
|
22
|
+
|
23
|
+
export const getInitialGroupForm = () => {
|
24
|
+
const form = isBrowser
|
25
|
+
? //LocalStorage.get(CONTRACT_CREATE_FORM_LOCALSTORAGE_KEY) ||
|
26
|
+
initialContractStoreState.groupForm
|
27
|
+
: initialContractStoreState.groupForm
|
28
|
+
return form
|
29
|
+
}
|
30
|
+
|
31
|
+
export const getContractById = (
|
32
|
+
contractId: string,
|
33
|
+
contracts: Contract[],
|
34
|
+
): Contract | undefined => {
|
35
|
+
return contracts.find((contract) => contract.contract_id === contractId)
|
36
|
+
}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import { ContractCreateForm, ContractGroupCreateForm } from "./types"
|
2
|
+
import { ModuleWithConstructorArgs } from "../types"
|
3
|
+
import { WindowHapiUtils } from "../_window/utils.types"
|
4
|
+
|
5
|
+
export type WindowHapiUtilsContract = ModuleWithConstructorArgs<
|
6
|
+
{
|
7
|
+
getInitialContractForm: () => ContractCreateForm
|
8
|
+
getInitialGroupForm: () => ContractGroupCreateForm
|
9
|
+
},
|
10
|
+
{ readonly utils: WindowHapiUtils }
|
11
|
+
>
|
@@ -0,0 +1,104 @@
|
|
1
|
+
import {
|
2
|
+
ZodAny,
|
3
|
+
ZodArray,
|
4
|
+
ZodBoolean,
|
5
|
+
ZodNull,
|
6
|
+
ZodNullable,
|
7
|
+
ZodNumber,
|
8
|
+
ZodObject,
|
9
|
+
ZodOptional,
|
10
|
+
ZodRecord,
|
11
|
+
ZodString,
|
12
|
+
ZodUnion,
|
13
|
+
} from "zod"
|
14
|
+
import {
|
15
|
+
ZodProductLogosWithSizes,
|
16
|
+
ZodProductLogoUrl,
|
17
|
+
ZodProductWithContractSupportComplete,
|
18
|
+
} from "../product/validations.types"
|
19
|
+
|
20
|
+
export type ZodContractAlias = ZodOptional<ZodNullable<ZodString>>
|
21
|
+
export type ZodContractExpiryDate = ZodOptional<ZodNullable<ZodString>>
|
22
|
+
export type ZodContractCredits = ZodOptional<
|
23
|
+
ZodNullable<ZodUnion<[ZodNumber, ZodString]>>
|
24
|
+
>
|
25
|
+
export type ZodContractFacets = ZodOptional<ZodAny>
|
26
|
+
export type ZodContractChannel = ZodObject<{
|
27
|
+
id: ZodNumber
|
28
|
+
name: ZodString
|
29
|
+
url: ZodString
|
30
|
+
type: ZodString
|
31
|
+
}>
|
32
|
+
export type ZodContractProduct = ZodObject<{
|
33
|
+
product_id: ZodString
|
34
|
+
title: ZodString
|
35
|
+
}>
|
36
|
+
export type ZodContractPurchasePrice = ZodOptional<
|
37
|
+
ZodObject<{
|
38
|
+
amount: ZodNullable<ZodNumber>
|
39
|
+
currency: ZodNullable<ZodString>
|
40
|
+
}>
|
41
|
+
>
|
42
|
+
export type ZodContractGroup = ZodObject<{
|
43
|
+
id: ZodOptional<ZodString>
|
44
|
+
idx: ZodOptional<ZodNumber>
|
45
|
+
igb_customer_id: ZodOptional<ZodString>
|
46
|
+
name: ZodString
|
47
|
+
}>
|
48
|
+
export type ZodContractGroupSelected = ZodUnion<
|
49
|
+
[ZodString, ZodContractGroup, ZodNull]
|
50
|
+
>
|
51
|
+
export type ZodContractGroupCreateForm = ZodObject<{
|
52
|
+
name: ZodString
|
53
|
+
}>
|
54
|
+
export type ZodContractCreateForm = ZodObject<{
|
55
|
+
id: ZodOptional<ZodNumber>
|
56
|
+
credentials: ZodOptional<ZodObject<any>>
|
57
|
+
facets: ZodContractFacets
|
58
|
+
alias: ZodContractAlias
|
59
|
+
expiry_date: ZodContractExpiryDate
|
60
|
+
purchase_price: ZodContractPurchasePrice
|
61
|
+
credits: ZodContractCredits
|
62
|
+
followed_instructions: ZodOptional<ZodBoolean>
|
63
|
+
allow_renegotiation: ZodOptional<ZodBoolean>
|
64
|
+
}>
|
65
|
+
export type ZodContractPostingRequirementAutocompleteRequestOptions = ZodRecord<
|
66
|
+
ZodString,
|
67
|
+
ZodUnion<[ZodString, ZodArray<ZodString>]>
|
68
|
+
>
|
69
|
+
|
70
|
+
export type ZodContract = ZodObject<{
|
71
|
+
channel: ZodOptional<ZodContractChannel>
|
72
|
+
alias: ZodContractAlias
|
73
|
+
channel_id: ZodNumber
|
74
|
+
class_name: ZodString
|
75
|
+
contract_id: ZodString
|
76
|
+
customer_id: ZodString
|
77
|
+
facets: ZodContractFacets
|
78
|
+
credits: ZodContractCredits
|
79
|
+
expiry_date: ZodContractExpiryDate
|
80
|
+
logo_rectangle_url: ZodOptional<ZodNullable<ZodProductLogosWithSizes>>
|
81
|
+
logo_square_url: ZodOptional<ZodNullable<ZodProductLogosWithSizes>>
|
82
|
+
logo_url: ZodOptional<ZodNullable<ZodProductLogoUrl>>
|
83
|
+
product: ZodContractProduct
|
84
|
+
purchase_price: ZodNullable<ZodContractPurchasePrice>
|
85
|
+
group: ZodNullable<ZodContractGroup>
|
86
|
+
}>
|
87
|
+
export type WindowHapiValidationsContract = {
|
88
|
+
channel: ZodContractChannel
|
89
|
+
product: ZodContractProduct
|
90
|
+
contractPurchasePrice: ZodContractPurchasePrice
|
91
|
+
contractExpiryDate: ZodContractExpiryDate
|
92
|
+
contractAlias: ZodContractAlias
|
93
|
+
contractCredits: ZodContractCredits
|
94
|
+
contractFacets: ZodOptional<ZodAny>
|
95
|
+
contractForm: ZodContractCreateForm
|
96
|
+
contract: ZodContract
|
97
|
+
contractSelected: ZodNullable<ZodProductWithContractSupportComplete>
|
98
|
+
contracts: ZodArray<ZodContract>
|
99
|
+
group: ZodContractGroup
|
100
|
+
groupSelected: ZodContractGroupSelected
|
101
|
+
groups: ZodArray<ZodContractGroup>
|
102
|
+
groupForm: ZodContractGroupCreateForm
|
103
|
+
postingRequirementAutocompleteRequestOptions: ZodContractPostingRequirementAutocompleteRequestOptions
|
104
|
+
}
|