@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,237 @@
|
|
1
|
+
import { ProductDuration, ProductIndustry } from "../product/types"
|
2
|
+
import { ContractPostingRequirement } from "../contract/types"
|
3
|
+
import { ProductPriceCurrency } from "../product/enums"
|
4
|
+
import { EmploymentType, SalaryPeriod } from "./enums"
|
5
|
+
|
6
|
+
export type CampaignProductSpecs = {
|
7
|
+
contractId: string | null
|
8
|
+
deliveredOn: string | null
|
9
|
+
duration: string
|
10
|
+
durationPeriod: ProductDuration
|
11
|
+
jobBoardLink: string | null
|
12
|
+
postingRequirements: Record<string, any> | null
|
13
|
+
productId: string
|
14
|
+
status: CampaignStatus
|
15
|
+
utm: string | null
|
16
|
+
statusDescription: string | null
|
17
|
+
}
|
18
|
+
|
19
|
+
export type CampaignPostingDetailsContactInfo = {
|
20
|
+
emailAddress?: string | null
|
21
|
+
name?: string | null
|
22
|
+
phoneNumber?: string | null
|
23
|
+
}
|
24
|
+
|
25
|
+
export type CampaignPostingDetailsOrganization = {
|
26
|
+
companyLogo: string
|
27
|
+
name: string
|
28
|
+
}
|
29
|
+
|
30
|
+
export type CampaignProductPostingDetailsSalaryIndicationRange = {
|
31
|
+
currency?: string | null
|
32
|
+
from?: number | null
|
33
|
+
to: number
|
34
|
+
}
|
35
|
+
|
36
|
+
export type CampaignPostingDetailsSalaryIndication = {
|
37
|
+
period: SalaryPeriod
|
38
|
+
range: CampaignProductPostingDetailsSalaryIndicationRange
|
39
|
+
}
|
40
|
+
|
41
|
+
export type CampaignPostingDetailsWeeklyWorkingHours = {
|
42
|
+
to: number
|
43
|
+
from?: number | null
|
44
|
+
}
|
45
|
+
|
46
|
+
export type CampaignPostingDetailsWorkingLocation = {
|
47
|
+
addressLine1: string
|
48
|
+
addressLine2: string
|
49
|
+
allowsRemoteWork?: boolean | number | null
|
50
|
+
city: string
|
51
|
+
country: string
|
52
|
+
postCode?: string | null
|
53
|
+
postcode: string
|
54
|
+
}
|
55
|
+
|
56
|
+
export type CampaignPostingDetails = {
|
57
|
+
applicationUrl: string
|
58
|
+
contactInfo: CampaignPostingDetailsContactInfo
|
59
|
+
description: string
|
60
|
+
employmentType: EmploymentType
|
61
|
+
jobPageUrl: string
|
62
|
+
organization: CampaignPostingDetailsOrganization
|
63
|
+
salaryIndication: CampaignPostingDetailsSalaryIndication
|
64
|
+
title: string
|
65
|
+
weeklyWorkingHours: CampaignPostingDetailsWeeklyWorkingHours
|
66
|
+
workingLocation: CampaignPostingDetailsWorkingLocation
|
67
|
+
yearsOfExperience: number
|
68
|
+
}
|
69
|
+
|
70
|
+
export type CampaignPosting = {
|
71
|
+
clicks: number
|
72
|
+
name: string
|
73
|
+
productId: string
|
74
|
+
}
|
75
|
+
|
76
|
+
export type CampaignRecruiterInfo = {
|
77
|
+
id?: number | null
|
78
|
+
name: string
|
79
|
+
emailAddress?: string | null
|
80
|
+
}
|
81
|
+
|
82
|
+
export type CampaignTargetGroupData = {
|
83
|
+
description: string
|
84
|
+
vonqId: string | number
|
85
|
+
}
|
86
|
+
|
87
|
+
export type CampaignTargetGroup = {
|
88
|
+
educationLevel: CampaignTargetGroupData[]
|
89
|
+
industry: CampaignTargetGroupData[]
|
90
|
+
jobCategory: CampaignTargetGroupData[]
|
91
|
+
seniority: CampaignTargetGroupData[]
|
92
|
+
}
|
93
|
+
|
94
|
+
export type CampaignTotalPrice = {
|
95
|
+
amount: number
|
96
|
+
currency: ProductPriceCurrency
|
97
|
+
}
|
98
|
+
|
99
|
+
export type CampaignStatus = "in progress" | "offline"
|
100
|
+
|
101
|
+
export type CampaignDetailsStatusOrderedProductStatus = {
|
102
|
+
productId: string
|
103
|
+
status: CampaignStatus
|
104
|
+
statusDescription: string | null
|
105
|
+
}
|
106
|
+
|
107
|
+
export type CampaignDetailedStatus = {
|
108
|
+
campaignId: string
|
109
|
+
status: CampaignStatus
|
110
|
+
orderedProductsStatuses: CampaignDetailsStatusOrderedProductStatus[]
|
111
|
+
}
|
112
|
+
|
113
|
+
export type Campaign = {
|
114
|
+
currency: ProductPriceCurrency
|
115
|
+
campaignId: string
|
116
|
+
campaignName: string | null
|
117
|
+
companyId: string
|
118
|
+
createdOn: string
|
119
|
+
customerId: string
|
120
|
+
orderReference: string | null
|
121
|
+
orderedProducts: string[]
|
122
|
+
orderedProductsSpecs: CampaignProductSpecs[]
|
123
|
+
postingDetails: CampaignPostingDetails
|
124
|
+
postings: CampaignPosting[]
|
125
|
+
recruiterInfo: CampaignRecruiterInfo
|
126
|
+
status: CampaignStatus
|
127
|
+
targetGroup: CampaignTargetGroup
|
128
|
+
totalPrice: CampaignTotalPrice
|
129
|
+
walletId: string
|
130
|
+
detailedStatus?: CampaignDetailedStatus //this is only added virtually on FE on demand
|
131
|
+
}
|
132
|
+
|
133
|
+
export type CampaignCreateFormTargetGroupEducationLevel =
|
134
|
+
TaxonomyEducationAndSeniorityLevel
|
135
|
+
|
136
|
+
export type CampaignCreateFormTargetGroupSeniority = TaxonomySeniority
|
137
|
+
|
138
|
+
export type CampaignCreateFormTargetGroupIndustry = ProductIndustry
|
139
|
+
|
140
|
+
export type CampaignCreateFormTargetGroupJobCategory = {
|
141
|
+
label: string
|
142
|
+
value: number
|
143
|
+
}
|
144
|
+
|
145
|
+
export type CampaignCreateFormTargetGroup = {
|
146
|
+
educationLevel: CampaignCreateFormTargetGroupEducationLevel[]
|
147
|
+
seniority: CampaignCreateFormTargetGroupSeniority[]
|
148
|
+
industry: CampaignCreateFormTargetGroupIndustry[]
|
149
|
+
jobCategory: CampaignCreateFormTargetGroupJobCategory[]
|
150
|
+
}
|
151
|
+
|
152
|
+
export type CampaignCreateFormOrderedProductSpecBase = {
|
153
|
+
productId: string
|
154
|
+
utm: string
|
155
|
+
contractId: string
|
156
|
+
postingRequirements: ContractPostingRequirement[]
|
157
|
+
}
|
158
|
+
export type CampaignCreateFormOrderedProductSpec =
|
159
|
+
CampaignCreateFormOrderedProductSpecBase & { [k: string]: any }
|
160
|
+
|
161
|
+
export type CampaignCreateForm = {
|
162
|
+
companyId: string
|
163
|
+
campaignName?: string | null
|
164
|
+
poNumber?: string
|
165
|
+
targetGroup: CampaignCreateFormTargetGroup
|
166
|
+
recruiterInfo: CampaignRecruiterInfo
|
167
|
+
postingDetails: {
|
168
|
+
title: string
|
169
|
+
description: string
|
170
|
+
organization: CampaignPostingDetailsOrganization
|
171
|
+
workingLocation: CampaignPostingDetailsWorkingLocation
|
172
|
+
yearsOfExperience: number
|
173
|
+
employmentType: EmploymentType
|
174
|
+
weeklyWorkingHours: CampaignPostingDetailsWeeklyWorkingHours
|
175
|
+
salaryIndication: CampaignPostingDetailsSalaryIndication
|
176
|
+
contactInfo: CampaignPostingDetailsContactInfo
|
177
|
+
jobPageUrl: string
|
178
|
+
applicationUrl: string
|
179
|
+
}
|
180
|
+
orderedProducts: string[] //Array of UUIDs
|
181
|
+
orderedProductsSpecs: Record<string, CampaignCreateFormOrderedProductSpec>
|
182
|
+
}
|
183
|
+
|
184
|
+
export type CampaignOrderRequestBodyOrderedProductsSpec = {
|
185
|
+
contractId: string
|
186
|
+
utm: string
|
187
|
+
productId: string
|
188
|
+
postingRequirements?: any
|
189
|
+
}
|
190
|
+
|
191
|
+
export type CampaignOrderRequestBody = {
|
192
|
+
companyId: string
|
193
|
+
campaignName: string | null | undefined
|
194
|
+
walletId?: string
|
195
|
+
poNumber?: string
|
196
|
+
recruiterInfo: Omit<CampaignRecruiterInfo, "id">
|
197
|
+
postingDetails: CampaignPostingDetails
|
198
|
+
targetGroup: CampaignTargetGroup
|
199
|
+
orderedProducts: string[]
|
200
|
+
orderedProductsSpecs: CampaignOrderRequestBodyOrderedProductsSpec[]
|
201
|
+
currency: string
|
202
|
+
}
|
203
|
+
|
204
|
+
export type CampaignTaxonomyNameWithLanguage = {
|
205
|
+
languageCode: string
|
206
|
+
value: string
|
207
|
+
}
|
208
|
+
|
209
|
+
export type TaxonomyEducationLevelName = CampaignTaxonomyNameWithLanguage
|
210
|
+
|
211
|
+
export type TaxonomySeniorityName = CampaignTaxonomyNameWithLanguage
|
212
|
+
|
213
|
+
export type TaxonomySeniority = {
|
214
|
+
id: number
|
215
|
+
name: TaxonomySeniorityName[]
|
216
|
+
}
|
217
|
+
|
218
|
+
export type TaxonomyEducationAndSeniorityLevel = {
|
219
|
+
id: number
|
220
|
+
name: TaxonomyEducationLevelName[]
|
221
|
+
}
|
222
|
+
|
223
|
+
export type TaxonomyEmploymentTypes = {
|
224
|
+
value: EmploymentType
|
225
|
+
label: string
|
226
|
+
}
|
227
|
+
export type TransformedPostingRequirementOption = {
|
228
|
+
value?: string
|
229
|
+
options?: { label: string; value: string; data?: any[] }[]
|
230
|
+
label: string
|
231
|
+
}
|
232
|
+
export type TransformedPostingRequirement = Omit<
|
233
|
+
ContractPostingRequirement,
|
234
|
+
"options"
|
235
|
+
> & {
|
236
|
+
options: TransformedPostingRequirementOption[] | null
|
237
|
+
}
|
@@ -0,0 +1,53 @@
|
|
1
|
+
import { TransformedPostingRequirement } from "./types"
|
2
|
+
|
3
|
+
export const getShouldDisplayPostingRequirement = (
|
4
|
+
requirement: TransformedPostingRequirement,
|
5
|
+
form: Record<string, any>,
|
6
|
+
) => {
|
7
|
+
const getIsFacetVisible = (
|
8
|
+
operation: string,
|
9
|
+
operationValues: any[],
|
10
|
+
value: any,
|
11
|
+
) => {
|
12
|
+
if (operation == "equal") {
|
13
|
+
return value == operationValues
|
14
|
+
} else if (operation == "in") {
|
15
|
+
if (Array.isArray(value)) {
|
16
|
+
const values = value.map((val) => val.value)
|
17
|
+
return operationValues.some((operationValue) =>
|
18
|
+
values.includes(operationValue),
|
19
|
+
)
|
20
|
+
}
|
21
|
+
return operationValues.includes(value)
|
22
|
+
} else if (operation === "notempty") {
|
23
|
+
if (typeof value === "string") {
|
24
|
+
return value.trim() !== ""
|
25
|
+
} else if (Array.isArray(value)) {
|
26
|
+
return value.length > 0
|
27
|
+
} else if (typeof value === "object") {
|
28
|
+
return Object.keys(value).length > 0
|
29
|
+
} else {
|
30
|
+
return !!value
|
31
|
+
}
|
32
|
+
}
|
33
|
+
return false
|
34
|
+
}
|
35
|
+
let shouldShow = true
|
36
|
+
if (!requirement.display_rules?.show?.length) return true
|
37
|
+
const foundRule = requirement.display_rules.show.findIndex((rule) => {
|
38
|
+
const facetCheckValue = form[rule.facet]
|
39
|
+
if (facetCheckValue === undefined) {
|
40
|
+
shouldShow = false
|
41
|
+
}
|
42
|
+
return getIsFacetVisible(
|
43
|
+
rule.op,
|
44
|
+
rule.value,
|
45
|
+
typeof facetCheckValue === "object" &&
|
46
|
+
!Array.isArray(facetCheckValue)
|
47
|
+
? facetCheckValue?.value
|
48
|
+
: facetCheckValue,
|
49
|
+
)
|
50
|
+
})
|
51
|
+
shouldShow = foundRule != -1
|
52
|
+
return shouldShow
|
53
|
+
}
|
@@ -0,0 +1,59 @@
|
|
1
|
+
import {
|
2
|
+
Campaign,
|
3
|
+
CampaignCreateForm,
|
4
|
+
CampaignCreateFormOrderedProductSpec,
|
5
|
+
CampaignCreateFormTargetGroup,
|
6
|
+
CampaignCreateFormTargetGroupEducationLevel,
|
7
|
+
CampaignCreateFormTargetGroupIndustry,
|
8
|
+
CampaignCreateFormTargetGroupJobCategory,
|
9
|
+
CampaignCreateFormTargetGroupSeniority,
|
10
|
+
CampaignOrderRequestBody,
|
11
|
+
CampaignOrderRequestBodyOrderedProductsSpec,
|
12
|
+
CampaignTargetGroup,
|
13
|
+
CampaignTargetGroupData,
|
14
|
+
} from "./types"
|
15
|
+
import { Product } from "../product/types"
|
16
|
+
import { Contract } from "../contract/types"
|
17
|
+
import { ModuleWithConstructorArgs } from "../types"
|
18
|
+
import { BasketProduct } from "../basket/types"
|
19
|
+
import { WindowHapiUtils } from "../_window/utils.types"
|
20
|
+
|
21
|
+
export type WindowHapiUtilsCampaign = ModuleWithConstructorArgs<
|
22
|
+
{
|
23
|
+
getInitialCampaignForm: () => CampaignCreateForm
|
24
|
+
mapCampaignsAndUpdateById: (
|
25
|
+
campaignId: string,
|
26
|
+
campaign: Partial<Campaign>,
|
27
|
+
) => void
|
28
|
+
getOrderCampaignRequestBody: () => CampaignOrderRequestBody
|
29
|
+
getCopyCampaignRequestBody: (
|
30
|
+
campaign: Campaign,
|
31
|
+
) => CampaignOrderRequestBody
|
32
|
+
getPostBodyValuesForTargetGroupProperty: (
|
33
|
+
selectValue:
|
34
|
+
| CampaignCreateFormTargetGroupEducationLevel[]
|
35
|
+
| CampaignCreateFormTargetGroupSeniority[]
|
36
|
+
| CampaignCreateFormTargetGroupIndustry[]
|
37
|
+
| CampaignCreateFormTargetGroupJobCategory[]
|
38
|
+
| undefined,
|
39
|
+
type: "educationLevel" | "seniority" | "industry" | "jobCategory",
|
40
|
+
) => CampaignTargetGroupData[]
|
41
|
+
getPostBodyForTargetGroup: (
|
42
|
+
targetGroup: CampaignCreateFormTargetGroup,
|
43
|
+
) => CampaignTargetGroup
|
44
|
+
getPostBodyForOrderedProductsFromBasketProducts: (
|
45
|
+
productsOrContracts: (Contract | Product)[],
|
46
|
+
) => string[]
|
47
|
+
getPostBodyForOrderedProductsSpecs: (
|
48
|
+
products: (Product | Contract)[],
|
49
|
+
orderedProductsSpecs: Record<
|
50
|
+
string,
|
51
|
+
CampaignCreateFormOrderedProductSpec
|
52
|
+
>,
|
53
|
+
) => CampaignOrderRequestBodyOrderedProductsSpec[]
|
54
|
+
getPostBodyForOrderedProductsSpecsPostingRequirement: (
|
55
|
+
postingRequirement: any,
|
56
|
+
) => any
|
57
|
+
},
|
58
|
+
{ readonly utils: WindowHapiUtils }
|
59
|
+
>
|
@@ -0,0 +1,215 @@
|
|
1
|
+
import {
|
2
|
+
ZodAny,
|
3
|
+
ZodArray,
|
4
|
+
ZodNullable,
|
5
|
+
ZodNumber,
|
6
|
+
ZodObject,
|
7
|
+
ZodOptional,
|
8
|
+
ZodRecord,
|
9
|
+
ZodString,
|
10
|
+
ZodUnion,
|
11
|
+
} from "zod"
|
12
|
+
import { ZodProductDuration } from "../product/validations.types"
|
13
|
+
|
14
|
+
export type ZodCampaignTotalPrice = ZodObject<{
|
15
|
+
amount: ZodNumber
|
16
|
+
currency: ZodString
|
17
|
+
}>
|
18
|
+
export type ZodCampaignEmploymentType = ZodObject<{
|
19
|
+
label: ZodString
|
20
|
+
value: ZodString
|
21
|
+
}>
|
22
|
+
export type ZodCampaignRecruiterInfo = ZodObject<{
|
23
|
+
id: ZodOptional<ZodNullable<ZodUnion<[ZodNumber, ZodString]>>>
|
24
|
+
name: ZodString
|
25
|
+
emailAddress: ZodOptional<ZodNullable<ZodString>>
|
26
|
+
}>
|
27
|
+
export type ZodCampaignTargetGroupData = ZodObject<{
|
28
|
+
description: ZodString
|
29
|
+
vonqId: ZodString
|
30
|
+
}>
|
31
|
+
export type ZodCampaignTargetGroupDatas = ZodArray<ZodCampaignTargetGroupData>
|
32
|
+
export type ZodCampaignTargetGroup = ZodObject<{
|
33
|
+
educationLevel: ZodCampaignTargetGroupDatas
|
34
|
+
industry: ZodCampaignTargetGroupDatas
|
35
|
+
jobCategory: ZodCampaignTargetGroupDatas
|
36
|
+
seniority: ZodCampaignTargetGroupDatas
|
37
|
+
}>
|
38
|
+
export type ZodCampaignPosting = ZodObject<{
|
39
|
+
clicks: ZodNumber
|
40
|
+
name: ZodString
|
41
|
+
productId: ZodString
|
42
|
+
}>
|
43
|
+
export type ZodCampaignPostings = ZodArray<ZodCampaignPosting>
|
44
|
+
export type ZodCampaignPostingDetailsContactInfo = ZodObject<{
|
45
|
+
emailAddress: ZodOptional<ZodNullable<ZodString>>
|
46
|
+
name: ZodOptional<ZodNullable<ZodString>>
|
47
|
+
phoneNumber: ZodOptional<ZodNullable<ZodString>>
|
48
|
+
}>
|
49
|
+
export type ZodCampaignPostingDetailsOrganization = ZodObject<{
|
50
|
+
companyLogo: ZodString
|
51
|
+
name: ZodString
|
52
|
+
}>
|
53
|
+
export type ZodCampaignPostingDetailsSalaryIndication = ZodObject<{
|
54
|
+
period: ZodString
|
55
|
+
range: ZodObject<{
|
56
|
+
currency: ZodOptional<ZodNullable<ZodString>>
|
57
|
+
from: ZodOptional<ZodNullable<ZodNumber>>
|
58
|
+
to: ZodNumber
|
59
|
+
}>
|
60
|
+
}>
|
61
|
+
export type ZodCampaignPostingDetailsWeeklyWorkingHours = ZodObject<{
|
62
|
+
from: ZodOptional<ZodNullable<ZodNumber>>
|
63
|
+
to: ZodNumber
|
64
|
+
}>
|
65
|
+
export type ZodCampaignPostingDetailsWorkingLocationPostCodeDefinition = {
|
66
|
+
postCode: ZodOptional<ZodNullable<ZodString>>
|
67
|
+
}
|
68
|
+
export type ZodCampaignPostingDetailsWorkingLocationAddressDetailsDefinition = {
|
69
|
+
addressLine1: ZodString
|
70
|
+
addressLine2: ZodOptional<ZodNullable<ZodString>>
|
71
|
+
allowsRemoteWork: ZodOptional<ZodNullable<ZodNumber>>
|
72
|
+
city: ZodString
|
73
|
+
country: ZodString
|
74
|
+
postcode: ZodString
|
75
|
+
}
|
76
|
+
export type ZodCampaignPostingDetailsWorkingLocation = ZodObject<
|
77
|
+
ZodCampaignPostingDetailsWorkingLocationAddressDetailsDefinition &
|
78
|
+
ZodCampaignPostingDetailsWorkingLocationPostCodeDefinition
|
79
|
+
>
|
80
|
+
export type ZodCampaignTaxonomyNameWithLanguage = ZodObject<{
|
81
|
+
languageCode: ZodString
|
82
|
+
value: ZodString
|
83
|
+
}>
|
84
|
+
export type ZodCampaignTaxonomyEducationLevel = ZodObject<{
|
85
|
+
id: ZodNumber
|
86
|
+
name: ZodArray<ZodCampaignTaxonomyNameWithLanguage>
|
87
|
+
}>
|
88
|
+
export type ZodCampaignTaxonomyEducationLevels =
|
89
|
+
ZodArray<ZodCampaignTaxonomyEducationLevel>
|
90
|
+
export type ZodCampaignTaxonomySeniority = ZodObject<{
|
91
|
+
id: ZodNumber
|
92
|
+
name: ZodArray<ZodCampaignTaxonomyNameWithLanguage>
|
93
|
+
}>
|
94
|
+
export type ZodCampaignTaxonomySeniorities =
|
95
|
+
ZodArray<ZodCampaignTaxonomySeniority>
|
96
|
+
export type ZodCampaignPostingDetails = ZodObject<{
|
97
|
+
applicationUrl: ZodString
|
98
|
+
description: ZodString
|
99
|
+
contactInfo: ZodCampaignPostingDetailsContactInfo
|
100
|
+
employmentType: ZodString
|
101
|
+
jobPageUrl: ZodString
|
102
|
+
organization: ZodCampaignPostingDetailsOrganization
|
103
|
+
salaryIndication: ZodCampaignPostingDetailsSalaryIndication
|
104
|
+
title: ZodString
|
105
|
+
weeklyWorkingHours: ZodCampaignPostingDetailsWeeklyWorkingHours
|
106
|
+
workingLocation: ZodCampaignPostingDetailsWorkingLocation
|
107
|
+
yearsOfExperience: ZodNumber
|
108
|
+
}>
|
109
|
+
export type ZodCampaignOrderedProductSpec = ZodObject<{
|
110
|
+
contractId: ZodNullable<ZodString>
|
111
|
+
postingRequirements: ZodNullable<ZodObject<any>>
|
112
|
+
productId: ZodString
|
113
|
+
utm: ZodNullable<ZodString>
|
114
|
+
deliveredOn: ZodNullable<ZodString>
|
115
|
+
duration: ZodString
|
116
|
+
durationPeriod: ZodProductDuration
|
117
|
+
jobBoardLink: ZodNullable<ZodString>
|
118
|
+
status: ZodString
|
119
|
+
statusDescription: ZodNullable<ZodString>
|
120
|
+
}>
|
121
|
+
export type ZodCampaignOrderedProductSpecs =
|
122
|
+
ZodArray<ZodCampaignOrderedProductSpec>
|
123
|
+
export type ZodCampaignCreateFormOrderedProductSpecs = ZodRecord<
|
124
|
+
ZodString,
|
125
|
+
ZodAny
|
126
|
+
>
|
127
|
+
|
128
|
+
export type ZodCampaign = ZodObject<{
|
129
|
+
currency: ZodString
|
130
|
+
campaignId: ZodString
|
131
|
+
campaignName: ZodNullable<ZodString>
|
132
|
+
companyId: ZodString
|
133
|
+
createdOn: ZodString
|
134
|
+
customerId: ZodString
|
135
|
+
orderReference: ZodNullable<ZodString>
|
136
|
+
orderedProducts: ZodArray<ZodString>
|
137
|
+
orderedProductsSpecs: ZodCampaignOrderedProductSpecs
|
138
|
+
postingDetails: ZodCampaignPostingDetails
|
139
|
+
postings: ZodCampaignPostings
|
140
|
+
recruiterInfo: ZodCampaignRecruiterInfo
|
141
|
+
status: ZodString
|
142
|
+
targetGroup: ZodCampaignTargetGroup
|
143
|
+
totalPrice: ZodCampaignTotalPrice
|
144
|
+
walletId: ZodOptional<ZodNullable<ZodString>>
|
145
|
+
poNumber: ZodOptional<ZodNullable<ZodString>>
|
146
|
+
}>
|
147
|
+
export type ZodCampaigns = ZodArray<ZodCampaign>
|
148
|
+
export type ZodCampaignCreateFormPostingDetails = ZodObject<{
|
149
|
+
title: ZodString
|
150
|
+
description: ZodString
|
151
|
+
organization: ZodCampaignPostingDetailsOrganization
|
152
|
+
workingLocation: ZodObject<ZodCampaignPostingDetailsWorkingLocationAddressDetailsDefinition>
|
153
|
+
yearsOfExperience: ZodNumber
|
154
|
+
employmentType: ZodString
|
155
|
+
weeklyWorkingHours: ZodCampaignPostingDetailsWeeklyWorkingHours
|
156
|
+
salaryIndication: ZodCampaignPostingDetailsSalaryIndication
|
157
|
+
jobPageUrl: ZodString
|
158
|
+
applicationUrl: ZodString
|
159
|
+
}>
|
160
|
+
export type ZodCampaignCreateFormTargetGroup = ZodObject<{
|
161
|
+
educationLevel: ZodCampaignTaxonomyEducationLevels
|
162
|
+
seniority: ZodCampaignTaxonomySeniorities
|
163
|
+
industry: ZodArray<ZodObject<{ id: ZodNumber; name: ZodString }>>
|
164
|
+
jobCategory: ZodArray<
|
165
|
+
ZodObject<{
|
166
|
+
label: ZodString
|
167
|
+
value: ZodNumber
|
168
|
+
}>
|
169
|
+
>
|
170
|
+
}>
|
171
|
+
export type ZodCampaignCreateForm = ZodObject<{
|
172
|
+
companyId: ZodString
|
173
|
+
campaignName: ZodOptional<ZodNullable<ZodString>>
|
174
|
+
targetGroup: ZodCampaignCreateFormTargetGroup
|
175
|
+
recruiterInfo: ZodCampaignRecruiterInfo
|
176
|
+
postingDetails: ZodCampaignCreateFormPostingDetails
|
177
|
+
orderedProductsSpecs: ZodCampaignCreateFormOrderedProductSpecs
|
178
|
+
orderedProducts: ZodArray<ZodString>
|
179
|
+
}>
|
180
|
+
export type WindowHapiValidationsCampaign = {
|
181
|
+
status: string[]
|
182
|
+
statusRegex: RegExp
|
183
|
+
supportedEmploymentType: string[]
|
184
|
+
employmentTypeRegex: RegExp
|
185
|
+
employmentType: ZodCampaignEmploymentType
|
186
|
+
employmentTypes: ZodArray<ZodCampaignEmploymentType>
|
187
|
+
salaryPeriod: string[]
|
188
|
+
salaryPeriodRegex: RegExp
|
189
|
+
totalPrice: ZodCampaignTotalPrice
|
190
|
+
recruiterInfo: ZodCampaignRecruiterInfo
|
191
|
+
targetGroupData: ZodCampaignTargetGroupData
|
192
|
+
targetGroupDatas: ZodCampaignTargetGroupDatas
|
193
|
+
targetGroup: ZodCampaignTargetGroup
|
194
|
+
posting: ZodCampaignPosting
|
195
|
+
postings: ZodCampaignPostings
|
196
|
+
postingDetailsContactInfo: ZodCampaignPostingDetailsContactInfo
|
197
|
+
postingDetailsOrganization: ZodCampaignPostingDetailsOrganization
|
198
|
+
postingDetailsSalaryIndication: ZodCampaignPostingDetailsSalaryIndication
|
199
|
+
postingDetailsWeeklyWorkingHours: ZodCampaignPostingDetailsWeeklyWorkingHours
|
200
|
+
postingDetailsWorkingLocation: ZodCampaignPostingDetailsWorkingLocation
|
201
|
+
nameWithLanguage: ZodCampaignTaxonomyNameWithLanguage
|
202
|
+
educationLevel: ZodCampaignTaxonomyEducationLevel
|
203
|
+
educationLevels: ZodCampaignTaxonomyEducationLevels
|
204
|
+
seniority: ZodCampaignTaxonomySeniority
|
205
|
+
seniorities: ZodCampaignTaxonomySeniorities
|
206
|
+
postingDetails: ZodCampaignPostingDetails
|
207
|
+
orderedProductsSpec: ZodCampaignOrderedProductSpec
|
208
|
+
orderedProductsSpecs: ZodCampaignOrderedProductSpecs
|
209
|
+
campaign: ZodCampaign
|
210
|
+
campaigns: ZodCampaigns
|
211
|
+
campaignForm: ZodCampaignCreateForm
|
212
|
+
campaignFormTargetGroup: ZodCampaignCreateFormTargetGroup
|
213
|
+
campaignFormPostingDetails: ZodCampaignCreateFormPostingDetails
|
214
|
+
campaignFormOrderedProductsSpecs: ZodCampaignCreateFormOrderedProductSpecs
|
215
|
+
}
|
@@ -0,0 +1,123 @@
|
|
1
|
+
import { isBrowser } from "./browser"
|
2
|
+
|
3
|
+
export default class LocalStorage {
|
4
|
+
private static localStorageFull: boolean = false
|
5
|
+
|
6
|
+
static set(key: string, value: any): void {
|
7
|
+
try {
|
8
|
+
if (isBrowser && !this.localStorageFull) {
|
9
|
+
localStorage.setItem(key, JSON.stringify(value))
|
10
|
+
}
|
11
|
+
} catch (e) {
|
12
|
+
try {
|
13
|
+
if (isBrowser && !this.localStorageFull) {
|
14
|
+
localStorage.setItem(key, JSON.stringify(value))
|
15
|
+
}
|
16
|
+
} catch (error) {
|
17
|
+
this.localStorageFull = true
|
18
|
+
}
|
19
|
+
}
|
20
|
+
}
|
21
|
+
|
22
|
+
static setPlain(key: string, value: any): void {
|
23
|
+
if (isBrowser) {
|
24
|
+
localStorage.setItem(key, value)
|
25
|
+
}
|
26
|
+
}
|
27
|
+
|
28
|
+
static remove(key: string): void {
|
29
|
+
if (isBrowser) {
|
30
|
+
localStorage.removeItem(key)
|
31
|
+
this.localStorageFull = false
|
32
|
+
}
|
33
|
+
}
|
34
|
+
|
35
|
+
static get(key: string): any {
|
36
|
+
if (isBrowser) {
|
37
|
+
const data = localStorage.getItem(key)
|
38
|
+
const value = !!data ? JSON.parse(data) : ""
|
39
|
+
return value
|
40
|
+
}
|
41
|
+
}
|
42
|
+
|
43
|
+
static getOrDefault<T>(key: string, defaultValue: T): T {
|
44
|
+
let response = defaultValue
|
45
|
+
if (isBrowser) {
|
46
|
+
const data = localStorage.getItem(key)
|
47
|
+
response = !!data ? JSON.parse(data) : defaultValue
|
48
|
+
}
|
49
|
+
return response
|
50
|
+
}
|
51
|
+
|
52
|
+
static getPlain(key: string): any {
|
53
|
+
if (isBrowser) {
|
54
|
+
return localStorage.getItem(key)
|
55
|
+
}
|
56
|
+
return null
|
57
|
+
}
|
58
|
+
|
59
|
+
// use with caution
|
60
|
+
static clear(): void {
|
61
|
+
if (isBrowser) {
|
62
|
+
localStorage.clear()
|
63
|
+
this.localStorageFull = false
|
64
|
+
}
|
65
|
+
}
|
66
|
+
|
67
|
+
static clearSpecific(keyChoice: (key: string) => boolean): void {
|
68
|
+
if (isBrowser) {
|
69
|
+
Object.keys(localStorage).forEach(
|
70
|
+
(key) => keyChoice(key) && localStorage.removeItem(key),
|
71
|
+
)
|
72
|
+
this.localStorageFull = false
|
73
|
+
}
|
74
|
+
}
|
75
|
+
|
76
|
+
static setWithExpiry = (key: string, value: any, ttl: number) => {
|
77
|
+
const now = new Date()
|
78
|
+
const item = {
|
79
|
+
value: value,
|
80
|
+
expiry: now.getTime() + ttl,
|
81
|
+
}
|
82
|
+
|
83
|
+
// New thing
|
84
|
+
localStorage.setItem(key, JSON.stringify(item))
|
85
|
+
}
|
86
|
+
|
87
|
+
static getWithExpiry = (key: string) => {
|
88
|
+
const itemStr = localStorage.getItem(key)
|
89
|
+
|
90
|
+
if (!itemStr) {
|
91
|
+
return null
|
92
|
+
}
|
93
|
+
|
94
|
+
const item = JSON.parse(itemStr)
|
95
|
+
const now = new Date()
|
96
|
+
|
97
|
+
if (now.getTime() > item.expiry) {
|
98
|
+
localStorage.removeItem(key)
|
99
|
+
return null
|
100
|
+
}
|
101
|
+
return item.value
|
102
|
+
}
|
103
|
+
|
104
|
+
static loadState = () => {
|
105
|
+
try {
|
106
|
+
const state = this.getWithExpiry("state")
|
107
|
+
if (state === null) {
|
108
|
+
return undefined
|
109
|
+
}
|
110
|
+
return state
|
111
|
+
} catch (err) {
|
112
|
+
return undefined
|
113
|
+
}
|
114
|
+
}
|
115
|
+
|
116
|
+
static saveState = (state: any) => {
|
117
|
+
try {
|
118
|
+
this.setWithExpiry("state", state, 30 * 24 * 60 * 60 * 1000) // Days * Hours * Minutes * Seconds * millis
|
119
|
+
} catch {
|
120
|
+
// ignore write errors
|
121
|
+
}
|
122
|
+
}
|
123
|
+
}
|