@everymatrix/player-profile-info 0.0.199 → 0.0.203

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.199",
3
+ "version": "0.0.203",
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": "92884caad124fb581a2825d771ad76a424b2c98c"
39
+ "gitHead": "31d7d9eeef7e68b954b83fb3dde25db05d8edf74"
40
40
  }
@@ -3,8 +3,11 @@
3
3
  <script lang="typescript">
4
4
  import { onMount } from 'svelte';
5
5
  import { getDevice } from 'rvhelper';
6
+ import { _, addNewMessages, setLocale } from './i18n';
7
+ import { PlayerProfileTranslations } from './translations';
6
8
 
7
9
  export let endpoint:string = '';
10
+ export let lang:string = 'en';
8
11
 
9
12
  let isLoading:boolean = false;
10
13
  let userAgent:String = window.navigator.userAgent;
@@ -23,8 +26,15 @@
23
26
  let prefixesArray:Array<Object> = [];
24
27
  let countriesArray:Array<Object> = []
25
28
 
29
+ let invalidCity:string = '';
30
+ let invalidPostalCode:string = '';
31
+ let invalidAddress:string = '';
32
+
26
33
  let showConfirmSave:boolean = false;
27
34
 
35
+ Object.keys(PlayerProfileTranslations).forEach((item:any) => {
36
+ addNewMessages(item, PlayerProfileTranslations[item]);
37
+ });
28
38
  const mediaQuery = window.matchMedia('(min-width: 768px)');
29
39
 
30
40
  // needed to keep track of data changes
@@ -61,7 +71,7 @@
61
71
  currency: "EUR",
62
72
  email: "email@here.com",
63
73
  firstname: "Joe",
64
- gender: "M",
74
+ userTitles: "M",
65
75
  lastname: "Johnson",
66
76
  mobile: {prefix: "+00", number: "00000000"},
67
77
  postalCode: "i.e.: 465531",
@@ -71,7 +81,7 @@
71
81
  username: "Username"
72
82
  };
73
83
 
74
- let {address1, birth, city, country, currency, mobile, email, firstname, gender, language, lastname, postalCode, securityAnswer, securityQuestion, username, consents} = profileDetails;
84
+ let {address1, birth, city, country, currency, mobile, email, firstname, userTitles, language, lastname, postalCode, securityAnswer, securityQuestion, username, consents} = profileDetails;
75
85
 
76
86
  const messageHandler = (e:any) => {
77
87
  if (e.data) {
@@ -89,7 +99,7 @@
89
99
  language = profileDetails.language;
90
100
  birth = profileDetails.birth.day + '/' + profileDetails.birth.month + '/' + profileDetails.birth.year;
91
101
  currency = profileDetails.currency;
92
- gender = profileDetails.gender;
102
+ userTitles = profileDetails.title;
93
103
  country = profileDetails.country;
94
104
  // match country code to country name
95
105
  selectedCountry = countriesArray.find(country => country.Alpha2Code === profileDetails.country);
@@ -153,7 +163,7 @@
153
163
  let isValid:Boolean = false;
154
164
 
155
165
  const checkIsValid = () => {
156
- if (playerQuestion.length <= 0 || playerAnswer.length <= 0 || !playerCity.value || !playerAddress.value || !playerPostalCode.value || playerMobileNumber.length <= 0) {
166
+ if (playerQuestion.length <= 0 || playerAnswer.length <= 0 || invalidCity || invalidAddress || invalidPostalCode || playerMobileNumber.length <= 0) {
157
167
  isValid = false;
158
168
  }
159
169
  else {
@@ -161,6 +171,45 @@
161
171
  }
162
172
  }
163
173
 
174
+ const checkCity = () => {
175
+ if(playerCity.value && playerCity.value.length <= 50) {
176
+ return true;
177
+ }
178
+
179
+ return false;
180
+ }
181
+
182
+ const validateCity = () => {
183
+ invalidCity = !checkCity();
184
+ checkIsValid();
185
+ }
186
+
187
+ const checkPostalCode = () => {
188
+ if(playerPostalCode.value && playerPostalCode.value.length <= 20) {
189
+ return true;
190
+ }
191
+
192
+ return false;
193
+ }
194
+
195
+ const validatePostalCode = () => {
196
+ invalidPostalCode = !checkPostalCode();
197
+ checkIsValid();
198
+ }
199
+
200
+ const checkAddress = () => {
201
+ if(playerAddress.value && playerAddress.value.length <= 100) {
202
+ return true;
203
+ }
204
+
205
+ return false;
206
+ }
207
+
208
+ const validateAddress = () => {
209
+ invalidAddress = !checkAddress();
210
+ checkIsValid();
211
+ }
212
+
164
213
  const updatePlayerInfo = () => {
165
214
  if (differencesExist == true && isValid == true) {
166
215
  window.postMessage({ type: 'UpdatePlayerInfo', provisionalArray }, window.location.href);
@@ -213,6 +262,10 @@
213
262
  }
214
263
  }
215
264
 
265
+ const initialLoad = () => {
266
+ setLocale(lang);
267
+ }
268
+
216
269
  onMount(() => {
217
270
  window.addEventListener('message', messageHandler, false);
218
271
  return () => {
@@ -220,6 +273,7 @@
220
273
  }
221
274
  });
222
275
 
276
+ $: lang && initialLoad();
223
277
  $: endpoint && getCountriesList();
224
278
  $: endpoint && getPhoneCodes();
225
279
  </script>
@@ -236,22 +290,22 @@
236
290
  <path class="aaa" d="M7.5,0,6.136,1.364,11.3,6.526H0V8.474H11.3L6.136,13.636,7.5,15,15,7.5Z" transform="translate(15 15) rotate(180)"/>
237
291
  </g></g>
238
292
  </svg>
239
- <h2 class="MyAccountCategoryTitleMobile">Profile Info</h2>
293
+ <h2 class="MyAccountCategoryTitleMobile">{$_('playerProfile.title')}</h2>
240
294
  </div>
241
295
  {/if}
242
296
 
243
- <h2 class="MyAccountCategoryTitle {isMobile ? 'MyAccountCategoryTitleNone' : ''}">Profile Info</h2>
297
+ <h2 class="MyAccountCategoryTitle {isMobile ? 'MyAccountCategoryTitleNone' : ''}">{$_('playerProfile.title')}</h2>
244
298
 
245
299
  <div class="PlayerNotificationsHeader">
246
- <h3>Personal Details</h3>
300
+ <h3>{$_('playerProfile.personalDetails')}</h3>
247
301
  </div>
248
302
  <section class="PlayerDetailsContent">
249
303
  <div class="PlayerInfoBox">
250
- <label>User name:</label>
304
+ <label>{$_('playerProfile.userName')}</label>
251
305
  <input type="text" class="FieldDisabled" value={username} readonly />
252
306
  </div>
253
307
  <div class="PlayerInfoBox">
254
- <label>Phone:</label>
308
+ <label>{$_('playerProfile.userPhone')}</label>
255
309
  <div class="PlayerPhoneNumber">
256
310
  <select bind:value={playerPrefix} on:change={() => checkForChanges()}>
257
311
  {#each prefixesArray as pref}
@@ -266,86 +320,95 @@
266
320
  </div>
267
321
  </div>
268
322
  <div class="PlayerInfoBox">
269
- <label>Email:</label>
323
+ <label>{$_('playerProfile.userEmail')}</label>
270
324
  <input type="email" class="FieldDisabled" value={email} readonly />
271
325
  </div>
272
326
  <div class="PlayerInfoBox">
273
- <label>Security Question:</label>
327
+ <label>{$_('playerProfile.securityQuestion')}</label>
274
328
  <input type="text" bind:value={playerQuestion} on:keyup={() => checkForChanges()} placeholder={noPlayerData ? securityQuestion : ''} />
275
329
  </div>
276
330
  <div class="PlayerInfoBox">
277
- <label>First name:</label>
331
+ <label>{$_('playerProfile.firstName')}</label>
278
332
  <input type="text" class="FieldDisabled" value={firstname} readonly />
279
333
  </div>
280
334
  <div class="PlayerInfoBox">
281
- <label>Security Answer:</label>
335
+ <label>{$_('playerProfile.securityAnswer')}</label>
282
336
  <input type="text" bind:value={playerAnswer} on:keyup={() => checkForChanges()} placeholder={noPlayerData ? securityAnswer : ''} />
283
337
  </div>
284
338
  <div class="PlayerInfoBox">
285
- <label>Last Name:</label>
339
+ <label>{$_('playerProfile.lastName')}</label>
286
340
  <input type="text" class="FieldDisabled" value={lastname} readonly />
287
341
  </div>
288
342
  <div class="PlayerInfoBox">
289
- <label>Date of birth:</label>
343
+ <label>{$_('playerProfile.dateOfBirth')}</label>
290
344
  <input type="text" class="FieldDisabled" value={birth} readonly />
291
345
  </div>
292
346
  <div class="PlayerInfoBox">
293
- <label>Currency:</label>
347
+ <label>{$_('playerProfile.currency')}</label>
294
348
  <input type="text" class="FieldDisabled" value={currency} readonly />
295
349
  </div>
296
350
  <div class="PlayerInfoBox">
297
- <label>Title:</label>
298
- <input type="text" class="FieldDisabled" value={gender} readonly />
351
+ <label>{$_('playerProfile.userTitle')}</label>
352
+ <input type="text" class="FieldDisabled" value={userTitles} readonly />
299
353
  </div>
300
354
  </section>
301
355
 
302
356
  <div class="PlayerLocationHeader">
303
- <h3>Location Details</h3>
357
+ <h3>{$_('playerProfile.locationDetails')}</h3>
304
358
  </div>
305
359
  <section class="PlayerLocationContent">
306
360
  <div class="PlayerInfoBox">
307
- <label>Country:</label>
361
+ <label>{$_('playerProfile.userCountry')}</label>
308
362
  <input type="text" class="PlayerCountry FieldDisabled" placeholder={country} value={selectedCountry.Name} readonly />
309
363
  </div>
310
- <div class="PlayerInfoBox">
311
- <label>City:</label>
312
- <input bind:this={playerCity} type="text" on:keyup={() => checkForChanges()} placeholder={noPlayerData ? city : ''} value={noPlayerData ? '' : initialValuesArray.city} />
364
+ <div class="PlayerInfoBox {invalidCity ? 'InvalidField' : ''}">
365
+ <label>{$_('playerProfile.userCity')}</label>
366
+ <input bind:this={playerCity} type="text" on:blur={validateCity} on:keyup={() => checkForChanges()} placeholder={noPlayerData ? city : ''} value={noPlayerData ? '' : initialValuesArray.city} />
367
+ {#if invalidCity}
368
+ <p class="InvalidInput">City must be at least 1 character long and 50 characters maximum.</p>
369
+ {/if}
313
370
  </div>
314
- <div class="PlayerInfoBox">
315
- <label>Address:</label>
316
- <input bind:this={playerAddress} placeholder={address1} type="text" on:keyup={() => checkForChanges()} value={noPlayerData ? '' : initialValuesArray.address} />
371
+ <div class="PlayerInfoBox {invalidAddress ? 'InvalidField' : ''}">
372
+ <label>{$_('playerProfile.userAddress')}</label>
373
+ <input bind:this={playerAddress} placeholder={address1} type="text" on:blur={validateAddress} on:keyup={() => checkForChanges()} value={noPlayerData ? '' : initialValuesArray.address} />
374
+ {#if invalidAddress}
375
+ <p class="InvalidInput">Address must be at least 1 character long and 100 characters maximum.</p>
376
+ {/if}
317
377
  </div>
318
- <div class="PlayerInfoBox">
319
- <label>Postal Code:</label>
320
- <input bind:this={playerPostalCode} type="number" on:keyup={() => checkForChanges()} placeholder={noPlayerData ? postalCode : ''} value={noPlayerData ? '' : initialValuesArray.postalCode} />
378
+ <div class="PlayerInfoBox {invalidPostalCode ? 'InvalidField' : ''}">
379
+ <label>{$_('playerProfile.userPostalCode')}</label>
380
+ <input bind:this={playerPostalCode} type="number" on:blur={validatePostalCode} on:keyup={() => checkForChanges()} placeholder={noPlayerData ? postalCode : ''} value={noPlayerData ? '' : initialValuesArray.postalCode} />
381
+ {#if invalidPostalCode}
382
+ <p class="InvalidInput">Postal Code must be at least 1 character long and 20 characters maximum.</p>
383
+ {/if}
321
384
  </div>
322
385
  </section>
323
386
 
324
387
  <div class="PlayerNotificationsHeader">
325
- <h3>Notifications</h3>
388
+ <h3>{$_('playerProfile.userNotifications')}</h3>
326
389
  </div>
327
390
  <section class="PlayerNotificationsCheckboxArea">
328
391
  <div class="PlayerNotificationBox">
329
392
  <label for="SMSNotification">
330
393
  <input bind:checked={giveConsentSMS} on:change={checkForChanges} type="checkbox" id="SMSNotification" name="Enable SMS notifications" />
331
394
  <span class="Checkmark"></span>
332
- <span>Enable SMS notifications</span>
395
+ <span>{$_('playerProfile.userSMSNotification')}</span>
333
396
  </label>
334
397
  </div>
335
398
  <div class="PlayerNotificationBox">
336
399
  <label for="EmailNotification">
337
400
  <input bind:checked={giveConsentEmail} on:change={checkForChanges} type="checkbox" id="EmailNotification" name="Enable Emails" />
338
401
  <span class="Checkmark"></span>
339
- <span>Enable Emails</span>
402
+ <span>{$_('playerProfile.userEmailNotification')}</span>
340
403
  </label>
341
404
  </div>
342
405
  </section>
343
406
  <section class="PlayerDetailsButtonsArea {isMobile ? 'PlayerDetailsButtonsAreaMobile' : ''}">
344
- <div class="PlayerDetailsSaveButton {differencesExist && isValid ? '' : 'PlayerButtonDisabled'}" on:click={() => updatePlayerInfo()}>Save Changes</div>
407
+ <div class="PlayerDetailsSaveButton {differencesExist && isValid ? '' : 'PlayerButtonDisabled'}" on:click={() => updatePlayerInfo()}>{$_('playerProfile.userProfileSaveChanges')}</div>
345
408
  </section>
346
409
  {#if showConfirmSave}
347
410
  <section class="PlayerDetailsConfirmSave">
348
- <p class="PlayerDetailsConfirmSaveText">Your changes have been saved!</p>
411
+ <p class="PlayerDetailsConfirmSaveText">{$_('playerProfile.userProfileConfirmationMessage')}</p>
349
412
  </section>
350
413
  {/if}
351
414
  </form>
@@ -436,6 +499,22 @@
436
499
  box-shadow: 0 0 0 1pt #D0046C;
437
500
  }
438
501
  }
502
+
503
+ &.InvalidField {
504
+ input {
505
+ border: 1px solid #FD2839;
506
+ background: #FFF1F1;
507
+ color: #FD2839;
508
+ }
509
+ }
510
+
511
+ .InvalidInput {
512
+ color: #FD2839;
513
+ font-size: 10px;
514
+ line-height: 10px;
515
+ }
516
+
517
+
439
518
  .FieldDisabled {
440
519
  opacity: 0.5;
441
520
  }
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,54 @@
1
+ export const PlayerProfileTranslations = {
2
+ en: {
3
+ playerProfile: {
4
+ title: `Profile Info`,
5
+ personalDetails: `Personal Details`,
6
+ userName: `User name:`,
7
+ userPhone: `Phone:`,
8
+ userEmail: `Email:`,
9
+ securityQuestion: `Security Question:`,
10
+ firstName: `First name:`,
11
+ securityAnswer: `Security Answer:`,
12
+ lastName: `Last Name:`,
13
+ dateOfBirth: `Date of birth:`,
14
+ currency: `Currency:`,
15
+ userTitle: `Title:`,
16
+ locationDetails: `Location Details`,
17
+ userCountry: `Country:`,
18
+ userCity: `City:`,
19
+ userAddress: `Address:`,
20
+ userPostalCode: `Postal Code:`,
21
+ userNotifications: `Notifications`,
22
+ userSMSNotification: `Enable SMS notifications`,
23
+ userEmailNotification: `Enable Emails`,
24
+ userProfileSaveChanges: `Save Changes`,
25
+ userProfileConfirmationMessage: `Your changes have been saved!`
26
+ }
27
+ },
28
+ ro: {
29
+ playerProfile: {
30
+ title: `Informații profil`,
31
+ personalDetails: `Detalii Personale`,
32
+ userName: `Nume utilizator:`,
33
+ userPhone: `Telefon:`,
34
+ userEmail: `E-mail:`,
35
+ securityQuestion: `Întrebare securitate:`,
36
+ firstName: `Prenume:`,
37
+ securityAnswer: `Răspuns securitate:`,
38
+ lastName: `Nume:`,
39
+ dateOfBirth: `Data nașterii:`,
40
+ currency: `Monedă:`,
41
+ userTitle: `Titlu:`,
42
+ locationDetails: `Detalii de Localizare`,
43
+ userCountry: `Țară:`,
44
+ userCity: `Oraș:`,
45
+ userAddress: `Adresă:`,
46
+ userPostalCode: `Cod poștal:`,
47
+ userNotifications: `Notificări`,
48
+ userSMSNotification: `Activează notificări prin SMS`,
49
+ userEmailNotification: `Activează notificări prin E-mail`,
50
+ userProfileSaveChanges: `Salvează`,
51
+ userProfileConfirmationMessage: `Modificările au fost salvate!`
52
+ }
53
+ }
54
+ };