@everymatrix/player-profile-info 0.0.215 → 0.0.219

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/player-profile-info",
3
- "version": "0.0.215",
3
+ "version": "0.0.219",
4
4
  "main": "dist/player-profile-info.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": "9c9f7a9e6a715010e0746e271e930d92e64e16d2"
39
+ "gitHead": "b1dd26e91c542c1d18b2f2d8f1dbb391eb2330ee"
40
40
  }
@@ -6,17 +6,22 @@
6
6
  import { _, addNewMessages, setLocale } from './i18n';
7
7
  import { PlayerProfileTranslations } from './translations';
8
8
 
9
+ // Native bridge
10
+ import { isNative, call as callNative, registerEventListener as registerNativeEventListener } from 'js-native-bridge';
11
+
12
+
9
13
  export let endpoint:string = '';
10
14
  export let lang:string = 'en';
11
15
 
12
16
  let isLoading:boolean = false;
13
- let userAgent:String = window.navigator.userAgent;
14
- let isMobile = (getDevice(userAgent) === 'PC') ? false : true;
17
+ let userAgent:string = window.navigator.userAgent;
18
+ let isMobile:boolean = (getDevice(userAgent) === 'PC') ? false : true;
15
19
  let noPlayerData:boolean = true;
16
20
 
17
21
  let playerPostalCode:HTMLElement, playerAddress:HTMLElement, playerCity:HTMLElement;
18
22
  let giveConsentSMS:boolean = false;
19
23
  let giveConsentEmail:boolean = false;
24
+ let biometricsSelection:boolean = false;
20
25
  let playerQuestion:string = '';
21
26
  let playerAnswer:string = '';
22
27
  let playerPrefix:string = '';
@@ -26,19 +31,24 @@
26
31
  let prefixesArray:Array<Object> = [];
27
32
  let countriesArray:Array<Object> = []
28
33
 
34
+ let isValid:boolean = false;
29
35
 
30
36
  let invalidCity:string = '';
31
37
  let invalidPostalCode:string = '';
32
38
  let invalidAddress:string = '';
33
- let invalidSecurityQuestion:Boolean = false;
34
- let invalidSecurityAnswer:Boolean = false;
35
- let invalidMobile:string = '';
39
+ let invalidSecurityQuestion:boolean = false;
40
+ let invalidSecurityAnswer:boolean = false;
41
+ let invalidMobile:boolean;
36
42
 
37
43
  let showConfirmSave:boolean = false;
38
44
 
45
+ // Native bridge
46
+ let isOnNative:boolean = false;
47
+
39
48
  Object.keys(PlayerProfileTranslations).forEach((item:any) => {
40
49
  addNewMessages(item, PlayerProfileTranslations[item]);
41
50
  });
51
+
42
52
  const mediaQuery = window.matchMedia('(min-width: 768px)');
43
53
 
44
54
  // needed to keep track of data changes
@@ -53,6 +63,7 @@
53
63
  securityAnswer: '',
54
64
  securityQuestion: '',
55
65
  }
66
+
56
67
  // needed to keep track of data changes
57
68
  let initialValuesArray:any = {
58
69
  acceptNewsEmail: false,
@@ -65,6 +76,7 @@
65
76
  securityAnswer: '',
66
77
  securityQuestion: ''
67
78
  }
79
+
68
80
  // placeholder field values
69
81
  let profileDetails:any = {
70
82
  address1: "i.e.: Glanmire Rd.",
@@ -87,7 +99,7 @@
87
99
 
88
100
  let {address1, birth, city, country, currency, mobile, email, firstname, userTitles, language, lastname, postalCode, securityAnswer, securityQuestion, username, consents} = profileDetails;
89
101
 
90
- const messageHandler = (e:any) => {
102
+ const messageHandler = (e:any):void => {
91
103
  if (e.data) {
92
104
  switch(e.data.type) {
93
105
  case 'ProfileDetailsData':
@@ -128,22 +140,37 @@
128
140
  securityAnswer: profileDetails.securityAnswer,
129
141
  securityQuestion: profileDetails.securityQuestion,
130
142
  }
131
-
132
143
  break;
133
144
 
134
145
  case 'ConfirmProfileInfoSave':
146
+ if (isOnNative) {
147
+ registerNativeEventListener(
148
+ 'BIOMETRICS_ENABLED',
149
+ (biometricsEnabled) => {
150
+ if (biometricsEnabled !== biometricsSelection) {
151
+ biometricsSelection = biometricsEnabled;
152
+ }
153
+ },
154
+ );
155
+
156
+ const methodFound = callNative(
157
+ biometricsSelection ? 'ENABLE_BIOMETRICS' : 'DISABLE_BIOMETRICS',
158
+ );
159
+
160
+ if (!methodFound) {
161
+ // Nothing to do here yet
162
+ }
163
+ }
164
+
135
165
  differencesExist = false;
136
- showConfirmMessage();
137
- break;
138
166
 
139
- default:
140
- // do nothing
141
- break;
167
+ showConfirmMessage();
168
+ break;
142
169
  }
143
170
  }
144
171
  }
145
172
 
146
- const getCountriesList = () => {
173
+ const getCountriesList = ():void => {
147
174
  fetch(`${endpoint}/player/countries`)
148
175
  .then((res:any) => res.json())
149
176
  .then(data => {
@@ -151,7 +178,7 @@
151
178
  });
152
179
  }
153
180
 
154
- const getPhoneCodes = () => {
181
+ const getPhoneCodes = ():void => {
155
182
  fetch(`${endpoint}/player/phonecodes`)
156
183
  .then((res:any) => res.json())
157
184
  .then(data => {
@@ -159,14 +186,13 @@
159
186
  });
160
187
  }
161
188
 
162
- const showConfirmMessage = () => {
189
+ const showConfirmMessage = ():void => {
163
190
  showConfirmSave = true;
164
191
  setTimeout(() => {showConfirmSave = false;}, 3000);
165
192
  }
166
193
 
167
- let isValid:Boolean = false;
168
194
 
169
- const checkIsValid = () => {
195
+ const checkIsValid = ():void => {
170
196
  if (invalidSecurityQuestion || invalidSecurityAnswer || invalidCity || invalidAddress || invalidPostalCode || invalidMobile) {
171
197
  isValid = false;
172
198
  }
@@ -175,7 +201,7 @@
175
201
  }
176
202
  }
177
203
 
178
- const checkMobile = () => {
204
+ const checkMobile = ():boolean => {
179
205
  if(playerMobileNumber && playerMobileNumber.length >= 5 && playerMobileNumber.length <= 30) {
180
206
  return true;
181
207
  }
@@ -183,12 +209,12 @@
183
209
  return false;
184
210
  }
185
211
 
186
- const validateMobile = () => {
212
+ const validateMobile = ():void => {
187
213
  invalidMobile = !checkMobile();
188
214
  checkIsValid();
189
215
  }
190
216
 
191
- const checkSecurityQuestion = () => {
217
+ const checkSecurityQuestion = ():boolean => {
192
218
  if (playerQuestion && playerQuestion.length <= 120) {
193
219
  return true;
194
220
  }
@@ -196,12 +222,12 @@
196
222
  return false;
197
223
  }
198
224
 
199
- const validateSecurityQuestion = () => {
225
+ const validateSecurityQuestion = ():void => {
200
226
  invalidSecurityQuestion = !checkSecurityQuestion();
201
227
  checkIsValid();
202
228
  }
203
229
 
204
- const checkSecurityAnswer = () => {
230
+ const checkSecurityAnswer = ():boolean => {
205
231
  if (playerAnswer && playerAnswer.length <= 120) {
206
232
  return true;
207
233
  }
@@ -209,38 +235,38 @@
209
235
  return false;
210
236
  }
211
237
 
212
- const validateSecurityAnswer = () => {
238
+ const validateSecurityAnswer = ():void => {
213
239
  invalidSecurityAnswer = !checkSecurityAnswer();
214
240
  checkIsValid();
215
241
  }
216
242
 
217
- const checkCity = () => {
218
- if(playerCity.value && playerCity.value.length <= 50) {
243
+ const checkCity = ():boolean => {
244
+ if (playerCity.value && playerCity.value.length <= 50) {
219
245
  return true;
220
246
  }
221
247
 
222
248
  return false;
223
249
  }
224
250
 
225
- const validateCity = () => {
251
+ const validateCity = ():void => {
226
252
  invalidCity = !checkCity();
227
253
  checkIsValid();
228
254
  }
229
255
 
230
- const checkPostalCode = () => {
231
- if(playerPostalCode.value && playerPostalCode.value.length <= 20) {
256
+ const checkPostalCode = ():boolean => {
257
+ if (playerPostalCode.value && playerPostalCode.value.length <= 20) {
232
258
  return true;
233
259
  }
234
260
 
235
261
  return false;
236
262
  }
237
263
 
238
- const validatePostalCode = () => {
264
+ const validatePostalCode = ():void => {
239
265
  invalidPostalCode = !checkPostalCode();
240
266
  checkIsValid();
241
267
  }
242
268
 
243
- const checkAddress = () => {
269
+ const checkAddress = ():boolean => {
244
270
  if(playerAddress.value && playerAddress.value.length <= 100) {
245
271
  return true;
246
272
  }
@@ -248,23 +274,22 @@
248
274
  return false;
249
275
  }
250
276
 
251
- const validateAddress = () => {
277
+ const validateAddress = ():void => {
252
278
  invalidAddress = !checkAddress();
253
279
  checkIsValid();
254
280
  }
255
281
 
256
- const updatePlayerInfo = () => {
282
+ const updatePlayerInfo = ():void => {
257
283
  if (differencesExist == true && isValid == true) {
258
284
  window.postMessage({ type: 'UpdatePlayerInfo', provisionalArray }, window.location.href);
259
285
  }
260
286
  }
261
287
 
262
- const toggleScreen = () => {
288
+ const toggleScreen = ():void => {
263
289
  window.postMessage({ type: 'ReturnToMenu' }, window.location.href);
264
290
  }
265
291
 
266
- const checkForChanges = () => {
267
-
292
+ const checkForChanges = ():void => {
268
293
  provisionalArray = {
269
294
  acceptNewsEmail: giveConsentEmail,
270
295
  acceptSMSOffers: giveConsentSMS,
@@ -281,9 +306,7 @@
281
306
  checkIsValid();
282
307
  }
283
308
 
284
- const resetPlayerInfo = () => {
285
- // provisionalArray = initialValuesArray;
286
-
309
+ const resetPlayerInfo = ():void => {
287
310
  playerAddress.value = initialValuesArray.address;
288
311
  playerCity.value = initialValuesArray.city;
289
312
  giveConsentEmail = initialValuesArray.acceptNewsEmail;
@@ -297,7 +320,7 @@
297
320
  toggleScreen();
298
321
  }
299
322
 
300
- const checkEquality = (a, b) => {
323
+ const checkEquality = (a, b):void => {
301
324
  if(JSON.stringify(a) === JSON.stringify(b)) {
302
325
  differencesExist = false;
303
326
  } else {
@@ -305,18 +328,32 @@
305
328
  }
306
329
  }
307
330
 
308
- const initialLoad = () => {
331
+ const setActiveLanguage = ():void => {
309
332
  setLocale(lang);
310
333
  }
311
334
 
312
335
  onMount(() => {
313
336
  window.addEventListener('message', messageHandler, false);
337
+
338
+ isOnNative = !!isNative(userAgent);
339
+
340
+ if (isOnNative) {
341
+ registerNativeEventListener(
342
+ 'BIOMETRICS_ENABLED',
343
+ (biometricsEnabled) => {
344
+ biometricsSelection = !!biometricsEnabled
345
+ },
346
+ );
347
+
348
+ callNative('BIOMETRICS_ENABLED');
349
+ }
350
+
314
351
  return () => {
315
352
  window.removeEventListener('message', messageHandler);
316
353
  }
317
354
  });
318
355
 
319
- $: lang && initialLoad();
356
+ $: lang && setActiveLanguage();
320
357
  $: endpoint && getCountriesList();
321
358
  $: endpoint && getPhoneCodes();
322
359
  </script>
@@ -455,6 +492,20 @@
455
492
  </label>
456
493
  </div>
457
494
  </section>
495
+ {#if isOnNative}
496
+ <div class="PlayerNotificationsHeader">
497
+ <h3>{$_('playerProfile.userAppSettings')}</h3>
498
+ </div>
499
+ <section class="PlayerNotificationsCheckboxArea">
500
+ <div class="PlayerNotificationBox">
501
+ <label for="Biometrics">
502
+ <input bind:checked={biometricsSelection} on:change={checkForChanges} type="checkbox" id="BiometricsEnabled" name="Biometric Enabled" />
503
+ <span class="Checkmark"></span>
504
+ <span>{$_('playerProfile.userBiometrics')}</span>
505
+ </label>
506
+ </div>
507
+ </section>
508
+ {/if}
458
509
  <section class="PlayerDetailsButtonsArea {isMobile ? 'PlayerDetailsButtonsAreaMobile' : ''}">
459
510
  <div class="PlayerDetailsSaveButton {differencesExist && isValid ? '' : 'PlayerButtonDisabled'}" on:click={() => updatePlayerInfo()}>{$_('playerProfile.userProfileSaveChanges')}</div>
460
511
  </section>
@@ -25,7 +25,9 @@ export const PlayerProfileTranslations = {
25
25
  userPostalCode: `Postal Code:`,
26
26
  userPostalCodeError: 'Postal Code must be at least 1 character long and 20 characters maximum.',
27
27
  userNotifications: `Notifications`,
28
+ userAppSettings: `Biometrics`,
28
29
  userSMSNotification: `Enable SMS notifications`,
30
+ userBiometrics: `Enable biometrics`,
29
31
  userEmailNotification: `Enable Emails`,
30
32
  userProfileSaveChanges: `Save Changes`,
31
33
  userProfileConfirmationMessage: `Your changes have been saved!`