@everymatrix/general-player-register-form 0.0.214 → 0.0.218
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@everymatrix/general-player-register-form",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.218",
|
|
4
4
|
"main": "dist/general-player-register-form.js",
|
|
5
5
|
"svelte": "src/index.ts",
|
|
6
6
|
"scripts": {
|
|
@@ -36,5 +36,5 @@
|
|
|
36
36
|
"publishConfig": {
|
|
37
37
|
"access": "public"
|
|
38
38
|
},
|
|
39
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "ae78406d20c106f1d3c352c0e97189a7bdffacfb"
|
|
40
40
|
}
|
|
@@ -1,27 +1,34 @@
|
|
|
1
1
|
<svelte:options tag={null} />
|
|
2
2
|
|
|
3
|
-
<script lang="
|
|
3
|
+
<script lang="ts">
|
|
4
4
|
import { getDevice } from 'rvhelper';
|
|
5
5
|
import { onMount } from "svelte";
|
|
6
|
+
import { _, addNewMessages, setLocale, setupI18n } from './i18n';
|
|
7
|
+
import { RegisterFormTranslations } from './translations';
|
|
8
|
+
|
|
9
|
+
// Native bridge
|
|
10
|
+
import { isNative, call as callNative, registerEventListener as registerNativeEventListener } from 'js-native-bridge';
|
|
6
11
|
|
|
7
12
|
import '@everymatrix/general-player-register-form-step1';
|
|
8
13
|
import '@everymatrix/general-player-register-form-step2';
|
|
9
14
|
import '@everymatrix/general-player-register-form-step3';
|
|
10
15
|
|
|
11
16
|
export let endpoint:string = '';
|
|
12
|
-
export let cmsendpoint:
|
|
17
|
+
export let cmsendpoint:string = '';
|
|
13
18
|
export let imagedesktop:string = '';
|
|
14
19
|
export let playerid:string = '';
|
|
15
20
|
export let session:string = '';
|
|
16
21
|
export let trackedanalyticsdata:string = '';
|
|
17
22
|
export let captchakey:string = '';
|
|
23
|
+
export let lang:string = '';
|
|
24
|
+
export let licenseyears:string = '';
|
|
18
25
|
|
|
19
26
|
let isLoading:boolean = false;
|
|
20
27
|
|
|
21
|
-
let showRegisterStepOne:
|
|
22
|
-
let showRegisterStepTwo:
|
|
23
|
-
let showRegisterStepThree:
|
|
24
|
-
let showConfirmation:
|
|
28
|
+
let showRegisterStepOne:boolean = true;
|
|
29
|
+
let showRegisterStepTwo:boolean = false;
|
|
30
|
+
let showRegisterStepThree:boolean = false;
|
|
31
|
+
let showConfirmation:boolean = false;
|
|
25
32
|
let cmsData:any;
|
|
26
33
|
let showError:boolean = false;
|
|
27
34
|
|
|
@@ -30,18 +37,34 @@
|
|
|
30
37
|
let accountCreationMessage:string = '';
|
|
31
38
|
let image:Object = {};
|
|
32
39
|
|
|
33
|
-
let userAgent:
|
|
34
|
-
let isMobile = (getDevice(userAgent) === 'PC') ? false : true;
|
|
40
|
+
let userAgent:string = window.navigator.userAgent;
|
|
41
|
+
let isMobile:boolean = (getDevice(userAgent) === 'PC') ? false : true;
|
|
35
42
|
|
|
43
|
+
// @TODO typescript model type for userData
|
|
36
44
|
let userData:any = {};
|
|
37
|
-
let stepTwoVisited:
|
|
38
|
-
let stepThreeVisited:
|
|
39
|
-
let userconsentsexist:
|
|
45
|
+
let stepTwoVisited:boolean = false;
|
|
46
|
+
let stepThreeVisited:boolean = false;
|
|
47
|
+
let userconsentsexist:boolean = false;
|
|
40
48
|
let error:string = '';
|
|
41
49
|
|
|
42
50
|
let scrollSteps:HTMLElement;
|
|
43
51
|
|
|
44
|
-
|
|
52
|
+
// Native bridge
|
|
53
|
+
let isOnNative:boolean = false;
|
|
54
|
+
|
|
55
|
+
// @TODO typescript model for loginFields
|
|
56
|
+
let loginFields:any = {
|
|
57
|
+
username: '',
|
|
58
|
+
password: '',
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
// setupI18n({ withLocale: 'en', translations: {}});
|
|
62
|
+
|
|
63
|
+
Object.keys(RegisterFormTranslations).forEach((item:any) => {
|
|
64
|
+
addNewMessages(item, RegisterFormTranslations[item]);
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
const verifyUserConsents = ():void => {
|
|
45
68
|
fetch(`${endpoint}/player/consentRequirements`)
|
|
46
69
|
.then((res:any) => res.json())
|
|
47
70
|
.then(data => {
|
|
@@ -53,15 +76,17 @@
|
|
|
53
76
|
});
|
|
54
77
|
}
|
|
55
78
|
|
|
56
|
-
const getCmsData = () => {
|
|
57
|
-
|
|
79
|
+
const getCmsData = ():void => {
|
|
80
|
+
let url:URL = new URL(`${cmsendpoint}${lang}/login-register-content`);
|
|
81
|
+
|
|
82
|
+
fetch(url.href)
|
|
58
83
|
.then((res: any) => res.json())
|
|
59
84
|
.then((data: any) => {
|
|
60
|
-
cmsData = data.
|
|
85
|
+
cmsData = data.registerData;
|
|
61
86
|
|
|
62
|
-
accountCreationTitle = cmsData.
|
|
63
|
-
accountCreationSubTitle = cmsData.
|
|
64
|
-
accountCreationMessage = cmsData.
|
|
87
|
+
accountCreationTitle = cmsData.title;
|
|
88
|
+
accountCreationSubTitle = cmsData.subtitle;
|
|
89
|
+
accountCreationMessage = cmsData.content;
|
|
65
90
|
|
|
66
91
|
})
|
|
67
92
|
.catch((err: any) => {
|
|
@@ -69,11 +94,12 @@
|
|
|
69
94
|
});
|
|
70
95
|
};
|
|
71
96
|
|
|
72
|
-
const scrollTop = () => {
|
|
97
|
+
const scrollTop = ():void => {
|
|
73
98
|
scrollSteps.scrollIntoView();
|
|
74
99
|
}
|
|
75
100
|
|
|
76
|
-
|
|
101
|
+
// @TODO data typescript
|
|
102
|
+
const createData = (step:string, data:any):void => {
|
|
77
103
|
if (step === 'RegisterStepOne') {
|
|
78
104
|
userData.email = data.userEmail;
|
|
79
105
|
userData.username = data.userValue;
|
|
@@ -105,16 +131,17 @@
|
|
|
105
131
|
// analytics data
|
|
106
132
|
userData.affiliateMarker = trackedanalyticsdata;
|
|
107
133
|
|
|
108
|
-
if(userconsentsexist) {
|
|
134
|
+
if (userconsentsexist) {
|
|
109
135
|
userData.userConsents.additionalProp1 = data.consentOffersSms;
|
|
110
136
|
userData.userConsents.additionalProp2 = data.consentOffersEmail;
|
|
111
137
|
userData.userConsents.additionalProp3 = data.consentTerms;
|
|
112
138
|
}
|
|
139
|
+
|
|
113
140
|
userData.token = data.token;
|
|
114
141
|
}
|
|
115
142
|
}
|
|
116
143
|
|
|
117
|
-
const messageHandler = (e:any) => {
|
|
144
|
+
const messageHandler = (e:any):void => {
|
|
118
145
|
if (e.data) {
|
|
119
146
|
switch(e.data.type) {
|
|
120
147
|
case 'RegisterStepOne':
|
|
@@ -169,8 +196,26 @@
|
|
|
169
196
|
}
|
|
170
197
|
}
|
|
171
198
|
|
|
172
|
-
const
|
|
199
|
+
const handlePostRegister = ():void => {
|
|
200
|
+
if (isOnNative) {
|
|
201
|
+
registerNativeEventListener(
|
|
202
|
+
'BIOMETRICS_ENABLED',
|
|
203
|
+
() => {
|
|
204
|
+
},
|
|
205
|
+
);
|
|
173
206
|
|
|
207
|
+
const { username, password } = loginFields;
|
|
208
|
+
|
|
209
|
+
const methodFound = callNative('ENABLE_BIOMETRICS', { username, password });
|
|
210
|
+
|
|
211
|
+
if (!methodFound) {
|
|
212
|
+
// Nothing to do here
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
// @TODO typescript data model for userData
|
|
218
|
+
const sendData = async (userData:any):Promise<any> => {
|
|
174
219
|
let sendRegistrationData = {
|
|
175
220
|
method: "PUT",
|
|
176
221
|
headers: {
|
|
@@ -187,29 +232,45 @@
|
|
|
187
232
|
if (response.ok) {
|
|
188
233
|
showRegisterStepThree = false;
|
|
189
234
|
showConfirmation = true;
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
loginFields = {
|
|
238
|
+
username: userData.username,
|
|
239
|
+
password: userData.password
|
|
240
|
+
};
|
|
241
|
+
|
|
242
|
+
handlePostRegister();
|
|
190
243
|
} else {
|
|
191
|
-
// Parsing GMCore message 'cuz it's stupid and it doesn't know how to send error messages in 2021 ffs
|
|
244
|
+
// Parsing GMCore message 'cuz it's stupid and it doesn't know how to send error messages in 2021...2022 already ffs
|
|
245
|
+
// I really hope this piece of code won't survive long enough so that the years above will reach 2025 or something ... like, for real, please ... some real errors? plox ...
|
|
192
246
|
error = data.error.substring(data.error.indexOf('errorMessage') + 13, data.error.length);
|
|
193
247
|
showError = true;
|
|
194
248
|
window.postMessage({ type: "ShowRegistrationError", showError, error }, window.location.href);
|
|
195
249
|
}
|
|
196
250
|
}
|
|
197
251
|
|
|
198
|
-
const switchToLogin = () => {
|
|
252
|
+
const switchToLogin = ():void => {
|
|
199
253
|
window.postMessage({ type: "ToLogin" }, window.location.href);
|
|
200
254
|
}
|
|
201
255
|
|
|
256
|
+
const setActiveLanguage = ():void => {
|
|
257
|
+
setLocale(lang);
|
|
258
|
+
}
|
|
259
|
+
|
|
202
260
|
onMount(() => {
|
|
203
|
-
verifyUserConsents();
|
|
204
|
-
getCmsData();
|
|
205
261
|
window.addEventListener('message', messageHandler, false);
|
|
206
262
|
|
|
263
|
+
verifyUserConsents();
|
|
264
|
+
isOnNative = !!isNative(userAgent);
|
|
265
|
+
|
|
207
266
|
return () => {
|
|
208
267
|
window.removeEventListener('message', messageHandler);
|
|
209
268
|
}
|
|
210
269
|
});
|
|
211
270
|
|
|
271
|
+
$: cmsendpoint && getCmsData();
|
|
212
272
|
$: playerid && session;
|
|
273
|
+
$: lang && setActiveLanguage();
|
|
213
274
|
</script>
|
|
214
275
|
|
|
215
276
|
{#if isLoading}
|
|
@@ -229,17 +290,17 @@ $: playerid && session;
|
|
|
229
290
|
{/if}
|
|
230
291
|
{#if showRegisterStepOne}
|
|
231
292
|
<div class="RegisterFormStep1">
|
|
232
|
-
<general-player-register-form-step1 />
|
|
293
|
+
<general-player-register-form-step1 {lang} />
|
|
233
294
|
</div>
|
|
234
295
|
{/if}
|
|
235
296
|
{#if showRegisterStepTwo}
|
|
236
297
|
<div class="RegisterFormStep2">
|
|
237
|
-
<general-player-register-form-step2 {endpoint} />
|
|
298
|
+
<general-player-register-form-step2 {endpoint} {lang} {licenseyears} />
|
|
238
299
|
</div>
|
|
239
300
|
{/if}
|
|
240
301
|
{#if showRegisterStepThree}
|
|
241
302
|
<div class="RegisterFormStep3">
|
|
242
|
-
<general-player-register-form-step3 {userconsentsexist} {endpoint} {captchakey} />
|
|
303
|
+
<general-player-register-form-step3 {userconsentsexist} {endpoint} {captchakey} {lang} />
|
|
243
304
|
</div>
|
|
244
305
|
{/if}
|
|
245
306
|
{#if showConfirmation}
|
|
@@ -248,7 +309,7 @@ $: playerid && session;
|
|
|
248
309
|
<h2 class="RegisterConfirmationTitle">{accountCreationTitle}</h2>
|
|
249
310
|
<p class="RegisterConfirmationSubtitle">{accountCreationSubTitle}</p>
|
|
250
311
|
<p class="RegisterConfirmationNote">{accountCreationMessage}</p>
|
|
251
|
-
<button class="RegisterConfirmationGoToLogin" on:click={switchToLogin}>
|
|
312
|
+
<button class="RegisterConfirmationGoToLogin" on:click={switchToLogin}>{$_('registerForm.goToLoginButton')}</button>
|
|
252
313
|
</div>
|
|
253
314
|
{/if}
|
|
254
315
|
</div>
|
|
@@ -289,7 +350,7 @@ $: playerid && session;
|
|
|
289
350
|
scrollbar-color: #cfcfcf #f1f1f1;
|
|
290
351
|
scrollbar-width: thin;
|
|
291
352
|
&.RegisterFormContainerMobile {
|
|
292
|
-
padding:
|
|
353
|
+
padding: 40px 20px;;
|
|
293
354
|
height: auto;
|
|
294
355
|
overflow-y: initial;
|
|
295
356
|
}
|
|
@@ -311,15 +372,15 @@ $: playerid && session;
|
|
|
311
372
|
|
|
312
373
|
.RegisterSteps {
|
|
313
374
|
display: flex;
|
|
314
|
-
gap:
|
|
315
|
-
padding:
|
|
375
|
+
gap: 10px;
|
|
376
|
+
padding: 20px 0 30px;
|
|
316
377
|
}
|
|
317
378
|
|
|
318
379
|
.RegisterFirstStepDash,
|
|
319
380
|
.RegisterSecondStepDash,
|
|
320
381
|
.RegisterThirdStepDash {
|
|
321
|
-
width:
|
|
322
|
-
height:
|
|
382
|
+
width: 50px;
|
|
383
|
+
height: 2px;
|
|
323
384
|
background-color: #D1D1D1;
|
|
324
385
|
}
|
|
325
386
|
|
package/src/i18n.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import {
|
|
2
|
+
dictionary,
|
|
3
|
+
locale,
|
|
4
|
+
addMessages,
|
|
5
|
+
_
|
|
6
|
+
} from 'svelte-i18n';
|
|
7
|
+
|
|
8
|
+
function setupI18n({ withLocale: _locale, translations }) {
|
|
9
|
+
locale.subscribe((data) => {
|
|
10
|
+
if (data == null) {
|
|
11
|
+
dictionary.set(translations);
|
|
12
|
+
locale.set(_locale);
|
|
13
|
+
}
|
|
14
|
+
}); // maybe we will need this to make sure that the i18n is set up only once
|
|
15
|
+
/*dictionary.set(translations);
|
|
16
|
+
locale.set(_locale);*/
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function addNewMessages(lang, dict) {
|
|
20
|
+
addMessages(lang, dict);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function setLocale(_locale) {
|
|
24
|
+
locale.set(_locale);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export { _, setupI18n, addNewMessages, setLocale };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export const RegisterFormTranslations = {
|
|
2
|
+
en: {
|
|
3
|
+
registerForm: {
|
|
4
|
+
goToLoginButton: 'Go To Login',
|
|
5
|
+
}
|
|
6
|
+
},
|
|
7
|
+
tr: {
|
|
8
|
+
registerForm: {
|
|
9
|
+
goToLoginButton: 'Giriş Yap',
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
ro: {
|
|
13
|
+
registerForm: {
|
|
14
|
+
goToLoginButton: 'Catre Autentificare',
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
};
|