@everymatrix/player-profile-info 0.0.303 → 0.0.306

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.303",
3
+ "version": "0.0.306",
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": "2e4012fec1bb6695caae9c8d4877c56b4dc427a3"
39
+ "gitHead": "0ffc4733ddf2ecc310c00a80bcf3d56109977cd0"
40
40
  }
@@ -32,6 +32,11 @@
32
32
  let prefixesArray:Array<Object> = [];
33
33
  let countriesArray:Array<Object> = []
34
34
 
35
+ let profileConsent:Array<Object> = [];
36
+ let showEmail:boolean = false;
37
+ let showSMS:boolean = false;
38
+ let consentArray:any = { items: [] };
39
+
35
40
  let isValid:boolean = false;
36
41
 
37
42
  let invalidCity:string = '';
@@ -57,7 +62,8 @@
57
62
  address1: '',
58
63
  address2: '',
59
64
  city: '',
60
- consents: {acceptNewsEmail: false, acceptSMSOffers: false},
65
+ acceptNewsEmail: false,
66
+ acceptSMSOffers : false,
61
67
  country: '',
62
68
  mobile: {prefix: '', number: ''},
63
69
  postalCode: '',
@@ -83,7 +89,6 @@
83
89
  address1: "i.e.: Glanmire Rd.",
84
90
  birth: '01/01/1990',
85
91
  city: "i.e.: Cork",
86
- consents: {acceptNewsEmail: false, acceptSMSOffers: false},
87
92
  country: "i.e.: Ireland",
88
93
  currency: "EUR",
89
94
  email: "email@here.com",
@@ -119,8 +124,6 @@
119
124
  userTitles = profileDetails.title;
120
125
 
121
126
  // editable field values used for bindings
122
- giveConsentSMS = profileDetails.consents?.acceptSMSOffers;
123
- giveConsentEmail = profileDetails.consents?.acceptNewsEmail;
124
127
  playerQuestion = profileDetails.securityQuestion;
125
128
  playerAnswer = profileDetails.securityAnswer;
126
129
  playerPrefix = profileDetails.mobile?.prefix;
@@ -130,8 +133,6 @@
130
133
  initialValuesArray = {
131
134
  address: profileDetails.address1,
132
135
  city: profileDetails.city,
133
- acceptNewsEmail: profileDetails.consents?.acceptNewsEmail,
134
- acceptSMSOffers: profileDetails.consents?.acceptSMSOffers,
135
136
  mobilePrefix: mobile?.prefix,
136
137
  mobileNumber: mobile?.number,
137
138
  postalCode: profileDetails.postalCode,
@@ -140,6 +141,23 @@
140
141
  }
141
142
  break;
142
143
 
144
+ case 'ProfileConsentData':
145
+ profileConsent = e.data.consent.items;
146
+ if (Array.isArray(profileConsent)) {
147
+ profileConsent.forEach((item) => {
148
+ if (item.tagCode == 'emailmarketing') {
149
+ showEmail = true;
150
+ giveConsentEmail = item.status == 'Accepted';
151
+ initialValuesArray.acceptNewsEmail = giveConsentEmail;
152
+ } else if (item.tagCode == 'sms') {
153
+ showSMS = true;
154
+ giveConsentSMS = item.status == 'Accepted';
155
+ initialValuesArray.acceptSMSOffers = giveConsentSMS;
156
+ }
157
+ });
158
+ }
159
+ break;
160
+
143
161
  case 'ConfirmProfileInfoSave':
144
162
  if (isOnNative) {
145
163
  registerNativeEventListener(
@@ -300,6 +318,7 @@
300
318
  const updatePlayerInfo = ():void => {
301
319
  if (differencesExist == true && isValid == true) {
302
320
  window.postMessage({ type: 'UpdatePlayerInfo', provisionalArray }, window.location.href);
321
+ window.postMessage({ type: 'UpdatePlayerConsent', consentArray }, window.location.href);
303
322
  }
304
323
  }
305
324
 
@@ -321,9 +340,20 @@
321
340
  }
322
341
 
323
342
  checkEquality(provisionalArray, initialValuesArray);
343
+ consentData();
324
344
  checkIsValid();
325
345
  }
326
346
 
347
+ const consentData = ():void => {
348
+ if (showSMS) {
349
+ consentArray.items.push({'tagCode': 'sms', 'status': giveConsentSMS ? 'Accepted' : 'Denied'})
350
+ }
351
+
352
+ if (showEmail) {
353
+ consentArray.items.push({'tagCode': 'emailmarketing', 'status': giveConsentEmail ? 'Accepted' : 'Denied'})
354
+ }
355
+ }
356
+
327
357
  const resetPlayerInfo = ():void => {
328
358
  playerAddress.value = initialValuesArray.address;
329
359
  playerCity.value = initialValuesArray.city;
@@ -491,25 +521,31 @@
491
521
  </div>
492
522
  </section>
493
523
 
494
- <div class="PlayerNotificationsHeader" part="PlayerNotificationsHeader">
495
- <h3>{$_('playerProfile.userNotifications')}</h3>
496
- </div>
497
- <section class="PlayerNotificationsCheckboxArea" part="PlayerNotificationsCheckboxArea">
498
- <div class="PlayerNotificationBox" part="PlayerNotificationBox">
499
- <label for="SMSNotification">
500
- <input bind:checked={giveConsentSMS} on:change={checkForChanges} type="checkbox" id="SMSNotification" name="Enable SMS notifications" />
501
- <span class="Checkmark" part="Checkmark"></span>
502
- <span>{$_('playerProfile.userSMSNotification')}</span>
503
- </label>
504
- </div>
505
- <div class="PlayerNotificationBox" part="PlayerNotificationBox">
506
- <label for="EmailNotification">
507
- <input bind:checked={giveConsentEmail} on:change={checkForChanges} type="checkbox" id="EmailNotification" name="Enable Emails" />
508
- <span class="Checkmark" part="Checkmark"></span>
509
- <span>{$_('playerProfile.userEmailNotification')}</span>
510
- </label>
524
+ {#if showEmail || showSMS}
525
+ <div class="PlayerNotificationsHeader" part="PlayerNotificationsHeader">
526
+ <h3>{$_('playerProfile.userNotifications')}</h3>
511
527
  </div>
512
- </section>
528
+ <section class="PlayerNotificationsCheckboxArea" part="PlayerNotificationsCheckboxArea">
529
+ {#if showSMS}
530
+ <div class="PlayerNotificationBox" part="PlayerNotificationBox">
531
+ <label for="SMSNotification">
532
+ <input bind:checked={giveConsentSMS} on:change={checkForChanges} type="checkbox" id="SMSNotification" name="Enable SMS notifications" />
533
+ <span class="Checkmark" part="Checkmark"></span>
534
+ <span>{$_('playerProfile.userSMSNotification')}</span>
535
+ </label>
536
+ </div>
537
+ {/if}
538
+ {#if showEmail}
539
+ <div class="PlayerNotificationBox" part="PlayerNotificationBox">
540
+ <label for="EmailNotification">
541
+ <input bind:checked={giveConsentEmail} on:change={checkForChanges} type="checkbox" id="EmailNotification" name="Enable Emails" />
542
+ <span class="Checkmark" part="Checkmark"></span>
543
+ <span>{$_('playerProfile.userEmailNotification')}</span>
544
+ </label>
545
+ </div>
546
+ {/if}
547
+ </section>
548
+ {/if}
513
549
  {#if isOnNative}
514
550
  <div class="PlayerNotificationsHeader" part="PlayerNotificationsHeader">
515
551
  <h3>{$_('playerProfile.userAppSettings')}</h3>