@everymatrix/user-action-controller 1.34.0 → 1.34.2

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.
@@ -7,32 +7,38 @@ const TRANSLATIONS = {
7
7
  en: {
8
8
  termsandconditions: 'Terms and Conditions',
9
9
  sms: 'SMS marketing',
10
- emailmarketing: 'Email marketing'
10
+ emailmarketing: 'Email marketing',
11
+ privacypolicy: 'Privacy Policy'
11
12
  },
12
13
  ro: {
13
14
  termsandconditions: 'Termeni şi condiţii',
14
15
  sms: 'SMS marketing',
15
- emailmarketing: 'Email marketing'
16
+ emailmarketing: 'Email marketing',
17
+ privacypolicy: 'Privacy Policy'
16
18
  },
17
19
  hr: {
18
20
  termsandconditions: 'Terms and Conditions',
19
21
  sms: 'SMS marketing',
20
- emailmarketing: 'Email marketing'
22
+ emailmarketing: 'Email marketing',
23
+ privacypolicy: 'Privacy Policy'
21
24
  },
22
25
  fr: {
23
26
  termsandconditions: 'Terms and Conditions',
24
27
  sms: 'SMS marketing',
25
- emailmarketing: 'Email marketing'
28
+ emailmarketing: 'Email marketing',
29
+ privacypolicy: 'Privacy Policy'
26
30
  },
27
31
  cs: {
28
32
  termsandconditions: 'Terms and Conditions',
29
33
  sms: 'SMS marketing',
30
- emailmarketing: 'Email marketing'
34
+ emailmarketing: 'Email marketing',
35
+ privacypolicy: 'Privacy Policy'
31
36
  },
32
37
  de: {
33
38
  termsandconditions: 'Terms and Conditions',
34
39
  sms: 'SMS marketing',
35
- emailmarketing: 'Email marketing'
40
+ emailmarketing: 'Email marketing',
41
+ privacypolicy: 'Privacy Policy'
36
42
  },
37
43
  };
38
44
  const getTranslations = (url) => {
@@ -100,13 +106,14 @@ const UserActionController$1 = /*@__PURE__*/ proxyCustomElement(class extends HT
100
106
  this.limitStylingAppends = false;
101
107
  this.isLoading = true;
102
108
  this.mandatoryActionsChecked = 0;
103
- //for now this variable is hardcoded bcs we have only terms and conditions mandatory and we dont receive with these new functionality the mandatory actions
104
- this.mandatoryActions = ['termsandconditions'];
109
+ //for now this variable is hardcoded bcs we have terms and conditions and privacy policy mandatory and we dont receive with these new functionality the mandatory actions
110
+ this.mandatoryActions = ['termsandconditions', 'privacypolicy'];
105
111
  this.userActions = [];
106
112
  this.consentTitles = {
107
113
  termsandconditions: translate('termsandconditions', this.lang),
108
114
  sms: translate('sms', this.lang),
109
- emailmarketing: translate('emailmarketing', this.lang)
115
+ emailmarketing: translate('emailmarketing', this.lang),
116
+ privacypolicy: translate('privacypolicy', this.lang)
110
117
  };
111
118
  this.setClientStyling = () => {
112
119
  let sheet = document.createElement('style');
@@ -148,56 +155,62 @@ const UserActionController$1 = /*@__PURE__*/ proxyCustomElement(class extends HT
148
155
  this.receivedQueryResponses++;
149
156
  }
150
157
  }
151
- determineUserActions() {
158
+ determineUserActionsCore() {
152
159
  const url = new URL(`${this.endpoint}/v1/player/${this.userId}/consent`);
153
160
  const headers = new Headers();
154
161
  headers.append('X-SessionId', this.userSession);
155
- let requestOptions;
156
- requestOptions = {
162
+ let requestOptions = {
157
163
  method: 'GET',
158
164
  headers
159
165
  };
160
- if (url && requestOptions) {
161
- return fetch(url.href, requestOptions)
162
- .then(res => res.json())
163
- .then(data => {
164
- const actionItems = data.items;
165
- actionItems.forEach(element => {
166
- if (element.status === 'Expired') {
167
- this.activeUserActions.push(element.tagCode);
168
- }
169
- });
170
- this.isLoading = false;
171
- })
172
- .catch(error => {
173
- console.error('Error fetching data:', error);
174
- this.isLoading = false;
166
+ return fetch(url.href, requestOptions)
167
+ .then(res => res.json())
168
+ .then(data => {
169
+ const actionItems = data.items;
170
+ actionItems.forEach(element => {
171
+ if (element.status === 'Expired') {
172
+ this.activeUserActions.push(element.tagCode);
173
+ }
175
174
  });
176
- }
177
- else {
178
- return Promise.reject('Unsupported endpoint');
179
- }
175
+ this.isLoading = false;
176
+ })
177
+ .catch(error => {
178
+ console.error('Error fetching data:', error);
179
+ this.isLoading = false;
180
+ });
181
+ }
182
+ determineUserActions16() {
183
+ const url = new URL(`${this.endpoint}/v1/player/${this.userId}/legislation/consents`);
184
+ const headers = new Headers();
185
+ headers.append('X-SessionId', this.userSession);
186
+ let requestOptions = {
187
+ method: 'GET',
188
+ headers
189
+ };
190
+ return fetch(url.href, requestOptions)
191
+ .then(res => res.json())
192
+ .then(data => {
193
+ const actionItems = data.consents;
194
+ actionItems.forEach(element => {
195
+ if (element.status === 2) {
196
+ this.activeUserActions.push(element.tagCode);
197
+ }
198
+ });
199
+ this.isLoading = false;
200
+ })
201
+ .catch(error => {
202
+ console.error('Error fetching data:', error);
203
+ this.isLoading = false;
204
+ });
180
205
  }
181
206
  updateUserConsents() {
182
- let url;
183
- let requestOptions;
184
- url = (this.gmVersion === 'gmcore')
207
+ const url = (this.gmVersion === 'gmcore')
185
208
  ? new URL(`${this.endpoint}/v1/player/${this.userId}/consent`)
186
209
  : new URL(`${this.endpoint}/v1/player/${this.userId}/legislation/consents`);
187
- const body = (this.gmVersion === 'gmcore')
188
- ? {
189
- items: this.userActions
190
- }
191
- : {
192
- consents: [
193
- {
194
- tagCode: "termsandconditions",
195
- note: "",
196
- status: 1
197
- }
198
- ]
199
- };
200
- requestOptions = {
210
+ const body = {
211
+ items: this.userActions
212
+ };
213
+ let requestOptions = {
201
214
  method: 'POST',
202
215
  headers: {
203
216
  'Content-Type': 'application/json',
@@ -206,43 +219,40 @@ const UserActionController$1 = /*@__PURE__*/ proxyCustomElement(class extends HT
206
219
  },
207
220
  body: JSON.stringify(body)
208
221
  };
209
- if (url && requestOptions) {
210
- fetch(url.href, requestOptions)
211
- .then(res => res.json())
212
- .then(() => {
213
- window.postMessage({
214
- type: 'WidgetNotification',
215
- data: {
216
- type: 'success',
217
- message: 'Consent update successful!'
218
- }
219
- }, window.location.href);
220
- })
221
- .catch((err) => {
222
- window.postMessage({
223
- type: 'WidgetNotification',
224
- data: {
225
- type: 'error',
226
- message: 'Server might not be responding',
227
- err
228
- }
229
- }, window.location.href);
230
- })
231
- .finally(() => {
232
- window.postMessage({ type: 'UserActionsCompleted' }, window.location.href);
233
- });
234
- }
222
+ fetch(url.href, requestOptions)
223
+ .then(res => res.json())
224
+ .then(() => {
225
+ window.postMessage({
226
+ type: 'WidgetNotification',
227
+ data: {
228
+ type: 'success',
229
+ message: 'Consent update successful!'
230
+ }
231
+ }, window.location.href);
232
+ })
233
+ .catch((err) => {
234
+ window.postMessage({
235
+ type: 'WidgetNotification',
236
+ data: {
237
+ type: 'error',
238
+ message: 'Server might not be responding',
239
+ err
240
+ }
241
+ }, window.location.href);
242
+ })
243
+ .finally(() => {
244
+ window.postMessage({ type: 'UserActionsCompleted' }, window.location.href);
245
+ });
235
246
  }
236
247
  handleApplyClick() {
237
248
  this.queryFired = true;
238
249
  }
239
250
  async componentWillLoad() {
240
251
  if (this.gmVersion === 'gmcore') {
241
- return this.determineUserActions();
252
+ this.determineUserActionsCore();
242
253
  }
243
- else {
244
- this.activeUserActions = ['termsandconditions'];
245
- this.isLoading = false;
254
+ if (this.gmVersion === 'gm16') {
255
+ this.determineUserActions16();
246
256
  }
247
257
  if (this.translationUrl.length > 2) {
248
258
  await getTranslations(this.translationUrl);
@@ -260,17 +270,19 @@ const UserActionController$1 = /*@__PURE__*/ proxyCustomElement(class extends HT
260
270
  // end custom styling area
261
271
  }
262
272
  render() {
263
- const isMandatoryPresent = this.mandatoryActions.every(action => this.activeUserActions.includes(action));
264
- if (isMandatoryPresent) {
265
- this.userActionsValidated = !(this.mandatoryActionsChecked === this.mandatoryActions.length);
266
- }
267
- else {
268
- this.userActionsValidated = false;
269
- }
273
+ let mandatoryItems = 0;
274
+ const isMandatoryPresent = this.mandatoryActions.some(action => {
275
+ const isPresent = this.activeUserActions.includes(action);
276
+ if (isPresent) {
277
+ mandatoryItems++;
278
+ }
279
+ return isPresent;
280
+ });
281
+ this.userActionsValidated = isMandatoryPresent && (this.mandatoryActionsChecked === mandatoryItems);
270
282
  return (h("div", { class: "QueryReferenceContainer", ref: el => this.stylingContainer = el }, this.isLoading ? (h("slot", { name: 'spinner' })
271
283
  &&
272
- h("svg", { class: "spinner", viewBox: "0 0 50 50" }, h("circle", { class: "path", cx: "25", cy: "25", r: "20", fill: "none", "stroke-width": "5" }))) : (h("div", { class: "UserActionController" }, h("h2", { class: "UserConsentNotice" }, this.userNoticeText), h("div", { class: "PlayerLegislationWrapper" }, this.activeUserActions.map(action => (h("slot", { name: action }, h("player-user-consents", { lang: this.lang, "translation-url": this.translationUrl, slot: action, consentType: action, consentTitle: this.consentTitles[action], queried: this.queryFired, mandatory: this.mandatoryActions.includes(action), "client-styling": this.clientStyling }))))), this.includeSubmitButton &&
273
- h("button", { class: "ConsentSubmitButton", disabled: this.userActionsValidated, onClick: () => this.handleApplyClick() }, this.submitButtonText)))));
284
+ h("svg", { class: "spinner", viewBox: "0 0 50 50" }, h("circle", { class: "path", cx: "25", cy: "25", r: "20", fill: "none", "stroke-width": "5" }))) : (h("div", { class: "UserActionController" }, h("h2", { class: "UserConsentNotice" }, this.userNoticeText), h("div", { class: "PlayerLegislationWrapper" }, this.activeUserActions.map(action => (h("slot", { name: action }, h("player-user-consents", { lang: this.lang, "gm-version": this.gmVersion, "translation-url": this.translationUrl, slot: action, consentType: action, consentTitle: this.consentTitles[action], queried: this.queryFired, mandatory: this.mandatoryActions.includes(action), "client-styling": this.clientStyling }))))), this.includeSubmitButton &&
285
+ h("button", { class: "ConsentSubmitButton", disabled: !this.userActionsValidated, onClick: () => this.handleApplyClick() }, this.submitButtonText)))));
274
286
  }
275
287
  static get watchers() { return {
276
288
  "translationUrl": ["handleNewTranslations"],
@@ -10,7 +10,7 @@ const patchEsm = () => {
10
10
  const defineCustomElements = (win, options) => {
11
11
  if (typeof window === 'undefined') return Promise.resolve();
12
12
  return patchEsm().then(() => {
13
- return bootstrapLazy([["player-user-consents_2",[[1,"user-action-controller",{"endpoint":[513],"userSession":[513,"user-session"],"userId":[513,"user-id"],"lang":[1537],"includeSubmitButton":[516,"include-submit-button"],"submitButtonText":[513,"submit-button-text"],"userNoticeText":[513,"user-notice-text"],"gmVersion":[1,"gm-version"],"translationUrl":[513,"translation-url"],"clientStyling":[1537,"client-styling"],"clientStylingUrl":[513,"client-styling-url"],"queryFired":[32],"readyActionsCount":[32],"activeUserActions":[32],"userActionsValidated":[32],"receivedQueryResponses":[32],"limitStylingAppends":[32],"isLoading":[32],"mandatoryActionsChecked":[32]},[[0,"userLegislationConsent","userLegislationConsentHandler"]]],[1,"player-user-consents",{"lang":[1537],"queried":[516],"consentType":[513,"consent-type"],"mandatory":[516],"consentTitle":[513,"consent-title"],"clientStyling":[1,"client-styling"],"translationUrl":[513,"translation-url"],"textContent":[32],"limitStylingAppends":[32]}]]]], options);
13
+ return bootstrapLazy([["player-user-consents_2",[[1,"user-action-controller",{"endpoint":[513],"userSession":[513,"user-session"],"userId":[513,"user-id"],"lang":[1537],"includeSubmitButton":[516,"include-submit-button"],"submitButtonText":[513,"submit-button-text"],"userNoticeText":[513,"user-notice-text"],"gmVersion":[1,"gm-version"],"translationUrl":[513,"translation-url"],"clientStyling":[1537,"client-styling"],"clientStylingUrl":[513,"client-styling-url"],"queryFired":[32],"readyActionsCount":[32],"activeUserActions":[32],"userActionsValidated":[32],"receivedQueryResponses":[32],"limitStylingAppends":[32],"isLoading":[32],"mandatoryActionsChecked":[32]},[[0,"userLegislationConsent","userLegislationConsentHandler"]]],[1,"player-user-consents",{"lang":[1537],"queried":[516],"consentType":[513,"consent-type"],"mandatory":[516],"gmVersion":[1,"gm-version"],"consentTitle":[513,"consent-title"],"clientStyling":[1,"client-styling"],"translationUrl":[513,"translation-url"],"textContent":[32],"limitStylingAppends":[32]}]]]], options);
14
14
  });
15
15
  };
16
16