@everymatrix/lottery-tipping-ticket-controller 1.87.28 → 1.87.29

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 (30) hide show
  1. package/dist/cjs/general-tooltip_7.cjs.entry.js +379 -117
  2. package/dist/cjs/index.cjs.js +1 -1
  3. package/dist/cjs/loader.cjs.js +1 -1
  4. package/dist/cjs/{lottery-tipping-ticket-controller-38883843.js → lottery-tipping-ticket-controller-90ba14f0.js} +45 -15
  5. package/dist/cjs/lottery-tipping-ticket-controller.cjs.js +1 -1
  6. package/dist/collection/collection-manifest.json +7 -2
  7. package/dist/collection/components/lottery-tipping-ticket-controller/lottery-tipping-ticket-controller.js +13 -12
  8. package/dist/collection/models/index.js +10 -0
  9. package/dist/collection/utils/api.js +11 -1
  10. package/dist/collection/utils/locale.utils.js +1 -1
  11. package/dist/collection/utils/utils.js +14 -0
  12. package/dist/esm/general-tooltip_7.entry.js +380 -118
  13. package/dist/esm/index.js +1 -1
  14. package/dist/esm/loader.js +1 -1
  15. package/dist/esm/{lottery-tipping-ticket-controller-7714da55.js → lottery-tipping-ticket-controller-f46b8ced.js} +46 -14
  16. package/dist/esm/lottery-tipping-ticket-controller.js +1 -1
  17. package/dist/lottery-tipping-ticket-controller/general-tooltip_7.entry.js +1 -1
  18. package/dist/lottery-tipping-ticket-controller/index.esm.js +1 -1
  19. package/dist/lottery-tipping-ticket-controller/{lottery-tipping-ticket-controller-7714da55.js → lottery-tipping-ticket-controller-f46b8ced.js} +1 -1
  20. package/dist/lottery-tipping-ticket-controller/lottery-tipping-ticket-controller.esm.js +1 -1
  21. package/dist/types/components/lottery-tipping-ticket-controller/lottery-tipping-ticket-controller.d.ts +3 -1
  22. package/dist/types/components.d.ts +0 -55
  23. package/dist/types/models/index.d.ts +181 -0
  24. package/dist/types/utils/utils.d.ts +2 -0
  25. package/package.json +1 -1
  26. package/dist/collection/components/lottery-tipping-ticket-banner/locale.utils.js +0 -36
  27. package/dist/collection/components/lottery-tipping-ticket-banner/lottery-tipping-ticket-banner.css +0 -73
  28. package/dist/collection/components/lottery-tipping-ticket-banner/lottery-tipping-ticket-banner.js +0 -259
  29. package/dist/types/components/lottery-tipping-ticket-banner/locale.utils.d.ts +0 -2
  30. package/dist/types/components/lottery-tipping-ticket-banner/lottery-tipping-ticket-banner.d.ts +0 -28
@@ -6791,6 +6791,16 @@ var BettingTypeEnum;
6791
6791
  BettingTypeEnum["HalfTime"] = "HalfTime";
6792
6792
  BettingTypeEnum["Both"] = "Both";
6793
6793
  })(BettingTypeEnum || (BettingTypeEnum = {}));
6794
+ var DrawStatus;
6795
+ (function (DrawStatus) {
6796
+ DrawStatus["OPEN"] = "OPEN";
6797
+ })(DrawStatus || (DrawStatus = {}));
6798
+ var TicketState;
6799
+ (function (TicketState) {
6800
+ TicketState["Settled"] = "Settled";
6801
+ TicketState["Purchased"] = "Purchased";
6802
+ TicketState["Canceled"] = "Canceled";
6803
+ })(TicketState || (TicketState = {}));
6794
6804
 
6795
6805
  const DEFAULT_LANGUAGE = 'en';
6796
6806
  const SUPPORTED_LANGUAGES = ['ro', 'en', 'fr', 'ar', 'hr'];
@@ -6801,7 +6811,7 @@ const TRANSLATIONS = {
6801
6811
  turnover: 'Turnover: ',
6802
6812
  selectionCleared: 'Your selection will be cleared.',
6803
6813
  ticketSubmitted: 'Ticket submitted successfully.',
6804
- ticketFailed: 'Failed to purchase the ticket. Please try again.',
6814
+ ticketFailed: 'Failed to submit tickets.',
6805
6815
  lines: 'Lines',
6806
6816
  line: 'Line',
6807
6817
  bettingType: 'Betting Type',
@@ -9503,6 +9513,20 @@ const getPlayTypeConfig = ({ rawData, selectedBettingType, selectedPlayingMode }
9503
9513
  return { betTypeId, betType };
9504
9514
  };
9505
9515
  const getMinValue = (arr) => (arr.length ? Math.min.apply(null, arr) : undefined);
9516
+ function formattedTurnover(turnover, unit = '€') {
9517
+ if (turnover === null || turnover === undefined)
9518
+ return '';
9519
+ return `${unit}${turnover ? thousandSeparator(turnover) : 0}`;
9520
+ }
9521
+ function formattedWeekName(date) {
9522
+ if (!date)
9523
+ return '';
9524
+ const _temp = formatDate({ date, format: 'EEEE' });
9525
+ if (!['saturday', 'sunday'].includes(_temp.toLowerCase())) {
9526
+ return 'MIDWEEK';
9527
+ }
9528
+ return _temp.toUpperCase();
9529
+ }
9506
9530
 
9507
9531
  const TICKET_INVALID_TOKEN = 'TICKET_INVALID_TOKEN';
9508
9532
  const generateUUID = () => {
@@ -9529,9 +9553,18 @@ const doSubmitTicket = ({ body, sessionId, url }) => {
9529
9553
  if (res.status > 300) {
9530
9554
  throw new Error(res.statusText);
9531
9555
  }
9532
- return res.json();
9556
+ return res.json().then((data) => {
9557
+ if (checkTicketDetailHasError(data.tickets))
9558
+ throw new Error(res.statusText);
9559
+ return data;
9560
+ });
9533
9561
  });
9534
9562
  };
9563
+ function checkTicketDetailHasError(tickets) {
9564
+ if (!tickets || !tickets.length)
9565
+ return true;
9566
+ return tickets.some((i) => i.state !== TicketState.Purchased);
9567
+ }
9535
9568
  async function fetchSaleStatistics({ endpoint, gameId, drawId }) {
9536
9569
  try {
9537
9570
  const res = await fetchRequest(`${endpoint}/games/${gameId}/draws/${drawId}/saleStatistics`);
@@ -9573,6 +9606,7 @@ const LotteryTippingTicketController = class {
9573
9606
  this.hasSelectAllBullet = undefined;
9574
9607
  this.totalLineCombination = 0;
9575
9608
  this.submitLoading = undefined;
9609
+ this.drawSubmitAvailable = false;
9576
9610
  this.rawData = {};
9577
9611
  this.saleStatisticsInfo = {};
9578
9612
  this.currentStake = undefined;
@@ -9743,6 +9777,9 @@ const LotteryTippingTicketController = class {
9743
9777
  setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`, this.stylingSubscription);
9744
9778
  }
9745
9779
  }
9780
+ handleTimerStop() {
9781
+ this.drawSubmitAvailable = true;
9782
+ }
9746
9783
  componentWillLoad() {
9747
9784
  if (this.translationUrl) {
9748
9785
  resolveTranslationUrl(this.translationUrl);
@@ -9865,19 +9902,14 @@ const LotteryTippingTicketController = class {
9865
9902
  }
9866
9903
  renderOrderSummary() {
9867
9904
  var _a;
9868
- return (index.h("div", { class: "LotteryTippingTicketController__main--right order-summary" }, index.h("h3", { class: "order-summary__title" }, translate('orderSummaryTitle', this.language)), index.h("div", { class: "order-summary__ticket-info" }, index.h("div", { class: "order-summary__ticket" }, translate('orderSummaryTickets', this.language), ":"), index.h("div", { class: "order-summary__details" }, index.h("span", { class: "order-summary__line-count" }, this.lineCountRender), index.h("div", null, this.currentStake && index.h("span", { class: "order-summary__multiplier" }, "x"), index.h("span", { class: "order-summary__stake" }, this.currentStakeFormatted)), this.isBothBettingType && (index.h("div", null, index.h("span", { class: "order-summary__multiplier" }, "x"), index.h("span", { class: "order-summary__stake" }, this.bothBettingTypeMultiplier))))), index.h("hr", { class: "order-summary__divider" }), index.h("div", { class: "order-summary__ticket-info" }, index.h("div", { class: "order-summary__ticket" }, translate('orderSummaryTotal', this.language), ":"), index.h("span", { class: "order-summary__details" }, this.totalAmountFormatted)), index.h("div", { class: "order-summary__button-wrapper" }, index.h("lottery-button", { onClick: this.handleSubmit.bind(this), loading: this.submitLoading, disabled: !this.hasSelectAllBullet || this.submitLoading || ((_a = this.currentStake) === null || _a === void 0 ? void 0 : _a.value) === undefined, text: translate('orderSummarySubmit', this.language) }))));
9869
- }
9870
- get formattedTurnover() {
9871
- var _a, _b, _c;
9872
- const turnover = (_c = (_b = (_a = this.saleStatisticsInfo) === null || _a === void 0 ? void 0 : _a.wagerSegment) === null || _b === void 0 ? void 0 : _b.totalSalesCrossDraw) !== null && _c !== void 0 ? _c : 0;
9873
- if (turnover === null || turnover === undefined)
9874
- return '';
9875
- const unit = '€';
9876
- return `${unit}${turnover ? thousandSeparator(turnover) : 0}`;
9905
+ return (index.h("div", { class: "LotteryTippingTicketController__main--right order-summary" }, index.h("h3", { class: "order-summary__title" }, translate('orderSummaryTitle', this.language)), index.h("div", { class: "order-summary__ticket-info" }, index.h("div", { class: "order-summary__ticket" }, translate('orderSummaryTickets', this.language), ":"), index.h("div", { class: "order-summary__details" }, index.h("span", { class: "order-summary__line-count" }, this.lineCountRender), index.h("div", null, this.currentStake && index.h("span", { class: "order-summary__multiplier" }, "x"), index.h("span", { class: "order-summary__stake" }, this.currentStakeFormatted)), this.isBothBettingType && (index.h("div", null, index.h("span", { class: "order-summary__multiplier" }, "x"), index.h("span", { class: "order-summary__stake" }, this.bothBettingTypeMultiplier))))), index.h("hr", { class: "order-summary__divider" }), index.h("div", { class: "order-summary__ticket-info" }, index.h("div", { class: "order-summary__ticket" }, translate('orderSummaryTotal', this.language), ":"), index.h("span", { class: "order-summary__details" }, this.totalAmountFormatted)), index.h("div", { class: "order-summary__button-wrapper" }, index.h("lottery-button", { onClick: this.handleSubmit.bind(this), loading: this.submitLoading, disabled: !this.hasSelectAllBullet ||
9906
+ this.submitLoading ||
9907
+ ((_a = this.currentStake) === null || _a === void 0 ? void 0 : _a.value) === undefined ||
9908
+ !this.drawSubmitAvailable, text: translate('orderSummarySubmit', this.language) }))));
9877
9909
  }
9878
9910
  render() {
9879
- var _a, _b, _c, _d, _e, _f, _g;
9880
- return (index.h("div", { key: '353f56111a3dc6f6e7365d563163a38c850f2e88', class: "lottery-tipping-ticket-controller__container", ref: (el) => (this.stylingContainer = el) }, index.h("lottery-tipping-ticket-banner", { key: '3a2472f0bf9195547f5e4c6c2c0a2362c790aa27', "client-styling": this.clientStyling, "client-styling-Url": this.clientStylingUrl, stopTime: (_b = (_a = this.rawData) === null || _a === void 0 ? void 0 : _a.currentDraw) === null || _b === void 0 ? void 0 : _b.wagerCloseTime, period: (_d = (_c = this.rawData) === null || _c === void 0 ? void 0 : _c.currentDraw) === null || _d === void 0 ? void 0 : _d.date, "formatted-turnover": this.formattedTurnover, language: this.language, "translation-url": this.translationUrl, "logo-url": this.logoUrl }), this.renderBettingControls(), index.h("div", { key: '9d0a9391ccf79351959cc280e3c15efc657a966f', class: "flex flex-wrap LotteryTippingTicketController__main" }, index.h("div", { key: 'c61fdb41d41694227971478e193cc5162bff30c3', class: "LotteryTippingTicketController__main--left" }, index.h("lottery-tipping-ticket-bet", { key: '56964177a4366a366279b2ebfff2ee52d1e27de0', ref: (el) => (this.childRef = el), endpoint: this.endpoint, "session-id": this.sessionId, "game-id": (_e = this.rawData) === null || _e === void 0 ? void 0 : _e.type, "draw-id": this.drawId, language: this.language, "translation-url": this.translationUrl, "max-total-pages": this.lineNumberRange.maxLineNumber, "min-total-pages": this.lineNumberRange.minLineNumber, "total-pages": this.lineNumberRange.defaultBoards, mode: this.selectedPlayingMode === PlayModeEnum.SingleBet ? 'single' : 'multi', "client-styling": this.clientStyling, "client-styling-Url": this.clientStylingUrl })), this.renderOrderSummary()), this.dialogConfig.visible && (index.h("vaadin-confirm-dialog", { key: 'fe8eb6d26eecee3c6e10b20c4f2ad968f707d51c', rejectButtonVisible: true, rejectText: translate('cancel', this.language), confirmText: translate('confirm', this.language), opened: (_f = this.dialogConfig) === null || _f === void 0 ? void 0 : _f.visible, onConfirm: this.dialogConfig.onConfirm, onReject: this.dialogConfig.onCancel }, (_g = this.dialogConfig) === null || _g === void 0 ? void 0 : _g.content))));
9911
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
9912
+ return (index.h("div", { key: '71d1e6567f13267094ca2bdc32caa02891ad8540', class: "lottery-tipping-ticket-controller__container", ref: (el) => (this.stylingContainer = el) }, index.h("lottery-banner", { key: '4393c6b8cf885f3aa6df61e0283172f99d22fd12', "client-styling": this.clientStyling, "client-styling-Url": this.clientStylingUrl, stopTime: (_b = (_a = this.rawData) === null || _a === void 0 ? void 0 : _a.currentDraw) === null || _b === void 0 ? void 0 : _b.wagerCloseTime, startTime: (_d = (_c = this.rawData) === null || _c === void 0 ? void 0 : _c.currentDraw) === null || _d === void 0 ? void 0 : _d.wagerStartTime, "banner-title": formattedWeekName((_f = (_e = this.rawData) === null || _e === void 0 ? void 0 : _e.currentDraw) === null || _f === void 0 ? void 0 : _f.date), turnover: formattedTurnover((_h = (_g = this.saleStatisticsInfo) === null || _g === void 0 ? void 0 : _g.wagerSegment) === null || _h === void 0 ? void 0 : _h.totalSalesCrossDraw), language: this.language, "translation-url": this.translationUrl, "logo-url": this.logoUrl, onLotteryBannerTimerStop: this.handleTimerStop.bind(this) }), this.renderBettingControls(), index.h("div", { key: 'd054f3970388474745f6e92e7aa028d4509e6250', class: "flex flex-wrap LotteryTippingTicketController__main" }, index.h("div", { key: '736a9c1c2ff1d5c88252b64e6a90a08d185574a0', class: "LotteryTippingTicketController__main--left" }, index.h("lottery-tipping-ticket-bet", { key: '3976fecaa6e049c6d3b7521e58c8fcdf37fa9db4', ref: (el) => (this.childRef = el), endpoint: this.endpoint, "session-id": this.sessionId, "game-id": (_j = this.rawData) === null || _j === void 0 ? void 0 : _j.type, "draw-id": this.drawId, language: this.language, "translation-url": this.translationUrl, "max-total-pages": this.lineNumberRange.maxLineNumber, "min-total-pages": this.lineNumberRange.minLineNumber, "total-pages": this.lineNumberRange.defaultBoards, mode: this.selectedPlayingMode === PlayModeEnum.SingleBet ? 'single' : 'multi', "client-styling": this.clientStyling, "client-styling-Url": this.clientStylingUrl })), this.renderOrderSummary()), this.dialogConfig.visible && (index.h("vaadin-confirm-dialog", { key: '60415251900e4e1c12c14b78314d8085bfbc4c5b', rejectButtonVisible: true, rejectText: translate('cancel', this.language), confirmText: translate('confirm', this.language), opened: (_k = this.dialogConfig) === null || _k === void 0 ? void 0 : _k.visible, onConfirm: this.dialogConfig.onConfirm, onReject: this.dialogConfig.onCancel }, (_l = this.dialogConfig) === null || _l === void 0 ? void 0 : _l.content))));
9881
9913
  }
9882
9914
  static get assetsDirs() { return ["../static"]; }
9883
9915
  static get watchers() { return {
@@ -9890,10 +9922,8 @@ LotteryTippingTicketController.style = LotteryTippingTicketControllerStyle0;
9890
9922
 
9891
9923
  exports.LotteryTippingTicketController = LotteryTippingTicketController;
9892
9924
  exports.format = format;
9893
- exports.formatDate = formatDate;
9894
9925
  exports.parseISO = parseISO;
9895
9926
  exports.requiredArgs = requiredArgs;
9896
- exports.resolveTranslationUrl = resolveTranslationUrl;
9897
9927
  exports.setClientStyling = setClientStyling;
9898
9928
  exports.setClientStylingURL = setClientStylingURL;
9899
9929
  exports.setStreamStyling = setStreamStyling;
@@ -19,7 +19,7 @@ var patchBrowser = () => {
19
19
 
20
20
  patchBrowser().then(async (options) => {
21
21
  await appGlobals.globalScripts();
22
- return index.bootstrapLazy([["general-tooltip_7.cjs",[[1,"lottery-tipping-ticket-controller",{"mbSource":[513,"mb-source"],"clientStyling":[513,"client-styling"],"clientStylingUrl":[513,"client-styling-url"],"translationUrl":[513,"translation-url"],"language":[513],"logoUrl":[513,"logo-url"],"endpoint":[513],"sessionId":[513,"session-id"],"gameId":[513,"game-id"],"playerId":[513,"player-id"],"drawId":[513,"draw-id"],"isLoading":[32],"bettingTypeOptions":[32],"playingModeOptions":[32],"selectedBettingType":[32],"selectedPlayingMode":[32],"hasSelectBullet":[32],"hasSelectAllBullet":[32],"totalLineCombination":[32],"submitLoading":[32],"rawData":[32],"saleStatisticsInfo":[32],"currentStake":[32],"dialogConfig":[32]},[[0,"lotteryTippingBulletBetSelect","lotteryTippingBulletGroupSelectionHandler"]],{"clientStyling":["handleClientStylingChange"],"clientStylingUrl":["handleClientStylingUrlChange"],"mbSource":["handleMbSourceChange"]}],[1,"lottery-tipping-ticket-bet",{"mbSource":[513,"mb-source"],"clientStyling":[513,"client-styling"],"clientStylingUrl":[513,"client-styling-url"],"translationUrl":[513,"translation-url"],"language":[513],"sessionId":[513,"session-id"],"endpoint":[513],"gameId":[513,"game-id"],"drawId":[513,"draw-id"],"totalPages":[1538,"total-pages"],"minTotalPages":[514,"min-total-pages"],"maxTotalPages":[514,"max-total-pages"],"mode":[513],"readPretty":[516,"read-pretty"],"defaultBulletConfigLineGroup":[513,"default-bullet-config-line-group"],"translationData":[32],"clientStylingUrlContent":[32],"bulletConfigLineGroup":[32],"currentPage":[32],"isLoading":[32],"hasErrors":[32],"dialogConfig":[32],"ticketDataSource":[32],"resetBulletConfig":[64],"getData":[64]},[[0,"lotteryTippingBulletGroupToggle","lotteryTippingBulletGroupSelectionHandler"]],{"translationUrl":["handleNewTranslations"],"clientStyling":["handleClientStylingChange"],"clientStylingUrl":["handleClientStylingUrlChange"],"mbSource":["handleMbSourceChange"],"gameId":["fetchMatchData"],"sessionId":["fetchMatchData"],"drawId":["fetchMatchData"],"defaultBulletConfigLineGroup":["fetchMatchData"],"currentPage":["handleCurrentPageChange"]}],[1,"lottery-button",{"variant":[513],"size":[513],"color":[513],"disabled":[516],"loading":[516],"text":[513],"mbSource":[513,"mb-source"],"language":[513],"clientStyling":[513,"client-styling"],"clientStylingUrl":[513,"client-styling-url"],"translationUrl":[513,"translation-url"],"ripples":[32]},null,{"clientStyling":["handleClientStylingChange"],"clientStylingUrl":["handleClientStylingUrlChange"],"mbSource":["handleMbSourceChange"]}],[1,"lottery-tipping-ticket-banner",{"mbSource":[513,"mb-source"],"clientStyling":[513,"client-styling"],"clientStylingUrl":[513,"client-styling-url"],"language":[513],"translationUrl":[513,"translation-url"],"logoUrl":[513,"logo-url"],"stopTime":[1,"stop-time"],"period":[1],"formattedTurnover":[1,"formatted-turnover"]},null,{"clientStyling":["handleClientStylingChange"],"clientStylingUrl":["handleClientStylingUrlChange"],"mbSource":["handleMbSourceChange"]}],[1,"lottery-tipping-bullet-group",{"mbSource":[513,"mb-source"],"clientStyling":[513,"client-styling"],"clientStylingUrl":[513,"client-styling-url"],"positionIdx":[513,"position-idx"],"theme":[513],"mode":[513],"bulletConfigContent":[513,"bullet-config-content"]},[[0,"lotteryTippingBulletToggle","lotteryTippingBulletSelectionHandler"]],{"clientStyling":["handleClientStylingChange"],"clientStylingUrl":["handleClientStylingUrlChange"],"mbSource":["handleMbSourceChange"]}],[1,"general-tooltip",{"mbSource":[513,"mb-source"],"clientStyling":[513,"client-styling"],"clientStylingUrl":[513,"client-styling-url"],"position":[1],"delay":[2],"isVisible":[32],"_tooltipId":[32]},[[1,"mouseenter","handleMouseEnterOrFocus"],[0,"focusin","handleMouseEnterOrFocus"],[1,"mouseleave","handleMouseLeaveOrBlur"],[0,"focusout","handleMouseLeaveOrBlur"],[0,"keydown","handleKeyDown"]],{"clientStyling":["handleClientStylingChange"],"clientStylingUrl":["handleClientStylingUrlChange"],"mbSource":["handleMbSourceChange"]}],[1,"lottery-tipping-bullet",{"mbSource":[513,"mb-source"],"clientStyling":[513,"client-styling"],"clientStylingUrl":[513,"client-styling-url"],"positionIdx":[514,"position-idx"],"theme":[513],"value":[513],"disabled":[516],"isSelected":[516,"is-selected"]},null,{"clientStyling":["handleClientStylingChange"],"clientStylingUrl":["handleClientStylingUrlChange"],"mbSource":["handleMbSourceChange"]}]]]], options);
22
+ return index.bootstrapLazy([["general-tooltip_7.cjs",[[1,"lottery-tipping-ticket-controller",{"mbSource":[513,"mb-source"],"clientStyling":[513,"client-styling"],"clientStylingUrl":[513,"client-styling-url"],"translationUrl":[513,"translation-url"],"language":[513],"logoUrl":[513,"logo-url"],"endpoint":[513],"sessionId":[513,"session-id"],"gameId":[513,"game-id"],"playerId":[513,"player-id"],"drawId":[513,"draw-id"],"isLoading":[32],"bettingTypeOptions":[32],"playingModeOptions":[32],"selectedBettingType":[32],"selectedPlayingMode":[32],"hasSelectBullet":[32],"hasSelectAllBullet":[32],"totalLineCombination":[32],"submitLoading":[32],"drawSubmitAvailable":[32],"rawData":[32],"saleStatisticsInfo":[32],"currentStake":[32],"dialogConfig":[32]},[[0,"lotteryTippingBulletBetSelect","lotteryTippingBulletGroupSelectionHandler"]],{"clientStyling":["handleClientStylingChange"],"clientStylingUrl":["handleClientStylingUrlChange"],"mbSource":["handleMbSourceChange"]}],[1,"lottery-tipping-ticket-bet",{"mbSource":[513,"mb-source"],"clientStyling":[513,"client-styling"],"clientStylingUrl":[513,"client-styling-url"],"translationUrl":[513,"translation-url"],"language":[513],"sessionId":[513,"session-id"],"endpoint":[513],"gameId":[513,"game-id"],"drawId":[513,"draw-id"],"totalPages":[1538,"total-pages"],"minTotalPages":[514,"min-total-pages"],"maxTotalPages":[514,"max-total-pages"],"mode":[513],"readPretty":[516,"read-pretty"],"defaultBulletConfigLineGroup":[513,"default-bullet-config-line-group"],"translationData":[32],"clientStylingUrlContent":[32],"bulletConfigLineGroup":[32],"currentPage":[32],"isLoading":[32],"hasErrors":[32],"dialogConfig":[32],"ticketDataSource":[32],"resetBulletConfig":[64],"getData":[64]},[[0,"lotteryTippingBulletGroupToggle","lotteryTippingBulletGroupSelectionHandler"]],{"translationUrl":["handleNewTranslations"],"clientStyling":["handleClientStylingChange"],"clientStylingUrl":["handleClientStylingUrlChange"],"mbSource":["handleMbSourceChange"],"gameId":["fetchMatchData"],"sessionId":["fetchMatchData"],"drawId":["fetchMatchData"],"defaultBulletConfigLineGroup":["fetchMatchData"],"currentPage":["handleCurrentPageChange"]}],[1,"lottery-banner",{"mbSource":[513,"mb-source"],"clientStyling":[513,"client-styling"],"clientStylingUrl":[513,"client-styling-url"],"translationUrl":[513,"translation-url"],"language":[513],"logoUrl":[513,"logo-url"],"stopTime":[1,"stop-time"],"startTime":[1,"start-time"],"bannerTitle":[1,"banner-title"],"turnover":[1],"layout":[1],"formattedTime":[32]},null,{"clientStyling":["handleClientStylingChange"],"clientStylingUrl":["handleClientStylingUrlChange"],"mbSource":["handleMbSourceChange"],"startTime":["handleTimeChange"],"stopTime":["handleTimeChange"]}],[1,"lottery-button",{"variant":[513],"size":[513],"color":[513],"disabled":[516],"loading":[516],"text":[513],"mbSource":[513,"mb-source"],"language":[513],"clientStyling":[513,"client-styling"],"clientStylingUrl":[513,"client-styling-url"],"translationUrl":[513,"translation-url"],"ripples":[32]},null,{"clientStyling":["handleClientStylingChange"],"clientStylingUrl":["handleClientStylingUrlChange"],"mbSource":["handleMbSourceChange"]}],[1,"lottery-tipping-bullet-group",{"mbSource":[513,"mb-source"],"clientStyling":[513,"client-styling"],"clientStylingUrl":[513,"client-styling-url"],"positionIdx":[513,"position-idx"],"theme":[513],"mode":[513],"bulletConfigContent":[513,"bullet-config-content"]},[[0,"lotteryTippingBulletToggle","lotteryTippingBulletSelectionHandler"]],{"clientStyling":["handleClientStylingChange"],"clientStylingUrl":["handleClientStylingUrlChange"],"mbSource":["handleMbSourceChange"]}],[1,"general-tooltip",{"mbSource":[513,"mb-source"],"clientStyling":[513,"client-styling"],"clientStylingUrl":[513,"client-styling-url"],"position":[1],"delay":[2],"isVisible":[32],"_tooltipId":[32]},[[1,"mouseenter","handleMouseEnterOrFocus"],[0,"focusin","handleMouseEnterOrFocus"],[1,"mouseleave","handleMouseLeaveOrBlur"],[0,"focusout","handleMouseLeaveOrBlur"],[0,"keydown","handleKeyDown"]],{"clientStyling":["handleClientStylingChange"],"clientStylingUrl":["handleClientStylingUrlChange"],"mbSource":["handleMbSourceChange"]}],[1,"lottery-tipping-bullet",{"mbSource":[513,"mb-source"],"clientStyling":[513,"client-styling"],"clientStylingUrl":[513,"client-styling-url"],"positionIdx":[514,"position-idx"],"theme":[513],"value":[513],"disabled":[516],"isSelected":[516,"is-selected"]},null,{"clientStyling":["handleClientStylingChange"],"clientStylingUrl":["handleClientStylingUrlChange"],"mbSource":["handleMbSourceChange"]}]]]], options);
23
23
  });
24
24
 
25
25
  exports.setNonce = index.setNonce;
@@ -1,7 +1,6 @@
1
1
  {
2
2
  "entries": [
3
- "components/lottery-tipping-ticket-controller/lottery-tipping-ticket-controller.js",
4
- "components/lottery-tipping-ticket-banner/lottery-tipping-ticket-banner.js"
3
+ "components/lottery-tipping-ticket-controller/lottery-tipping-ticket-controller.js"
5
4
  ],
6
5
  "compiler": {
7
6
  "name": "@stencil/core",
@@ -9,6 +8,12 @@
9
8
  "typescriptVersion": "5.4.5"
10
9
  },
11
10
  "collections": [
11
+ {
12
+ "name": "@everymatrix/lottery-banner",
13
+ "tags": [
14
+ "lottery-banner"
15
+ ]
16
+ },
12
17
  {
13
18
  "name": "@everymatrix/lottery-button",
14
19
  "tags": [
@@ -1,3 +1,4 @@
1
+ import "../../../../../lottery-banner/dist/types/index";
1
2
  import "../../../../../lottery-button/dist/types/index";
2
3
  import "../../../../../lottery-tipping-ticket-bet/dist/types/index";
3
4
  import { h } from "@stencil/core";
@@ -5,7 +6,7 @@ import "../../../../../../../libs/vaadin-facade/index";
5
6
  import { setClientStyling, setClientStylingURL, setStreamStyling } from "../../../../../../../../libs/common/src/styling/index";
6
7
  import { BettingTypeEnum, PlayModeEnum } from "../../models";
7
8
  import { resolveTranslationUrl, translate } from "../../utils/locale.utils";
8
- import { buildSubmitParam, calculatePlayingModeOptions, fetchRequest, getCheckedCountForEachLineAndEachMatch, getDefaultType, getEnableOptions, getPlayTypeConfig, showNotification, thousandSeparator, getMinValue } from "../../utils/utils";
9
+ import { buildSubmitParam, calculatePlayingModeOptions, fetchRequest, formattedTurnover, formattedWeekName, getCheckedCountForEachLineAndEachMatch, getDefaultType, getEnableOptions, getMinValue, getPlayTypeConfig, showNotification, thousandSeparator } from "../../utils/utils";
9
10
  import { doSubmitTicket, fetchSaleStatistics, TICKET_INVALID_TOKEN } from "../../utils/api";
10
11
  // value:
11
12
  export class LotteryTippingTicketController {
@@ -34,6 +35,7 @@ export class LotteryTippingTicketController {
34
35
  this.hasSelectAllBullet = undefined;
35
36
  this.totalLineCombination = 0;
36
37
  this.submitLoading = undefined;
38
+ this.drawSubmitAvailable = false;
37
39
  this.rawData = {};
38
40
  this.saleStatisticsInfo = {};
39
41
  this.currentStake = undefined;
@@ -204,6 +206,9 @@ export class LotteryTippingTicketController {
204
206
  setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`, this.stylingSubscription);
205
207
  }
206
208
  }
209
+ handleTimerStop() {
210
+ this.drawSubmitAvailable = true;
211
+ }
207
212
  componentWillLoad() {
208
213
  if (this.translationUrl) {
209
214
  resolveTranslationUrl(this.translationUrl);
@@ -326,19 +331,14 @@ export class LotteryTippingTicketController {
326
331
  }
327
332
  renderOrderSummary() {
328
333
  var _a;
329
- return (h("div", { class: "LotteryTippingTicketController__main--right order-summary" }, h("h3", { class: "order-summary__title" }, translate('orderSummaryTitle', this.language)), h("div", { class: "order-summary__ticket-info" }, h("div", { class: "order-summary__ticket" }, translate('orderSummaryTickets', this.language), ":"), h("div", { class: "order-summary__details" }, h("span", { class: "order-summary__line-count" }, this.lineCountRender), h("div", null, this.currentStake && h("span", { class: "order-summary__multiplier" }, "x"), h("span", { class: "order-summary__stake" }, this.currentStakeFormatted)), this.isBothBettingType && (h("div", null, h("span", { class: "order-summary__multiplier" }, "x"), h("span", { class: "order-summary__stake" }, this.bothBettingTypeMultiplier))))), h("hr", { class: "order-summary__divider" }), h("div", { class: "order-summary__ticket-info" }, h("div", { class: "order-summary__ticket" }, translate('orderSummaryTotal', this.language), ":"), h("span", { class: "order-summary__details" }, this.totalAmountFormatted)), h("div", { class: "order-summary__button-wrapper" }, h("lottery-button", { onClick: this.handleSubmit.bind(this), loading: this.submitLoading, disabled: !this.hasSelectAllBullet || this.submitLoading || ((_a = this.currentStake) === null || _a === void 0 ? void 0 : _a.value) === undefined, text: translate('orderSummarySubmit', this.language) }))));
330
- }
331
- get formattedTurnover() {
332
- var _a, _b, _c;
333
- const turnover = (_c = (_b = (_a = this.saleStatisticsInfo) === null || _a === void 0 ? void 0 : _a.wagerSegment) === null || _b === void 0 ? void 0 : _b.totalSalesCrossDraw) !== null && _c !== void 0 ? _c : 0;
334
- if (turnover === null || turnover === undefined)
335
- return '';
336
- const unit = '€';
337
- return `${unit}${turnover ? thousandSeparator(turnover) : 0}`;
334
+ return (h("div", { class: "LotteryTippingTicketController__main--right order-summary" }, h("h3", { class: "order-summary__title" }, translate('orderSummaryTitle', this.language)), h("div", { class: "order-summary__ticket-info" }, h("div", { class: "order-summary__ticket" }, translate('orderSummaryTickets', this.language), ":"), h("div", { class: "order-summary__details" }, h("span", { class: "order-summary__line-count" }, this.lineCountRender), h("div", null, this.currentStake && h("span", { class: "order-summary__multiplier" }, "x"), h("span", { class: "order-summary__stake" }, this.currentStakeFormatted)), this.isBothBettingType && (h("div", null, h("span", { class: "order-summary__multiplier" }, "x"), h("span", { class: "order-summary__stake" }, this.bothBettingTypeMultiplier))))), h("hr", { class: "order-summary__divider" }), h("div", { class: "order-summary__ticket-info" }, h("div", { class: "order-summary__ticket" }, translate('orderSummaryTotal', this.language), ":"), h("span", { class: "order-summary__details" }, this.totalAmountFormatted)), h("div", { class: "order-summary__button-wrapper" }, h("lottery-button", { onClick: this.handleSubmit.bind(this), loading: this.submitLoading, disabled: !this.hasSelectAllBullet ||
335
+ this.submitLoading ||
336
+ ((_a = this.currentStake) === null || _a === void 0 ? void 0 : _a.value) === undefined ||
337
+ !this.drawSubmitAvailable, text: translate('orderSummarySubmit', this.language) }))));
338
338
  }
339
339
  render() {
340
- var _a, _b, _c, _d, _e, _f, _g;
341
- return (h("div", { key: '353f56111a3dc6f6e7365d563163a38c850f2e88', class: "lottery-tipping-ticket-controller__container", ref: (el) => (this.stylingContainer = el) }, h("lottery-tipping-ticket-banner", { key: '3a2472f0bf9195547f5e4c6c2c0a2362c790aa27', "client-styling": this.clientStyling, "client-styling-Url": this.clientStylingUrl, stopTime: (_b = (_a = this.rawData) === null || _a === void 0 ? void 0 : _a.currentDraw) === null || _b === void 0 ? void 0 : _b.wagerCloseTime, period: (_d = (_c = this.rawData) === null || _c === void 0 ? void 0 : _c.currentDraw) === null || _d === void 0 ? void 0 : _d.date, "formatted-turnover": this.formattedTurnover, language: this.language, "translation-url": this.translationUrl, "logo-url": this.logoUrl }), this.renderBettingControls(), h("div", { key: '9d0a9391ccf79351959cc280e3c15efc657a966f', class: "flex flex-wrap LotteryTippingTicketController__main" }, h("div", { key: 'c61fdb41d41694227971478e193cc5162bff30c3', class: "LotteryTippingTicketController__main--left" }, h("lottery-tipping-ticket-bet", { key: '56964177a4366a366279b2ebfff2ee52d1e27de0', ref: (el) => (this.childRef = el), endpoint: this.endpoint, "session-id": this.sessionId, "game-id": (_e = this.rawData) === null || _e === void 0 ? void 0 : _e.type, "draw-id": this.drawId, language: this.language, "translation-url": this.translationUrl, "max-total-pages": this.lineNumberRange.maxLineNumber, "min-total-pages": this.lineNumberRange.minLineNumber, "total-pages": this.lineNumberRange.defaultBoards, mode: this.selectedPlayingMode === PlayModeEnum.SingleBet ? 'single' : 'multi', "client-styling": this.clientStyling, "client-styling-Url": this.clientStylingUrl })), this.renderOrderSummary()), this.dialogConfig.visible && (h("vaadin-confirm-dialog", { key: 'fe8eb6d26eecee3c6e10b20c4f2ad968f707d51c', rejectButtonVisible: true, rejectText: translate('cancel', this.language), confirmText: translate('confirm', this.language), opened: (_f = this.dialogConfig) === null || _f === void 0 ? void 0 : _f.visible, onConfirm: this.dialogConfig.onConfirm, onReject: this.dialogConfig.onCancel }, (_g = this.dialogConfig) === null || _g === void 0 ? void 0 : _g.content))));
340
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
341
+ return (h("div", { key: '71d1e6567f13267094ca2bdc32caa02891ad8540', class: "lottery-tipping-ticket-controller__container", ref: (el) => (this.stylingContainer = el) }, h("lottery-banner", { key: '4393c6b8cf885f3aa6df61e0283172f99d22fd12', "client-styling": this.clientStyling, "client-styling-Url": this.clientStylingUrl, stopTime: (_b = (_a = this.rawData) === null || _a === void 0 ? void 0 : _a.currentDraw) === null || _b === void 0 ? void 0 : _b.wagerCloseTime, startTime: (_d = (_c = this.rawData) === null || _c === void 0 ? void 0 : _c.currentDraw) === null || _d === void 0 ? void 0 : _d.wagerStartTime, "banner-title": formattedWeekName((_f = (_e = this.rawData) === null || _e === void 0 ? void 0 : _e.currentDraw) === null || _f === void 0 ? void 0 : _f.date), turnover: formattedTurnover((_h = (_g = this.saleStatisticsInfo) === null || _g === void 0 ? void 0 : _g.wagerSegment) === null || _h === void 0 ? void 0 : _h.totalSalesCrossDraw), language: this.language, "translation-url": this.translationUrl, "logo-url": this.logoUrl, onLotteryBannerTimerStop: this.handleTimerStop.bind(this) }), this.renderBettingControls(), h("div", { key: 'd054f3970388474745f6e92e7aa028d4509e6250', class: "flex flex-wrap LotteryTippingTicketController__main" }, h("div", { key: '736a9c1c2ff1d5c88252b64e6a90a08d185574a0', class: "LotteryTippingTicketController__main--left" }, h("lottery-tipping-ticket-bet", { key: '3976fecaa6e049c6d3b7521e58c8fcdf37fa9db4', ref: (el) => (this.childRef = el), endpoint: this.endpoint, "session-id": this.sessionId, "game-id": (_j = this.rawData) === null || _j === void 0 ? void 0 : _j.type, "draw-id": this.drawId, language: this.language, "translation-url": this.translationUrl, "max-total-pages": this.lineNumberRange.maxLineNumber, "min-total-pages": this.lineNumberRange.minLineNumber, "total-pages": this.lineNumberRange.defaultBoards, mode: this.selectedPlayingMode === PlayModeEnum.SingleBet ? 'single' : 'multi', "client-styling": this.clientStyling, "client-styling-Url": this.clientStylingUrl })), this.renderOrderSummary()), this.dialogConfig.visible && (h("vaadin-confirm-dialog", { key: '60415251900e4e1c12c14b78314d8085bfbc4c5b', rejectButtonVisible: true, rejectText: translate('cancel', this.language), confirmText: translate('confirm', this.language), opened: (_k = this.dialogConfig) === null || _k === void 0 ? void 0 : _k.visible, onConfirm: this.dialogConfig.onConfirm, onReject: this.dialogConfig.onCancel }, (_l = this.dialogConfig) === null || _l === void 0 ? void 0 : _l.content))));
342
342
  }
343
343
  static get is() { return "lottery-tipping-ticket-controller"; }
344
344
  static get encapsulation() { return "shadow"; }
@@ -559,6 +559,7 @@ export class LotteryTippingTicketController {
559
559
  "hasSelectAllBullet": {},
560
560
  "totalLineCombination": {},
561
561
  "submitLoading": {},
562
+ "drawSubmitAvailable": {},
562
563
  "rawData": {},
563
564
  "saleStatisticsInfo": {},
564
565
  "currentStake": {},
@@ -9,3 +9,13 @@ export var BettingTypeEnum;
9
9
  BettingTypeEnum["HalfTime"] = "HalfTime";
10
10
  BettingTypeEnum["Both"] = "Both";
11
11
  })(BettingTypeEnum || (BettingTypeEnum = {}));
12
+ export var DrawStatus;
13
+ (function (DrawStatus) {
14
+ DrawStatus["OPEN"] = "OPEN";
15
+ })(DrawStatus || (DrawStatus = {}));
16
+ export var TicketState;
17
+ (function (TicketState) {
18
+ TicketState["Settled"] = "Settled";
19
+ TicketState["Purchased"] = "Purchased";
20
+ TicketState["Canceled"] = "Canceled";
21
+ })(TicketState || (TicketState = {}));
@@ -1,3 +1,4 @@
1
+ import { TicketState } from "../models";
1
2
  import { fetchRequest } from "./utils";
2
3
  export const TICKET_INVALID_TOKEN = 'TICKET_INVALID_TOKEN';
3
4
  const generateUUID = () => {
@@ -24,9 +25,18 @@ export const doSubmitTicket = ({ body, sessionId, url }) => {
24
25
  if (res.status > 300) {
25
26
  throw new Error(res.statusText);
26
27
  }
27
- return res.json();
28
+ return res.json().then((data) => {
29
+ if (checkTicketDetailHasError(data.tickets))
30
+ throw new Error(res.statusText);
31
+ return data;
32
+ });
28
33
  });
29
34
  };
35
+ function checkTicketDetailHasError(tickets) {
36
+ if (!tickets || !tickets.length)
37
+ return true;
38
+ return tickets.some((i) => i.state !== TicketState.Purchased);
39
+ }
30
40
  export async function fetchSaleStatistics({ endpoint, gameId, drawId }) {
31
41
  try {
32
42
  const res = await fetchRequest(`${endpoint}/games/${gameId}/draws/${drawId}/saleStatistics`);
@@ -7,7 +7,7 @@ const TRANSLATIONS = {
7
7
  turnover: 'Turnover: ',
8
8
  selectionCleared: 'Your selection will be cleared.',
9
9
  ticketSubmitted: 'Ticket submitted successfully.',
10
- ticketFailed: 'Failed to purchase the ticket. Please try again.',
10
+ ticketFailed: 'Failed to submit tickets.',
11
11
  lines: 'Lines',
12
12
  line: 'Line',
13
13
  bettingType: 'Betting Type',
@@ -152,3 +152,17 @@ export const getPlayTypeConfig = ({ rawData, selectedBettingType, selectedPlayin
152
152
  return { betTypeId, betType };
153
153
  };
154
154
  export const getMinValue = (arr) => (arr.length ? Math.min.apply(null, arr) : undefined);
155
+ export function formattedTurnover(turnover, unit = '€') {
156
+ if (turnover === null || turnover === undefined)
157
+ return '';
158
+ return `${unit}${turnover ? thousandSeparator(turnover) : 0}`;
159
+ }
160
+ export function formattedWeekName(date) {
161
+ if (!date)
162
+ return '';
163
+ const _temp = formatDate({ date, format: 'EEEE' });
164
+ if (!['saturday', 'sunday'].includes(_temp.toLowerCase())) {
165
+ return 'MIDWEEK';
166
+ }
167
+ return _temp.toUpperCase();
168
+ }