@everymatrix/general-player-register-form-step2 0.0.249 → 0.0.252

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-step2",
3
- "version": "0.0.249",
3
+ "version": "0.0.252",
4
4
  "main": "dist/general-player-register-form-step2.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": "38af455e241b6ef7ccabb2367be2be59e6b24352"
39
+ "gitHead": "6824e7c03c551fb8c35921b8846fdbbb49f76169"
40
40
  }
@@ -12,6 +12,7 @@
12
12
 
13
13
  let invalidFirstName:boolean = false;
14
14
  let invalidLastName:boolean = false;
15
+ let invalidBirthDate:boolean = false;
15
16
  let invalidBirthPlace:boolean = false;
16
17
 
17
18
  let userTitleSelected:string;
@@ -29,6 +30,7 @@
29
30
  let currentDate:Date = new Date();
30
31
  let minDate:number;
31
32
  let maxDate:number;
33
+ let yearsDifference:string;
32
34
 
33
35
  let isValid:boolean = false;
34
36
  let isLoading:boolean = true;
@@ -50,6 +52,15 @@
50
52
  isLoading = false;
51
53
  }
52
54
 
55
+ const validateBirthDate = ():void => {
56
+ if (birthYearSelected && birthMonthSelected && birthDaySelected) {
57
+ yearsDifference = moment(currentDate.setDate(currentDate.getDate())).diff(moment(`${birthYearSelected}-${birthMonthSelected}-${birthDaySelected}`, 'YYYY-MM-DD'), 'years').toString();
58
+ invalidBirthDate = (yearsDifference < licenseyears);
59
+ }
60
+
61
+ checkIsValid();
62
+ }
63
+
53
64
  const getCurrencies = ():void => {
54
65
  fetch(`${endpoint}/player/operatorSupportedCurrencies`)
55
66
  .then((res:any) => res.json())
@@ -63,7 +74,7 @@
63
74
  }
64
75
 
65
76
  const checkIsValid = ():void => {
66
- isValid = !(invalidFirstName || invalidLastName || invalidBirthPlace);
77
+ isValid = !(invalidFirstName || invalidLastName || invalidBirthDate || invalidBirthPlace);
67
78
 
68
79
  if (userFirstName.length <= 0 || userLastName.length <= 0 || birthPlace.length <= 0 || !userTitleSelected || !birthDaySelected || !birthMonthSelected || !birthYearSelected) {
69
80
  isValid = false;
@@ -179,7 +190,7 @@
179
190
  <div class="RegisterFormContent" part="RegisterFormContent">
180
191
  <div class="UserTitleContainer" part="UserTitleContainer">
181
192
  <label for="Title">{$_('registerFormStep2.registerUserTitle')}:<span class="FormRequired" part="FormRequired">*</span></label>
182
- <select bind:value={userTitleSelected} on:blur={checkIsValid} id="Title">
193
+ <select bind:value={userTitleSelected} on:change={checkIsValid} id="Title">
183
194
  <option value="" disabled selected>{$_('registerFormStep2.registerUserTitleSelect')}</option>
184
195
  <option value="Mr.">{$_('registerFormStep2.registerUserTitleSelectMr')}</option>
185
196
  <option value="Mrs.">{$_('registerFormStep2.registerUserTitleSelectMrs')}</option>
@@ -201,21 +212,21 @@
201
212
  {/if}
202
213
  </div>
203
214
  <div class="BirthDateContainer" part="BirthDateContainer">
204
- <label for="BirthDate">{$_('registerFormStep2.registerDateOfBirth')}:<span class="FormRequired" part="FormRequired">*</span></label>
215
+ <label>{$_('registerFormStep2.registerDateOfBirth')}:<span class="FormRequired" part="FormRequired">*</span></label>
205
216
  <div class="BirthDateOptions" part="BirthDateOptions">
206
- <select bind:value={birthDaySelected} on:blur={checkIsValid} class="BirthDaySelected" part="BirthDaySelected">
217
+ <select bind:value={birthDaySelected} on:change={validateBirthDate} class="BirthDaySelected" part="BirthDaySelected">
207
218
  <option value="" disabled selected>{$_('registerFormStep2.registerBirthDay')}</option>
208
219
  {#each birthDays as birthDay}
209
220
  <option value={birthDay}>{birthDay}</option>
210
221
  {/each}
211
222
  </select>
212
- <select bind:value={birthMonthSelected} on:blur={checkIsValid} class="BirthMonthSelected" part="BirthMonthSelected">
223
+ <select bind:value={birthMonthSelected} on:change={validateBirthDate} class="BirthMonthSelected" part="BirthMonthSelected">
213
224
  <option value="" disabled selected>{$_('registerFormStep2.registerBirthMonth')}</option>
214
225
  {#each birthMonths as birthMonth}
215
226
  <option value={birthMonth}>{birthMonth}</option>
216
227
  {/each}
217
228
  </select>
218
- <select bind:value={birthYearSelected} on:blur={checkIsValid} class="BirthYearSelected" part="BirthYearSelected">
229
+ <select bind:value={birthYearSelected} on:change={validateBirthDate} class="BirthYearSelected" part="BirthYearSelected">
219
230
  <option value="" disabled selected>{$_('registerFormStep2.registerBirthYear')}</option>
220
231
  {#if !isLoading}
221
232
  {#each birthYears as birthYear}
@@ -223,6 +234,9 @@
223
234
  {/each}
224
235
  {/if}
225
236
  </select>
237
+ {#if invalidBirthDate}
238
+ <p class="InvalidInput" part="InvalidInput">{$_('registerFormStep2.registerBirthDateError', { values: { licenseyears: licenseyears}})}</p>
239
+ {/if}
226
240
  </div>
227
241
  </div>
228
242
  <div class="BirthPlaceContainer {invalidBirthPlace ? 'InvalidField' : ''}" part="BirthPlaceContainer {invalidBirthPlace ? 'InvalidField' : ''}">
@@ -15,6 +15,7 @@ export const RegisterFormStep2Translations = {
15
15
  registerBirthDay: 'Day',
16
16
  registerBirthMonth: 'Month',
17
17
  registerBirthYear: 'Year',
18
+ registerBirthDateError: `The minimum registratione age is {licenseyears} years.`,
18
19
  registerBirthPlace: 'Birth Place',
19
20
  registerBirthPlaceError: 'Birth place must be at least 1 character long.',
20
21
  registerCurrency: 'Currency',
@@ -37,6 +38,7 @@ export const RegisterFormStep2Translations = {
37
38
  registerBirthDay: 'Gün',
38
39
  registerBirthMonth: 'Ay',
39
40
  registerBirthYear: 'Yıl',
41
+ registerBirthDateError: `Minimum kayıt yaşı {licenseyears} yıllar.`,
40
42
  registerBirthPlace: 'Doğum yeri',
41
43
  registerBirthPlaceError: 'Doğum yeri en az 1 karakter uzunluğunda olmalıdır.',
42
44
  registerCurrency: 'Para birimi',
@@ -59,6 +61,7 @@ export const RegisterFormStep2Translations = {
59
61
  registerBirthDay: 'Zi',
60
62
  registerBirthMonth: 'Luna',
61
63
  registerBirthYear: 'An',
64
+ registerBirthDateError: `Varsta minima pentru inregistrare este de {licenseyears} ani.`,
62
65
  registerBirthPlace: 'Locule nasterii',
63
66
  registerBirthPlaceError: 'Locul nasterii trebuie sa contina minim o litera',
64
67
  registerCurrency: 'Moneda',