@everymatrix/general-registration 1.10.2 → 1.10.4
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/checkbox-input_11.cjs.entry.js +28188 -719
- package/dist/cjs/general-registration.cjs.js +2 -2
- package/dist/cjs/{index-c04f4a2a.js → index-9a07d1e9.js} +5 -0
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/collection/components/general-registration/general-registration.js +289 -223
- package/dist/components/checkbox-input2.js +9 -5
- package/dist/components/date-input2.js +6490 -7
- package/dist/components/email-input2.js +2 -1
- package/dist/components/general-input2.js +11 -9
- package/dist/components/general-registration.js +288 -223
- package/dist/components/locale.utils.js +2 -1
- package/dist/components/number-input2.js +2 -1
- package/dist/components/password-input2.js +8 -1
- package/dist/components/select-input2.js +13 -4
- package/dist/components/tel-input2.js +30 -2
- package/dist/components/text-input2.js +4 -4
- package/dist/components/vaadin-combo-box.js +4423 -0
- package/dist/components/virtual-keyboard-controller.js +16466 -0
- package/dist/esm/checkbox-input_11.entry.js +28188 -719
- package/dist/esm/general-registration.js +2 -2
- package/dist/esm/{index-79f297c1.js → index-0505440f.js} +5 -1
- package/dist/esm/loader.js +2 -2
- package/dist/general-registration/general-registration.esm.js +1 -1
- package/dist/general-registration/p-1a88a312.js +1 -0
- package/dist/general-registration/p-6a27a1e0.entry.js +3164 -0
- package/dist/types/Users/{user/workspace/everymatrix → adrian.pripon/Documents/Work/stencil}/widgets-stencil/packages/general-registration/.stencil/packages/general-input/src/utils/types.d.ts +8 -0
- package/dist/types/Users/adrian.pripon/Documents/Work/stencil/widgets-stencil/packages/general-registration/.stencil/packages/general-registration/stencil.config.d.ts +2 -0
- package/dist/types/components/general-registration/general-registration.d.ts +265 -7
- package/package.json +7 -5
- package/dist/general-registration/p-0e7175cd.js +0 -1
- package/dist/general-registration/p-d92411a2.entry.js +0 -1
- package/dist/types/Users/user/workspace/everymatrix/widgets-stencil/packages/general-registration/.stencil/packages/general-registration/stencil.config.d.ts +0 -2
- /package/dist/types/Users/{user/workspace/everymatrix → adrian.pripon/Documents/Work/stencil}/widgets-stencil/packages/general-registration/.stencil/packages/general-input/src/utils/locale.utils.d.ts +0 -0
|
@@ -19,7 +19,8 @@ const TRANSLATIONS = {
|
|
|
19
19
|
lengthError: `The length should be between {minLength} and {maxLength}`,
|
|
20
20
|
requiredError: 'This input is required.',
|
|
21
21
|
nextButton: 'Next',
|
|
22
|
-
backButton: 'Back'
|
|
22
|
+
backButton: 'Back',
|
|
23
|
+
doneButton: 'Done'
|
|
23
24
|
},
|
|
24
25
|
ro: {
|
|
25
26
|
lengthError: `Cuvântul introdus este prea scurt. {minLength} and {maxLength}`,
|
|
@@ -62,196 +63,192 @@ const GeneralRegistration$1 = /*@__PURE__*/ proxyCustomElement(class extends HTM
|
|
|
62
63
|
"autofill": false
|
|
63
64
|
},
|
|
64
65
|
{
|
|
65
|
-
"name": "
|
|
66
|
-
"displayName": "
|
|
66
|
+
"name": "lastName",
|
|
67
|
+
"displayName": "Last name",
|
|
67
68
|
"defaultValue": null,
|
|
68
69
|
"validate": {
|
|
69
70
|
"mandatory": true,
|
|
70
71
|
"minLength": 3,
|
|
71
72
|
"maxLength": 20
|
|
72
73
|
},
|
|
73
|
-
"autofill": false
|
|
74
74
|
},
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
// },
|
|
253
|
-
// "inputType" : "dropdown"
|
|
254
|
-
// }
|
|
75
|
+
{
|
|
76
|
+
"name": "telephone",
|
|
77
|
+
"displayName": "Telephone",
|
|
78
|
+
"action": "GET https://demo-api.stage.norway.everymatrix.com/v1/player/phonecodes",
|
|
79
|
+
"defaultValue": null,
|
|
80
|
+
"validate": {
|
|
81
|
+
"mandatory": true
|
|
82
|
+
},
|
|
83
|
+
"autofill": false,
|
|
84
|
+
"inputType": "tel"
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
"name": "dateOfBirth",
|
|
88
|
+
"displayName": "Date of Birth",
|
|
89
|
+
"defaultValue": null,
|
|
90
|
+
"validate": {
|
|
91
|
+
"min": "2022-05-01",
|
|
92
|
+
"max": "2022-05-29",
|
|
93
|
+
"mandatory": true,
|
|
94
|
+
},
|
|
95
|
+
"inputType": "datetime"
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
"name": "email",
|
|
99
|
+
"displayName": "Email",
|
|
100
|
+
"defaultValue": 'a@a.com',
|
|
101
|
+
"validate": {
|
|
102
|
+
"mandatory": true,
|
|
103
|
+
"custom": [
|
|
104
|
+
{
|
|
105
|
+
"rule": "regex",
|
|
106
|
+
"pattern": "^[a-zA-Z0-9._%+-]+@[a-zA-Z-9.-]+\\.[a-zA-Z]{2,3}$",
|
|
107
|
+
"errorMessage": "Please enter a valid email address"
|
|
108
|
+
}
|
|
109
|
+
]
|
|
110
|
+
},
|
|
111
|
+
"inputType": "email"
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
"name": "password",
|
|
115
|
+
"displayName": "Password",
|
|
116
|
+
"defaultValue": null,
|
|
117
|
+
"validate": {
|
|
118
|
+
"mandatory": true,
|
|
119
|
+
"minLength": 3,
|
|
120
|
+
"maxLength": 20,
|
|
121
|
+
"type": "password",
|
|
122
|
+
"custom": [
|
|
123
|
+
{
|
|
124
|
+
"rule": "regex",
|
|
125
|
+
"pattern": "(?=.*\\d+)(?=.*[A-Za-z]+).{8,20}",
|
|
126
|
+
"errorMessage": "Password must contain at least 1 letter and 1 digit, and its minimal length is 8."
|
|
127
|
+
}
|
|
128
|
+
]
|
|
129
|
+
},
|
|
130
|
+
"inputType": "password"
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
"name": "email",
|
|
134
|
+
"displayName": "Email",
|
|
135
|
+
"defaultValue": null,
|
|
136
|
+
"validate": {
|
|
137
|
+
"mandatory": true,
|
|
138
|
+
"type": "email",
|
|
139
|
+
"custom": [
|
|
140
|
+
{
|
|
141
|
+
"rule": "unique-email",
|
|
142
|
+
"errorMessage": "Please check your email"
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
"rule": "regex",
|
|
146
|
+
"pattern": "^[a-zA-Z0-9._%+-]+@[a-zA-Z-9.-]+\\.[a-zA-Z]{2,3}$",
|
|
147
|
+
"errorMessage": "Please enter a valid email address"
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
"rule": "duplicate-input",
|
|
151
|
+
"displayName": "pt al doilea input gen: Confirm Email",
|
|
152
|
+
"errorMessage": "Different Email! Pls."
|
|
153
|
+
}
|
|
154
|
+
]
|
|
155
|
+
}
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
"name": "termsAndConditions",
|
|
159
|
+
"displayName": "Terms and Conditions",
|
|
160
|
+
"validate": {
|
|
161
|
+
"mandatory": true,
|
|
162
|
+
"type": "boolean"
|
|
163
|
+
},
|
|
164
|
+
"inputType": "checkbox"
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
"name": "pepCheck",
|
|
168
|
+
"validate": {
|
|
169
|
+
"mandatory": true
|
|
170
|
+
},
|
|
171
|
+
"inputType": "checkbox"
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
"name": "gender",
|
|
175
|
+
"data": {
|
|
176
|
+
"values": [
|
|
177
|
+
{
|
|
178
|
+
"label": "🍆",
|
|
179
|
+
"value": "m"
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
"label": "🍑",
|
|
183
|
+
"value": "f"
|
|
184
|
+
}
|
|
185
|
+
]
|
|
186
|
+
},
|
|
187
|
+
"validate": {
|
|
188
|
+
"mandatory": true
|
|
189
|
+
},
|
|
190
|
+
"inputType": "radio"
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
"name": "dateOfBirth",
|
|
194
|
+
"validate": {
|
|
195
|
+
"mandatory": true,
|
|
196
|
+
"custom": [
|
|
197
|
+
{
|
|
198
|
+
"rule": "regex",
|
|
199
|
+
"pattern": "(?:19\\d{2}|20[01][0-9]|2020)[-/.](?:0[1-9]|1[012])[-/.](?:0[1-9]|[12][0-9]|3[01])",
|
|
200
|
+
"errorMessage": "Invalid date format"
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
"rule": "min-18-years",
|
|
204
|
+
"errorMessage": "Not old enough to ride the roller coaster"
|
|
205
|
+
}
|
|
206
|
+
]
|
|
207
|
+
}
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
"name": "city",
|
|
211
|
+
"displayName": "Cities",
|
|
212
|
+
"action": null,
|
|
213
|
+
"data": {
|
|
214
|
+
"values": [
|
|
215
|
+
{
|
|
216
|
+
"label": "Budapest",
|
|
217
|
+
"value": "Budapest"
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
"label": "Debrecen",
|
|
221
|
+
"value": "Debrecen"
|
|
222
|
+
},
|
|
223
|
+
{
|
|
224
|
+
"label": "Miskolc",
|
|
225
|
+
"value": "Miskolc"
|
|
226
|
+
},
|
|
227
|
+
{
|
|
228
|
+
"label": "Szeged",
|
|
229
|
+
"value": "Szeged"
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
"label": "Zuglo",
|
|
233
|
+
"value": "Zuglo"
|
|
234
|
+
}
|
|
235
|
+
]
|
|
236
|
+
},
|
|
237
|
+
"validate": {
|
|
238
|
+
"mandatory": true
|
|
239
|
+
},
|
|
240
|
+
"inputType": "dropdown"
|
|
241
|
+
},
|
|
242
|
+
{
|
|
243
|
+
"name": "city",
|
|
244
|
+
"displayName": "Cities",
|
|
245
|
+
"data": null,
|
|
246
|
+
"action": "GET https://demo-api.stage.norway.everymatrix.com/v1/player/countries",
|
|
247
|
+
"validate": {
|
|
248
|
+
"mandatory": true
|
|
249
|
+
},
|
|
250
|
+
"inputType": "dropdown"
|
|
251
|
+
}
|
|
255
252
|
],
|
|
256
253
|
"actions": [
|
|
257
254
|
"get-next-step",
|
|
@@ -269,7 +266,13 @@ const GeneralRegistration$1 = /*@__PURE__*/ proxyCustomElement(class extends HTM
|
|
|
269
266
|
this.isLoading = true;
|
|
270
267
|
this.listOfInputValues = [];
|
|
271
268
|
this.listOfActions = [];
|
|
272
|
-
this.
|
|
269
|
+
this.steps = [];
|
|
270
|
+
this.registrationStepsState = {
|
|
271
|
+
regId: null
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
logger() {
|
|
275
|
+
console.log(this.registrationStep);
|
|
273
276
|
}
|
|
274
277
|
checkInputsValidityHandler(event) {
|
|
275
278
|
// Set isValid state of the input in the list.
|
|
@@ -278,37 +281,84 @@ const GeneralRegistration$1 = /*@__PURE__*/ proxyCustomElement(class extends HTM
|
|
|
278
281
|
this.isFormValid = !this.getInvalidStatus(this.listOfInputs);
|
|
279
282
|
}
|
|
280
283
|
getInputsValueHandler(event) {
|
|
281
|
-
this.listOfInputValues.find(input => input.name == event.detail.name).
|
|
284
|
+
this.listOfInputValues.find(input => input.name == event.detail.name).value = event.detail.value;
|
|
282
285
|
/*Note to self: -- what about the inputs that received a default value.
|
|
283
286
|
They will send an undefined because there was no input
|
|
284
287
|
Handle it somehow!!!!!, one idea can be that value equals defaultValue but dependes on how the api wants stuff*/
|
|
288
|
+
this.stepsStateMachine({ event: 'set', type: 'values' });
|
|
285
289
|
}
|
|
286
290
|
componentWillLoad() {
|
|
287
291
|
// const mockCall = Promise.resolve(this.data);
|
|
288
292
|
// return mockCall.then((data) => {
|
|
289
293
|
// this.listOfInputs = data.content.fields.map((field) => {
|
|
294
|
+
// this.isLoading = false;
|
|
290
295
|
// return { ...field, isValid: false };
|
|
291
296
|
// });
|
|
292
297
|
// });
|
|
293
|
-
// Initial Fetch
|
|
294
298
|
return this.getRegisterConfig().then((config) => {
|
|
295
299
|
this.formatConfig(config);
|
|
300
|
+
this.stepsStateMachine({ event: 'set', type: 'inputs' });
|
|
296
301
|
});
|
|
297
302
|
}
|
|
298
303
|
nextHandler(e) {
|
|
299
304
|
e.preventDefault();
|
|
300
305
|
// Trigger events in subwidgets.
|
|
301
306
|
this.emitValue = true;
|
|
302
|
-
// if (this.isFormValid) {
|
|
303
307
|
this.setRegisterStep();
|
|
304
|
-
|
|
308
|
+
}
|
|
309
|
+
backHandler(e) {
|
|
310
|
+
e.preventDefault();
|
|
311
|
+
this.steps.pop();
|
|
312
|
+
this.registrationStep = this.steps.at(-1);
|
|
313
|
+
this.stepsStateMachine({ event: 'get', type: 'inputs' });
|
|
314
|
+
this.stepsStateMachine({ event: 'get', type: 'values' });
|
|
315
|
+
}
|
|
316
|
+
stepsStateMachine(state) {
|
|
317
|
+
switch (state.event) {
|
|
318
|
+
case 'set':
|
|
319
|
+
if (state.type == 'inputs') {
|
|
320
|
+
this.registrationStepsState[this.registrationStep].fields = this.listOfInputs;
|
|
321
|
+
}
|
|
322
|
+
if (state.type == 'values') {
|
|
323
|
+
this.registrationStepsState[this.registrationStep].registerUserData = this.listOfInputValues.reduce((acc, curr) => {
|
|
324
|
+
// @TODO remove this once GMCore is smart enough to understand the concept of UNIQUE KEYS
|
|
325
|
+
if (curr.value != null) {
|
|
326
|
+
acc[curr.name] = curr.value;
|
|
327
|
+
}
|
|
328
|
+
return acc;
|
|
329
|
+
}, {});
|
|
330
|
+
}
|
|
331
|
+
localStorage.setItem('registrationStepsState', JSON.stringify(this.registrationStepsState));
|
|
332
|
+
break;
|
|
333
|
+
case 'get':
|
|
334
|
+
const savedUserData = JSON.parse(localStorage.getItem('registrationStepsState'));
|
|
335
|
+
if (!savedUserData)
|
|
336
|
+
return;
|
|
337
|
+
if (state.type == 'inputs') {
|
|
338
|
+
this.listOfInputs = this.registrationStepsState[this.registrationStep].fields;
|
|
339
|
+
}
|
|
340
|
+
if (state.type == 'values') {
|
|
341
|
+
const savedValues = savedUserData[this.registrationStep].registerUserData;
|
|
342
|
+
this.listOfInputValues = Object.keys(savedValues).map(name => {
|
|
343
|
+
return { name, value: savedValues[name] };
|
|
344
|
+
});
|
|
345
|
+
// Give to each field the user input as the default value.
|
|
346
|
+
this.listOfInputValues.forEach(inputValue => {
|
|
347
|
+
const input = this.listOfInputs.find(input => input.name === inputValue.name);
|
|
348
|
+
if (input) {
|
|
349
|
+
input.defaultValue = inputValue.value;
|
|
350
|
+
}
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
break;
|
|
354
|
+
}
|
|
305
355
|
}
|
|
306
356
|
getRegisterConfig(registrationID) {
|
|
307
|
-
const url = new URL(`${this.endpoint}/
|
|
357
|
+
const url = new URL(`${this.endpoint}/v1/player/legislation/registration/config`);
|
|
308
358
|
const headers = new Headers();
|
|
309
|
-
headers.append('X-Tenant-ID', this.tenantId);
|
|
310
|
-
headers.append('X-Client-ID', this.clientId);
|
|
311
|
-
headers.append('X-Api-Key', this.apiKey);
|
|
359
|
+
// headers.append('X-Tenant-ID', this.tenantId);
|
|
360
|
+
// headers.append('X-Client-ID', this.clientId);
|
|
361
|
+
// headers.append('X-Api-Key', this.apiKey);
|
|
312
362
|
headers.append('Content-Type', 'application/json');
|
|
313
363
|
headers.append('Accept', 'application/json');
|
|
314
364
|
if (registrationID) {
|
|
@@ -334,22 +384,22 @@ const GeneralRegistration$1 = /*@__PURE__*/ proxyCustomElement(class extends HTM
|
|
|
334
384
|
}
|
|
335
385
|
setRegisterStep() {
|
|
336
386
|
this.isLoading = true;
|
|
337
|
-
const url = new URL(`${this.endpoint}/
|
|
387
|
+
const url = new URL(`${this.endpoint}/v1/player/legislation/registration/step`);
|
|
338
388
|
const registerStep = {
|
|
339
389
|
registrationId: this.registrationID,
|
|
340
390
|
registerUserDto: this.listOfInputValues.reduce((acc, curr) => {
|
|
341
391
|
// @TODO remove this once GMCore is smart enough to understand the concept of UNIQUE KEYS
|
|
342
|
-
if (curr.
|
|
343
|
-
acc[curr.name] = curr.
|
|
392
|
+
if (curr.value != null) {
|
|
393
|
+
acc[curr.name] = curr.value;
|
|
344
394
|
}
|
|
345
395
|
return acc;
|
|
346
396
|
}, {}),
|
|
347
397
|
step: this.registrationStep,
|
|
348
398
|
};
|
|
349
399
|
const headers = new Headers();
|
|
350
|
-
headers.append('X-Tenant-ID', this.tenantId);
|
|
351
|
-
headers.append('X-Client-ID', this.clientId);
|
|
352
|
-
headers.append('X-Api-Key', this.apiKey);
|
|
400
|
+
// headers.append('X-Tenant-ID', this.tenantId);
|
|
401
|
+
// headers.append('X-Client-ID', this.clientId);
|
|
402
|
+
// headers.append('X-Api-Key', this.apiKey);
|
|
353
403
|
headers.append('Content-Type', 'application/json');
|
|
354
404
|
headers.append('Accept', 'application/json');
|
|
355
405
|
const options = {
|
|
@@ -365,13 +415,17 @@ const GeneralRegistration$1 = /*@__PURE__*/ proxyCustomElement(class extends HTM
|
|
|
365
415
|
return res.json();
|
|
366
416
|
})
|
|
367
417
|
.then((data) => {
|
|
368
|
-
console.log('data', data);
|
|
369
418
|
this.registrationID = data.registrationId;
|
|
370
419
|
if (this.listOfActions.some(action => action == '/register')) {
|
|
371
420
|
this.setRegister();
|
|
372
421
|
}
|
|
373
422
|
else {
|
|
374
|
-
this.getRegisterConfig(this.registrationID).then((config) =>
|
|
423
|
+
this.getRegisterConfig(this.registrationID).then((config) => {
|
|
424
|
+
// Format the new step config.
|
|
425
|
+
this.formatConfig(config);
|
|
426
|
+
// Set it in local storage
|
|
427
|
+
this.stepsStateMachine({ event: 'set', type: 'inputs' });
|
|
428
|
+
});
|
|
375
429
|
}
|
|
376
430
|
})
|
|
377
431
|
.catch((err) => {
|
|
@@ -383,24 +437,24 @@ const GeneralRegistration$1 = /*@__PURE__*/ proxyCustomElement(class extends HTM
|
|
|
383
437
|
}
|
|
384
438
|
setRegister() {
|
|
385
439
|
this.isLoading = true;
|
|
386
|
-
const url = new URL(`${this.endpoint}/
|
|
440
|
+
const url = new URL(`${this.endpoint}/v1/player/legislation/register`);
|
|
387
441
|
const headers = new Headers();
|
|
388
|
-
headers.append('X-Tenant-ID', this.tenantId);
|
|
389
|
-
headers.append('X-Client-ID', this.clientId);
|
|
390
|
-
headers.append('X-Api-Key', this.apiKey);
|
|
442
|
+
// headers.append('X-Tenant-ID', this.tenantId);
|
|
443
|
+
// headers.append('X-Client-ID', this.clientId);
|
|
444
|
+
// headers.append('X-Api-Key', this.apiKey);
|
|
391
445
|
headers.append('Content-Type', 'application/json');
|
|
392
446
|
headers.append('Accept', 'application/json');
|
|
393
|
-
const registerStep = {
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
};
|
|
447
|
+
// const registerStep = {
|
|
448
|
+
// registrationId: this.registrationID,
|
|
449
|
+
// registerUserDto: this.listOfInputValues.reduce((acc, curr) => {
|
|
450
|
+
// acc[curr.name] = curr.value;
|
|
451
|
+
// return acc;
|
|
452
|
+
// }, {}),
|
|
453
|
+
// step: this.registrationStep,
|
|
454
|
+
// };
|
|
401
455
|
const options = {
|
|
402
|
-
method: '
|
|
403
|
-
body: JSON.stringify(
|
|
456
|
+
method: 'PUT',
|
|
457
|
+
body: JSON.stringify({ registrationId: this.registrationID }),
|
|
404
458
|
headers
|
|
405
459
|
};
|
|
406
460
|
fetch(url.href, options)
|
|
@@ -411,13 +465,12 @@ const GeneralRegistration$1 = /*@__PURE__*/ proxyCustomElement(class extends HTM
|
|
|
411
465
|
return res.json();
|
|
412
466
|
})
|
|
413
467
|
.then((data) => {
|
|
414
|
-
console.log(data);
|
|
415
468
|
if (data.userId) {
|
|
416
469
|
alert(`User registered - the user ID is ${data.userId}`);
|
|
417
470
|
}
|
|
418
471
|
})
|
|
419
472
|
.catch((err) => {
|
|
420
|
-
console.
|
|
473
|
+
console.error(err);
|
|
421
474
|
})
|
|
422
475
|
.finally(() => {
|
|
423
476
|
this.isLoading = false;
|
|
@@ -430,24 +483,32 @@ const GeneralRegistration$1 = /*@__PURE__*/ proxyCustomElement(class extends HTM
|
|
|
430
483
|
});
|
|
431
484
|
// Populate the list of inputs values and set as null in the beginning
|
|
432
485
|
this.listOfInputValues = config.content.fields.map(field => {
|
|
433
|
-
return { name: field.name,
|
|
486
|
+
return { name: field.name, value: null };
|
|
434
487
|
});
|
|
435
488
|
// Set the list of actions
|
|
436
489
|
this.listOfActions = config.content.actions.map(action => action);
|
|
490
|
+
this.isLastStep = this.listOfActions.some(action => action == '/register');
|
|
437
491
|
this.registrationID = config.content.registrationID;
|
|
438
492
|
this.registrationStep = config.content.step;
|
|
493
|
+
this.steps.push(this.registrationStep);
|
|
494
|
+
// Add the step to the registrationStepsData
|
|
495
|
+
this.registrationStepsState.regId = this.registrationID;
|
|
496
|
+
if (!this.registrationStepsState[this.registrationStep]) {
|
|
497
|
+
this.registrationStepsState[this.registrationStep] = {
|
|
498
|
+
fields: [],
|
|
499
|
+
registerUserData: {}
|
|
500
|
+
};
|
|
501
|
+
}
|
|
439
502
|
}
|
|
440
503
|
getInvalidStatus(listOfInputs) {
|
|
441
504
|
return listOfInputs.filter(input => input.isValid == false).length > 0;
|
|
442
505
|
}
|
|
443
506
|
renderInputs() {
|
|
444
|
-
return (this.listOfInputs.map(input => h("general-input", { type: input.inputType, name: input.name, displayName: input.displayName, validation: input.validate, action: input.action || null, options: input.data ? input.data.values : [], defaultValue: input.defaultValue, emitValue: this.emitValue, language: this.language })));
|
|
507
|
+
return (this.listOfInputs.map(input => h("general-input", { type: input.inputType, name: input.name, displayName: input.displayName, validation: input.validate, action: input.action || null, options: input.data ? input.data.values : [], defaultValue: input.defaultValue, autofilled: input.autofill, emitValue: this.emitValue, language: this.language })));
|
|
445
508
|
}
|
|
446
509
|
;
|
|
447
510
|
renderButtons() {
|
|
448
|
-
return (h("div", { class: 'registration__buttons-wrapper' }, h("button", { class: 'registration__button'
|
|
449
|
-
// disabled={!this.isFormValid}
|
|
450
|
-
ref: (el) => this.buttonReference = el }, translate('nextButton', this.language))));
|
|
511
|
+
return (h("div", { class: 'registration__buttons-wrapper' }, h("button", { class: `registration__button ${this.isLastStep ? 'registration__button--done' : ''}`, type: 'submit', form: 'RegistrationForm', onClick: (e) => this.nextHandler(e) }, this.isLastStep ? translate('doneButton', this.language) : translate('nextButton', this.language)), this.registrationStep !== 'Step1' && h("button", { class: 'registration__button', onClick: (e) => this.backHandler(e) }, translate('backButton', this.language))));
|
|
451
512
|
}
|
|
452
513
|
render() {
|
|
453
514
|
if (this.isLoading) {
|
|
@@ -455,6 +516,9 @@ const GeneralRegistration$1 = /*@__PURE__*/ proxyCustomElement(class extends HTM
|
|
|
455
516
|
}
|
|
456
517
|
return (h("div", { class: 'registration' }, h("form", { action: '.', id: 'RegistrationForm', class: 'registration__form' }, this.renderInputs()), this.renderButtons()));
|
|
457
518
|
}
|
|
519
|
+
static get watchers() { return {
|
|
520
|
+
"registrationStep": ["logger"]
|
|
521
|
+
}; }
|
|
458
522
|
static get style() { return generalRegistrationCss; }
|
|
459
523
|
}, [1, "general-registration", {
|
|
460
524
|
"endpoint": [1],
|
|
@@ -466,7 +530,8 @@ const GeneralRegistration$1 = /*@__PURE__*/ proxyCustomElement(class extends HTM
|
|
|
466
530
|
"emitValue": [32],
|
|
467
531
|
"isFormValid": [32],
|
|
468
532
|
"listOfInputs": [32],
|
|
469
|
-
"isLoading": [32]
|
|
533
|
+
"isLoading": [32],
|
|
534
|
+
"registrationStep": [32]
|
|
470
535
|
}, [[0, "sendValidityState", "checkInputsValidityHandler"], [0, "sendInputValue", "getInputsValueHandler"]]]);
|
|
471
536
|
function defineCustomElement$1() {
|
|
472
537
|
if (typeof customElements === "undefined") {
|