@everymatrix/player-elevate-card 1.56.3 → 1.57.0

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.
Files changed (26) hide show
  1. package/dist/cjs/{general-styling-wrapper_5.cjs.entry.js → general-styling-wrapper_6.cjs.entry.js} +224 -9
  2. package/dist/cjs/{index-ea33d8f2.js → index-5e07cb40.js} +6 -3
  3. package/dist/cjs/loader.cjs.js +2 -2
  4. package/dist/cjs/player-elevate-card.cjs.js +2 -2
  5. package/dist/collection/collection-manifest.json +2 -1
  6. package/dist/collection/components/player-elevate-card/player-elevate-card.stories.js +58 -0
  7. package/dist/collection/components/player-rakeback-card/player-rakeback-card.css +87 -0
  8. package/dist/collection/components/player-rakeback-card/player-rakeback-card.js +339 -0
  9. package/dist/collection/utils/locale.utils.js +68 -8
  10. package/dist/esm/{general-styling-wrapper_5.entry.js → general-styling-wrapper_6.entry.js} +224 -10
  11. package/dist/esm/{index-98f17aff.js → index-f1097e33.js} +6 -3
  12. package/dist/esm/loader.js +3 -3
  13. package/dist/esm/player-elevate-card.js +3 -3
  14. package/dist/player-elevate-card/p-5a173e2d.entry.js +1 -0
  15. package/dist/player-elevate-card/{p-17f8d580.js → p-9222d554.js} +1 -1
  16. package/dist/player-elevate-card/player-elevate-card.esm.js +1 -1
  17. package/dist/storybook/main.js +47 -0
  18. package/dist/storybook/preview.js +9 -0
  19. package/dist/types/Users/maria.bumbar/Desktop/widgets-monorepo/packages/stencil/player-elevate-card/.stencil/libs/common/src/storybook/storybook-utils.d.ts +39 -0
  20. package/dist/types/Users/maria.bumbar/Desktop/widgets-monorepo/packages/stencil/player-elevate-card/.stencil/packages/stencil/player-elevate-card/storybook/main.d.ts +3 -0
  21. package/dist/types/Users/maria.bumbar/Desktop/widgets-monorepo/packages/stencil/player-elevate-card/.stencil/packages/stencil/player-elevate-card/storybook/preview.d.ts +70 -0
  22. package/dist/types/components/player-elevate-card/player-elevate-card.stories.d.ts +5 -0
  23. package/dist/types/components/player-rakeback-card/player-rakeback-card.d.ts +63 -0
  24. package/dist/types/components.d.ts +79 -0
  25. package/package.json +1 -1
  26. package/dist/player-elevate-card/p-45b4751e.entry.js +0 -1
@@ -0,0 +1,339 @@
1
+ import { h } from "@stencil/core";
2
+ import { TRANSLATIONS, translate, translateWithParams } from "../../utils/locale.utils";
3
+ export class PlayerRakebackCard {
4
+ constructor() {
5
+ /**
6
+ * Truncate number to specified decimal places (without rounding)
7
+ * @param num Number to be processed
8
+ * @param digits Number of decimal places to keep
9
+ */
10
+ this.truncateNumber = (num, digits = 2) => {
11
+ const str = num.toString();
12
+ const [integer, decimal = ''] = str.split('.');
13
+ return digits > 0 ? `${integer}.${decimal ? decimal.slice(0, digits) : '00'}` : `${integer}`;
14
+ };
15
+ this.sendRakebackClaimedEvent = () => {
16
+ if (!this.endpoint || !this.session || !this.rakebackInfo.claimable || this.isLoading) {
17
+ return;
18
+ }
19
+ window.postMessage({ type: 'RakebackClaimTrigger', points: this.rakebackInfo.points }, window.location.href);
20
+ };
21
+ this.endpoint = undefined;
22
+ this.theme = 'Dark';
23
+ this.session = undefined;
24
+ this.language = 'en';
25
+ this.clientStyling = '';
26
+ this.clientStylingUrl = '';
27
+ this.translationUrl = '';
28
+ this.show = true;
29
+ this.rakebackInfo = {
30
+ hasRakebackWallet: false,
31
+ points: 0.0,
32
+ currency: 'TRY',
33
+ claimable: false,
34
+ minutesCanClaim: 0,
35
+ showCanClaim: false
36
+ };
37
+ this.isLoading = false;
38
+ this.coolingOffPeriod = false;
39
+ this.showTheWidget = false;
40
+ }
41
+ async onSessionOrEndpointChange() {
42
+ await this.loadRakebackInfo();
43
+ }
44
+ async onShowOrHasRakebackWalletChange() {
45
+ this.showTheWidget = this.show && this.rakebackInfo.hasRakebackWallet;
46
+ }
47
+ handleMessage(event) {
48
+ const { type } = event === null || event === void 0 ? void 0 : event.data;
49
+ if (type === 'RakebackClaimConfirmed') {
50
+ this.claimRakeback();
51
+ }
52
+ }
53
+ async loadRakebackInfo() {
54
+ if (!this.endpoint || !this.session) {
55
+ return;
56
+ }
57
+ this.isLoading = true;
58
+ try {
59
+ const url = new URL(`${this.endpoint}/v1/elevate/playerInfo?language=${this.language}`);
60
+ const response = await fetch(url.href, {
61
+ method: 'GET',
62
+ headers: {
63
+ 'X-Sessionid': this.session,
64
+ 'Content-Type': 'application/json'
65
+ }
66
+ });
67
+ if (!response.ok) {
68
+ throw new Error(`HTTP error! status: ${response.status}`);
69
+ }
70
+ const data = await response.json();
71
+ if (!data.success) {
72
+ throw new Error(data.errorMessage || 'Failed to load rakeback info');
73
+ }
74
+ const { rakebackWallet } = data === null || data === void 0 ? void 0 : data.data;
75
+ if (!rakebackWallet) {
76
+ window.postMessage({ type: 'RakebackWalletMissing' }, window.location.href);
77
+ return;
78
+ }
79
+ const { total, claimable, currency, minutesCanClaim } = rakebackWallet || {};
80
+ this.rakebackInfo = {
81
+ hasRakebackWallet: true,
82
+ points: (total === null || total === void 0 ? void 0 : total.points) ? this.truncateNumber(total.points, 2) : `0.00`,
83
+ currency: currency || '',
84
+ claimable: claimable || false,
85
+ showCanClaim: Boolean(minutesCanClaim && minutesCanClaim > 0),
86
+ minutesCanClaim: minutesCanClaim
87
+ ? minutesCanClaim <= 1 && minutesCanClaim > 0
88
+ ? 1
89
+ : this.truncateNumber(minutesCanClaim, 0)
90
+ : 0
91
+ };
92
+ }
93
+ catch (err) {
94
+ console.error('Error loading rakeback info:', err);
95
+ window.postMessage({ type: 'RakebackClaimError', message: err.message }, window.location.href);
96
+ }
97
+ finally {
98
+ this.isLoading = false;
99
+ }
100
+ }
101
+ async claimRakeback() {
102
+ this.isLoading = true;
103
+ try {
104
+ const url = new URL(`${this.endpoint}/v1/elevate/rakeback/claim`);
105
+ const response = await fetch(url.href, {
106
+ method: 'PUT',
107
+ headers: {
108
+ 'X-Sessionid': this.session,
109
+ 'Content-Type': 'application/json'
110
+ },
111
+ body: JSON.stringify({})
112
+ });
113
+ if (!response.ok) {
114
+ throw new Error(`HTTP error! status: ${response.status}`);
115
+ }
116
+ const data = await response.json();
117
+ if (!data.success) {
118
+ throw new Error(data.errorMessage || 'Failed to claim rakeback');
119
+ }
120
+ // Refresh rakeback information
121
+ await this.loadRakebackInfo();
122
+ // Send event notification for successful redemption
123
+ window.postMessage({ type: 'RakebackClaimed', points: this.rakebackInfo.points }, window.location.href);
124
+ }
125
+ catch (err) {
126
+ console.error('Error claiming rakeback:', err);
127
+ window.postMessage({ type: 'RakebackClaimError', message: err.message }, window.location.href);
128
+ }
129
+ finally {
130
+ this.isLoading = false;
131
+ }
132
+ }
133
+ async componentWillLoad() {
134
+ await this.loadRakebackInfo();
135
+ await this.onShowOrHasRakebackWalletChange();
136
+ }
137
+ render() {
138
+ return this.showTheWidget ? (h("div", { class: "RakebackCard" }, h("general-styling-wrapper", { clientStyling: this.clientStyling, clientStylingUrl: this.clientStylingUrl, targetTranslations: TRANSLATIONS, translationUrl: this.translationUrl }), h("div", { class: "RakebackCardContent" }, h("div", { class: "RakebackTitle" }, translate('rakebackTitle', this.language)), h("div", { class: "RakebackDetails" }, h("div", { class: "RakebackInfo" }, h("div", { class: "RakebackNumContainer" }, h("span", { class: "RakebackNum" }, this.rakebackInfo.points), h("span", { class: "RakebackCurrency" }, this.rakebackInfo.currency))), h("div", { class: `RakebackButton ${this.isLoading || !this.rakebackInfo.claimable ? 'disabled' : ''}`, onClick: this.sendRakebackClaimedEvent }, translate('claim', this.language))), !this.rakebackInfo.claimable && this.rakebackInfo.showCanClaim && (h("div", { class: "RakebackCoolOff" }, translateWithParams('minutesCanClaim', {
139
+ lang: this.language,
140
+ minutes: this.rakebackInfo.minutesCanClaim
141
+ })))))) : null;
142
+ }
143
+ static get is() { return "player-rakeback-card"; }
144
+ static get encapsulation() { return "shadow"; }
145
+ static get originalStyleUrls() {
146
+ return {
147
+ "$": ["player-rakeback-card.scss"]
148
+ };
149
+ }
150
+ static get styleUrls() {
151
+ return {
152
+ "$": ["player-rakeback-card.css"]
153
+ };
154
+ }
155
+ static get properties() {
156
+ return {
157
+ "endpoint": {
158
+ "type": "string",
159
+ "mutable": false,
160
+ "complexType": {
161
+ "original": "string",
162
+ "resolved": "string",
163
+ "references": {}
164
+ },
165
+ "required": true,
166
+ "optional": false,
167
+ "docs": {
168
+ "tags": [],
169
+ "text": "The NWA endpoint"
170
+ },
171
+ "attribute": "endpoint",
172
+ "reflect": true
173
+ },
174
+ "theme": {
175
+ "type": "string",
176
+ "mutable": false,
177
+ "complexType": {
178
+ "original": "string",
179
+ "resolved": "string",
180
+ "references": {}
181
+ },
182
+ "required": false,
183
+ "optional": false,
184
+ "docs": {
185
+ "tags": [],
186
+ "text": "The style that widget shows, available value: Dark, Light\nDefault: Dark"
187
+ },
188
+ "attribute": "theme",
189
+ "reflect": true,
190
+ "defaultValue": "'Dark'"
191
+ },
192
+ "session": {
193
+ "type": "string",
194
+ "mutable": false,
195
+ "complexType": {
196
+ "original": "string",
197
+ "resolved": "string",
198
+ "references": {}
199
+ },
200
+ "required": true,
201
+ "optional": false,
202
+ "docs": {
203
+ "tags": [],
204
+ "text": "The NWA session for the logged-in user"
205
+ },
206
+ "attribute": "session",
207
+ "reflect": true
208
+ },
209
+ "language": {
210
+ "type": "string",
211
+ "mutable": false,
212
+ "complexType": {
213
+ "original": "string",
214
+ "resolved": "string",
215
+ "references": {}
216
+ },
217
+ "required": false,
218
+ "optional": false,
219
+ "docs": {
220
+ "tags": [],
221
+ "text": "Widget Language to show"
222
+ },
223
+ "attribute": "language",
224
+ "reflect": true,
225
+ "defaultValue": "'en'"
226
+ },
227
+ "clientStyling": {
228
+ "type": "string",
229
+ "mutable": false,
230
+ "complexType": {
231
+ "original": "string",
232
+ "resolved": "string",
233
+ "references": {}
234
+ },
235
+ "required": false,
236
+ "optional": false,
237
+ "docs": {
238
+ "tags": [],
239
+ "text": "Client custom styling via inline styles"
240
+ },
241
+ "attribute": "client-styling",
242
+ "reflect": true,
243
+ "defaultValue": "''"
244
+ },
245
+ "clientStylingUrl": {
246
+ "type": "string",
247
+ "mutable": false,
248
+ "complexType": {
249
+ "original": "string",
250
+ "resolved": "string",
251
+ "references": {}
252
+ },
253
+ "required": false,
254
+ "optional": false,
255
+ "docs": {
256
+ "tags": [],
257
+ "text": "Client custom styling via url"
258
+ },
259
+ "attribute": "client-styling-url",
260
+ "reflect": true,
261
+ "defaultValue": "''"
262
+ },
263
+ "translationUrl": {
264
+ "type": "string",
265
+ "mutable": false,
266
+ "complexType": {
267
+ "original": "string",
268
+ "resolved": "string",
269
+ "references": {}
270
+ },
271
+ "required": false,
272
+ "optional": false,
273
+ "docs": {
274
+ "tags": [],
275
+ "text": "Translation via url"
276
+ },
277
+ "attribute": "translation-url",
278
+ "reflect": true,
279
+ "defaultValue": "''"
280
+ },
281
+ "show": {
282
+ "type": "boolean",
283
+ "mutable": false,
284
+ "complexType": {
285
+ "original": "boolean",
286
+ "resolved": "boolean",
287
+ "references": {}
288
+ },
289
+ "required": false,
290
+ "optional": false,
291
+ "docs": {
292
+ "tags": [{
293
+ "name": "default",
294
+ "text": "true"
295
+ }],
296
+ "text": "Show the widget"
297
+ },
298
+ "attribute": "show",
299
+ "reflect": true,
300
+ "defaultValue": "true"
301
+ }
302
+ };
303
+ }
304
+ static get states() {
305
+ return {
306
+ "rakebackInfo": {},
307
+ "isLoading": {},
308
+ "coolingOffPeriod": {},
309
+ "showTheWidget": {}
310
+ };
311
+ }
312
+ static get watchers() {
313
+ return [{
314
+ "propName": "session",
315
+ "methodName": "onSessionOrEndpointChange"
316
+ }, {
317
+ "propName": "endpoint",
318
+ "methodName": "onSessionOrEndpointChange"
319
+ }, {
320
+ "propName": "language",
321
+ "methodName": "onSessionOrEndpointChange"
322
+ }, {
323
+ "propName": "show",
324
+ "methodName": "onShowOrHasRakebackWalletChange"
325
+ }, {
326
+ "propName": "rakebackInfo",
327
+ "methodName": "onShowOrHasRakebackWalletChange"
328
+ }];
329
+ }
330
+ static get listeners() {
331
+ return [{
332
+ "name": "message",
333
+ "method": "handleMessage",
334
+ "target": "window",
335
+ "capture": false,
336
+ "passive": false
337
+ }];
338
+ }
339
+ }
@@ -3,6 +3,7 @@ const SUPPORTED_LANGUAGES = ['en', 'zh-hk', 'it', 'fr', 'tr', 'hr'];
3
3
  export const TRANSLATIONS = {
4
4
  en: {
5
5
  redeem: 'Redeem',
6
+ claim: 'Claim',
6
7
  expireOn: 'Expire on ',
7
8
  pointsToBeExpired: '${expirationPoints} points to expire in ${expireDay} days',
8
9
  pointsToBeExpiredDay: '${expirationPoints} points to expire in ${expireDay} day',
@@ -17,9 +18,13 @@ export const TRANSLATIONS = {
17
18
  xp: 'XP',
18
19
  sp: 'Coins',
19
20
  termAndConditions: 'Term & Conditions',
21
+ rakebackTitle: 'Available Rakeback',
22
+ loading: 'Loading',
23
+ minutesCanClaim: 'Next Claim is available in ${minutes} minutes'
20
24
  },
21
25
  'zh-hk': {
22
26
  redeem: '兑奖',
27
+ claim: '返佣',
23
28
  expireOn: 'Expire on ',
24
29
  pointsToBeExpired: '${expirationPoints} points to expire in ${expireDay} days',
25
30
  pointsToBeExpiredDay: '${expirationPoints} points to expire in ${expireDay} day',
@@ -34,9 +39,13 @@ export const TRANSLATIONS = {
34
39
  xp: 'XP',
35
40
  sp: 'Coins',
36
41
  termAndConditions: 'Term & Conditions',
42
+ rakebackTitle: '可用的返利',
43
+ loading: '加載中',
44
+ minutesCanClaim: '下次可領取時間為${minutes}分鐘後'
37
45
  },
38
46
  de: {
39
47
  redeem: 'Redeem',
48
+ claim: 'Anspruch',
40
49
  expireOn: 'Expire on ',
41
50
  pointsToBeExpired: '${expirationPoints} points to expire in ${expireDay} days',
42
51
  pointsToBeExpiredDay: '${expirationPoints} points to expire in ${expireDay} day',
@@ -51,9 +60,13 @@ export const TRANSLATIONS = {
51
60
  xp: 'XP',
52
61
  sp: 'Coins',
53
62
  termAndConditions: 'Term & Conditions',
63
+ rakebackTitle: 'Verfügbarer Rakeback',
64
+ loading: 'Laden',
65
+ minutesCanClaim: 'Nächster Anspruch ist in ${minutes} Minuten verfügbar'
54
66
  },
55
67
  it: {
56
68
  redeem: 'Redeem',
69
+ claim: 'Richiesta',
57
70
  expireOn: 'Expire on ',
58
71
  pointsToBeExpired: '${expirationPoints} points to expire in ${expireDay} days',
59
72
  pointsToBeExpiredDay: '${expirationPoints} points to expire in ${expireDay} day',
@@ -68,9 +81,13 @@ export const TRANSLATIONS = {
68
81
  xp: 'XP',
69
82
  sp: 'Coins',
70
83
  termAndConditions: 'Term & Conditions',
84
+ rakebackTitle: 'Rakeback Disponibile',
85
+ loading: 'Caricamento',
86
+ minutesCanClaim: 'La prossima richiesta sarà disponibile tra ${minutes} minuti'
71
87
  },
72
88
  fr: {
73
89
  redeem: 'Redeem',
90
+ claim: 'Réclamer',
74
91
  expireOn: 'Expire on ',
75
92
  pointsToBeExpired: '${expirationPoints} points to expire in ${expireDay} days',
76
93
  pointsToBeExpiredDay: '${expirationPoints} points to expire in ${expireDay} day',
@@ -85,12 +102,20 @@ export const TRANSLATIONS = {
85
102
  xp: 'XP',
86
103
  sp: 'Coins',
87
104
  termAndConditions: 'Term & Conditions',
105
+ rakebackTitle: 'Rakeback Disponible',
106
+ loading: 'Chargement',
107
+ minutesCanClaim: 'La prochaine réclamation sera disponible dans ${minutes} minutes'
88
108
  },
89
109
  es: {
90
- redeem: 'Redeem'
110
+ redeem: 'Redeem',
111
+ claim: 'Reclamar',
112
+ rakebackTitle: 'Rakeback Disponible',
113
+ loading: 'Cargando',
114
+ minutesCanClaim: 'La próxima reclamación estará disponible en ${minutes} minutos'
91
115
  },
92
116
  tr: {
93
117
  redeem: 'Redeem',
118
+ claim: 'Talep',
94
119
  expireOn: 'Expire on ',
95
120
  pointsToBeExpired: '${expirationPoints} points to expire in ${expireDay} days',
96
121
  pointsToBeExpiredDay: '${expirationPoints} points to expire in ${expireDay} day',
@@ -105,15 +130,27 @@ export const TRANSLATIONS = {
105
130
  xp: 'XP',
106
131
  sp: 'Coins',
107
132
  termAndConditions: 'Term & Conditions',
133
+ rakebackTitle: 'Mevcut Rakeback',
134
+ loading: 'Yükleniyor',
135
+ minutesCanClaim: 'Sonraki talep ${minutes} dakika içinde kullanılabilir'
108
136
  },
109
137
  ru: {
110
- redeem: 'Redeem'
138
+ redeem: 'Redeem',
139
+ claim: 'Требовать',
140
+ rakebackTitle: 'Доступный Рейкбек',
141
+ loading: 'Загрузка',
142
+ minutesCanClaim: 'Следующее требование будет доступно через ${minutes} минут'
111
143
  },
112
144
  ro: {
113
- redeem: 'Redeem'
145
+ redeem: 'Redeem',
146
+ claim: 'Revendicare',
147
+ rakebackTitle: 'Rakeback Disponibil',
148
+ loading: 'Se încarcă',
149
+ minutesCanClaim: 'Următoarea revendicare va fi disponibilă în ${minutes} minute'
114
150
  },
115
151
  hr: {
116
152
  redeem: 'Otkupiti',
153
+ claim: 'Zahtjev',
117
154
  expireOn: 'Istječe',
118
155
  pointsToBeExpired: '${expirationPoints} bodova ističe za ${expireDay} dana',
119
156
  pointsToBeExpiredHours: '${expirationPoints} points to expire in ${expireDay} hours',
@@ -124,21 +161,44 @@ export const TRANSLATIONS = {
124
161
  spendablePoints: 'Bodovi za potrošit:',
125
162
  details: 'Detalji',
126
163
  xp: 'XP',
164
+ rakebackTitle: 'Dostupan Rakeback',
165
+ loading: 'Učitavanje',
166
+ minutesCanClaim: 'Sljedeći zahtjev bit će dostupan za ${minutes} minuta'
127
167
  },
128
168
  hu: {
129
- redeem: 'Redeem'
169
+ redeem: 'Redeem',
170
+ claim: 'Igény',
171
+ rakebackTitle: 'Elérhető Rakeback',
172
+ loading: 'Betöltés',
173
+ minutesCanClaim: 'A következő igény ${minutes} perc múlva lesz elérhető'
130
174
  },
131
175
  pl: {
132
- redeem: 'Redeem'
176
+ redeem: 'Redeem',
177
+ claim: 'Roszczenie',
178
+ rakebackTitle: 'Dostępny Rakeback',
179
+ loading: 'Ładowanie',
180
+ minutesCanClaim: 'Następne roszczenie będzie dostępne za ${minutes} minut'
133
181
  },
134
182
  pt: {
135
- redeem: 'Redeem'
183
+ redeem: 'Redeem',
184
+ claim: 'Reivindicar',
185
+ rakebackTitle: 'Rakeback Disponível',
186
+ loading: 'Carregando',
187
+ minutesCanClaim: 'Próxima reivindicação disponível em ${minutes} minutos'
136
188
  },
137
189
  sl: {
138
- redeem: 'Redeem'
190
+ redeem: 'Redeem',
191
+ claim: 'Zahtevek',
192
+ rakebackTitle: 'Razpoložljiv Rakeback',
193
+ loading: 'Nalaganje',
194
+ minutesCanClaim: 'Naslednji zahtevek bo na voljo čez ${minutes} minut'
139
195
  },
140
196
  sr: {
141
- redeem: 'Redeem'
197
+ redeem: 'Redeem',
198
+ claim: 'Zahtev',
199
+ rakebackTitle: 'Dostupan Rakeback',
200
+ loading: 'Učitavanje',
201
+ minutesCanClaim: 'Sledeći zahtev biće dostupan za ${minutes} minuta'
142
202
  }
143
203
  };
144
204
  export const translate = (key, customLang) => {