@everymatrix/general-registration-multistep 0.0.1
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/dist/cjs/app-globals-3a1e7e63.js +5 -0
- package/dist/cjs/checkbox-group-input_15.cjs.entry.js +17272 -0
- package/dist/cjs/general-registration-multistep.cjs.js +25 -0
- package/dist/cjs/index-2b1397e1.js +1322 -0
- package/dist/cjs/index.cjs.js +14 -0
- package/dist/cjs/loader.cjs.js +15 -0
- package/dist/collection/collection-manifest.json +32 -0
- package/dist/collection/components/general-registration-multisteps/general-registration-multistep.css +230 -0
- package/dist/collection/components/general-registration-multisteps/general-registration-multistep.js +1470 -0
- package/dist/collection/components/general-registration-multisteps/index.js +1 -0
- package/dist/collection/index.js +13 -0
- package/dist/collection/utils/locale.utils.js +1107 -0
- package/dist/collection/utils/utils.js +3 -0
- package/dist/esm/app-globals-0f993ce5.js +3 -0
- package/dist/esm/checkbox-group-input_15.entry.js +17254 -0
- package/dist/esm/general-registration-multistep.js +20 -0
- package/dist/esm/index-9ed15dae.js +1293 -0
- package/dist/esm/index.js +12 -0
- package/dist/esm/loader.js +11 -0
- package/dist/general-registration-multistep/app-globals-0f993ce5.js +1 -0
- package/dist/general-registration-multistep/checkbox-group-input_15.entry.js +6657 -0
- package/dist/general-registration-multistep/general-registration-multistep.esm.js +1 -0
- package/dist/general-registration-multistep/index-9ed15dae.js +2 -0
- package/dist/general-registration-multistep/index.esm.js +1 -0
- package/dist/index.cjs.js +1 -0
- package/dist/index.js +1 -0
- package/dist/stencil.config.dev.js +19 -0
- package/dist/stencil.config.js +19 -0
- package/dist/storybook/main.js +43 -0
- package/dist/storybook/preview.js +9 -0
- package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/general-registration-multistep/.stencil/libs/common/src/storybook/storybook-utils.d.ts +39 -0
- package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/general-registration-multistep/.stencil/packages/stencil/general-input/src/utils/types.d.ts +111 -0
- package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/general-registration-multistep/.stencil/packages/stencil/general-registration-multistep/stencil.config.d.ts +2 -0
- package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/general-registration-multistep/.stencil/packages/stencil/general-registration-multistep/stencil.config.dev.d.ts +2 -0
- package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/general-registration-multistep/.stencil/packages/stencil/general-registration-multistep/storybook/main.d.ts +3 -0
- package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/general-registration-multistep/.stencil/packages/stencil/general-registration-multistep/storybook/preview.d.ts +70 -0
- package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/general-registration-multistep/.stencil/tools/plugins/index.d.ts +4 -0
- package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/general-registration-multistep/.stencil/tools/plugins/lazy-load-chunk-plugin.d.ts +12 -0
- package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/general-registration-multistep/.stencil/tools/plugins/stencil-clean-deps-plugin.d.ts +5 -0
- package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/general-registration-multistep/.stencil/tools/plugins/vite-chunk-plugin.d.ts +6 -0
- package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/general-registration-multistep/.stencil/tools/plugins/vite-clean-deps-plugin.d.ts +4 -0
- package/dist/types/components/general-registration-multisteps/general-registration-multistep.d.ts +178 -0
- package/dist/types/components/general-registration-multisteps/index.d.ts +1 -0
- package/dist/types/components.d.ts +161 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/stencil-public-runtime.d.ts +1674 -0
- package/dist/types/utils/locale.utils.d.ts +33 -0
- package/dist/types/utils/utils.d.ts +1 -0
- package/loader/cdn.js +1 -0
- package/loader/index.cjs.js +1 -0
- package/loader/index.d.ts +24 -0
- package/loader/index.es2017.js +1 -0
- package/loader/index.js +2 -0
- package/loader/package.json +11 -0
- package/package.json +27 -0
package/dist/collection/components/general-registration-multisteps/general-registration-multistep.js
ADDED
|
@@ -0,0 +1,1470 @@
|
|
|
1
|
+
import { h } from "@stencil/core";
|
|
2
|
+
import { getTranslations, translate, TRANSLATIONS, DEFAULT_LANGUAGE, extractBirthDate, CONSTANTS } from "../../utils/locale.utils";
|
|
3
|
+
import { dispatchCustomEvent } from "../../../../../../../../libs/custom-events/src/index";
|
|
4
|
+
import { checkEmptyValue } from "../../../../../../../../libs/common/src/utils/index";
|
|
5
|
+
import "../../../../../general-input/dist/types/index";
|
|
6
|
+
import "../../../../../../svelte/player-consents/es2015/player-consents";
|
|
7
|
+
export class GeneralRegistrationMultistep {
|
|
8
|
+
constructor() {
|
|
9
|
+
this.isSelectingAddress = false;
|
|
10
|
+
this.lastPostalCode = null;
|
|
11
|
+
this.pinAttemptsExceeded = false;
|
|
12
|
+
this.documentIdNineDigits = false;
|
|
13
|
+
this.selectedCountry = '';
|
|
14
|
+
this.listOfInputValues = [];
|
|
15
|
+
this.listOfInputValidity = [];
|
|
16
|
+
this.listOfActions = [];
|
|
17
|
+
this.listOfInputs = [];
|
|
18
|
+
this.conditionalValidationMap = {};
|
|
19
|
+
this.lastStep = '';
|
|
20
|
+
this.emitValue = false;
|
|
21
|
+
this.form = null;
|
|
22
|
+
this.errorCode = '';
|
|
23
|
+
this.backButtonPressed = false;
|
|
24
|
+
this.registerErrors = false;
|
|
25
|
+
this.extraActions = [];
|
|
26
|
+
this.registerCredentialsEvent = null;
|
|
27
|
+
this.twofaDestination = '';
|
|
28
|
+
this.postalcodelength = 5;
|
|
29
|
+
this.registrationStepsState = {
|
|
30
|
+
regId: null
|
|
31
|
+
};
|
|
32
|
+
this.getIgnoreCountry = (input) => {
|
|
33
|
+
return input.name === 'PostalCode' && this.haspostalcodelookup && !this.listOfInputs.some(i => i.name === 'CountryCode');
|
|
34
|
+
};
|
|
35
|
+
this.getStepClass = (step) => {
|
|
36
|
+
if (this.currentStep === step)
|
|
37
|
+
return "bullet active";
|
|
38
|
+
if (this.currentStep > step)
|
|
39
|
+
return "bullet checked";
|
|
40
|
+
return "bullet";
|
|
41
|
+
};
|
|
42
|
+
this.setClientStyling = () => {
|
|
43
|
+
let sheet = document.createElement('style');
|
|
44
|
+
sheet.innerHTML = this.clientStyling;
|
|
45
|
+
this.host.shadowRoot.prepend(sheet);
|
|
46
|
+
};
|
|
47
|
+
this.setClientStylingURL = () => {
|
|
48
|
+
let url = new URL(this.clientStylingUrl);
|
|
49
|
+
let cssFile = document.createElement('style');
|
|
50
|
+
fetch(url.href)
|
|
51
|
+
.then((res) => res.text())
|
|
52
|
+
.then((data) => {
|
|
53
|
+
cssFile.innerHTML = data;
|
|
54
|
+
this.clientStyling = data;
|
|
55
|
+
setTimeout(() => { this.host.shadowRoot.prepend(cssFile); }, 1);
|
|
56
|
+
});
|
|
57
|
+
};
|
|
58
|
+
this.setStreamStyling = (domain) => {
|
|
59
|
+
if (window.emMessageBus) {
|
|
60
|
+
const sheet = document.createElement('style');
|
|
61
|
+
this.stylingSubscription = window.emMessageBus.subscribe(domain, (data) => {
|
|
62
|
+
sheet.innerHTML = data;
|
|
63
|
+
this.clientStyling = data;
|
|
64
|
+
this.host.shadowRoot.prepend(sheet);
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
// handles sending a custom event for initial interaction with the registration form
|
|
69
|
+
this.handleInitialClick = (e) => {
|
|
70
|
+
if (!this.isInitalInteraction)
|
|
71
|
+
return;
|
|
72
|
+
dispatchCustomEvent('register_start', { field: e.target.name });
|
|
73
|
+
this.isInitalInteraction = false;
|
|
74
|
+
};
|
|
75
|
+
this.endpoint = undefined;
|
|
76
|
+
this.language = 'en';
|
|
77
|
+
this.clientStyling = '';
|
|
78
|
+
this.mbSource = undefined;
|
|
79
|
+
this.clientStylingUrl = '';
|
|
80
|
+
this.translationUrl = '';
|
|
81
|
+
this.dateFormat = undefined;
|
|
82
|
+
this.buttonInsideForm = undefined;
|
|
83
|
+
this.btag = null;
|
|
84
|
+
this.emitOnClick = false;
|
|
85
|
+
this.haspostalcodelookup = false;
|
|
86
|
+
this.ignorebtag = false;
|
|
87
|
+
this.enableSouthAfricanMode = true;
|
|
88
|
+
this.errorMessage = '';
|
|
89
|
+
this.isFormValid = false;
|
|
90
|
+
this.isConsentValid = false;
|
|
91
|
+
this.isConsentReady = false;
|
|
92
|
+
this.isLoading = true;
|
|
93
|
+
this.isLoadingPOST = false;
|
|
94
|
+
this.registrationStep = '';
|
|
95
|
+
this.forms = {};
|
|
96
|
+
this.limitStylingAppends = false;
|
|
97
|
+
this.autofilled = false;
|
|
98
|
+
this.isInitalInteraction = true;
|
|
99
|
+
this.addresses = [];
|
|
100
|
+
this.addressUpdateKey = 0;
|
|
101
|
+
this.currentStep = 1;
|
|
102
|
+
}
|
|
103
|
+
sendStep() {
|
|
104
|
+
this.registrationStepUpdated.emit(this.registrationStep);
|
|
105
|
+
window.postMessage({ type: 'registrationStepUpdated', step: this.registrationStep }, window.location.href);
|
|
106
|
+
const stepNum = Number(this.registrationStep.replace('Step', ''));
|
|
107
|
+
this.currentStep = stepNum;
|
|
108
|
+
}
|
|
109
|
+
handleStylingChange(newValue, oldValue) {
|
|
110
|
+
if (newValue !== oldValue)
|
|
111
|
+
this.setClientStyling();
|
|
112
|
+
}
|
|
113
|
+
handleStylingUrlChange(newValue, oldValue) {
|
|
114
|
+
if (newValue !== oldValue)
|
|
115
|
+
this.setClientStylingURL();
|
|
116
|
+
}
|
|
117
|
+
setFormValidity() {
|
|
118
|
+
this.errorMessage = '';
|
|
119
|
+
if (this.listOfInputValidity) {
|
|
120
|
+
this.isFormValid = !this.getInvalidStatus(this.listOfInputValidity);
|
|
121
|
+
}
|
|
122
|
+
//Check for autofilled.
|
|
123
|
+
if (this.listOfInputs.some(inputs => inputs.autofill)) {
|
|
124
|
+
this.autofilled = true;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
addBtag() {
|
|
128
|
+
this.addBtagValue();
|
|
129
|
+
}
|
|
130
|
+
checkInputsValidityHandler(event) {
|
|
131
|
+
this.listOfInputValidity.find(input => input.name == event.detail.name).isValid = event.detail.valid;
|
|
132
|
+
// Check if any one is invalid.
|
|
133
|
+
this.isFormValid = !this.getInvalidStatus(this.listOfInputValidity);
|
|
134
|
+
}
|
|
135
|
+
getInputsValueHandler(event) {
|
|
136
|
+
var _a, _b, _c, _d;
|
|
137
|
+
this.listOfInputValues.find(input => {
|
|
138
|
+
if (input.name == event.detail.name) {
|
|
139
|
+
input.value = event.detail.value;
|
|
140
|
+
input.type = event.detail.type || null;
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
// ---- Document type and document id logic - New custom registration for SA ---- //
|
|
144
|
+
const { name, value } = event.detail;
|
|
145
|
+
// Check SA identity id if valid
|
|
146
|
+
if (name === CONSTANTS.DOCUMENT_TYPE) {
|
|
147
|
+
let type = event.detail.value;
|
|
148
|
+
if ((type || "").replace(CONSTANTS.REMOVE_WHITESPACE_REGEX, "").toLowerCase() === CONSTANTS.IDENTITY_CARD_NORMALIZED) {
|
|
149
|
+
type = CONSTANTS.SOUTH_AFRICAN_ID;
|
|
150
|
+
}
|
|
151
|
+
window.documentTypeValue = type;
|
|
152
|
+
const docField = this.listOfInputValues.find(i => i.name === CONSTANTS.DOCUMENT_NUMBER);
|
|
153
|
+
if (docField)
|
|
154
|
+
docField.value = "";
|
|
155
|
+
const docValidity = this.listOfInputValidity.find(v => v.name === CONSTANTS.DOCUMENT_NUMBER);
|
|
156
|
+
if (docValidity)
|
|
157
|
+
docValidity.isValid = false;
|
|
158
|
+
window.dispatchEvent(new CustomEvent("documentNumberUpdatedExternally", { detail: "" }));
|
|
159
|
+
window.dispatchEvent(new CustomEvent("documentNumberResetValidation"));
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
const docType = window.documentTypeValue;
|
|
163
|
+
// Check if Passport value length and dispatch events to modify the birth date value
|
|
164
|
+
if (name === CONSTANTS.DOCUMENT_NUMBER && docType === CONSTANTS.PASSPORT) {
|
|
165
|
+
if (value.length === 8 || value.length === 9) {
|
|
166
|
+
const extractedBirthDate = extractBirthDate(value);
|
|
167
|
+
window.dispatchEvent(new CustomEvent('documentIdUpdated', { detail: extractedBirthDate || '' }));
|
|
168
|
+
this.documentIdNineDigits = true;
|
|
169
|
+
}
|
|
170
|
+
else {
|
|
171
|
+
if (this.documentIdNineDigits) {
|
|
172
|
+
window.dispatchEvent(new CustomEvent('documentIdUpdated', { detail: '' }));
|
|
173
|
+
}
|
|
174
|
+
this.documentIdNineDigits = false;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
// If number starts with '0', remove it
|
|
178
|
+
if (name === CONSTANTS.MOBILE) {
|
|
179
|
+
const rawVal = (_b = (_a = event === null || event === void 0 ? void 0 : event.detail) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : {};
|
|
180
|
+
const phoneRaw = typeof rawVal.phone === "string" ? rawVal.phone : "";
|
|
181
|
+
let phone = phoneRaw;
|
|
182
|
+
if (phone.startsWith("0")) {
|
|
183
|
+
phone = phone.slice(1);
|
|
184
|
+
}
|
|
185
|
+
const mobileField = this.listOfInputValues.find(i => i.name === CONSTANTS.MOBILE);
|
|
186
|
+
if (mobileField) {
|
|
187
|
+
mobileField.value = {
|
|
188
|
+
prefix: (_c = rawVal.prefix) !== null && _c !== void 0 ? _c : "",
|
|
189
|
+
phone
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
// ---- Postal code lookup logic ---- //
|
|
194
|
+
if (this.haspostalcodelookup) {
|
|
195
|
+
const { name, value } = event.detail;
|
|
196
|
+
if (name === 'CountryCode') {
|
|
197
|
+
this.selectedCountry = value;
|
|
198
|
+
if (value === 'GB') {
|
|
199
|
+
this.selectedCountry = 'UK';
|
|
200
|
+
}
|
|
201
|
+
this.resetAllAddressFields();
|
|
202
|
+
window.dispatchEvent(new CustomEvent('countryCodeUpdated', { detail: { name, value: this.selectedCountry } }));
|
|
203
|
+
}
|
|
204
|
+
if (name === 'PostalCode') {
|
|
205
|
+
if (!this.listOfInputs.some(i => i.name === 'CountryCode')) {
|
|
206
|
+
this.selectedCountry = 'UK';
|
|
207
|
+
}
|
|
208
|
+
if (!this.isSelectingAddress && this.addresses.length > 0 && value !== this.lastPostalCode) {
|
|
209
|
+
this.addresses = [];
|
|
210
|
+
}
|
|
211
|
+
if (value.length >= this.postalcodelength) {
|
|
212
|
+
if (this.isSelectingAddress) {
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
const shouldFetch = !this.lastPostalCode ||
|
|
216
|
+
this.lastPostalCode !== value ||
|
|
217
|
+
this.addresses.length === 0;
|
|
218
|
+
if (shouldFetch) {
|
|
219
|
+
const country = this.selectedCountry ||
|
|
220
|
+
((_d = this.listOfInputValues.find(i => i.name === 'CountryCode')) === null || _d === void 0 ? void 0 : _d.value) || '';
|
|
221
|
+
if (this.selectedCountry === 'GB' || this.selectedCountry === 'UK') {
|
|
222
|
+
if (this.addrDebounce)
|
|
223
|
+
clearTimeout(this.addrDebounce);
|
|
224
|
+
this.addrDebounce = setTimeout(() => {
|
|
225
|
+
this.fetchAddresses(country, value);
|
|
226
|
+
}, 500);
|
|
227
|
+
}
|
|
228
|
+
this.lastPostalCode = value;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
else if (value.length < this.postalcodelength) {
|
|
232
|
+
this.addresses = [];
|
|
233
|
+
this.lastPostalCode = null;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
this.stepsStateMachine({ event: 'set', type: 'values' });
|
|
238
|
+
this.handleConditionalValidation(event.detail.name, event.detail.value);
|
|
239
|
+
}
|
|
240
|
+
handleAddressSelection(event) {
|
|
241
|
+
const { city, address1, address2 } = event.detail;
|
|
242
|
+
// Update input values
|
|
243
|
+
this.listOfInputValues = this.listOfInputValues.map(input => {
|
|
244
|
+
if (input.name === 'address1')
|
|
245
|
+
return Object.assign(Object.assign({}, input), { value: address1 || '' });
|
|
246
|
+
if (input.name === 'address2')
|
|
247
|
+
return Object.assign(Object.assign({}, input), { value: address2 || '' });
|
|
248
|
+
if (input.name === 'City')
|
|
249
|
+
return Object.assign(Object.assign({}, input), { value: city || '' });
|
|
250
|
+
return input;
|
|
251
|
+
});
|
|
252
|
+
if (this.forms[this.registrationStep]) {
|
|
253
|
+
this.forms[this.registrationStep] = this.forms[this.registrationStep].map(input => {
|
|
254
|
+
if (input.name === 'address1')
|
|
255
|
+
return Object.assign(Object.assign({}, input), { defaultValue: address1 });
|
|
256
|
+
if (input.name === 'address2')
|
|
257
|
+
return Object.assign(Object.assign({}, input), { defaultValue: address2 });
|
|
258
|
+
if (input.name === 'City')
|
|
259
|
+
return Object.assign(Object.assign({}, input), { defaultValue: city });
|
|
260
|
+
return input;
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
// force re-render
|
|
264
|
+
this.addressUpdateKey = Date.now();
|
|
265
|
+
this.forms = Object.assign({}, this.forms);
|
|
266
|
+
this.stepsStateMachine({ event: 'set', type: 'values' });
|
|
267
|
+
this.isFormValid = !this.getInvalidStatus(this.listOfInputValidity);
|
|
268
|
+
this.isSelectingAddress = false;
|
|
269
|
+
}
|
|
270
|
+
handleCountryCodeUpdateGlobal(event) {
|
|
271
|
+
const { name } = event.detail;
|
|
272
|
+
if (name === 'CountryCode') {
|
|
273
|
+
const savedState = localStorage.getItem('registrationStepsState');
|
|
274
|
+
if (savedState) {
|
|
275
|
+
const parsedState = JSON.parse(savedState);
|
|
276
|
+
Object.keys(parsedState).forEach(stepKey => {
|
|
277
|
+
if (parsedState[stepKey] && parsedState[stepKey].registerUserData) {
|
|
278
|
+
['address1', 'address2', 'City', 'PostalCode'].forEach(field => {
|
|
279
|
+
if (parsedState[stepKey].registerUserData[field]) {
|
|
280
|
+
parsedState[stepKey].registerUserData[field].value = '';
|
|
281
|
+
}
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
});
|
|
285
|
+
localStorage.setItem('registrationStepsState', JSON.stringify(parsedState));
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
handleRequestTwofa() {
|
|
290
|
+
if (!this.twofaDestination)
|
|
291
|
+
return;
|
|
292
|
+
const url = new URL(`${this.endpoint}/api/v1/gm/legislation/twoFaCode/`);
|
|
293
|
+
const headers = new Headers({
|
|
294
|
+
'Content-Type': 'application/problem+json; charset=utf-8'
|
|
295
|
+
});
|
|
296
|
+
const body = JSON.stringify({
|
|
297
|
+
channel: 'Sms',
|
|
298
|
+
destination: this.twofaDestination
|
|
299
|
+
});
|
|
300
|
+
const options = { method: 'POST', headers, body };
|
|
301
|
+
fetch(url.href, options)
|
|
302
|
+
.then(res => {
|
|
303
|
+
if (res.ok)
|
|
304
|
+
return;
|
|
305
|
+
res.json().then(err => {
|
|
306
|
+
var _a;
|
|
307
|
+
const errorCode = (_a = err.thirdPartyResponse) === null || _a === void 0 ? void 0 : _a.errorCode;
|
|
308
|
+
this.errorMessage = translate(errorCode, this.language) || translate('requestTwofaError', this.language);
|
|
309
|
+
});
|
|
310
|
+
})
|
|
311
|
+
.catch((err) => console.log(err));
|
|
312
|
+
}
|
|
313
|
+
messageHandler(e) {
|
|
314
|
+
//Handle Consents Message
|
|
315
|
+
if (!e.data)
|
|
316
|
+
return;
|
|
317
|
+
switch (e.data.type) {
|
|
318
|
+
case 'isConsentsValid':
|
|
319
|
+
this.listOfInputValidity.find((input) => input.name === "Consents").isValid = e.data.isValid;
|
|
320
|
+
this.isConsentValid = e.data.isValid;
|
|
321
|
+
this.isFormValid = !this.getInvalidStatus(this.listOfInputValidity);
|
|
322
|
+
break;
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
handleBirthDateUpdated(event) {
|
|
326
|
+
var _a;
|
|
327
|
+
const dob = event.detail.birthDate;
|
|
328
|
+
const docType = (_a = this.listOfInputValues.find(i => i.name === CONSTANTS.DOCUMENT_TYPE)) === null || _a === void 0 ? void 0 : _a.value;
|
|
329
|
+
if (docType !== CONSTANTS.PASSPORT)
|
|
330
|
+
return;
|
|
331
|
+
const docField = this.listOfInputValues.find(i => i.name === CONSTANTS.DOCUMENT_NUMBER);
|
|
332
|
+
if (!dob) {
|
|
333
|
+
docField.value = "";
|
|
334
|
+
window.dispatchEvent(new CustomEvent('documentNumberUpdatedExternally', { detail: "" }));
|
|
335
|
+
return;
|
|
336
|
+
}
|
|
337
|
+
const formatted = dob.replace(CONSTANTS.DATE_DASH_SEPARATOR_REGEX, "");
|
|
338
|
+
const prefix = formatted.slice(2);
|
|
339
|
+
if (docField.value && docField.value.length >= 6) {
|
|
340
|
+
docField.value = prefix + docField.value.slice(6);
|
|
341
|
+
}
|
|
342
|
+
else {
|
|
343
|
+
docField.value = prefix;
|
|
344
|
+
}
|
|
345
|
+
window.dispatchEvent(new CustomEvent('documentNumberUpdatedExternally', { detail: docField.value }));
|
|
346
|
+
}
|
|
347
|
+
componentWillLoad() {
|
|
348
|
+
return this.getRegisterConfig()
|
|
349
|
+
.then((config) => {
|
|
350
|
+
this.formatConfig(config);
|
|
351
|
+
this.isFormValid = !this.getInvalidStatus(this.listOfInputValidity);
|
|
352
|
+
this.stepsStateMachine({ event: 'set', type: 'inputs' });
|
|
353
|
+
this.setupConditionalValidationMap();
|
|
354
|
+
}, (err) => {
|
|
355
|
+
console.error(err);
|
|
356
|
+
});
|
|
357
|
+
}
|
|
358
|
+
componentDidLoad() {
|
|
359
|
+
this.registrationWidgetLoaded.emit();
|
|
360
|
+
window.postMessage({ type: 'registrationWidgetLoaded' }, window.location.href);
|
|
361
|
+
if (!this.limitStylingAppends && this.host) {
|
|
362
|
+
if (window.emMessageBus != undefined) {
|
|
363
|
+
this.setStreamStyling(`${this.mbSource}.Style`);
|
|
364
|
+
}
|
|
365
|
+
else {
|
|
366
|
+
if (this.clientStyling)
|
|
367
|
+
this.setClientStyling();
|
|
368
|
+
if (this.clientStylingUrl)
|
|
369
|
+
this.setClientStylingURL();
|
|
370
|
+
this.limitStylingAppends = true;
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
disconnectedCallback() {
|
|
375
|
+
this.stylingSubscription && this.stylingSubscription.unsubscribe();
|
|
376
|
+
}
|
|
377
|
+
/**
|
|
378
|
+
* This function produces the conditionalValidationMap object presented below
|
|
379
|
+
*
|
|
380
|
+
* this.conditionalValidationMap =
|
|
381
|
+
* {
|
|
382
|
+
* correlationField: {
|
|
383
|
+
* correlationValue: {
|
|
384
|
+
* field: {
|
|
385
|
+
* ...validation
|
|
386
|
+
* },
|
|
387
|
+
* ...
|
|
388
|
+
* },
|
|
389
|
+
* ...
|
|
390
|
+
* },
|
|
391
|
+
* ...
|
|
392
|
+
* }
|
|
393
|
+
*
|
|
394
|
+
* - this object describes the conditional validation of some fields based on the value of others.
|
|
395
|
+
* - correlationField is the conditioning field, correlationValue is the value of the correlationField for which
|
|
396
|
+
* a certain validation is applied to the affected fields. {...validation} is an object of type ValidationSchema
|
|
397
|
+
*/
|
|
398
|
+
setupConditionalValidationMap() {
|
|
399
|
+
for (const input of this.listOfInputs) {
|
|
400
|
+
// unconditioned rules (i.e correlationField and corrlationValue == null)
|
|
401
|
+
const staticRules = [];
|
|
402
|
+
// conditional rules
|
|
403
|
+
const conditionalRules = [];
|
|
404
|
+
for (const rule of input.validate.custom) {
|
|
405
|
+
if (!rule.correlationField || !rule.correlationValue) {
|
|
406
|
+
staticRules.push(rule);
|
|
407
|
+
continue;
|
|
408
|
+
}
|
|
409
|
+
conditionalRules.push(rule);
|
|
410
|
+
}
|
|
411
|
+
for (const rule of conditionalRules) {
|
|
412
|
+
if (rule.rule === 'regex') {
|
|
413
|
+
/**
|
|
414
|
+
* copy the original validation, replace the original "custom" rules (which contain all conditional rules)
|
|
415
|
+
* with only one conditional rule + all static rules, resulting in the validation for ${input} when
|
|
416
|
+
* ${rule.correlationField} takes value ${rule.correlationValue}
|
|
417
|
+
*/
|
|
418
|
+
const validate = Object.assign({}, input.validate);
|
|
419
|
+
validate.custom = [...staticRules, rule];
|
|
420
|
+
const cf = rule.correlationField;
|
|
421
|
+
const cv = rule.correlationValue;
|
|
422
|
+
// assign new validation to ${input}
|
|
423
|
+
this.conditionalValidationMap[cf] = this.conditionalValidationMap[cf] || {};
|
|
424
|
+
this.conditionalValidationMap[cf][cv] = this.conditionalValidationMap[cf][cv] || {};
|
|
425
|
+
this.conditionalValidationMap[cf][cv][input.name] = validate;
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
/**
|
|
431
|
+
* Whenever a field changes its value, we check if it is conditioning any other fields and
|
|
432
|
+
* if it is we update the validation of the affected fields.
|
|
433
|
+
*/
|
|
434
|
+
handleConditionalValidation(correlationField, correlationValue) {
|
|
435
|
+
if (!this.conditionalValidationMap[correlationField] ||
|
|
436
|
+
!this.conditionalValidationMap[correlationField][correlationValue]) {
|
|
437
|
+
return;
|
|
438
|
+
}
|
|
439
|
+
for (const [field, validation] of Object.entries(this.conditionalValidationMap[correlationField][correlationValue])) {
|
|
440
|
+
const registrationStepIdx = this.registrationStep && parseInt(this.registrationStep.replace('Step', '')) - 1;
|
|
441
|
+
if (this.forms[registrationStepIdx]) {
|
|
442
|
+
this.forms[registrationStepIdx][this.registrationStep].find(item => item.name === field).validate = validation;
|
|
443
|
+
this.validationChange.emit({ validation, field });
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
nextHandler(e) {
|
|
448
|
+
e.preventDefault();
|
|
449
|
+
this.emitValue = true;
|
|
450
|
+
this.errorMessage = '';
|
|
451
|
+
this.registerErrors = false;
|
|
452
|
+
this.setRegisterStep();
|
|
453
|
+
}
|
|
454
|
+
backHandler(e) {
|
|
455
|
+
e.preventDefault();
|
|
456
|
+
this.registrationStep = this.stepChange('decrement');
|
|
457
|
+
this.errorMessage = '';
|
|
458
|
+
this.stepsStateMachine({ event: 'get', type: 'inputs' });
|
|
459
|
+
this.stepsStateMachine({ event: 'get', type: 'values' });
|
|
460
|
+
}
|
|
461
|
+
dispatchRegisterCredentialsEvent() {
|
|
462
|
+
let userNameEmail = '';
|
|
463
|
+
let userPassword = '';
|
|
464
|
+
Object.keys(this.registrationStepsState).forEach((step) => {
|
|
465
|
+
if (!this.registrationStepsState[step]['registerUserData'])
|
|
466
|
+
return;
|
|
467
|
+
if (!userNameEmail) {
|
|
468
|
+
userNameEmail = this.registrationStepsState[step]['registerUserData']['Email']
|
|
469
|
+
? this.registrationStepsState[step]['registerUserData']['Email']['value']
|
|
470
|
+
: userNameEmail;
|
|
471
|
+
}
|
|
472
|
+
if (!userPassword) {
|
|
473
|
+
userPassword = this.registrationStepsState[step]['registerUserData']['Password']
|
|
474
|
+
? this.registrationStepsState[step]['registerUserData']['Password']['value']
|
|
475
|
+
: userPassword;
|
|
476
|
+
}
|
|
477
|
+
});
|
|
478
|
+
this.registerCredentialsEvent = new CustomEvent('RegisterCredentials', {
|
|
479
|
+
bubbles: true,
|
|
480
|
+
detail: {
|
|
481
|
+
userNameEmail: userNameEmail,
|
|
482
|
+
userPassword: userPassword
|
|
483
|
+
}
|
|
484
|
+
});
|
|
485
|
+
window.dispatchEvent(this.registerCredentialsEvent);
|
|
486
|
+
}
|
|
487
|
+
stepsStateMachine(state) {
|
|
488
|
+
var _a;
|
|
489
|
+
const saveToLocalStorage = () => {
|
|
490
|
+
localStorage.setItem('registrationStepsState', JSON.stringify(this.registrationStepsState));
|
|
491
|
+
};
|
|
492
|
+
const loadFromLocalStorage = () => {
|
|
493
|
+
return JSON.parse(localStorage.getItem('registrationStepsState'));
|
|
494
|
+
};
|
|
495
|
+
switch (state.event) {
|
|
496
|
+
case 'set':
|
|
497
|
+
if (state.type == 'inputs') {
|
|
498
|
+
// Store input-related data into the current step state
|
|
499
|
+
const currentStep = this.registrationStepsState[this.registrationStep];
|
|
500
|
+
currentStep.fields = this.listOfInputs;
|
|
501
|
+
currentStep.actions = this.listOfActions;
|
|
502
|
+
currentStep.fieldsValidity = this.listOfInputValidity;
|
|
503
|
+
}
|
|
504
|
+
if (state.type == 'values') {
|
|
505
|
+
// Map input values into the current step state
|
|
506
|
+
const currentStep = this.registrationStepsState[this.registrationStep];
|
|
507
|
+
currentStep.registerUserData = this.listOfInputValues.reduce((acc, curr) => {
|
|
508
|
+
acc[curr.name] = { value: curr.value, isDuplicate: curr.isDuplicate };
|
|
509
|
+
return acc;
|
|
510
|
+
}, {});
|
|
511
|
+
}
|
|
512
|
+
saveToLocalStorage();
|
|
513
|
+
break;
|
|
514
|
+
case 'get':
|
|
515
|
+
const savedUserData = loadFromLocalStorage();
|
|
516
|
+
if (!savedUserData)
|
|
517
|
+
return;
|
|
518
|
+
if (state.type == 'inputs') {
|
|
519
|
+
// Load input-related data from the saved state
|
|
520
|
+
const currentStep = this.registrationStepsState[this.registrationStep];
|
|
521
|
+
this.listOfInputs = currentStep.fields;
|
|
522
|
+
this.listOfActions = currentStep.actions;
|
|
523
|
+
this.listOfInputValidity = currentStep.fieldsValidity;
|
|
524
|
+
}
|
|
525
|
+
if (state.type == 'values') {
|
|
526
|
+
const savedValues = savedUserData[this.registrationStep].registerUserData;
|
|
527
|
+
// Convert saved values to the expected format for inputs
|
|
528
|
+
this.listOfInputValues = Object.keys(savedValues).map(name => {
|
|
529
|
+
return { name, value: savedValues[name].value, isDuplicate: savedValues[name].isDuplicate };
|
|
530
|
+
});
|
|
531
|
+
// Set the right documentTypeValue when the step is loaded
|
|
532
|
+
let docType = (_a = this.listOfInputValues.find(i => i.name === CONSTANTS.DOCUMENT_TYPE)) === null || _a === void 0 ? void 0 : _a.value;
|
|
533
|
+
if (docType === CONSTANTS.IDENTITY_CARD)
|
|
534
|
+
docType = CONSTANTS.SOUTH_AFRICAN_ID;
|
|
535
|
+
window.documentTypeValue = docType;
|
|
536
|
+
// Give to each field the user input as the default value.
|
|
537
|
+
this.listOfInputValues.forEach(inputValue => {
|
|
538
|
+
const input = this.listOfInputs.find(input => input.name === inputValue.name);
|
|
539
|
+
if (input) {
|
|
540
|
+
input.defaultValue = inputValue.value;
|
|
541
|
+
// if the input is a togglecheckbox, set the default value for each subfield.
|
|
542
|
+
if (input.inputType === 'togglecheckbox') {
|
|
543
|
+
input.data.subFields.forEach((subfield) => {
|
|
544
|
+
const subfieldValue = this.listOfInputValues.find(subfieldValue => subfieldValue.name === subfield.name);
|
|
545
|
+
subfield.defaultValue = subfieldValue.value;
|
|
546
|
+
});
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
});
|
|
550
|
+
}
|
|
551
|
+
this.isConsentReady = this.listOfActions.some(action => action === '/Consents');
|
|
552
|
+
this.isFormValid = !this.getInvalidStatus(this.listOfInputValidity);
|
|
553
|
+
break;
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
triggerNotification(errMsg, errType = 'WidgetNotification') {
|
|
557
|
+
window.postMessage({
|
|
558
|
+
type: errType,
|
|
559
|
+
data: {
|
|
560
|
+
type: 'error',
|
|
561
|
+
message: errMsg
|
|
562
|
+
}
|
|
563
|
+
}, window.location.href);
|
|
564
|
+
}
|
|
565
|
+
getRegisterConfig(registrationID) {
|
|
566
|
+
const url = new URL(`${this.endpoint}/v1/player/legislation/registration/config/`);
|
|
567
|
+
const headers = new Headers();
|
|
568
|
+
headers.append('Content-Type', 'application/json');
|
|
569
|
+
headers.append('Accept', 'application/json');
|
|
570
|
+
if (registrationID) {
|
|
571
|
+
url.searchParams.append('registrationId', registrationID);
|
|
572
|
+
}
|
|
573
|
+
const options = {
|
|
574
|
+
method: 'GET',
|
|
575
|
+
headers
|
|
576
|
+
};
|
|
577
|
+
return new Promise((resolve, reject) => {
|
|
578
|
+
this.isLoading = true;
|
|
579
|
+
fetch(url.href, options)
|
|
580
|
+
.then((res) => {
|
|
581
|
+
if (!res.ok) {
|
|
582
|
+
this.registerErrors = true;
|
|
583
|
+
return res.json().then(error => {
|
|
584
|
+
this.errorCode = error.thirdPartyResponse.errorCode;
|
|
585
|
+
this.errorMessage = translate(`${this.errorCode}`, this.language) || translate(`generalError`, this.language);
|
|
586
|
+
this.triggerNotification(this.errorMessage);
|
|
587
|
+
});
|
|
588
|
+
}
|
|
589
|
+
return res.json();
|
|
590
|
+
})
|
|
591
|
+
.then((config) => {
|
|
592
|
+
this.isLoading = false;
|
|
593
|
+
if (!config) {
|
|
594
|
+
return reject('Get register config is empty or has an error.');
|
|
595
|
+
}
|
|
596
|
+
return resolve(config);
|
|
597
|
+
}, (err) => {
|
|
598
|
+
console.error('Get register config is empty or has an error: ', err);
|
|
599
|
+
return reject(err);
|
|
600
|
+
}).finally(() => {
|
|
601
|
+
this.isLoading = false;
|
|
602
|
+
});
|
|
603
|
+
});
|
|
604
|
+
}
|
|
605
|
+
setRegisterStep() {
|
|
606
|
+
this.isLoadingPOST = true;
|
|
607
|
+
const url = new URL(`${this.endpoint}/v1/player/legislation/registration/step/`);
|
|
608
|
+
const registerStep = {
|
|
609
|
+
registrationId: this.registrationID,
|
|
610
|
+
registerUserDto: this.listOfInputValues
|
|
611
|
+
.filter(input => !input.isDuplicate)
|
|
612
|
+
.reduce((acc, curr) => {
|
|
613
|
+
// Because the API is very robust, some values need to be split as separate entities.
|
|
614
|
+
if (curr.name === 'TypeOfPublicArea') {
|
|
615
|
+
acc[curr.name] = curr.value.toLowerCase();
|
|
616
|
+
}
|
|
617
|
+
else if (curr.type === 'tel') {
|
|
618
|
+
//@ts-ignore
|
|
619
|
+
acc['MobilePrefix'] = curr.value.prefix;
|
|
620
|
+
//@ts-ignore
|
|
621
|
+
acc[curr.name] = curr.value.phone;
|
|
622
|
+
}
|
|
623
|
+
else if (curr.type === 'checkboxgroup') {
|
|
624
|
+
// Skip adding the parent of the checkboxgroup as a key.
|
|
625
|
+
if (curr.value !== null) {
|
|
626
|
+
Object.entries(curr.value).forEach(([key, value]) => {
|
|
627
|
+
acc[key] = value ? 'true' : 'false';
|
|
628
|
+
});
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
else if (curr.type === 'toggle') {
|
|
632
|
+
acc[curr.name] = curr.value ? 'true' : 'false';
|
|
633
|
+
}
|
|
634
|
+
else {
|
|
635
|
+
acc[curr.name] = curr.value;
|
|
636
|
+
}
|
|
637
|
+
return acc;
|
|
638
|
+
}, {}),
|
|
639
|
+
step: this.registrationStep,
|
|
640
|
+
};
|
|
641
|
+
const headers = new Headers();
|
|
642
|
+
headers.append('Content-Type', 'application/json');
|
|
643
|
+
headers.append('Accept', 'application/json');
|
|
644
|
+
const options = {
|
|
645
|
+
method: 'POST',
|
|
646
|
+
body: JSON.stringify(registerStep),
|
|
647
|
+
headers
|
|
648
|
+
};
|
|
649
|
+
if (this.lastStep === this.registrationStep) {
|
|
650
|
+
dispatchCustomEvent('register_submit', { registrationId: this.registrationID });
|
|
651
|
+
}
|
|
652
|
+
fetch(url.href, options)
|
|
653
|
+
.then((res) => {
|
|
654
|
+
if (!res.ok) {
|
|
655
|
+
return res.json().then(error => {
|
|
656
|
+
this.errorCode = error.thirdPartyResponse.errorCode;
|
|
657
|
+
// Show the idomsoft error if it is the case
|
|
658
|
+
if (this.errorCode == 'GmErr_BadRequest_IdomsoftVerification_ShouldRetry') {
|
|
659
|
+
this.errorMessage = error.thirdPartyResponse.message;
|
|
660
|
+
}
|
|
661
|
+
else if (this.errorCode === 'GmErr_Forbidden_UserAccount_NavExcluded') {
|
|
662
|
+
this.errorMessage = translate(`${this.errorCode}`, this.language);
|
|
663
|
+
}
|
|
664
|
+
else if (this.errorCode == 'GmErr_BadRequest') {
|
|
665
|
+
this.errorMessage = error.thirdPartyResponse.message;
|
|
666
|
+
if (error.thirdPartyResponse.message == CONSTANTS.THIRDPARTY_SMS_ERROR) {
|
|
667
|
+
this.errorMessage = translate('GmErr_BadRequest_INVALID_CODE', this.language);
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
else if (this.errorCode == 'GmErr_ATTEMPTS_EXCEEDED') {
|
|
671
|
+
this.pinAttemptsExceeded = true;
|
|
672
|
+
this.errorMessage = translate(this.errorCode, this.language);
|
|
673
|
+
}
|
|
674
|
+
else {
|
|
675
|
+
this.errorMessage = translate(`${this.errorCode}`, this.language) || translate(`generalError`, this.language);
|
|
676
|
+
}
|
|
677
|
+
this.triggerNotification(this.errorMessage);
|
|
678
|
+
return Promise.reject(this.errorMessage);
|
|
679
|
+
});
|
|
680
|
+
}
|
|
681
|
+
// handles sending custom events and the requested data for each registration step
|
|
682
|
+
if (this.registrationStep === 'Step1') {
|
|
683
|
+
const eventData = {
|
|
684
|
+
// @ts-ignore
|
|
685
|
+
IBAN: registerStep.registerUserDto.IBAN,
|
|
686
|
+
// @ts-ignore
|
|
687
|
+
username: registerStep.registerUserDto.Username,
|
|
688
|
+
};
|
|
689
|
+
dispatchCustomEvent('register_step1', { eventLabel: this.registrationStep, eventAction: 'nextStep', eventCategory: 'Registration', eventData: eventData });
|
|
690
|
+
}
|
|
691
|
+
else if (this.registrationStep === 'Step2') {
|
|
692
|
+
const eventData = {
|
|
693
|
+
// @ts-ignore
|
|
694
|
+
gender: registerStep.registerUserDto.Gender,
|
|
695
|
+
// @ts-ignore
|
|
696
|
+
fullName: `${registerStep.registerUserDto.FirstnameOnDocument} ${registerStep.registerUserDto.LastNameOnDocument}`,
|
|
697
|
+
// @ts-ignore
|
|
698
|
+
city: registerStep.registerUserDto.City
|
|
699
|
+
};
|
|
700
|
+
dispatchCustomEvent('register_step2', { eventLabel: this.registrationStep, eventAction: 'nextStep', eventCategory: 'Registration', eventData: eventData });
|
|
701
|
+
}
|
|
702
|
+
else if (this.registrationStep === 'Step3') {
|
|
703
|
+
const eventData = {
|
|
704
|
+
// @ts-ignore
|
|
705
|
+
OIB: registerStep.registerUserDto.PersonalID,
|
|
706
|
+
// @ts-ignore
|
|
707
|
+
documentType: registerStep.registerUserDto.DocumentType,
|
|
708
|
+
};
|
|
709
|
+
dispatchCustomEvent('register_step3', { eventLabel: this.registrationStep, eventAction: 'nextStep', eventCategory: 'Registration', eventData: eventData });
|
|
710
|
+
}
|
|
711
|
+
return res.json();
|
|
712
|
+
})
|
|
713
|
+
.then((data) => {
|
|
714
|
+
this.isLoadingPOST = false;
|
|
715
|
+
this.registrationID = data.registrationId;
|
|
716
|
+
if (this.listOfActions.find(action => action === '/request-2FA')) {
|
|
717
|
+
this.twofaDestination = Object.values(this.listOfInputValues.find(item => item.type === 'tel').value).join('');
|
|
718
|
+
this.handleRequestTwofa();
|
|
719
|
+
}
|
|
720
|
+
if (this.listOfActions.some(action => action == '/register')) {
|
|
721
|
+
if (this.listOfActions.some(action => action == '/generate-2FA-code/Generate2FACode')) {
|
|
722
|
+
this.extraActions.push('2fa');
|
|
723
|
+
}
|
|
724
|
+
if (localStorage.getItem('playerConsents')) {
|
|
725
|
+
localStorage.removeItem("playerConsents");
|
|
726
|
+
}
|
|
727
|
+
this.setRegister();
|
|
728
|
+
}
|
|
729
|
+
else {
|
|
730
|
+
if (this.isConsentValid) {
|
|
731
|
+
window.postMessage({ type: 'setUpPlayerConsents', registerid: this.registrationID });
|
|
732
|
+
}
|
|
733
|
+
// After sending the current step, increment and check if the next one is in state.
|
|
734
|
+
this.registrationStep = this.stepChange('increment');
|
|
735
|
+
// If step is present in state do NOT fetch the next config.
|
|
736
|
+
if (Object.keys(this.registrationStepsState).find(key => key == this.registrationStep)) {
|
|
737
|
+
// Use the one from state
|
|
738
|
+
this.stepsStateMachine({ event: 'get', type: 'inputs' });
|
|
739
|
+
this.stepsStateMachine({ event: 'get', type: 'values' });
|
|
740
|
+
}
|
|
741
|
+
else {
|
|
742
|
+
this.getRegisterConfig(this.registrationID).then((config) => {
|
|
743
|
+
// Format the new step config.
|
|
744
|
+
this.formatConfig(config);
|
|
745
|
+
// Set it in local storage.
|
|
746
|
+
this.stepsStateMachine({ event: 'set', type: 'inputs' });
|
|
747
|
+
// Setup conditionalValidationMap
|
|
748
|
+
this.setupConditionalValidationMap();
|
|
749
|
+
}, (err) => {
|
|
750
|
+
// Only send the error to user because this.getRegisterConfig already has proper error logging
|
|
751
|
+
this.triggerNotification(err);
|
|
752
|
+
});
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
})
|
|
756
|
+
.catch((err) => {
|
|
757
|
+
this.isLoadingPOST = false;
|
|
758
|
+
console.error(err);
|
|
759
|
+
}).finally(() => {
|
|
760
|
+
this.isLoadingPOST = false;
|
|
761
|
+
});
|
|
762
|
+
}
|
|
763
|
+
setRegister() {
|
|
764
|
+
this.isLoading = true;
|
|
765
|
+
this.registerErrors = false;
|
|
766
|
+
const url = new URL(`${this.endpoint}/v1/player/legislation/register/`);
|
|
767
|
+
const headers = new Headers();
|
|
768
|
+
headers.append('Content-Type', 'application/json');
|
|
769
|
+
headers.append('Accept', 'application/json');
|
|
770
|
+
const options = {
|
|
771
|
+
method: 'PUT',
|
|
772
|
+
body: JSON.stringify({ registrationId: this.registrationID }),
|
|
773
|
+
headers
|
|
774
|
+
};
|
|
775
|
+
fetch(url.href, options)
|
|
776
|
+
.then((res) => {
|
|
777
|
+
if (!res.ok) {
|
|
778
|
+
this.registerErrors = true;
|
|
779
|
+
return res.json().then(error => {
|
|
780
|
+
this.errorCode = error.thirdPartyResponse.errorCode;
|
|
781
|
+
// Show the idomsoft error if it is the case
|
|
782
|
+
if (this.errorCode == 'GmErr_BadRequest_IdomsoftVerification_ShouldRetry') {
|
|
783
|
+
this.errorMessage = error.thirdPartyResponse.message;
|
|
784
|
+
}
|
|
785
|
+
else if (this.errorCode == 'GmErr_BadRequest') {
|
|
786
|
+
this.errorMessage = error.thirdPartyResponse.message;
|
|
787
|
+
}
|
|
788
|
+
else {
|
|
789
|
+
this.errorMessage = translate(`${this.errorCode}`, this.language) || translate(`generalError`, this.language);
|
|
790
|
+
}
|
|
791
|
+
window.postMessage({ type: 'registrationFailed', errorMessage: error === null || error === void 0 ? void 0 : error.thirdPartyResponse.message }, window.location.href);
|
|
792
|
+
this.triggerNotification(this.errorMessage);
|
|
793
|
+
dispatchCustomEvent('register_fail', { error: this.errorMessage });
|
|
794
|
+
});
|
|
795
|
+
}
|
|
796
|
+
return res.json();
|
|
797
|
+
})
|
|
798
|
+
.then((data) => {
|
|
799
|
+
this.isLoading = false;
|
|
800
|
+
if (!this.registerErrors) {
|
|
801
|
+
this.dispatchRegisterCredentialsEvent();
|
|
802
|
+
window.postMessage({ type: 'registrationSuccessful', userId: data === null || data === void 0 ? void 0 : data.userId, extraActions: this.extraActions }, window.location.href);
|
|
803
|
+
window.postMessage({
|
|
804
|
+
type: 'WidgetNotification', data: {
|
|
805
|
+
type: 'success',
|
|
806
|
+
message: translate('successMessage', this.language)
|
|
807
|
+
}
|
|
808
|
+
}, window.location.href);
|
|
809
|
+
dispatchCustomEvent('register_closed', { userId: data.userId });
|
|
810
|
+
}
|
|
811
|
+
})
|
|
812
|
+
.catch((err) => {
|
|
813
|
+
this.isLoading = false;
|
|
814
|
+
console.error(err);
|
|
815
|
+
})
|
|
816
|
+
.finally(() => {
|
|
817
|
+
this.isLoading = false;
|
|
818
|
+
});
|
|
819
|
+
}
|
|
820
|
+
formatConfig(config) {
|
|
821
|
+
this.listOfInputs = config.content.fields.flatMap((field) => {
|
|
822
|
+
const duplicateInputRule = field.validate.custom.find(customRule => customRule.rule === 'duplicate-input');
|
|
823
|
+
const inputElement = Object.assign({}, field);
|
|
824
|
+
if (duplicateInputRule) {
|
|
825
|
+
const duplicateInput = Object.assign(Object.assign({}, field), { name: `${field.name}Duplicate`, displayName: duplicateInputRule.displayName, isDuplicateInput: true });
|
|
826
|
+
return [inputElement, duplicateInput];
|
|
827
|
+
}
|
|
828
|
+
else {
|
|
829
|
+
return [inputElement];
|
|
830
|
+
}
|
|
831
|
+
});
|
|
832
|
+
this.listOfInputValidity = this.listOfInputs.reduce((acc, field) => {
|
|
833
|
+
var _a;
|
|
834
|
+
// If the field is a togglecheckbox, add its subfields
|
|
835
|
+
if (((_a = field.inputType) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === "togglecheckbox") {
|
|
836
|
+
field.data.subFields.forEach(subfield => {
|
|
837
|
+
acc.push({
|
|
838
|
+
name: subfield.name,
|
|
839
|
+
isValid: this.setInitialValidStatus(subfield)
|
|
840
|
+
});
|
|
841
|
+
});
|
|
842
|
+
}
|
|
843
|
+
else {
|
|
844
|
+
acc.push({
|
|
845
|
+
name: field.name,
|
|
846
|
+
isValid: this.setInitialValidStatus(field)
|
|
847
|
+
});
|
|
848
|
+
}
|
|
849
|
+
return acc;
|
|
850
|
+
}, []);
|
|
851
|
+
this.listOfInputValues = this.listOfInputs.reduce((acc, field) => {
|
|
852
|
+
var _a;
|
|
853
|
+
const inputType = (_a = field.inputType) === null || _a === void 0 ? void 0 : _a.toLowerCase();
|
|
854
|
+
// If the field type is a 'togglecheckbox', add its subfields
|
|
855
|
+
if (inputType === 'togglecheckbox') {
|
|
856
|
+
field.data.subFields.forEach(subfield => {
|
|
857
|
+
var _a;
|
|
858
|
+
acc.push({
|
|
859
|
+
name: subfield.name,
|
|
860
|
+
value: ((_a = subfield.inputType) === null || _a === void 0 ? void 0 : _a.toLowerCase()) == 'checkbox' ? 'false' : null,
|
|
861
|
+
isDuplicate: subfield.isDuplicateInput || false,
|
|
862
|
+
type: inputType === 'togglecheckbox' ? 'togglecheckbox' : null
|
|
863
|
+
});
|
|
864
|
+
});
|
|
865
|
+
}
|
|
866
|
+
acc.push({
|
|
867
|
+
name: field.name,
|
|
868
|
+
value: inputType === 'checkbox' || inputType === 'togglecheckbox' ? 'false' : null,
|
|
869
|
+
isDuplicate: field.isDuplicateInput || false,
|
|
870
|
+
type: inputType === 'checkboxgroup' ? 'checkboxgroup' : (inputType === 'togglecheckbox' ? 'toggle' : null)
|
|
871
|
+
});
|
|
872
|
+
return acc;
|
|
873
|
+
}, []);
|
|
874
|
+
if (this.btag)
|
|
875
|
+
this.addBtagValue();
|
|
876
|
+
// Set the list of actions
|
|
877
|
+
this.listOfActions = config.content.actions.map(action => action);
|
|
878
|
+
this.registrationID = config.content.registrationID;
|
|
879
|
+
this.registrationStep = config.content.step;
|
|
880
|
+
if (this.listOfActions.some(action => action == '/register')) {
|
|
881
|
+
this.lastStep = this.registrationStep;
|
|
882
|
+
}
|
|
883
|
+
;
|
|
884
|
+
if (this.listOfActions.some(action => action == '/Consents')) {
|
|
885
|
+
if (this.isConsentReady) {
|
|
886
|
+
this.listOfInputValidity.find((input) => input.name === "Consents").isValid = false;
|
|
887
|
+
this.isFormValid = !this.getInvalidStatus(this.listOfInputValidity);
|
|
888
|
+
return;
|
|
889
|
+
}
|
|
890
|
+
this.listOfInputValidity.push({ name: 'Consents', isValid: false });
|
|
891
|
+
this.isConsentReady = true;
|
|
892
|
+
}
|
|
893
|
+
else {
|
|
894
|
+
this.isConsentReady = false;
|
|
895
|
+
}
|
|
896
|
+
this.forms = Object.assign(Object.assign({}, this.forms), { [this.registrationStep]: this.listOfInputs.map(input => (Object.assign({}, input))) });
|
|
897
|
+
// The translations for fields happens here.
|
|
898
|
+
if (this.translationUrl) {
|
|
899
|
+
getTranslations(this.translationUrl).then(() => {
|
|
900
|
+
this.listOfInputs.forEach(field => {
|
|
901
|
+
var _a, _b;
|
|
902
|
+
this.addTranslation(field);
|
|
903
|
+
// Logic for field types that have subfields
|
|
904
|
+
if (((_a = field.inputType) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === 'togglecheckbox') {
|
|
905
|
+
field.data.subFields.forEach(subField => this.addTranslation(subField));
|
|
906
|
+
}
|
|
907
|
+
if (((_b = field.inputType) === null || _b === void 0 ? void 0 : _b.toLowerCase()) === 'checkboxgroup') {
|
|
908
|
+
this.addTranslation(field);
|
|
909
|
+
field.data.subFields.forEach(subField => this.addTranslation(subField));
|
|
910
|
+
}
|
|
911
|
+
return field;
|
|
912
|
+
});
|
|
913
|
+
})
|
|
914
|
+
.catch((error) => {
|
|
915
|
+
console.error('Failed to fetch translations:', error);
|
|
916
|
+
});
|
|
917
|
+
}
|
|
918
|
+
// Add the step to the registrationStepsData
|
|
919
|
+
this.registrationStepsState.regId = this.registrationID;
|
|
920
|
+
if (!this.registrationStepsState[this.registrationStep]) {
|
|
921
|
+
this.registrationStepsState[this.registrationStep] = {
|
|
922
|
+
fields: [],
|
|
923
|
+
fieldsValidity: [],
|
|
924
|
+
registerUserData: {},
|
|
925
|
+
actions: []
|
|
926
|
+
};
|
|
927
|
+
}
|
|
928
|
+
}
|
|
929
|
+
addBtagValue() {
|
|
930
|
+
const btagField = this.listOfInputs.find(input => input.name.toLowerCase() === 'btag');
|
|
931
|
+
if (btagField) {
|
|
932
|
+
btagField.defaultValue = this.btag;
|
|
933
|
+
}
|
|
934
|
+
const btagValue = this.listOfInputValues.find(input => input.name.toLowerCase() === 'btag');
|
|
935
|
+
if (btagValue) {
|
|
936
|
+
btagValue.value = this.btag;
|
|
937
|
+
}
|
|
938
|
+
}
|
|
939
|
+
addTranslation(field) {
|
|
940
|
+
const lang = TRANSLATIONS[this.language] ? this.language : DEFAULT_LANGUAGE;
|
|
941
|
+
if (TRANSLATIONS[lang][field.name]) {
|
|
942
|
+
Object.keys(TRANSLATIONS[this.language][field.name]).forEach((key) => {
|
|
943
|
+
field[key] = TRANSLATIONS[this.language][field.name][key];
|
|
944
|
+
});
|
|
945
|
+
}
|
|
946
|
+
}
|
|
947
|
+
setInitialValidStatus(field) {
|
|
948
|
+
var _a, _b, _c, _d, _e, _f;
|
|
949
|
+
if (((_a = field.inputType) === null || _a === void 0 ? void 0 : _a.toLowerCase()) == 'checkbox' && ((_b = field.validate) === null || _b === void 0 ? void 0 : _b.mandatory) == false) {
|
|
950
|
+
return true;
|
|
951
|
+
}
|
|
952
|
+
if (((_c = field.inputType) === null || _c === void 0 ? void 0 : _c.toLowerCase()) === 'checkbox' && ((_d = field.validate) === null || _d === void 0 ? void 0 : _d.mandatory) && field.defaultValue !== 'true') {
|
|
953
|
+
return false;
|
|
954
|
+
}
|
|
955
|
+
if (field.defaultValue !== null) {
|
|
956
|
+
return true;
|
|
957
|
+
}
|
|
958
|
+
if (((_e = field.validate) === null || _e === void 0 ? void 0 : _e.mandatory) === false) {
|
|
959
|
+
return true;
|
|
960
|
+
}
|
|
961
|
+
if (((_f = field.validate) === null || _f === void 0 ? void 0 : _f.mandatory) === true) {
|
|
962
|
+
return false;
|
|
963
|
+
}
|
|
964
|
+
return false;
|
|
965
|
+
}
|
|
966
|
+
stepChange(action) {
|
|
967
|
+
const stepNum = parseInt(this.registrationStep.replace('Step', ''));
|
|
968
|
+
if (action === 'increment') {
|
|
969
|
+
return 'Step' + (stepNum + 1);
|
|
970
|
+
}
|
|
971
|
+
if (action === 'decrement') {
|
|
972
|
+
return 'Step' + (stepNum - 1);
|
|
973
|
+
}
|
|
974
|
+
}
|
|
975
|
+
getInvalidStatus(listOfInputs) {
|
|
976
|
+
const invalidInputs = listOfInputs.filter(input => {
|
|
977
|
+
var _a;
|
|
978
|
+
const inputConfig = this.listOfInputs.find(i => i.name === input.name);
|
|
979
|
+
const inputValue = (_a = this.listOfInputValues.find(v => v.name === input.name)) === null || _a === void 0 ? void 0 : _a.value;
|
|
980
|
+
if (inputConfig && !inputConfig.validate.mandatory) {
|
|
981
|
+
// Use the helper function to check if value is empty
|
|
982
|
+
if (checkEmptyValue(inputValue)) {
|
|
983
|
+
return false;
|
|
984
|
+
}
|
|
985
|
+
}
|
|
986
|
+
return input.isValid === false;
|
|
987
|
+
});
|
|
988
|
+
return invalidInputs.length > 0;
|
|
989
|
+
}
|
|
990
|
+
renderErrorMessage(errorMsg) {
|
|
991
|
+
return (h("p", { class: "registration registration__error-message" }, errorMsg));
|
|
992
|
+
}
|
|
993
|
+
resetAllAddressFields() {
|
|
994
|
+
this.listOfInputValues = this.listOfInputValues.map(input => {
|
|
995
|
+
if (['address1', 'address2', 'City', 'PostalCode'].includes(input.name)) {
|
|
996
|
+
return Object.assign(Object.assign({}, input), { value: '' });
|
|
997
|
+
}
|
|
998
|
+
return input;
|
|
999
|
+
});
|
|
1000
|
+
// Update forms with new structure
|
|
1001
|
+
Object.keys(this.forms).forEach(stepKey => {
|
|
1002
|
+
this.forms[stepKey] = this.forms[stepKey].map(input => {
|
|
1003
|
+
if (['address1', 'address2', 'City', 'PostalCode'].includes(input.name)) {
|
|
1004
|
+
return Object.assign(Object.assign({}, input), { defaultValue: '' });
|
|
1005
|
+
}
|
|
1006
|
+
return input;
|
|
1007
|
+
});
|
|
1008
|
+
});
|
|
1009
|
+
// Reset validity
|
|
1010
|
+
this.listOfInputValidity = this.listOfInputValidity.map(input => {
|
|
1011
|
+
if (['address1', 'address2', 'City', 'PostalCode'].includes(input.name)) {
|
|
1012
|
+
return Object.assign(Object.assign({}, input), { isValid: false });
|
|
1013
|
+
}
|
|
1014
|
+
return input;
|
|
1015
|
+
});
|
|
1016
|
+
this.addresses = [];
|
|
1017
|
+
this.forms = Object.assign({}, this.forms);
|
|
1018
|
+
}
|
|
1019
|
+
fetchAddresses(countryCode, postalCode) {
|
|
1020
|
+
var _a;
|
|
1021
|
+
const currentPostalCode = (_a = this.listOfInputValues.find(i => i.name === 'PostalCode')) === null || _a === void 0 ? void 0 : _a.value;
|
|
1022
|
+
if (!currentPostalCode || currentPostalCode.length < this.postalcodelength) {
|
|
1023
|
+
return;
|
|
1024
|
+
}
|
|
1025
|
+
window.dispatchEvent(new CustomEvent('addressFetchStarted', {
|
|
1026
|
+
detail: { postalCode }
|
|
1027
|
+
}));
|
|
1028
|
+
const url = new URL(`${this.endpoint}/api/pam/v1/lookup/addresses?country=${countryCode}&postalCode=${postalCode}`);
|
|
1029
|
+
const headers = new Headers();
|
|
1030
|
+
headers.append('Content-Type', 'application/json');
|
|
1031
|
+
headers.append('Accept', 'application/json');
|
|
1032
|
+
const options = {
|
|
1033
|
+
method: 'GET',
|
|
1034
|
+
headers
|
|
1035
|
+
};
|
|
1036
|
+
fetch(url.href, options)
|
|
1037
|
+
.then(async (res) => {
|
|
1038
|
+
if (!res.ok) {
|
|
1039
|
+
const err = await res.json();
|
|
1040
|
+
throw new Error(`Failed to fetch addresses: ${err.message || JSON.stringify(err)}`);
|
|
1041
|
+
}
|
|
1042
|
+
return res.json();
|
|
1043
|
+
})
|
|
1044
|
+
.then((data) => {
|
|
1045
|
+
var _a;
|
|
1046
|
+
const currentPostalCode = (_a = this.listOfInputValues.find(i => i.name === 'PostalCode')) === null || _a === void 0 ? void 0 : _a.value;
|
|
1047
|
+
if (currentPostalCode && currentPostalCode.length >= this.postalcodelength) {
|
|
1048
|
+
this.addresses = data.addresses || [];
|
|
1049
|
+
}
|
|
1050
|
+
else {
|
|
1051
|
+
this.addresses = [];
|
|
1052
|
+
}
|
|
1053
|
+
})
|
|
1054
|
+
.catch(() => {
|
|
1055
|
+
this.addresses = [];
|
|
1056
|
+
this.lastPostalCode = null;
|
|
1057
|
+
});
|
|
1058
|
+
}
|
|
1059
|
+
renderForm() {
|
|
1060
|
+
return (h("div", null, h("div", { class: "RegisterTimeline custom__reg" }, h("button", { class: `RegisterBackButton ${this.registrationStep == CONSTANTS.REGISTRATION_STEP_ONE ? 'disabledRegBtn' : ''}`, onClick: (e) => this.backHandler(e) }, h("span", { class: "arrow" }, "\u2190"), "Back"), h("div", { class: "RegisterTimelineWrapper" }, h("div", { class: "RegisterTimeline__content" }, h("div", { class: "step step__one" }, h("span", { class: this.getStepClass(1), "data-number": "1" })), h("div", { class: "connector" }), h("div", { class: "step step__two" }, h("span", { class: this.getStepClass(2), "data-number": "2" })), h("div", { class: "connector" }), h("div", { class: "step step__three" }, h("span", { class: this.getStepClass(3), "data-number": "3" })))), this.errorMessage && h("p", { class: "RegisterTimeline__errorMsg", innerHTML: this.errorMessage })), h("form", { action: ".", id: `RegistrationForm${this.registrationStep}`, class: `registration__form`, ref: (el) => (this.form = el), onClick: this.handleInitialClick }, this.forms[this.registrationStep] &&
|
|
1061
|
+
this.forms[this.registrationStep].map((input) => {
|
|
1062
|
+
var _a, _b;
|
|
1063
|
+
return (h("div", { key: input.name, class: `input-wrapper ${this.ignorebtag && input.name === 'Btag' ? 'hide-btag' : ''}` }, h("general-input", { type: input.inputType, name: input.name, displayName: input.displayName, validation: input.validate, action: input.action || null, options: input.data
|
|
1064
|
+
? input.inputType.toLowerCase() === 'checkboxgroup' ||
|
|
1065
|
+
input.inputType.toLowerCase() === 'togglecheckbox'
|
|
1066
|
+
? input.data.subFields
|
|
1067
|
+
: input.data.values
|
|
1068
|
+
: [], defaultValue: input.defaultValue, autofilled: input.autofill, emitValue: this.emitValue, language: this.language, mbSource: this.mbSource, isDuplicateInput: input.isDuplicateInput, "client-styling": this.clientStyling, tooltip: input.tooltip, placeholder: input.placeholder == null ? '' : input.placeholder, "date-format": this.dateFormat, "twofa-destination": this.twofaDestination, "twofa-resend-interval-seconds": (_a = input.customInfo) === null || _a === void 0 ? void 0 : _a.twofaResendIntervalSeconds, "translation-url": this.translationUrl, emitOnClick: this.emitOnClick, onClick: this.handleInitialClick, haspostalcodelookup: this.haspostalcodelookup, addresses: this.haspostalcodelookup ? this.addresses : null, postalcodelength: this.haspostalcodelookup ? this.postalcodelength : null, "enable-south-african-mode": this.enableSouthAfricanMode, key: ['address1', 'address2', 'City'].includes(input.name)
|
|
1069
|
+
? `${input.name}-${this.addressUpdateKey}`
|
|
1070
|
+
: input.name, "ignore-country": this.getIgnoreCountry(input), "pin-attempts-exceeded": this.pinAttemptsExceeded }), ((_b = input.customInfo) === null || _b === void 0 ? void 0 : _b.description) && h("div", { class: "input-description" }, input.customInfo.description)));
|
|
1071
|
+
}), this.forms[this.registrationStep] && this.isConsentReady && this.renderConsents(), this.forms[this.registrationStep] && this.buttonInsideForm && this.renderButtons(), h("div", { class: "registration__wrapper--flex" }, h("p", { class: "registration__error-message", innerHTML: this.errorMessage })))));
|
|
1072
|
+
}
|
|
1073
|
+
renderConsents() {
|
|
1074
|
+
return (h("div", { class: "consentsContainer" }, h("player-consents", { endpoint: this.endpoint })));
|
|
1075
|
+
}
|
|
1076
|
+
renderButtons() {
|
|
1077
|
+
return (h("div", null, this.isLoadingPOST
|
|
1078
|
+
&& h("slot", { name: 'spinner' })
|
|
1079
|
+
&& h("svg", { class: "spinner", viewBox: "0 0 50 50" }, h("circle", { class: "path", cx: "25", cy: "25", r: "20", fill: "none", "stroke-width": "5" })), !this.isLoadingPOST && h("div", { class: `registration__buttons-wrapper ${this.autofilled ? 'registration__buttons-wrapper--autofilled' : ''}` }, h("button", { class: `registration__button registration__button--next ${this.registrationStep} ${!this.isFormValid || this.pinAttemptsExceeded ? 'registration__button--disabled' : ''}`, type: 'submit', form: `RegistrationForm${this.registrationStep}`, onClick: (e) => this.nextHandler(e), disabled: this.pinAttemptsExceeded ? true : !this.isFormValid }, this.registrationStep === "Step2"
|
|
1080
|
+
? translate('verifyButton', this.language)
|
|
1081
|
+
: (this.lastStep === this.registrationStep
|
|
1082
|
+
? translate('doneButton', this.language)
|
|
1083
|
+
: translate('nextButton', this.language))), h("button", { class: `registration__button registration__button--back ${this.registrationStep == 'Step1' ? 'registration__button--first-step' : ''}`, onClick: (e) => this.backHandler(e) }, translate('backButton', this.language)))));
|
|
1084
|
+
}
|
|
1085
|
+
render() {
|
|
1086
|
+
if (this.isLoading && !this.registerErrors) {
|
|
1087
|
+
return h("p", { class: `registration registration__loading-message` }, translate('loadingMessage', this.language));
|
|
1088
|
+
}
|
|
1089
|
+
else if (!this.isLoading && this.registerErrors) {
|
|
1090
|
+
return this.renderErrorMessage(this.errorMessage);
|
|
1091
|
+
}
|
|
1092
|
+
return (h("div", { class: `registration registration__${this.registrationStep}` }, this.renderForm(), !this.buttonInsideForm && this.renderButtons()));
|
|
1093
|
+
}
|
|
1094
|
+
static get is() { return "general-registration-multistep"; }
|
|
1095
|
+
static get encapsulation() { return "shadow"; }
|
|
1096
|
+
static get originalStyleUrls() {
|
|
1097
|
+
return {
|
|
1098
|
+
"$": ["general-registration-multistep.scss"]
|
|
1099
|
+
};
|
|
1100
|
+
}
|
|
1101
|
+
static get styleUrls() {
|
|
1102
|
+
return {
|
|
1103
|
+
"$": ["general-registration-multistep.css"]
|
|
1104
|
+
};
|
|
1105
|
+
}
|
|
1106
|
+
static get properties() {
|
|
1107
|
+
return {
|
|
1108
|
+
"endpoint": {
|
|
1109
|
+
"type": "string",
|
|
1110
|
+
"mutable": false,
|
|
1111
|
+
"complexType": {
|
|
1112
|
+
"original": "string",
|
|
1113
|
+
"resolved": "string",
|
|
1114
|
+
"references": {}
|
|
1115
|
+
},
|
|
1116
|
+
"required": true,
|
|
1117
|
+
"optional": false,
|
|
1118
|
+
"docs": {
|
|
1119
|
+
"tags": [],
|
|
1120
|
+
"text": "NorWAy Endpoint for all the calls."
|
|
1121
|
+
},
|
|
1122
|
+
"attribute": "endpoint",
|
|
1123
|
+
"reflect": true
|
|
1124
|
+
},
|
|
1125
|
+
"language": {
|
|
1126
|
+
"type": "string",
|
|
1127
|
+
"mutable": false,
|
|
1128
|
+
"complexType": {
|
|
1129
|
+
"original": "string",
|
|
1130
|
+
"resolved": "string",
|
|
1131
|
+
"references": {}
|
|
1132
|
+
},
|
|
1133
|
+
"required": false,
|
|
1134
|
+
"optional": false,
|
|
1135
|
+
"docs": {
|
|
1136
|
+
"tags": [],
|
|
1137
|
+
"text": "Currently selected language"
|
|
1138
|
+
},
|
|
1139
|
+
"attribute": "language",
|
|
1140
|
+
"reflect": true,
|
|
1141
|
+
"defaultValue": "'en'"
|
|
1142
|
+
},
|
|
1143
|
+
"clientStyling": {
|
|
1144
|
+
"type": "string",
|
|
1145
|
+
"mutable": true,
|
|
1146
|
+
"complexType": {
|
|
1147
|
+
"original": "string",
|
|
1148
|
+
"resolved": "string",
|
|
1149
|
+
"references": {}
|
|
1150
|
+
},
|
|
1151
|
+
"required": false,
|
|
1152
|
+
"optional": false,
|
|
1153
|
+
"docs": {
|
|
1154
|
+
"tags": [],
|
|
1155
|
+
"text": "Client custom styling via inline styles"
|
|
1156
|
+
},
|
|
1157
|
+
"attribute": "client-styling",
|
|
1158
|
+
"reflect": true,
|
|
1159
|
+
"defaultValue": "''"
|
|
1160
|
+
},
|
|
1161
|
+
"mbSource": {
|
|
1162
|
+
"type": "string",
|
|
1163
|
+
"mutable": false,
|
|
1164
|
+
"complexType": {
|
|
1165
|
+
"original": "string",
|
|
1166
|
+
"resolved": "string",
|
|
1167
|
+
"references": {}
|
|
1168
|
+
},
|
|
1169
|
+
"required": false,
|
|
1170
|
+
"optional": false,
|
|
1171
|
+
"docs": {
|
|
1172
|
+
"tags": [],
|
|
1173
|
+
"text": "Client custom styling via streamStyling"
|
|
1174
|
+
},
|
|
1175
|
+
"attribute": "mb-source",
|
|
1176
|
+
"reflect": false
|
|
1177
|
+
},
|
|
1178
|
+
"clientStylingUrl": {
|
|
1179
|
+
"type": "string",
|
|
1180
|
+
"mutable": false,
|
|
1181
|
+
"complexType": {
|
|
1182
|
+
"original": "string",
|
|
1183
|
+
"resolved": "string",
|
|
1184
|
+
"references": {}
|
|
1185
|
+
},
|
|
1186
|
+
"required": false,
|
|
1187
|
+
"optional": false,
|
|
1188
|
+
"docs": {
|
|
1189
|
+
"tags": [],
|
|
1190
|
+
"text": "Client custom styling via url"
|
|
1191
|
+
},
|
|
1192
|
+
"attribute": "client-styling-url",
|
|
1193
|
+
"reflect": true,
|
|
1194
|
+
"defaultValue": "''"
|
|
1195
|
+
},
|
|
1196
|
+
"translationUrl": {
|
|
1197
|
+
"type": "string",
|
|
1198
|
+
"mutable": false,
|
|
1199
|
+
"complexType": {
|
|
1200
|
+
"original": "string",
|
|
1201
|
+
"resolved": "string",
|
|
1202
|
+
"references": {}
|
|
1203
|
+
},
|
|
1204
|
+
"required": false,
|
|
1205
|
+
"optional": false,
|
|
1206
|
+
"docs": {
|
|
1207
|
+
"tags": [],
|
|
1208
|
+
"text": "Translations via URL"
|
|
1209
|
+
},
|
|
1210
|
+
"attribute": "translation-url",
|
|
1211
|
+
"reflect": true,
|
|
1212
|
+
"defaultValue": "''"
|
|
1213
|
+
},
|
|
1214
|
+
"dateFormat": {
|
|
1215
|
+
"type": "string",
|
|
1216
|
+
"mutable": false,
|
|
1217
|
+
"complexType": {
|
|
1218
|
+
"original": "string",
|
|
1219
|
+
"resolved": "string",
|
|
1220
|
+
"references": {}
|
|
1221
|
+
},
|
|
1222
|
+
"required": false,
|
|
1223
|
+
"optional": false,
|
|
1224
|
+
"docs": {
|
|
1225
|
+
"tags": [],
|
|
1226
|
+
"text": "Date format for date picker"
|
|
1227
|
+
},
|
|
1228
|
+
"attribute": "date-format",
|
|
1229
|
+
"reflect": true
|
|
1230
|
+
},
|
|
1231
|
+
"buttonInsideForm": {
|
|
1232
|
+
"type": "boolean",
|
|
1233
|
+
"mutable": false,
|
|
1234
|
+
"complexType": {
|
|
1235
|
+
"original": "boolean",
|
|
1236
|
+
"resolved": "boolean",
|
|
1237
|
+
"references": {}
|
|
1238
|
+
},
|
|
1239
|
+
"required": true,
|
|
1240
|
+
"optional": false,
|
|
1241
|
+
"docs": {
|
|
1242
|
+
"tags": [],
|
|
1243
|
+
"text": "Boolean that decides the position of the button. e.g. button inside -- true / outside -- false the form."
|
|
1244
|
+
},
|
|
1245
|
+
"attribute": "button-inside-form",
|
|
1246
|
+
"reflect": true
|
|
1247
|
+
},
|
|
1248
|
+
"btag": {
|
|
1249
|
+
"type": "string",
|
|
1250
|
+
"mutable": false,
|
|
1251
|
+
"complexType": {
|
|
1252
|
+
"original": "string",
|
|
1253
|
+
"resolved": "string",
|
|
1254
|
+
"references": {}
|
|
1255
|
+
},
|
|
1256
|
+
"required": false,
|
|
1257
|
+
"optional": false,
|
|
1258
|
+
"docs": {
|
|
1259
|
+
"tags": [],
|
|
1260
|
+
"text": "Affiliate code to be passed in and sent in the registration."
|
|
1261
|
+
},
|
|
1262
|
+
"attribute": "btag",
|
|
1263
|
+
"reflect": true,
|
|
1264
|
+
"defaultValue": "null"
|
|
1265
|
+
},
|
|
1266
|
+
"emitOnClick": {
|
|
1267
|
+
"type": "boolean",
|
|
1268
|
+
"mutable": false,
|
|
1269
|
+
"complexType": {
|
|
1270
|
+
"original": "boolean",
|
|
1271
|
+
"resolved": "boolean",
|
|
1272
|
+
"references": {}
|
|
1273
|
+
},
|
|
1274
|
+
"required": false,
|
|
1275
|
+
"optional": false,
|
|
1276
|
+
"docs": {
|
|
1277
|
+
"tags": [],
|
|
1278
|
+
"text": "Boolean flag that tells inputs to emit an event on click."
|
|
1279
|
+
},
|
|
1280
|
+
"attribute": "emit-on-click",
|
|
1281
|
+
"reflect": true,
|
|
1282
|
+
"defaultValue": "false"
|
|
1283
|
+
},
|
|
1284
|
+
"haspostalcodelookup": {
|
|
1285
|
+
"type": "boolean",
|
|
1286
|
+
"mutable": false,
|
|
1287
|
+
"complexType": {
|
|
1288
|
+
"original": "boolean",
|
|
1289
|
+
"resolved": "boolean",
|
|
1290
|
+
"references": {}
|
|
1291
|
+
},
|
|
1292
|
+
"required": false,
|
|
1293
|
+
"optional": false,
|
|
1294
|
+
"docs": {
|
|
1295
|
+
"tags": [],
|
|
1296
|
+
"text": "Addresses dropdown suggestion based on postal code"
|
|
1297
|
+
},
|
|
1298
|
+
"attribute": "haspostalcodelookup",
|
|
1299
|
+
"reflect": true,
|
|
1300
|
+
"defaultValue": "false"
|
|
1301
|
+
},
|
|
1302
|
+
"ignorebtag": {
|
|
1303
|
+
"type": "boolean",
|
|
1304
|
+
"mutable": false,
|
|
1305
|
+
"complexType": {
|
|
1306
|
+
"original": "boolean",
|
|
1307
|
+
"resolved": "boolean",
|
|
1308
|
+
"references": {}
|
|
1309
|
+
},
|
|
1310
|
+
"required": false,
|
|
1311
|
+
"optional": false,
|
|
1312
|
+
"docs": {
|
|
1313
|
+
"tags": [],
|
|
1314
|
+
"text": "hide btag from field"
|
|
1315
|
+
},
|
|
1316
|
+
"attribute": "ignorebtag",
|
|
1317
|
+
"reflect": true,
|
|
1318
|
+
"defaultValue": "false"
|
|
1319
|
+
},
|
|
1320
|
+
"enableSouthAfricanMode": {
|
|
1321
|
+
"type": "boolean",
|
|
1322
|
+
"mutable": false,
|
|
1323
|
+
"complexType": {
|
|
1324
|
+
"original": "boolean",
|
|
1325
|
+
"resolved": "boolean",
|
|
1326
|
+
"references": {}
|
|
1327
|
+
},
|
|
1328
|
+
"required": false,
|
|
1329
|
+
"optional": false,
|
|
1330
|
+
"docs": {
|
|
1331
|
+
"tags": [],
|
|
1332
|
+
"text": "Enable South African registration mode"
|
|
1333
|
+
},
|
|
1334
|
+
"attribute": "enable-south-african-mode",
|
|
1335
|
+
"reflect": true,
|
|
1336
|
+
"defaultValue": "true"
|
|
1337
|
+
}
|
|
1338
|
+
};
|
|
1339
|
+
}
|
|
1340
|
+
static get states() {
|
|
1341
|
+
return {
|
|
1342
|
+
"errorMessage": {},
|
|
1343
|
+
"isFormValid": {},
|
|
1344
|
+
"isConsentValid": {},
|
|
1345
|
+
"isConsentReady": {},
|
|
1346
|
+
"isLoading": {},
|
|
1347
|
+
"isLoadingPOST": {},
|
|
1348
|
+
"registrationStep": {},
|
|
1349
|
+
"forms": {},
|
|
1350
|
+
"limitStylingAppends": {},
|
|
1351
|
+
"autofilled": {},
|
|
1352
|
+
"isInitalInteraction": {},
|
|
1353
|
+
"addresses": {},
|
|
1354
|
+
"addressUpdateKey": {},
|
|
1355
|
+
"currentStep": {}
|
|
1356
|
+
};
|
|
1357
|
+
}
|
|
1358
|
+
static get events() {
|
|
1359
|
+
return [{
|
|
1360
|
+
"method": "registrationWidgetLoaded",
|
|
1361
|
+
"name": "registrationWidgetLoaded",
|
|
1362
|
+
"bubbles": true,
|
|
1363
|
+
"cancelable": true,
|
|
1364
|
+
"composed": true,
|
|
1365
|
+
"docs": {
|
|
1366
|
+
"tags": [],
|
|
1367
|
+
"text": ""
|
|
1368
|
+
},
|
|
1369
|
+
"complexType": {
|
|
1370
|
+
"original": "any",
|
|
1371
|
+
"resolved": "any",
|
|
1372
|
+
"references": {}
|
|
1373
|
+
}
|
|
1374
|
+
}, {
|
|
1375
|
+
"method": "registrationStepUpdated",
|
|
1376
|
+
"name": "registrationStepUpdated",
|
|
1377
|
+
"bubbles": true,
|
|
1378
|
+
"cancelable": true,
|
|
1379
|
+
"composed": true,
|
|
1380
|
+
"docs": {
|
|
1381
|
+
"tags": [],
|
|
1382
|
+
"text": ""
|
|
1383
|
+
},
|
|
1384
|
+
"complexType": {
|
|
1385
|
+
"original": "string",
|
|
1386
|
+
"resolved": "string",
|
|
1387
|
+
"references": {}
|
|
1388
|
+
}
|
|
1389
|
+
}, {
|
|
1390
|
+
"method": "validationChange",
|
|
1391
|
+
"name": "validationChange",
|
|
1392
|
+
"bubbles": true,
|
|
1393
|
+
"cancelable": true,
|
|
1394
|
+
"composed": true,
|
|
1395
|
+
"docs": {
|
|
1396
|
+
"tags": [],
|
|
1397
|
+
"text": ""
|
|
1398
|
+
},
|
|
1399
|
+
"complexType": {
|
|
1400
|
+
"original": "any",
|
|
1401
|
+
"resolved": "any",
|
|
1402
|
+
"references": {}
|
|
1403
|
+
}
|
|
1404
|
+
}];
|
|
1405
|
+
}
|
|
1406
|
+
static get elementRef() { return "host"; }
|
|
1407
|
+
static get watchers() {
|
|
1408
|
+
return [{
|
|
1409
|
+
"propName": "registrationStep",
|
|
1410
|
+
"methodName": "sendStep"
|
|
1411
|
+
}, {
|
|
1412
|
+
"propName": "clientStyling",
|
|
1413
|
+
"methodName": "handleStylingChange"
|
|
1414
|
+
}, {
|
|
1415
|
+
"propName": "clientStylingUrl",
|
|
1416
|
+
"methodName": "handleStylingUrlChange"
|
|
1417
|
+
}, {
|
|
1418
|
+
"propName": "forms",
|
|
1419
|
+
"methodName": "setFormValidity"
|
|
1420
|
+
}, {
|
|
1421
|
+
"propName": "btag",
|
|
1422
|
+
"methodName": "addBtag"
|
|
1423
|
+
}];
|
|
1424
|
+
}
|
|
1425
|
+
static get listeners() {
|
|
1426
|
+
return [{
|
|
1427
|
+
"name": "sendValidityState",
|
|
1428
|
+
"method": "checkInputsValidityHandler",
|
|
1429
|
+
"target": undefined,
|
|
1430
|
+
"capture": false,
|
|
1431
|
+
"passive": false
|
|
1432
|
+
}, {
|
|
1433
|
+
"name": "sendInputValue",
|
|
1434
|
+
"method": "getInputsValueHandler",
|
|
1435
|
+
"target": undefined,
|
|
1436
|
+
"capture": false,
|
|
1437
|
+
"passive": false
|
|
1438
|
+
}, {
|
|
1439
|
+
"name": "sendAddressValue",
|
|
1440
|
+
"method": "handleAddressSelection",
|
|
1441
|
+
"target": undefined,
|
|
1442
|
+
"capture": false,
|
|
1443
|
+
"passive": false
|
|
1444
|
+
}, {
|
|
1445
|
+
"name": "countryCodeUpdated",
|
|
1446
|
+
"method": "handleCountryCodeUpdateGlobal",
|
|
1447
|
+
"target": "window",
|
|
1448
|
+
"capture": false,
|
|
1449
|
+
"passive": false
|
|
1450
|
+
}, {
|
|
1451
|
+
"name": "resendCode",
|
|
1452
|
+
"method": "handleRequestTwofa",
|
|
1453
|
+
"target": undefined,
|
|
1454
|
+
"capture": false,
|
|
1455
|
+
"passive": false
|
|
1456
|
+
}, {
|
|
1457
|
+
"name": "message",
|
|
1458
|
+
"method": "messageHandler",
|
|
1459
|
+
"target": "window",
|
|
1460
|
+
"capture": false,
|
|
1461
|
+
"passive": false
|
|
1462
|
+
}, {
|
|
1463
|
+
"name": "birthDateUpdated",
|
|
1464
|
+
"method": "handleBirthDateUpdated",
|
|
1465
|
+
"target": "window",
|
|
1466
|
+
"capture": false,
|
|
1467
|
+
"passive": false
|
|
1468
|
+
}];
|
|
1469
|
+
}
|
|
1470
|
+
}
|