iticket-seatingplan-dev 1.7.4 → 1.7.6

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 (74) hide show
  1. package/dist/components/Control.js +75 -0
  2. package/dist/{dist/components → components}/Map.js +33 -8
  3. package/dist/{dist/components → components}/PricingPopup.js +1 -42
  4. package/dist/{dist/components → components}/SeatingPlan.js +2 -1
  5. package/dist/{dist/utils → utils}/helpers.js +48 -2
  6. package/package.json +1 -1
  7. package/dist/__MACOSX/._dist +0 -0
  8. package/dist/__MACOSX/dist/._components +0 -0
  9. package/dist/__MACOSX/dist/._index.js +0 -0
  10. package/dist/__MACOSX/dist/._utils +0 -0
  11. package/dist/__MACOSX/dist/components/._Flexi.js +0 -0
  12. package/dist/__MACOSX/dist/components/._HoverPopup.js +0 -0
  13. package/dist/__MACOSX/dist/components/._InvalidSeatsPopup.js +0 -0
  14. package/dist/__MACOSX/dist/components/._Map.js +0 -0
  15. package/dist/__MACOSX/dist/components/._PriceButton.js +0 -0
  16. package/dist/__MACOSX/dist/components/._PricingPopup.js +0 -0
  17. package/dist/__MACOSX/dist/components/._RemoveMultipleSeatsPopup.js +0 -0
  18. package/dist/__MACOSX/dist/components/._SeatingPlan.js +0 -0
  19. package/dist/__MACOSX/dist/components/._SelectQuantityPopup.js +0 -0
  20. package/dist/__MACOSX/dist/components/._assets +0 -0
  21. package/dist/__MACOSX/dist/components/._gestureHandling.js +0 -0
  22. package/dist/__MACOSX/dist/components/._icons +0 -0
  23. package/dist/__MACOSX/dist/components/._styles +0 -0
  24. package/dist/__MACOSX/dist/components/assets/._encodedSvgs.js +0 -0
  25. package/dist/__MACOSX/dist/components/assets/._fit-icon.jpg +0 -0
  26. package/dist/__MACOSX/dist/components/assets/._layers-2x.png +0 -0
  27. package/dist/__MACOSX/dist/components/assets/._layers.png +0 -0
  28. package/dist/__MACOSX/dist/components/assets/._marker-icon.png +0 -0
  29. package/dist/__MACOSX/dist/components/assets/._refresh.png +0 -0
  30. package/dist/__MACOSX/dist/components/assets/._rippleload.gif +0 -0
  31. package/dist/__MACOSX/dist/components/assets/._wheelchair.png +0 -0
  32. package/dist/__MACOSX/dist/components/icons/._CloseIcon.js +0 -0
  33. package/dist/__MACOSX/dist/components/icons/._EditIcon.js +0 -0
  34. package/dist/__MACOSX/dist/components/icons/._FlexiIcon.js +0 -0
  35. package/dist/__MACOSX/dist/components/icons/._MinusIcon.js +0 -0
  36. package/dist/__MACOSX/dist/components/icons/._PlusIcon.js +0 -0
  37. package/dist/__MACOSX/dist/components/icons/._TicketIcon.js +0 -0
  38. package/dist/__MACOSX/dist/components/styles/._flexi.css +0 -0
  39. package/dist/__MACOSX/dist/components/styles/._gestureHandling.css +0 -0
  40. package/dist/__MACOSX/dist/components/styles/._index.css +0 -0
  41. package/dist/__MACOSX/dist/components/styles/._pos.css +0 -0
  42. package/dist/__MACOSX/dist/utils/._enums.js +0 -0
  43. package/dist/__MACOSX/dist/utils/._helpers.js +0 -0
  44. package/dist/__MACOSX/dist/utils/._index.js +0 -0
  45. package/dist/__MACOSX/dist/utils/._types.d.js +0 -0
  46. /package/dist/{dist/components → components}/Flexi.js +0 -0
  47. /package/dist/{dist/components → components}/HoverPopup.js +0 -0
  48. /package/dist/{dist/components → components}/InvalidSeatsPopup.js +0 -0
  49. /package/dist/{dist/components → components}/PriceButton.js +0 -0
  50. /package/dist/{dist/components → components}/RemoveMultipleSeatsPopup.js +0 -0
  51. /package/dist/{dist/components → components}/SelectQuantityPopup.js +0 -0
  52. /package/dist/{dist/components → components}/assets/encodedSvgs.js +0 -0
  53. /package/dist/{dist/components → components}/assets/fit-icon.jpg +0 -0
  54. /package/dist/{dist/components → components}/assets/layers-2x.png +0 -0
  55. /package/dist/{dist/components → components}/assets/layers.png +0 -0
  56. /package/dist/{dist/components → components}/assets/marker-icon.png +0 -0
  57. /package/dist/{dist/components → components}/assets/refresh.png +0 -0
  58. /package/dist/{dist/components → components}/assets/rippleload.gif +0 -0
  59. /package/dist/{dist/components → components}/assets/wheelchair.png +0 -0
  60. /package/dist/{dist/components → components}/gestureHandling.js +0 -0
  61. /package/dist/{dist/components → components}/icons/CloseIcon.js +0 -0
  62. /package/dist/{dist/components → components}/icons/EditIcon.js +0 -0
  63. /package/dist/{dist/components → components}/icons/FlexiIcon.js +0 -0
  64. /package/dist/{dist/components → components}/icons/MinusIcon.js +0 -0
  65. /package/dist/{dist/components → components}/icons/PlusIcon.js +0 -0
  66. /package/dist/{dist/components → components}/icons/TicketIcon.js +0 -0
  67. /package/dist/{dist/components → components}/styles/flexi.css +0 -0
  68. /package/dist/{dist/components → components}/styles/gestureHandling.css +0 -0
  69. /package/dist/{dist/components → components}/styles/index.css +0 -0
  70. /package/dist/{dist/components → components}/styles/pos.css +0 -0
  71. /package/dist/{dist/index.js → index.js} +0 -0
  72. /package/dist/{dist/utils → utils}/enums.js +0 -0
  73. /package/dist/{dist/utils → utils}/index.js +0 -0
  74. /package/dist/{dist/utils → utils}/types.d.js +0 -0
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _leaflet = _interopRequireDefault(require("leaflet"));
8
+ var _react = _interopRequireDefault(require("react"));
9
+ var _reactLeaflet = require("react-leaflet");
10
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
11
+ function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
12
+ const POSITION_CLASSES = {
13
+ bottomleft: "leaflet-bottom leaflet-left",
14
+ bottomright: "leaflet-bottom leaflet-right",
15
+ topleft: "leaflet-top leaflet-left",
16
+ topright: "leaflet-top leaflet-right"
17
+ };
18
+ const Control = props => {
19
+ var _props$container;
20
+ const [portalRoot, setPortalRoot] = _react.default.useState(document.createElement("div"));
21
+ const positionClass = props.position && POSITION_CLASSES[props.position] || POSITION_CLASSES.topright;
22
+ const controlContainerRef = /*#__PURE__*/_react.default.createRef();
23
+ const map = (0, _reactLeaflet.useMap)();
24
+
25
+ /**
26
+ * Whenever the control container ref is created,
27
+ * Ensure the click / scroll propagation is removed
28
+ * This way click/scroll events do not bubble down to the map
29
+ */
30
+ _react.default.useEffect(() => {
31
+ if (controlContainerRef.current !== null) {
32
+ _leaflet.default.DomEvent.disableClickPropagation(controlContainerRef.current);
33
+ _leaflet.default.DomEvent.disableScrollPropagation(controlContainerRef.current);
34
+ }
35
+ }, [controlContainerRef]);
36
+
37
+ /**
38
+ * Whenever the position is changed, go ahead and get the container of the map and the first
39
+ * instance of the position class in that map container
40
+ * Fixes #17
41
+ */
42
+ _react.default.useEffect(() => {
43
+ const mapContainer = map.getContainer();
44
+ const targetDiv = mapContainer.getElementsByClassName(positionClass);
45
+ setPortalRoot(targetDiv[0]);
46
+ }, [positionClass]);
47
+
48
+ /**
49
+ * Whenever the portal root is complete,
50
+ * append or prepend the control container to the portal root
51
+ */
52
+ _react.default.useEffect(() => {
53
+ if (portalRoot !== null) {
54
+ if (props.prepend !== undefined && props.prepend === true) {
55
+ portalRoot.prepend(controlContainerRef.current);
56
+ } else {
57
+ portalRoot.append(controlContainerRef.current);
58
+ }
59
+ }
60
+ }, [portalRoot, props.prepend, controlContainerRef]);
61
+
62
+ /**
63
+ * Concatenate the props.container className to the class of the control div
64
+ */
65
+ const className = (((_props$container = props.container) === null || _props$container === void 0 || (_props$container = _props$container.className) === null || _props$container === void 0 ? void 0 : _props$container.concat(" ")) || "") + "leaflet-control";
66
+
67
+ /**
68
+ * Render
69
+ */
70
+ return /*#__PURE__*/_react.default.createElement("div", _extends({}, props.container, {
71
+ ref: controlContainerRef,
72
+ className: className
73
+ }), props.children);
74
+ };
75
+ var _default = exports.default = Control;
@@ -61,7 +61,8 @@ function SeatMap(_ref) {
61
61
  desiredSeatQuantity,
62
62
  setSeatsToRemove,
63
63
  setRemoveMultipleSeatsPopupOpen,
64
- setInvalidSeatsPopupOpen
64
+ setInvalidSeatsPopupOpen,
65
+ batchAddTicketsToCart
65
66
  } = _ref;
66
67
  const [isLegendOpen, setIsLegendOpen] = (0, _react.useState)(false);
67
68
  const [isDragging, setIsDragging] = (0, _react.useState)(false);
@@ -450,9 +451,14 @@ function SeatMap(_ref) {
450
451
  radius: 12000,
451
452
  eventHandlers: {
452
453
  click: e => {
454
+ // pos multi-select mode
453
455
  if (mode === _utils.modes.DRAG || mode === _utils.modes.REMOVE || mode === _utils.modes.DRAW || selectedSeats.length > 0) {
454
456
  map.closePopup();
455
- } else if (seats.preventOrphanedSeats && desiredSeatQuantity > 0) {
457
+ return;
458
+ }
459
+
460
+ // orphan multi-select mode
461
+ if (seats.preventOrphanedSeats && desiredSeatQuantity > 0) {
456
462
  map.closePopup();
457
463
  if (s.s === _utils.statuses.USER_PENDING) {
458
464
  const newSeatsToRemove = (0, _utils.getAdjacentBookedSeats)(s, seatsMap);
@@ -462,18 +468,36 @@ function SeatMap(_ref) {
462
468
  setSeatsToRemove(newSeatsToRemove);
463
469
  setRemoveMultipleSeatsPopupOpen(true);
464
470
  }
465
- } else if (highlightedSeats.length > 0 && highlightedSeats.length === desiredSeatQuantity) {
471
+ return;
472
+ }
473
+ if (highlightedSeats.length > 0 && highlightedSeats.length === desiredSeatQuantity) {
466
474
  if ((0, _utils.isTouchScreen)() && clickedSeat !== s.ssId) {
467
475
  setClickedSeat(s.ssId);
468
476
  } else {
469
- setSelectedSeats([...highlightedSeats]);
470
- setPricingPopupOpen(true);
477
+ const groupedSeats = (0, _utils.groupSeatsByPriceSection)(highlightedSeats, seats.pricing, priceSectionIds);
478
+ const priceages = Object.values(groupedSeats).flatMap(group => group.priceages.map(pa => pa.priceage));
479
+ if (priceages.length === 1 && (priceages[0].q === null || priceages[0].q >= desiredSeatQuantity) && !isSingleFlexi) {
480
+ batchAddTicketsToCart(highlightedSeats.map(s => ({
481
+ seat: s,
482
+ priceage: priceages[0]
483
+ })));
484
+ } else {
485
+ setSelectedSeats([...highlightedSeats]);
486
+ setPricingPopupOpen(true);
487
+ }
471
488
  }
472
- } else if (greyedOutSeats.some(gs => gs.ssId === s.ssId)) {
489
+ return;
490
+ }
491
+ if (greyedOutSeats.some(gs => gs.ssId === s.ssId)) {
473
492
  setInvalidSeatsPopupOpen(true);
474
493
  }
475
- } else if (mode === _utils.modes.SINGLE && hasSeatPrices) {
494
+ return;
495
+ }
496
+
497
+ // single select mode
498
+ if (mode === _utils.modes.SINGLE && hasSeatPrices) {
476
499
  handleClickSeat(e, s);
500
+ return;
477
501
  }
478
502
  },
479
503
  popupopen: popup => {
@@ -499,7 +523,8 @@ function SeatMap(_ref) {
499
523
  } else {
500
524
  setIsHoveringOnSeat(true);
501
525
  setHoveredSeat(s);
502
- if (seats.preventOrphanedSeats && desiredSeatQuantity > 0 && s.s === _utils.statuses.UNSOLD) {
526
+ setClickedSeat(s.ssId);
527
+ if (seats.preventOrphanedSeats && desiredSeatQuantity > 0 && s.s === _utils.statuses.UNSOLD && mode === _utils.modes.SINGLE) {
503
528
  const seatsToBook = (0, _utils.getValidSeats)(s, seatsMap, desiredSeatQuantity);
504
529
  if (seatsToBook.valid) {
505
530
  setHighlightedSeats(seatsToBook.seats);
@@ -212,48 +212,7 @@ function PricingPopup(_ref4) {
212
212
  pricing,
213
213
  priceSectionIds
214
214
  } = _ref4;
215
- const [seatGroupsToBook, setSeatGroupsToBook] = (0, _react.useState)(selectedSeats.reduce((acc, curr) => {
216
- if (curr.psId) {
217
- const priceages = pricing.filter(price => price.psId === curr.psId && (!priceSectionIds || priceSectionIds.includes(price.psId)));
218
- const availablePriceages = priceages.filter(p => p.q === null || p.q > 0);
219
- const soldOutPriceages = priceages.filter(p => p.q === 0);
220
- const numSeats = selectedSeats.filter(s => s.psId === curr.psId).length;
221
- if (!acc[curr.psId]) {
222
- let qtyFilled = 0;
223
- acc[curr.psId] = {
224
- seats: [],
225
- priceages: [...availablePriceages.map(pa => {
226
- let qty = 0;
227
- if (qtyFilled < numSeats) {
228
- var _pa$q;
229
- qty = Math.min(numSeats - qtyFilled, (_pa$q = pa.q) !== null && _pa$q !== void 0 ? _pa$q : numSeats);
230
- qtyFilled += qty;
231
- }
232
- return {
233
- priceage: pa,
234
- qty
235
- };
236
- }), ...soldOutPriceages.map(pa => ({
237
- priceage: pa,
238
- qty: 0
239
- }))]
240
- };
241
- }
242
- const availablePriceage = availablePriceages.find(pa => {
243
- var _pa$q2;
244
- const qtyFilled = acc[curr.psId].seats.filter(s => {
245
- var _s$priceage2;
246
- return ((_s$priceage2 = s.priceage) === null || _s$priceage2 === void 0 ? void 0 : _s$priceage2.paId) === pa.paId;
247
- }).length;
248
- return qtyFilled < ((_pa$q2 = pa.q) !== null && _pa$q2 !== void 0 ? _pa$q2 : numSeats);
249
- });
250
- acc[curr.psId].seats.push({
251
- seat: curr,
252
- priceage: availablePriceage
253
- });
254
- }
255
- return acc;
256
- }, {}));
215
+ const [seatGroupsToBook, setSeatGroupsToBook] = (0, _react.useState)(() => (0, _utils.groupSeatsByPriceSection)(selectedSeats, pricing, priceSectionIds));
257
216
  const updateSeatGroupPriceage = (priceage, qty) => {
258
217
  const newSeatGroupsToBook = _objectSpread({}, seatGroupsToBook);
259
218
  const group = newSeatGroupsToBook[priceage.psId];
@@ -647,7 +647,8 @@ const SeatingPlan = _ref => {
647
647
  desiredSeatQuantity: desiredSeatQuantity,
648
648
  setSeatsToRemove: setSeatsToRemove,
649
649
  setRemoveMultipleSeatsPopupOpen: setRemoveMultipleSeatsPopupOpen,
650
- setInvalidSeatsPopupOpen: setInvalidSeatsPopupOpen
650
+ setInvalidSeatsPopupOpen: setInvalidSeatsPopupOpen,
651
+ batchAddTicketsToCart: batchAddTicketsToCart
651
652
  }))), mapContainer)) : /*#__PURE__*/_react.default.createElement("div", {
652
653
  className: "loading"
653
654
  }, /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement("svg", {
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.isTouchScreen = exports.getValidSeats = exports.getRowSection = exports.getRetryDelay = exports.getInitialColor = exports.getAdjacentBookedSeats = exports.createsOrphan = exports.canSelectSingleSeatGivenOrphanRules = exports.calculateCenterOfMap = exports.NZDollar = void 0;
6
+ exports.isTouchScreen = exports.groupSeatsByPriceSection = exports.getValidSeats = exports.getRowSection = exports.getRetryDelay = exports.getInitialColor = exports.getAdjacentBookedSeats = exports.createsOrphan = exports.canSelectSingleSeatGivenOrphanRules = exports.calculateCenterOfMap = exports.NZDollar = void 0;
7
7
  var _enums = require("./enums");
8
8
  const isTouchScreen = () => {
9
9
  let hasTouchScreen = false;
@@ -242,4 +242,50 @@ const getRetryDelay = (response, attempt) => {
242
242
  // adds jitter
243
243
  return attempt + Math.random() * 1000;
244
244
  };
245
- exports.getRetryDelay = getRetryDelay;
245
+ exports.getRetryDelay = getRetryDelay;
246
+ const groupSeatsByPriceSection = (seats, pricing, priceSectionIds) => {
247
+ const groupedSeats = seats.reduce((acc, curr) => {
248
+ if (curr.psId) {
249
+ const priceages = pricing.filter(price => price.psId === curr.psId && (!priceSectionIds || priceSectionIds.includes(price.psId)));
250
+ const availablePriceages = priceages.filter(p => p.q === null || p.q > 0);
251
+ const soldOutPriceages = priceages.filter(p => p.q === 0);
252
+ const numSeats = seats.filter(s => s.psId === curr.psId).length;
253
+ if (!acc[curr.psId]) {
254
+ let qtyFilled = 0;
255
+ acc[curr.psId] = {
256
+ seats: [],
257
+ priceages: [...availablePriceages.map(pa => {
258
+ let qty = 0;
259
+ if (qtyFilled < numSeats) {
260
+ var _pa$q;
261
+ qty = Math.min(numSeats - qtyFilled, (_pa$q = pa.q) !== null && _pa$q !== void 0 ? _pa$q : numSeats);
262
+ qtyFilled += qty;
263
+ }
264
+ return {
265
+ priceage: pa,
266
+ qty
267
+ };
268
+ }), ...soldOutPriceages.map(pa => ({
269
+ priceage: pa,
270
+ qty: 0
271
+ }))]
272
+ };
273
+ }
274
+ const availablePriceage = availablePriceages.find(pa => {
275
+ var _pa$q2;
276
+ const qtyFilled = acc[curr.psId].seats.filter(s => {
277
+ var _s$priceage;
278
+ return ((_s$priceage = s.priceage) === null || _s$priceage === void 0 ? void 0 : _s$priceage.paId) === pa.paId;
279
+ }).length;
280
+ return qtyFilled < ((_pa$q2 = pa.q) !== null && _pa$q2 !== void 0 ? _pa$q2 : numSeats);
281
+ });
282
+ acc[curr.psId].seats.push({
283
+ seat: curr,
284
+ priceage: availablePriceage
285
+ });
286
+ }
287
+ return acc;
288
+ }, {});
289
+ return groupedSeats;
290
+ };
291
+ exports.groupSeatsByPriceSection = groupSeatsByPriceSection;
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "iticket-seatingplan-dev",
3
3
  "description": "Seating plan with FLEXi pricing",
4
4
  "author": "gedwyne",
5
- "version": "1.7.4",
5
+ "version": "1.7.6",
6
6
  "private": false,
7
7
  "keywords": [
8
8
  "iticket",
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
File without changes
File without changes
File without changes
File without changes
File without changes