@everymatrix/player-profile-info 0.0.202 → 0.0.206

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.202",
3
+ "version": "0.0.206",
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": "d4e45d04feaefeedf3a6530ff705136d3a49ed86"
39
+ "gitHead": "19b20a886db165955575009bd82cc36d837d74d0"
40
40
  }
@@ -26,6 +26,10 @@
26
26
  let prefixesArray:Array<Object> = [];
27
27
  let countriesArray:Array<Object> = []
28
28
 
29
+ let invalidCity:string = '';
30
+ let invalidPostalCode:string = '';
31
+ let invalidAddress:string = '';
32
+
29
33
  let showConfirmSave:boolean = false;
30
34
 
31
35
  Object.keys(PlayerProfileTranslations).forEach((item:any) => {
@@ -159,7 +163,7 @@
159
163
  let isValid:Boolean = false;
160
164
 
161
165
  const checkIsValid = () => {
162
- 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) {
163
167
  isValid = false;
164
168
  }
165
169
  else {
@@ -167,6 +171,45 @@
167
171
  }
168
172
  }
169
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
+
170
213
  const updatePlayerInfo = () => {
171
214
  if (differencesExist == true && isValid == true) {
172
215
  window.postMessage({ type: 'UpdatePlayerInfo', provisionalArray }, window.location.href);
@@ -318,17 +361,26 @@
318
361
  <label>{$_('playerProfile.userCountry')}</label>
319
362
  <input type="text" class="PlayerCountry FieldDisabled" placeholder={country} value={selectedCountry.Name} readonly />
320
363
  </div>
321
- <div class="PlayerInfoBox">
364
+ <div class="PlayerInfoBox {invalidCity ? 'InvalidField' : ''}">
322
365
  <label>{$_('playerProfile.userCity')}</label>
323
- <input bind:this={playerCity} type="text" on:keyup={() => checkForChanges()} placeholder={noPlayerData ? city : ''} value={noPlayerData ? '' : initialValuesArray.city} />
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}
324
370
  </div>
325
- <div class="PlayerInfoBox">
371
+ <div class="PlayerInfoBox {invalidAddress ? 'InvalidField' : ''}">
326
372
  <label>{$_('playerProfile.userAddress')}</label>
327
- <input bind:this={playerAddress} placeholder={address1} type="text" on:keyup={() => checkForChanges()} value={noPlayerData ? '' : initialValuesArray.address} />
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}
328
377
  </div>
329
- <div class="PlayerInfoBox">
378
+ <div class="PlayerInfoBox {invalidPostalCode ? 'InvalidField' : ''}">
330
379
  <label>{$_('playerProfile.userPostalCode')}</label>
331
- <input bind:this={playerPostalCode} type="number" on:keyup={() => checkForChanges()} placeholder={noPlayerData ? postalCode : ''} value={noPlayerData ? '' : initialValuesArray.postalCode} />
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}
332
384
  </div>
333
385
  </section>
334
386
 
@@ -447,6 +499,22 @@
447
499
  box-shadow: 0 0 0 1pt #D0046C;
448
500
  }
449
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
+
450
518
  .FieldDisabled {
451
519
  opacity: 0.5;
452
520
  }