@everymatrix/casino-engagement-suite-challenges-list 1.35.0 → 1.36.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 (24) hide show
  1. package/dist/casino-engagement-suite-challenges-list/casino-engagement-suite-challenges-list.esm.js +1 -1
  2. package/dist/casino-engagement-suite-challenges-list/p-a9f41c83.entry.js +1 -0
  3. package/dist/casino-engagement-suite-challenges-list/p-fad4589e.js +1 -0
  4. package/dist/cjs/casino-engagement-suite-challenges-list.cjs.js +2 -2
  5. package/dist/cjs/casino-engagement-suite-challenges-list_2.cjs.entry.js +484 -0
  6. package/dist/cjs/{index-79c88755.js → index-0a011384.js} +38 -1
  7. package/dist/cjs/loader.cjs.js +2 -2
  8. package/dist/collection/collection-manifest.json +8 -1
  9. package/dist/collection/components/casino-engagement-suite-challenges-list/casino-engagement-suite-challenges-list.css +1 -0
  10. package/dist/collection/components/casino-engagement-suite-challenges-list/casino-engagement-suite-challenges-list.js +43 -16
  11. package/dist/components/casino-engagement-suite-challenges-list.js +51 -773
  12. package/dist/components/casino-engagement-suite-progress-bar.js +6 -0
  13. package/dist/components/casino-engagement-suite-progress-bar2.js +88 -0
  14. package/dist/esm/casino-engagement-suite-challenges-list.js +2 -2
  15. package/dist/esm/casino-engagement-suite-challenges-list_2.entry.js +479 -0
  16. package/dist/esm/{index-70e47fe0.js → index-ddf7e990.js} +38 -1
  17. package/dist/esm/loader.js +2 -2
  18. package/dist/types/components/casino-engagement-suite-challenges-list/casino-engagement-suite-challenges-list.d.ts +1 -0
  19. package/dist/types/models/challenge.d.ts +1 -0
  20. package/package.json +1 -1
  21. package/dist/casino-engagement-suite-challenges-list/p-7e171791.js +0 -1
  22. package/dist/casino-engagement-suite-challenges-list/p-eb36cbe7.entry.js +0 -1
  23. package/dist/cjs/casino-engagement-suite-challenges-list.cjs.entry.js +0 -1147
  24. package/dist/esm/casino-engagement-suite-challenges-list.entry.js +0 -1143
@@ -7,6 +7,13 @@
7
7
  "version": "2.15.2",
8
8
  "typescriptVersion": "4.5.4"
9
9
  },
10
- "collections": [],
10
+ "collections": [
11
+ {
12
+ "name": "@everymatrix/casino-engagement-suite-progress-bar",
13
+ "tags": [
14
+ "casino-engagement-suite-progress-bar"
15
+ ]
16
+ }
17
+ ],
11
18
  "bundles": []
12
19
  }
@@ -70,6 +70,7 @@ button:focus {
70
70
  border: 1px solid var(--emw--button-border-color, #403956);
71
71
  border-radius: 6px;
72
72
  position: relative;
73
+ cursor: pointer;
73
74
  }
74
75
 
75
76
  .ChallengeJoinButton.Joined::before,
@@ -2,7 +2,6 @@ import { Component, Element, Event, h, Listen, Prop, State, Watch } from '@stenc
2
2
  import { ChallengeLevelProgressStatus, ChallengeProgressStatus } from '../../models/challenge';
3
3
  import { translate } from '../../utils/locale.utils';
4
4
  import '@everymatrix/casino-engagement-suite-progress-bar';
5
- import intervalToDuration from 'date-fns/intervalToDuration';
6
5
  import differenceInSeconds from 'date-fns/differenceInSeconds';
7
6
  export class CasinoEngagementSuiteChallengesList {
8
7
  constructor() {
@@ -53,7 +52,7 @@ export class CasinoEngagementSuiteChallengesList {
53
52
  };
54
53
  this.handleChallengeClick = (ev) => {
55
54
  const id = +ev.currentTarget.getAttribute('data-id');
56
- window.postMessage({ type: `ChallengeClick`, id });
55
+ window.postMessage({ type: 'ChallengeClick', id });
57
56
  };
58
57
  this.showTooltip = () => {
59
58
  this.tooltip = true;
@@ -61,6 +60,35 @@ export class CasinoEngagementSuiteChallengesList {
61
60
  this.hideTooltip = () => {
62
61
  this.tooltip = false;
63
62
  };
63
+ this.changeChallengeStatus = (e) => {
64
+ e.stopPropagation();
65
+ const id = +e.currentTarget.getAttribute('data-id');
66
+ const inProgressChallenges = this.challenges.filter(c => c.Status === ChallengeProgressStatus.InProgress).map(c => c.Id);
67
+ if (inProgressChallenges.includes(id)) {
68
+ window.postMessage({
69
+ type: 'ShowConfirmationModal',
70
+ action: 'unjoin',
71
+ id,
72
+ });
73
+ return;
74
+ }
75
+ if ((inProgressChallenges === null || inProgressChallenges === void 0 ? void 0 : inProgressChallenges.length) > 0) {
76
+ window.postMessage({
77
+ type: 'ShowConfirmationModal',
78
+ action: 'join',
79
+ prevId: inProgressChallenges[0],
80
+ id,
81
+ });
82
+ return;
83
+ }
84
+ window.postMessage({
85
+ type: 'ChallengeAttendance',
86
+ confirmationData: {
87
+ action: 'join',
88
+ id,
89
+ },
90
+ });
91
+ };
64
92
  }
65
93
  challengesPropHandler(value) {
66
94
  if (!this.interval && value.length) {
@@ -104,23 +132,21 @@ export class CasinoEngagementSuiteChallengesList {
104
132
  }, 1000);
105
133
  }
106
134
  updateTimers() {
107
- const now = new Date();
135
+ const now = new Date().getTime();
108
136
  this.timers = this.challenges.filter(challenge => challenge.Status !== ChallengeProgressStatus.Expired).reduce((acc, challenge) => {
109
- const expirationDate = new Date(challenge.ExpirationTime);
110
- const diff = differenceInSeconds(expirationDate, now);
111
- const duration = intervalToDuration({
112
- start: now,
113
- end: expirationDate
114
- });
137
+ const expirationDate = new Date(challenge.ExpirationTime).getTime();
138
+ const diff = expirationDate - now;
115
139
  let countdown = '00h:00m:00s';
116
140
  if (diff < 1) {
117
141
  this.removeChallenge(challenge.Id);
118
142
  }
119
143
  else {
120
- const days = duration.days.toString().padStart(2, '0');
121
- const hours = duration.hours.toString().padStart(2, '0');
122
- const minutes = duration.minutes.toString().padStart(2, '0');
123
- const seconds = duration.seconds.toString().padStart(2, '0');
144
+ const { days, hours, minutes, seconds } = {
145
+ days: String(Math.floor(diff / (1000 * 60 * 60 * 24))).padStart(2, '0'),
146
+ hours: String(Math.floor((diff % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60))).padStart(2, '0'),
147
+ minutes: String(Math.floor((diff % (1000 * 60 * 60)) / (1000 * 60))).padStart(2, '0'),
148
+ seconds: String(Math.floor((diff % (1000 * 60)) / 1000)).padStart(2, '0')
149
+ };
124
150
  countdown = days === '00'
125
151
  ? `${hours}h:${minutes}m:${seconds}s`
126
152
  : `${days}d:${hours}h:${minutes}m`;
@@ -172,9 +198,10 @@ export class CasinoEngagementSuiteChallengesList {
172
198
  return -1;
173
199
  }
174
200
  getChallengeHeaderTemplate(challenge) {
201
+ const { Id } = challenge;
175
202
  return h("div", { class: "ChallengeCardHeader" },
176
203
  h("div", { class: "ChallengeName" }, challenge.ChallengePresentation.PresentationName),
177
- h("button", { class: challenge.Status === ChallengeProgressStatus.InProgress ? 'ChallengeJoinButton Joined' : 'ChallengeJoinButton' }, challenge.Status === ChallengeProgressStatus.InProgress
204
+ h("button", { class: challenge.Status === ChallengeProgressStatus.InProgress ? 'ChallengeJoinButton Joined' : 'ChallengeJoinButton', onClick: this.changeChallengeStatus, "data-id": Id }, challenge.Status === ChallengeProgressStatus.InProgress
178
205
  ? translate('unjoin', this.language)
179
206
  : translate('join', this.language)));
180
207
  }
@@ -195,7 +222,7 @@ export class CasinoEngagementSuiteChallengesList {
195
222
  h("img", { src: "https://static.everymatrix.com/gic/img/engagement-suite/help.svg", alt: "Show tooltip" })),
196
223
  h("div", { class: "ChallengesListPopupHeaderName" }, translate('challenges', this.language)),
197
224
  h("button", { class: "ChallengesIconButton", onClick: this.handleCloseClick },
198
- h("img", { src: "https://static.everymatrix.com/gic/img/engagement-suite/close.svg", alt: "\u0421lose challenges list" })));
225
+ h("img", { src: "https://static.everymatrix.com/gic/img/engagement-suite/close.svg", alt: "Close challenges list" })));
199
226
  }
200
227
  getListTemplate() {
201
228
  if (this.challenges.length) {
@@ -213,7 +240,7 @@ export class CasinoEngagementSuiteChallengesList {
213
240
  return h("div", { class: "ChallengesTooltipBackdrop" },
214
241
  h("div", { class: "ChallengesTooltip" },
215
242
  h("button", { class: "ChallengesIconButton", onClick: this.hideTooltip },
216
- h("img", { src: "https://static.everymatrix.com/gic/img/engagement-suite/close.svg", alt: "\u0421lose tooltip" })),
243
+ h("img", { src: "https://static.everymatrix.com/gic/img/engagement-suite/close.svg", alt: "Close tooltip" })),
217
244
  translate('tooltip', this.language)));
218
245
  }
219
246
  else {