@everymatrix/player-profile-info 1.43.2 → 1.43.4
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +1 -0
- package/dist/player-profile-info.js +1 -1
- package/dist/player-profile-info.js.map +1 -1
- package/package.json +2 -2
- package/src/PlayerProfileInfo.svelte +342 -349
- package/src/translations.js +20 -10
@@ -1,111 +1,37 @@
|
|
1
1
|
<svelte:options tag={null} />
|
2
2
|
|
3
3
|
<script lang="ts">
|
4
|
-
import { onMount } from 'svelte';
|
5
4
|
import { getDevice } from 'rvhelper';
|
6
5
|
import { _, addNewMessages, setLocale } from './i18n';
|
7
6
|
import { TRANSLATIONS } from './translations';
|
8
7
|
|
9
|
-
export let
|
8
|
+
export let userid:string;
|
9
|
+
export let sessionid:string;
|
10
|
+
export let endpoint:string;
|
10
11
|
export let lang:string = 'en';
|
11
|
-
export let
|
12
|
-
export let
|
13
|
-
export let
|
14
|
-
export let translationurl:string = '';
|
12
|
+
export let clientstyling:string;
|
13
|
+
export let clientstylingurl:string;
|
14
|
+
export let translationurl:string;
|
15
15
|
export let custominputtextswitch:string = 'false';
|
16
16
|
|
17
17
|
let customStylingContainer:HTMLElement;
|
18
18
|
let isLoading:boolean = true;
|
19
|
-
let userAgent:string = window.navigator.userAgent;
|
20
|
-
let isMobile:boolean = (getDevice(userAgent) === 'PC') ? false : true;
|
21
19
|
let noPlayerData:boolean = true;
|
22
|
-
|
23
|
-
|
24
|
-
let
|
25
|
-
let
|
26
|
-
let
|
27
|
-
let
|
28
|
-
|
29
|
-
let
|
30
|
-
let
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
let countriesArray:Array<Object> = []
|
35
|
-
|
36
|
-
let profileConsent:Array<Object> = [];
|
37
|
-
let showEmail:boolean = false;
|
38
|
-
let showSMS:boolean = false;
|
39
|
-
let consentArray:any = { items: [] };
|
40
|
-
|
41
|
-
let isValid:boolean = false;
|
42
|
-
|
43
|
-
let invalidCity:string = '';
|
44
|
-
let invalidPostalCode:string = '';
|
45
|
-
let invalidAddress:string = '';
|
46
|
-
let invalidSecurityQuestion:boolean = false;
|
47
|
-
let invalidSecurityAnswer:boolean = false;
|
48
|
-
let invalidMobile:boolean;
|
49
|
-
|
50
|
-
let showConfirmSave:boolean = false;
|
51
|
-
|
52
|
-
let regexValidators:any = {
|
53
|
-
document: /^(?=.*[a-zA-Z0-9])[a-zA-Z0-9\s]+$/
|
54
|
-
}
|
55
|
-
|
56
|
-
const setTranslationUrl = ():void => {
|
57
|
-
|
58
|
-
let url:string = translationurl;
|
59
|
-
|
60
|
-
fetch(url).then((res:any) => res.json())
|
61
|
-
.then((res) => {
|
62
|
-
Object.keys(res).forEach((item:any):void => {
|
63
|
-
addNewMessages(item, res[item]);
|
64
|
-
});
|
65
|
-
}).catch((err:any) => {
|
66
|
-
console.log(err);
|
67
|
-
});
|
68
|
-
}
|
69
|
-
|
70
|
-
Object.keys(TRANSLATIONS).forEach((item:any) => {
|
71
|
-
addNewMessages(item, TRANSLATIONS[item]);
|
72
|
-
});
|
73
|
-
|
74
|
-
const mediaQuery = window.matchMedia('(min-width: 768px)');
|
75
|
-
|
76
|
-
// needed to keep track of data changes
|
77
|
-
let provisionalArray:any = {
|
78
|
-
address1: '',
|
79
|
-
address2: '',
|
80
|
-
city: '',
|
81
|
-
acceptNewsEmail: false,
|
82
|
-
acceptSMSOffers : false,
|
83
|
-
country: '',
|
84
|
-
mobile: {prefix: '', number: ''},
|
85
|
-
postalCode: '',
|
86
|
-
securityAnswer: '',
|
87
|
-
securityQuestion: '',
|
88
|
-
}
|
89
|
-
|
90
|
-
// needed to keep track of data changes
|
91
|
-
let initialValuesArray:any = {
|
92
|
-
acceptNewsEmail: false,
|
93
|
-
acceptSMSOffers : false,
|
94
|
-
address: '',
|
95
|
-
city: '',
|
96
|
-
mobileNumber: '',
|
97
|
-
mobilePrefix: '',
|
98
|
-
postalCode: '',
|
99
|
-
securityAnswer: '',
|
100
|
-
securityQuestion: ''
|
101
|
-
}
|
102
|
-
|
103
|
-
// placeholder field values
|
104
|
-
let profileDetails:any = {
|
20
|
+
const isMobile:boolean = (getDevice(window.navigator.userAgent) === 'PC') ? false : true;
|
21
|
+
|
22
|
+
let prefixesArray:Array<Record<string, string>> = null;
|
23
|
+
let countriesArray:Array<Record<string, string>> = null;
|
24
|
+
let profileInfo:Record<string, any> = null;
|
25
|
+
let profileConsent:Array<Record<string, string>> = null;
|
26
|
+
|
27
|
+
let initialConsentValues:string;
|
28
|
+
let initialEditableValues:string;
|
29
|
+
const updatedEditableValues:Record<string, any> = {};
|
30
|
+
const readOnlyValues:Record<string, string> = {};
|
31
|
+
const defaultValues:any = {
|
105
32
|
address1: "i.e.: Glanmire Rd.",
|
106
33
|
birth: '01/01/1990',
|
107
34
|
city: "i.e.: Cork",
|
108
|
-
country: "i.e.: Ireland",
|
109
35
|
currency: "EUR",
|
110
36
|
iban: "",
|
111
37
|
email: "email@here.com",
|
@@ -120,68 +46,108 @@
|
|
120
46
|
username: "Username"
|
121
47
|
};
|
122
48
|
|
123
|
-
let
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
username = profileDetails.username;
|
134
|
-
mobile = profileDetails.mobile;
|
135
|
-
email = profileDetails.email;
|
136
|
-
firstname = profileDetails.firstname;
|
137
|
-
lastname = profileDetails.lastname;
|
138
|
-
language = profileDetails.language;
|
139
|
-
birth = profileDetails.birth?.day + '/' + profileDetails.birth?.month + '/' + profileDetails.birth?.year;
|
140
|
-
currency = profileDetails.currency;
|
141
|
-
iban = profileDetails.iban;
|
142
|
-
userTitles = profileDetails.title;
|
143
|
-
|
144
|
-
// editable field values used for bindings
|
145
|
-
playerQuestion = profileDetails.securityQuestion;
|
146
|
-
playerAnswer = profileDetails.securityAnswer;
|
147
|
-
playerPrefix = profileDetails.mobile?.prefix;
|
148
|
-
playerMobileNumber = profileDetails.mobile?.number;
|
149
|
-
|
150
|
-
// set values for the initial editable values object
|
151
|
-
initialValuesArray.address = profileDetails.address1;
|
152
|
-
initialValuesArray.city = profileDetails.city;
|
153
|
-
initialValuesArray.mobilePrefix = mobile?.prefix;
|
154
|
-
initialValuesArray.mobileNumber = mobile?.number;
|
155
|
-
initialValuesArray.postalCode = profileDetails.postalCode;
|
156
|
-
initialValuesArray.securityAnswer = profileDetails.securityAnswer;
|
157
|
-
initialValuesArray.securityQuestion = profileDetails.securityQuestion;
|
158
|
-
|
159
|
-
break;
|
49
|
+
let hasProfileInfoChanged:boolean = false;
|
50
|
+
let hasProfileConsentChanged:boolean = false;
|
51
|
+
let isValid:boolean = true;
|
52
|
+
let isCityValid:boolean = true;
|
53
|
+
let isPostalCodeValid:boolean = true;
|
54
|
+
let isAddressValid:boolean = true;
|
55
|
+
let isSecurityQuestionValid:boolean = true;
|
56
|
+
let isSecurityAnswerValid:boolean = true;
|
57
|
+
let isMobileValid:boolean = true;
|
58
|
+
let showConfirmSave:boolean = false;
|
160
59
|
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
profileConsent.forEach((item) => {
|
165
|
-
if (item.tagCode == 'emailmarketing') {
|
166
|
-
showEmail = true;
|
167
|
-
giveConsentEmail = item.status == 'Accepted';
|
168
|
-
initialValuesArray.acceptNewsEmail = giveConsentEmail;
|
169
|
-
} else if (item.tagCode == 'sms') {
|
170
|
-
showSMS = true;
|
171
|
-
giveConsentSMS = item.status == 'Accepted';
|
172
|
-
initialValuesArray.acceptSMSOffers = giveConsentSMS;
|
173
|
-
}
|
174
|
-
});
|
175
|
-
}
|
176
|
-
break;
|
60
|
+
const regexValidators:any = {
|
61
|
+
document: /^(?=.*[a-zA-Z0-9])[a-zA-Z0-9\s]+$/
|
62
|
+
}
|
177
63
|
|
178
|
-
|
179
|
-
differencesExist = false;
|
64
|
+
const mediaQuery = window.matchMedia('(min-width: 768px)');
|
180
65
|
|
181
|
-
|
182
|
-
|
183
|
-
|
66
|
+
const safeStringify = (obj:Record<string, any>):string => {
|
67
|
+
try { return JSON.stringify(obj); } catch { return null; }
|
68
|
+
}
|
69
|
+
|
70
|
+
const initPlayerInfoFields = ():void => {
|
71
|
+
readOnlyValues.username = profileInfo.username;
|
72
|
+
readOnlyValues.mobile = profileInfo.mobile;
|
73
|
+
readOnlyValues.email = profileInfo.email;
|
74
|
+
readOnlyValues.firstname = profileInfo.firstname;
|
75
|
+
readOnlyValues.lastname = profileInfo.lastname;
|
76
|
+
readOnlyValues.language = profileInfo.language;
|
77
|
+
readOnlyValues.birth = profileInfo.birth?.day + '/' + profileInfo.birth?.month + '/' + profileInfo.birth?.year;
|
78
|
+
readOnlyValues.currency = profileInfo.currency;
|
79
|
+
readOnlyValues.iban = profileInfo.iban;
|
80
|
+
readOnlyValues.userTitles = profileInfo.title;
|
81
|
+
readOnlyValues.countryCode = profileInfo.country;
|
82
|
+
readOnlyValues.countryName = countriesArray.find((country:any) => country.Alpha2Code === profileInfo.country).Name || 'I.E. Ireland';
|
83
|
+
|
84
|
+
updatedEditableValues.address1 = profileInfo.address1;
|
85
|
+
updatedEditableValues.city = profileInfo.city;
|
86
|
+
updatedEditableValues.mobile = {};
|
87
|
+
updatedEditableValues.mobile.prefix = profileInfo.mobile?.prefix;
|
88
|
+
updatedEditableValues.mobile.number = profileInfo.mobile?.number;
|
89
|
+
updatedEditableValues.postalCode = profileInfo.postalCode;
|
90
|
+
updatedEditableValues.securityAnswer = profileInfo.securityAnswer;
|
91
|
+
updatedEditableValues.securityQuestion = profileInfo.securityQuestion;
|
92
|
+
|
93
|
+
if (Array.isArray(profileConsent)) {
|
94
|
+
profileConsent.forEach((item) => {
|
95
|
+
if (item.tagCode === 'emailmarketing') {
|
96
|
+
updatedEditableValues.acceptNewsEmail = item.status === 'Accepted';
|
97
|
+
} else if (item.tagCode === 'sms') {
|
98
|
+
updatedEditableValues.acceptSMSOffers = item.status === 'Accepted';
|
99
|
+
}
|
100
|
+
});
|
184
101
|
}
|
102
|
+
|
103
|
+
initialEditableValues = safeStringify(updatedEditableValues);
|
104
|
+
initialConsentValues = safeStringify(new Object({
|
105
|
+
acceptNewsEmail: updatedEditableValues.acceptNewsEmail,
|
106
|
+
acceptSMSOffers: updatedEditableValues.acceptSMSOffers
|
107
|
+
}));
|
108
|
+
|
109
|
+
noPlayerData = false;
|
110
|
+
isLoading = false;
|
111
|
+
}
|
112
|
+
|
113
|
+
const getUserProfileInfo = ():void => {
|
114
|
+
const url:URL = new URL(`${endpoint}/v1/player/${userid}/profile`);
|
115
|
+
const headers:HeadersInit = new Headers();
|
116
|
+
|
117
|
+
headers.append('X-SessionID', sessionid);
|
118
|
+
|
119
|
+
const options:RequestInit = {
|
120
|
+
method: "GET",
|
121
|
+
headers: headers
|
122
|
+
};
|
123
|
+
|
124
|
+
fetch(url.href, options)
|
125
|
+
.then((res:any) => { return res.json(); })
|
126
|
+
.then((data:any) => {
|
127
|
+
profileInfo = data;
|
128
|
+
}, (err:any) => {
|
129
|
+
console.error(err);
|
130
|
+
});
|
131
|
+
}
|
132
|
+
|
133
|
+
const getUserProfileConsent = ():void => {
|
134
|
+
const url:URL = new URL(`${endpoint}/v1/player/${userid}/consent`);
|
135
|
+
const headers:HeadersInit = new Headers();
|
136
|
+
|
137
|
+
headers.append('X-SessionID', sessionid);
|
138
|
+
|
139
|
+
const options = {
|
140
|
+
method: "GET",
|
141
|
+
headers: headers
|
142
|
+
};
|
143
|
+
|
144
|
+
fetch(url.href, options)
|
145
|
+
.then((res:any) => { return res.json(); })
|
146
|
+
.then((data:any) => {
|
147
|
+
profileConsent = data.items;
|
148
|
+
}, (err:any) => {
|
149
|
+
console.error(err);
|
150
|
+
});
|
185
151
|
}
|
186
152
|
|
187
153
|
const getCountriesList = ():void => {
|
@@ -190,7 +156,6 @@
|
|
190
156
|
if (res.status >= 300) {
|
191
157
|
return new Error('Error while fetching the countries');
|
192
158
|
}
|
193
|
-
|
194
159
|
return res.json();
|
195
160
|
})
|
196
161
|
.then((countryList:any) => {
|
@@ -198,20 +163,16 @@
|
|
198
163
|
if (res.status >= 300) {
|
199
164
|
return new Error('Error while fetching the supported countries');
|
200
165
|
}
|
201
|
-
|
202
166
|
return res.json();
|
203
167
|
})
|
204
168
|
.then((supportedCountries:any) => {
|
205
169
|
countriesArray = countryList.countries.filter((item:any) => {
|
206
170
|
return supportedCountries.countries.indexOf(item.Alpha2Code) >= 0;
|
207
171
|
});
|
208
|
-
|
209
|
-
selectedCountry = countriesArray.find((country:any) => country.Alpha2Code === countrycode) || { Name: 'I.E. Ireland'};
|
210
|
-
isLoading = false;
|
211
172
|
});
|
212
173
|
});
|
213
174
|
}
|
214
|
-
|
175
|
+
|
215
176
|
const getPhoneCodes = ():void => {
|
216
177
|
fetch(`${endpoint}/v1/player/phonecodes`)
|
217
178
|
.then((res:any) => res.json())
|
@@ -220,182 +181,197 @@
|
|
220
181
|
});
|
221
182
|
}
|
222
183
|
|
223
|
-
const
|
224
|
-
|
225
|
-
|
226
|
-
}
|
227
|
-
|
228
|
-
|
229
|
-
const checkIsValid = ():void => {
|
230
|
-
if (invalidSecurityQuestion || invalidSecurityAnswer || invalidCity || invalidAddress || invalidPostalCode || invalidMobile) {
|
231
|
-
isValid = false;
|
232
|
-
}
|
233
|
-
else {
|
184
|
+
const validateAllFields = ():void => {
|
185
|
+
isValid = false;
|
186
|
+
if (isSecurityQuestionValid && isSecurityAnswerValid && isCityValid && isAddressValid && isPostalCodeValid && isMobileValid) {
|
234
187
|
isValid = true;
|
235
188
|
}
|
236
189
|
}
|
237
190
|
|
238
|
-
const
|
239
|
-
|
240
|
-
return true;
|
241
|
-
}
|
242
|
-
|
243
|
-
return false;
|
191
|
+
const checkForChanges = ():void => {
|
192
|
+
hasProfileInfoChanged = safeStringify(updatedEditableValues) !== initialConsentValues;
|
244
193
|
}
|
245
194
|
|
246
|
-
const
|
247
|
-
|
248
|
-
|
195
|
+
const checkForConsentChanges = ():void => {
|
196
|
+
const c = new Object({
|
197
|
+
acceptNewsEmail: updatedEditableValues.acceptNewsEmail,
|
198
|
+
acceptSMSOffers: updatedEditableValues.acceptSMSOffers
|
199
|
+
});
|
200
|
+
hasProfileConsentChanged = safeStringify(c) !== initialConsentValues;
|
249
201
|
}
|
250
202
|
|
251
|
-
const
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
if
|
256
|
-
|
203
|
+
const validateAndCheckForChanges = (key:string):void => {
|
204
|
+
switch (key) {
|
205
|
+
case 'mobileNumber':
|
206
|
+
isMobileValid = false;
|
207
|
+
if(updatedEditableValues.mobile.number && updatedEditableValues.mobile.number.length >= 5 && updatedEditableValues.mobile.number.length <= 12) {
|
208
|
+
isMobileValid = true;
|
257
209
|
}
|
258
210
|
break;
|
259
211
|
|
260
|
-
case '
|
261
|
-
|
262
|
-
|
212
|
+
case 'city':
|
213
|
+
isCityValid = false;
|
214
|
+
if (updatedEditableValues.city && updatedEditableValues.city.length <= 50) {
|
215
|
+
isCityValid = true;
|
263
216
|
}
|
264
217
|
break;
|
265
|
-
}
|
266
|
-
|
267
|
-
return false;
|
268
|
-
}
|
269
|
-
|
270
|
-
const validateSecurityQuestion = ():void => {
|
271
|
-
invalidSecurityQuestion = !checkSecurityQuestion();
|
272
|
-
checkIsValid();
|
273
|
-
}
|
274
218
|
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
if (regexValidators.document.test(securityAnswer) && securityAnswer.length <= 50) {
|
280
|
-
return true;
|
219
|
+
case 'postalCode':
|
220
|
+
isPostalCodeValid = false;
|
221
|
+
if (updatedEditableValues.postalCode && updatedEditableValues.postalCode.length <= 20) {
|
222
|
+
isPostalCodeValid = true;
|
281
223
|
}
|
282
224
|
break;
|
283
225
|
|
284
|
-
case '
|
285
|
-
|
286
|
-
|
226
|
+
case 'address':
|
227
|
+
isAddressValid = false;
|
228
|
+
if(updatedEditableValues.address1 && updatedEditableValues.address1.length <= 100) {
|
229
|
+
isAddressValid = true;
|
287
230
|
}
|
288
231
|
break;
|
289
|
-
}
|
290
|
-
|
291
|
-
return false;
|
292
|
-
}
|
293
232
|
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
233
|
+
case 'securityQuestion':
|
234
|
+
isSecurityQuestionValid = false;
|
235
|
+
if (updatedEditableValues.securityQuestion)
|
236
|
+
switch(custominputtextswitch) {
|
237
|
+
case 'true':
|
238
|
+
if (regexValidators.document.test(updatedEditableValues.securityQuestion) && updatedEditableValues.securityQuestion.length <= 50) {
|
239
|
+
isSecurityQuestionValid = true;
|
240
|
+
}
|
241
|
+
break;
|
303
242
|
|
304
|
-
|
305
|
-
|
243
|
+
case 'false':
|
244
|
+
if (updatedEditableValues.securityQuestion && updatedEditableValues.securityQuestion.length <= 120) {
|
245
|
+
isSecurityQuestionValid = true;
|
246
|
+
}
|
247
|
+
break;
|
248
|
+
}
|
249
|
+
break;
|
306
250
|
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
251
|
+
case 'securityAnswer':
|
252
|
+
isSecurityAnswerValid = false;
|
253
|
+
if (updatedEditableValues.securityAnswer)
|
254
|
+
switch(custominputtextswitch) {
|
255
|
+
case 'true':
|
256
|
+
if (regexValidators.document.test(updatedEditableValues.securityAnswer) && updatedEditableValues.securityAnswer.length <= 50) {
|
257
|
+
isSecurityAnswerValid = true;
|
258
|
+
}
|
259
|
+
break;
|
311
260
|
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
261
|
+
case 'false':
|
262
|
+
if (updatedEditableValues.securityAnswer && updatedEditableValues.securityAnswer.length <= 120) {
|
263
|
+
isSecurityAnswerValid = true;
|
264
|
+
}
|
265
|
+
break;
|
266
|
+
}
|
267
|
+
break;
|
316
268
|
|
317
|
-
|
318
|
-
|
269
|
+
case 'acceptSMSOffers':
|
270
|
+
checkForConsentChanges();
|
271
|
+
break;
|
319
272
|
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
}
|
273
|
+
case 'acceptNewsEmail':
|
274
|
+
checkForConsentChanges();
|
275
|
+
break;
|
324
276
|
|
325
|
-
const checkAddress = ():boolean => {
|
326
|
-
if(playerAddress.value && playerAddress.value.length <= 100) {
|
327
|
-
return true;
|
328
277
|
}
|
329
|
-
|
330
|
-
|
278
|
+
checkForChanges();
|
279
|
+
validateAllFields();
|
280
|
+
}
|
281
|
+
|
282
|
+
const showSuccessMessage = ():void => {
|
283
|
+
showConfirmSave = true;
|
284
|
+
setTimeout(() => {showConfirmSave = false;}, 3000);
|
285
|
+
window.postMessage({ type: 'WidgetNotification', data: {type: 'success', message: $_('profileUpdateSuccess')}}, window.location.href);
|
331
286
|
}
|
332
287
|
|
333
|
-
const
|
334
|
-
|
335
|
-
checkIsValid();
|
288
|
+
const showErrorMessage = ():void => {
|
289
|
+
window.postMessage({ type: 'WidgetNotification', data: {type: 'error', message: $_('userProfileUpdateError')}}, window.location.href);
|
336
290
|
}
|
337
291
|
|
338
|
-
const
|
292
|
+
const updatePlayerInfoAndConsent = (e:any):void => {
|
339
293
|
e.preventDefault();
|
340
|
-
|
341
|
-
|
342
|
-
|
294
|
+
|
295
|
+
if (hasProfileInfoChanged && !hasProfileConsentChanged && isValid) {
|
296
|
+
updateProfileInfo().then((success:boolean) => {
|
297
|
+
if (success) {
|
298
|
+
getUserProfileInfo();
|
299
|
+
showSuccessMessage();
|
300
|
+
}
|
301
|
+
});
|
302
|
+
return;
|
303
|
+
}
|
304
|
+
if (hasProfileInfoChanged && hasProfileConsentChanged && isValid) {
|
305
|
+
updateProfileInfo();
|
306
|
+
updateProfileConsent();
|
307
|
+
|
308
|
+
Promise.all([updateProfileInfo(), updateProfileConsent()]).then((success:Array<boolean>) => {
|
309
|
+
if (success[0] && success[1]) {
|
310
|
+
getUserProfileInfo();
|
311
|
+
getUserProfileConsent();
|
312
|
+
showSuccessMessage();
|
313
|
+
hasProfileInfoChanged = false;
|
314
|
+
hasProfileConsentChanged = false;
|
315
|
+
} else {
|
316
|
+
showErrorMessage();
|
317
|
+
}
|
318
|
+
});
|
319
|
+
return;
|
343
320
|
}
|
344
321
|
}
|
345
322
|
|
346
|
-
const
|
347
|
-
window.postMessage({type: 'PlayerAccountMenuActive', isMobile}, window.location.href);
|
348
|
-
}
|
323
|
+
const updateProfileInfo = async ():Promise<boolean> => {
|
349
324
|
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
securityQuestion: playerQuestion,
|
325
|
+
const url:URL = new URL(`${endpoint}/v1/player/${userid}/profile`);
|
326
|
+
const headers:HeadersInit = new Headers();
|
327
|
+
|
328
|
+
headers.append('X-SessionID', sessionid);
|
329
|
+
headers.append('Content-Type', 'application/json');
|
330
|
+
headers.append('Accept', 'application/json');
|
331
|
+
|
332
|
+
const body = safeStringify(updatedEditableValues);
|
333
|
+
if (body === null) {
|
334
|
+
return false;
|
361
335
|
}
|
336
|
+
|
337
|
+
let options:RequestInit = {
|
338
|
+
method: "POST",
|
339
|
+
headers: headers,
|
340
|
+
body: body
|
341
|
+
};
|
362
342
|
|
363
|
-
|
364
|
-
consentData();
|
365
|
-
checkIsValid();
|
343
|
+
return await fetch(url.href, options).then((res:any) => res.status == 200, (err) => {console.error(err); return false});
|
366
344
|
}
|
367
345
|
|
368
|
-
const
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
346
|
+
const updateProfileConsent = async ():Promise<boolean> => {
|
347
|
+
const updatedProfileConsent = [
|
348
|
+
{tagCode: 'sms', status: (updatedEditableValues.acceptSMSOffers ? 'Accepted' : 'Denied')},
|
349
|
+
{tagCode: 'emailmarketing', status: (updatedEditableValues.acceptNewsEmail ? 'Accepted' : 'Denied')}
|
350
|
+
];
|
351
|
+
|
352
|
+
const url:URL = new URL(`${endpoint}/v1/player/${userid}/consent`);
|
353
|
+
const headers:HeadersInit = new Headers();
|
354
|
+
|
355
|
+
headers.append('X-SessionID', sessionid);
|
356
|
+
headers.append('Content-Type', 'application/json');
|
357
|
+
headers.append('Accept', 'application/json');
|
373
358
|
|
374
|
-
|
375
|
-
|
359
|
+
const body = safeStringify({items: updatedProfileConsent});
|
360
|
+
if (body === null) {
|
361
|
+
return false;
|
376
362
|
}
|
377
|
-
}
|
378
363
|
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
playerPrefix = initialValuesArray.mobilePrefix;
|
385
|
-
playerMobileNumber = initialValuesArray.mobileNumber;
|
386
|
-
playerPostalCode.value = initialValuesArray.postalCode;
|
387
|
-
playerAnswer = initialValuesArray.securityAnswer;
|
388
|
-
playerQuestion = initialValuesArray.securityQuestion;
|
364
|
+
const options:RequestInit = {
|
365
|
+
method: "POST",
|
366
|
+
headers: headers,
|
367
|
+
body: body
|
368
|
+
};
|
389
369
|
|
390
|
-
|
370
|
+
return await fetch(url.href, options).then((res:any) => res.status == 200, (err) => {console.error(err); return false});
|
391
371
|
}
|
392
372
|
|
393
|
-
const
|
394
|
-
|
395
|
-
differencesExist = false;
|
396
|
-
} else {
|
397
|
-
differencesExist = true;
|
398
|
-
}
|
373
|
+
const toggleScreen = ():void => {
|
374
|
+
window.postMessage({type: 'PlayerAccountMenuActive', isMobile}, window.location.href);
|
399
375
|
}
|
400
376
|
|
401
377
|
const setActiveLanguage = ():void => {
|
@@ -421,18 +397,29 @@
|
|
421
397
|
});
|
422
398
|
}
|
423
399
|
|
424
|
-
|
400
|
+
const setTranslationUrl = ():void => {
|
401
|
+
const url:string = translationurl;
|
425
402
|
|
426
|
-
|
403
|
+
fetch(url).then((res:any) => res.json())
|
404
|
+
.then((res) => {
|
405
|
+
Object.keys(res).forEach((item:any):void => {
|
406
|
+
addNewMessages(item, res[item]);
|
407
|
+
});
|
408
|
+
}).catch((err:any) => {
|
409
|
+
console.log(err);
|
410
|
+
});
|
411
|
+
}
|
427
412
|
|
428
|
-
|
429
|
-
|
430
|
-
}
|
413
|
+
Object.keys(TRANSLATIONS).forEach((item:any) => {
|
414
|
+
addNewMessages(item, TRANSLATIONS[item]);
|
431
415
|
});
|
432
416
|
|
433
|
-
$:
|
434
|
-
$: endpoint &&
|
417
|
+
$: endpoint && userid && sessionid && getUserProfileInfo();
|
418
|
+
$: endpoint && userid && sessionid && getUserProfileConsent();
|
419
|
+
$: endpoint && getCountriesList();
|
435
420
|
$: endpoint && getPhoneCodes();
|
421
|
+
$: profileInfo && profileConsent && countriesArray && initPlayerInfoFields();
|
422
|
+
$: lang && setActiveLanguage();
|
436
423
|
$: clientstylingurl && customStylingContainer && setClientStylingURL();
|
437
424
|
$: clientstyling && customStylingContainer && setClientStyling();
|
438
425
|
$: translationurl && setTranslationUrl();
|
@@ -445,7 +432,7 @@
|
|
445
432
|
<form class="PlayerInfoWrapper {isMobile ? 'PlayerInfoWrapperMobile' : ''} {mediaQuery.matches && isMobile ? 'PlayerInfoWrapperTablet' : ''}">
|
446
433
|
|
447
434
|
{#if isMobile}
|
448
|
-
<div class="MenuReturnButton" on:click={
|
435
|
+
<div class="MenuReturnButton" on:click={toggleScreen} on:keyup={null}>
|
449
436
|
<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 15 15"><defs><style>.aaa{fill:var(--emw--pam-color-primary, var(--emw--color-primary, #22B04E));}</style></defs><g transform="translate(-20 -158)">
|
450
437
|
<g transform="translate(20 158)">
|
451
438
|
<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)"/>
|
@@ -462,69 +449,69 @@
|
|
462
449
|
</div>
|
463
450
|
<section class="PlayerDetailsContent">
|
464
451
|
<div class="PlayerInfoBox">
|
465
|
-
<
|
466
|
-
<input type="text" class="FieldDisabled" value={username} readonly />
|
452
|
+
<p>{$_('userName')}</p>
|
453
|
+
<input type="text" class="FieldDisabled" value={readOnlyValues.username} readonly />
|
467
454
|
</div>
|
468
|
-
<div class="PlayerInfoBox {
|
469
|
-
<
|
455
|
+
<div class="PlayerInfoBox {isMobileValid ? '' : 'InvalidField'}">
|
456
|
+
<p>{$_('userPhone')}</p>
|
470
457
|
<div class="PlayerPhoneNumber">
|
471
|
-
<select bind:value={
|
458
|
+
<select bind:value={updatedEditableValues.mobile.prefix} on:change={checkForChanges}>
|
472
459
|
{#each prefixesArray as pref}
|
473
|
-
{#if pref.Prefix ===
|
460
|
+
{#if pref.Prefix === updatedEditableValues.mobile.prefix}
|
474
461
|
<option selected>{pref.Prefix}</option>
|
475
462
|
{:else}
|
476
463
|
<option>{pref.Prefix}</option>
|
477
464
|
{/if}
|
478
465
|
{/each}
|
479
466
|
</select>
|
480
|
-
<input bind:value={
|
467
|
+
<input type="text" bind:value={updatedEditableValues.mobile.number} on:keyup={() => validateAndCheckForChanges('mobileNumber')} on:input={updatedEditableValues.mobile.number = updatedEditableValues.mobile.number.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1')} placeholder={defaultValues.mobile.number}/>
|
481
468
|
</div>
|
482
|
-
{#if
|
469
|
+
{#if !isMobileValid}
|
483
470
|
<p class="InvalidInput">{$_('userPhoneError')}</p>
|
484
471
|
{/if}
|
485
472
|
</div>
|
486
|
-
<div class="PlayerInfoBox {
|
473
|
+
<div class="PlayerInfoBox {isSecurityQuestionValid ? '' : 'InvalidField'}">
|
487
474
|
<label for="SecurityQuestion">{custominputtextswitch == 'true' ? $_('profileSecurityQuestion2') : $_('profileSecurityQuestion')}:<span class="FormRequired">*</span></label>
|
488
|
-
<input type="text" bind:value={
|
489
|
-
{#if
|
475
|
+
<input id="SecurityQuestion" type="text" bind:value={updatedEditableValues.securityQuestion} on:keyup={() => validateAndCheckForChanges('securityQuestion')} placeholder={defaultValues.securityQuestion} />
|
476
|
+
{#if !isSecurityQuestionValid}
|
490
477
|
<p class="InvalidInput">{custominputtextswitch == 'true' ? $_('profileSecurityQuestionError2') : $_('profileSecurityQuestionError')}</p>
|
491
478
|
{/if}
|
492
479
|
</div>
|
493
|
-
<div class="PlayerInfoBox {
|
480
|
+
<div class="PlayerInfoBox {isSecurityAnswerValid ? '' : 'InvalidField'}">
|
494
481
|
<label for="SecurityAnswer">{custominputtextswitch == 'true' ? $_('profileSecurityAnswer2') : $_('profileSecurityAnswer')}:<span class="FormRequired">*</span></label>
|
495
|
-
<input type="text" bind:value={
|
496
|
-
{#if
|
482
|
+
<input id="SecurityAnswer" type="text" bind:value={updatedEditableValues.securityAnswer} on:keyup={() => validateAndCheckForChanges('securityAnswer')} placeholder={defaultValues.securityAnswer} />
|
483
|
+
{#if !isSecurityAnswerValid}
|
497
484
|
<p class="InvalidInput">{custominputtextswitch == 'true' ? $_('profileSecurityAnswerError2') : $_('profileSecurityAnswerError')}</p>
|
498
485
|
{/if}
|
499
486
|
</div>
|
500
487
|
<div class="PlayerInfoBox">
|
501
|
-
<label>{$_('userEmail')}</label>
|
502
|
-
<input type="email" class="FieldDisabled" value={email} readonly />
|
488
|
+
<label for="UserEmail">{$_('userEmail')}</label>
|
489
|
+
<input id="UserEmail" type="email" class="FieldDisabled" value={readOnlyValues.email} readonly />
|
503
490
|
</div>
|
504
491
|
<div class="PlayerInfoBox">
|
505
|
-
<label>{$_('dateOfBirth')}</label>
|
506
|
-
<input type="text" class="FieldDisabled" value={birth} readonly />
|
492
|
+
<label for="DateOfBirth">{$_('dateOfBirth')}</label>
|
493
|
+
<input id="DateOfBirth" type="text" class="FieldDisabled" value={readOnlyValues.birth} readonly />
|
507
494
|
</div>
|
508
495
|
<div class="PlayerInfoBox">
|
509
|
-
<label>{$_('firstName')}</label>
|
510
|
-
<input type="text" class="FieldDisabled" value={firstname} readonly />
|
496
|
+
<label for="FirstName">{$_('firstName')}</label>
|
497
|
+
<input id="FirstName" type="text" class="FieldDisabled" value={readOnlyValues.firstname} readonly />
|
511
498
|
</div>
|
512
499
|
<div class="PlayerInfoBox">
|
513
|
-
<label>{$_('lastName')}</label>
|
514
|
-
<input type="text" class="FieldDisabled" value={lastname} readonly />
|
500
|
+
<label for="LastName">{$_('lastName')}</label>
|
501
|
+
<input id="LastName" type="text" class="FieldDisabled" value={readOnlyValues.lastname} readonly />
|
515
502
|
</div>
|
516
503
|
<div class="PlayerInfoBox">
|
517
|
-
<label>{$_('userTitle')}</label>
|
518
|
-
<input type="text" class="FieldDisabled" value={userTitles} readonly />
|
504
|
+
<label for="UserTitle">{$_('userTitle')}</label>
|
505
|
+
<input id="UserTitle" type="text" class="FieldDisabled" value={readOnlyValues.userTitles} readonly />
|
519
506
|
</div>
|
520
507
|
<div class="PlayerInfoBox">
|
521
|
-
<label>{$_('currency')}</label>
|
522
|
-
<input type="text" class="FieldDisabled" value={currency} readonly />
|
508
|
+
<label for="Currrency">{$_('currency')}</label>
|
509
|
+
<input id="Currency" type="text" class="FieldDisabled" value={readOnlyValues.currency} readonly />
|
523
510
|
</div>
|
524
|
-
{#if iban}
|
511
|
+
{#if readOnlyValues.iban}
|
525
512
|
<div class="PlayerInfoBox">
|
526
|
-
<label>{$_('iban')}</label>
|
527
|
-
<input type="text" class="FieldDisabled" value={iban} readonly />
|
513
|
+
<label for="Iban">{$_('iban')}</label>
|
514
|
+
<input id="Iban" type="text" class="FieldDisabled" value={readOnlyValues.iban} readonly />
|
528
515
|
</div>
|
529
516
|
{/if}
|
530
517
|
</section>
|
@@ -534,50 +521,50 @@
|
|
534
521
|
</div>
|
535
522
|
<section class="PlayerLocationContent">
|
536
523
|
<div class="PlayerInfoBox">
|
537
|
-
<label>{$_('userCountry')}</label>
|
538
|
-
<input type="text" class="PlayerCountry FieldDisabled"
|
524
|
+
<label for="UserCountry">{$_('userCountry')}</label>
|
525
|
+
<input id="UserCountry" type="text" class="PlayerCountry FieldDisabled" value={readOnlyValues.countryName} placeholder={readOnlyValues.countryCode} readonly />
|
539
526
|
</div>
|
540
|
-
<div class="PlayerInfoBox {
|
541
|
-
<label>{$_('userCity')}</label>
|
542
|
-
<input
|
543
|
-
{#if
|
527
|
+
<div class="PlayerInfoBox {isCityValid ? '' : 'InvalidField'}">
|
528
|
+
<label for="UserCity">{$_('userCity')}</label>
|
529
|
+
<input id="UserCity" type="text" bind:value={updatedEditableValues.city} on:keyup={() => validateAndCheckForChanges('city')} placeholder={defaultValues.city}/>
|
530
|
+
{#if !isCityValid}
|
544
531
|
<p class="InvalidInput">{$_('userCityError')}</p>
|
545
532
|
{/if}
|
546
533
|
</div>
|
547
|
-
<div class="PlayerInfoBox {
|
548
|
-
<label>{$_('userAddress')}</label>
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
534
|
+
<div class="PlayerInfoBox {isAddressValid ? '' : 'InvalidField'}">
|
535
|
+
<label for="UserAdress">{$_('userAddress')}</label>
|
536
|
+
<input id="UserAdress" type="text" bind:value={updatedEditableValues.address1} on:keyup={() => validateAndCheckForChanges('address')} placeholder={defaultValues.adress}/>
|
537
|
+
{#if !isAddressValid}
|
538
|
+
<p class="InvalidInput">{$_('userAddressError')}</p>
|
539
|
+
{/if}
|
553
540
|
</div>
|
554
|
-
<div class="PlayerInfoBox {
|
555
|
-
<label>{$_('userPostalCode')}</label>
|
556
|
-
<input
|
557
|
-
{#if
|
541
|
+
<div class="PlayerInfoBox {isPostalCodeValid ? '' : 'InvalidField'}">
|
542
|
+
<label for="UserPostalCode">{$_('userPostalCode')}</label>
|
543
|
+
<input id="UserPostalCode" type="text" bind:value={updatedEditableValues.postalCode} on:keyup={() => validateAndCheckForChanges('postalCode')} placeholder={defaultValues.postalCode}/>
|
544
|
+
{#if !isPostalCodeValid}
|
558
545
|
<p class="InvalidInput">{$_('userPostalCodeError')}</p>
|
559
546
|
{/if}
|
560
547
|
</div>
|
561
548
|
</section>
|
562
549
|
|
563
|
-
{#if
|
550
|
+
{#if updatedEditableValues.acceptSMSOffers !== undefined || updatedEditableValues.acceptNewsEmail !== undefined}
|
564
551
|
<div class="PlayerNotificationsHeader">
|
565
552
|
<h3>{$_('userNotifications')}</h3>
|
566
553
|
</div>
|
567
554
|
<section class="PlayerNotificationsCheckboxArea">
|
568
|
-
{#if
|
555
|
+
{#if updatedEditableValues.acceptSMSOffers !== undefined}
|
569
556
|
<div class="PlayerNotificationBox">
|
570
557
|
<label for="SMSNotification">
|
571
|
-
<input bind:checked={
|
558
|
+
<input bind:checked={updatedEditableValues.acceptSMSOffers} on:change={() => validateAndCheckForChanges('acceptSMSOffers')} type="checkbox" id="SMSNotification" name="Enable SMS notifications" />
|
572
559
|
<span class="Checkmark"></span>
|
573
560
|
<span>{$_('userSMSNotification')}</span>
|
574
561
|
</label>
|
575
562
|
</div>
|
576
563
|
{/if}
|
577
|
-
{#if
|
564
|
+
{#if updatedEditableValues.acceptNewsEmail !== undefined}
|
578
565
|
<div class="PlayerNotificationBox">
|
579
566
|
<label for="EmailNotification">
|
580
|
-
<input bind:checked={
|
567
|
+
<input bind:checked={updatedEditableValues.acceptNewsEmail} on:change={() => validateAndCheckForChanges('acceptNewsEmail')} type="checkbox" id="EmailNotification" name="Enable Emails" />
|
581
568
|
<span class="Checkmark"></span>
|
582
569
|
<span>{$_('userEmailNotification')}</span>
|
583
570
|
</label>
|
@@ -586,7 +573,7 @@
|
|
586
573
|
</section>
|
587
574
|
{/if}
|
588
575
|
<section class="PlayerDetailsButtonsArea {isMobile ? 'PlayerDetailsButtonsAreaMobile' : ''}" >
|
589
|
-
<button class="PlayerDetailsSaveButton {
|
576
|
+
<button class="PlayerDetailsSaveButton {hasProfileInfoChanged && isValid ? '' : 'PlayerButtonDisabled'}" on:click={updatePlayerInfoAndConsent}>{$_('userProfileSaveChanges')}</button>
|
590
577
|
</section>
|
591
578
|
{#if showConfirmSave}
|
592
579
|
<section class="PlayerDetailsConfirmSave">
|
@@ -599,7 +586,6 @@
|
|
599
586
|
|
600
587
|
<style lang="scss">
|
601
588
|
|
602
|
-
|
603
589
|
button {
|
604
590
|
font-family: var(--emw--button-typography);
|
605
591
|
}
|
@@ -628,7 +614,7 @@
|
|
628
614
|
color: var(--emw--pam-typography, var(--emw-color-contrast, #07072A));
|
629
615
|
background: var(--emw-color-pale, var(--emw--color-gray-50, #F1F1F1));
|
630
616
|
padding: 50px;
|
631
|
-
|
617
|
+
height: 100%;
|
632
618
|
border-radius: 20px;
|
633
619
|
}
|
634
620
|
|
@@ -737,6 +723,7 @@
|
|
737
723
|
/* Firefox */
|
738
724
|
input[type=number] {
|
739
725
|
-moz-appearance: textfield;
|
726
|
+
appearance: textfield;
|
740
727
|
}
|
741
728
|
}
|
742
729
|
|
@@ -803,8 +790,6 @@
|
|
803
790
|
.PlayerDetailsSaveButton, .PlayerDetailsCancelButton {
|
804
791
|
cursor: pointer;
|
805
792
|
border-radius: 5px;
|
806
|
-
width: 100%;
|
807
|
-
height: 50px;
|
808
793
|
display: flex;
|
809
794
|
align-items: center;
|
810
795
|
justify-content: center;
|
@@ -813,12 +798,19 @@
|
|
813
798
|
text-transform: uppercase;
|
814
799
|
transition-duration: 0.3s;
|
815
800
|
box-sizing: border-box;
|
801
|
+
max-width: 400px;
|
802
|
+
min-width: 200px;
|
816
803
|
}
|
817
804
|
.PlayerDetailsSaveButton {
|
818
805
|
background-image: linear-gradient(to bottom, color-mix(in srgb, var(--emw--color-primary, #22B04E) 80%, black 20%), var(--emw--color-primary, #22B04E), color-mix(in srgb, var(--emw--color-primary, #22B04E) 80%, white 30%));
|
819
806
|
border: 2px solid var(--emw--button-border-color, #0E5924);
|
820
807
|
color: var(--emw--button-text-color, #FFFFFF);
|
821
808
|
border-radius: var(--emw--button-border-radius, 50px);
|
809
|
+
max-width: 400px;
|
810
|
+
min-width: 200px;
|
811
|
+
padding: 13px 0;
|
812
|
+
width: 100%;
|
813
|
+
|
822
814
|
&:active {
|
823
815
|
background: var(--emw--pam-color-primary, var(--emw--color-primary, #22B04E));
|
824
816
|
}
|
@@ -859,6 +851,7 @@
|
|
859
851
|
padding: 20px 15px;
|
860
852
|
background: var(--emw-color-gray-50, #F9F8F8);
|
861
853
|
max-width: unset;
|
854
|
+
border-radius: 0;
|
862
855
|
.PlayerDetailsContent {
|
863
856
|
grid-template-columns: 1fr;
|
864
857
|
}
|