iticket-seatingplan-dev 1.8.9 → 1.8.10

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.
@@ -19,6 +19,7 @@ var _TicketIcon = _interopRequireDefault(require("./icons/TicketIcon"));
19
19
  var _FlexiIcon = _interopRequireDefault(require("./icons/FlexiIcon"));
20
20
  var _HoverPopup = _interopRequireDefault(require("./HoverPopup"));
21
21
  var _Controls = _interopRequireDefault(require("./Controls"));
22
+ var _constants = require("../utils/constants");
22
23
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
23
24
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
24
25
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
@@ -79,16 +80,11 @@ function SeatMap(_ref) {
79
80
  const resetTooltipTimeoutRef = (0, _react.useRef)(null);
80
81
  const hideTooltipTimeoutRef = (0, _react.useRef)(null);
81
82
  const map = (0, _reactLeaflet.useMap)();
83
+ const imgBounds = [[0, 0], [-_constants.SCALE, width / height * _constants.SCALE]];
82
84
  const seatsMap = (0, _react.useMemo)(() => new Map(seats.seats.map(s => {
83
- const isIcon = (!priceSectionIds || priceSectionIds.includes(s.psId)) && (s.s === _utils.statuses.WHEELCHAIR_ACCESS || s.s === _utils.statuses.USER_PENDING && s.m);
84
- const latlng = (0, _utils.getSeatCenterLatLng)(s, isIcon, height);
85
- const lat = s.r.includes("NORTH") ? (0, _utils.getNorthSeatLat)(s, height) : latlng.lat;
86
- const seatCenter = {
87
- lat,
88
- lng: latlng.lng
89
- };
85
+ const latlng = (0, _utils.getSeatCenterLatLng)(s, height, width, imgBounds);
90
86
  return [s.sId, _objectSpread(_objectSpread({}, s), {}, {
91
- center: seatCenter
87
+ center: latlng
92
88
  })];
93
89
  })), [seats.seats, height, priceSectionIds]);
94
90
  const isOrphanMode = (seats === null || seats === void 0 ? void 0 : seats.preventOrphanedSeats) && desiredSeatQuantity > 0;
@@ -288,8 +284,8 @@ function SeatMap(_ref) {
288
284
  }
289
285
  if (isTouchScreen && (clickedSeat === null || clickedSeat === void 0 ? void 0 : clickedSeat.ssId) !== s.ssId) {
290
286
  setClickedSeat(_objectSpread(_objectSpread({}, s), {}, {
291
- offset: (0, _utils.getSeatRadius)(e, map),
292
- xy: (0, _utils.getSeatXy)(e, map)
287
+ offset: _constants.RADIUS,
288
+ xy: map.latLngToContainerPoint(e.target.getLatLng())
293
289
  }));
294
290
  handleHighlightSeats(e, s);
295
291
  setIsHoveringOnSeat(true);
@@ -422,7 +418,7 @@ function SeatMap(_ref) {
422
418
  hasBookedSeats: (bookedSeats === null || bookedSeats === void 0 ? void 0 : bookedSeats.length) > 0
423
419
  }), (seats === null || seats === void 0 ? void 0 : seats.background) && /*#__PURE__*/_react.default.createElement(_reactLeaflet.ImageOverlay, {
424
420
  url: seats === null || seats === void 0 ? void 0 : seats.background,
425
- bounds: [[0, 0], [height * 0.03, width * 0.03]],
421
+ bounds: imgBounds,
426
422
  zIndex: 10,
427
423
  eventHandlers: {
428
424
  error: i => {
@@ -433,11 +429,14 @@ function SeatMap(_ref) {
433
429
  var _seatsMap$get2, _seats$pricing3, _chosenSeat$seat, _chosenSeat$seat2, _chosenSeat$seat3;
434
430
  const seatCenter = ((_seatsMap$get2 = seatsMap.get(s.sId)) === null || _seatsMap$get2 === void 0 ? void 0 : _seatsMap$get2.center) || {
435
431
  lat: s.y,
436
- lng: s.x
432
+ lng: s.x,
433
+ radius: 110
437
434
  };
438
435
  const seatPrices = ((_seats$pricing3 = seats.pricing) === null || _seats$pricing3 === void 0 ? void 0 : _seats$pricing3.filter(price => (!priceSectionIds || priceSectionIds.includes(price.psId)) && price.psId === s.psId)) || [];
439
436
  const hasSeatPrices = (seatPrices === null || seatPrices === void 0 ? void 0 : seatPrices.length) > 0;
440
437
  const isSingleFlexi = seatPrices.length === 1 && !!seatPrices[0].pMax && !!seatPrices[0].pMin && seatPrices[0].pMax > seatPrices[0].pMin;
438
+ const radiusInDeg = seatCenter.radius / _constants.ONE_DEG_LAT_IN_METERS;
439
+ const iconBounds = [[seatCenter.lat - radiusInDeg, seatCenter.lng - radiusInDeg], [seatCenter.lat + radiusInDeg, seatCenter.lng + radiusInDeg]];
441
440
  const eventHandlers = {
442
441
  click: e => {
443
442
  onClickSeat(e, s, isSingleFlexi, hasSeatPrices);
@@ -465,21 +464,21 @@ function SeatMap(_ref) {
465
464
  key: i
466
465
  }, (s.loading || ticketPopupOpen && (chosenSeat === null || chosenSeat === void 0 || (_chosenSeat$seat = chosenSeat.seat) === null || _chosenSeat$seat === void 0 ? void 0 : _chosenSeat$seat.ssId) === s.ssId) && /*#__PURE__*/_react.default.createElement(_reactLeaflet.ImageOverlay, {
467
466
  url: "https://iticketseatingplan.blob.core.windows.net/embed/static/media/rippleload.08e6a08dd832819226ef.gif",
468
- bounds: [[seatCenter.lat - 0.11, seatCenter.lng - 0.11], [seatCenter.lat + 0.11, seatCenter.lng + 0.11]],
467
+ bounds: iconBounds,
469
468
  opacity: s.loading || ticketPopupOpen && (chosenSeat === null || chosenSeat === void 0 || (_chosenSeat$seat2 = chosenSeat.seat) === null || _chosenSeat$seat2 === void 0 ? void 0 : _chosenSeat$seat2.ssId) === s.ssId ? 100 : 0,
470
469
  zIndex: 10
471
470
  }), !priceSectionIds || priceSectionIds.includes(s.psId) ? s.s === _utils.statuses.WHEELCHAIR_ACCESS ? /*#__PURE__*/_react.default.createElement(_reactLeaflet.ImageOverlay, {
472
471
  url: _encodedSvgs.wheelchairIcon,
473
- bounds: [[seatCenter.lat - 0.11, seatCenter.lng - 0.11], [seatCenter.lat + 0.11, seatCenter.lng + 0.11]],
472
+ bounds: iconBounds,
474
473
  zIndex: 10
475
474
  }) : s.s === _utils.statuses.USER_PENDING && s.m ? /*#__PURE__*/_react.default.createElement(_reactLeaflet.ImageOverlay, {
476
475
  url: _encodedSvgs.userIcon,
477
- bounds: [[seatCenter.lat - 0.11, seatCenter.lng - 0.15], [seatCenter.lat + 0.11, seatCenter.lng + 0.15]],
476
+ bounds: iconBounds,
478
477
  zIndex: 10
479
478
  }) : /*#__PURE__*/_react.default.createElement(_reactLeaflet.Circle, {
480
479
  center: [seatCenter.lat, seatCenter.lng],
481
480
  pathOptions: (0, _utils.getInitialColor)(s, price, s.loading || ticketPopupOpen && (chosenSeat === null || chosenSeat === void 0 || (_chosenSeat$seat3 = chosenSeat.seat) === null || _chosenSeat$seat3 === void 0 ? void 0 : _chosenSeat$seat3.ssId) === s.ssId, !hasSeatPrices, (selectedSeats.some(selectedSeat => selectedSeat.ssId === s.ssId) || highlightedSeats.some(hs => hs.ssId === s.ssId)) && isHoveringOnSeat, greyedOutSeats.some(gs => gs.ssId === s.ssId)),
482
- radius: 12000,
481
+ radius: seatCenter.radius,
483
482
  eventHandlers: eventHandlers
484
483
  }, s.s === _utils.statuses.UNSOLD && hasSeatPrices ? /*#__PURE__*/_react.default.createElement(_reactLeaflet.Popup, {
485
484
  className: "ticket-popup popup-".concat(s.sId)
@@ -9,6 +9,7 @@ require("./styles/pos.css");
9
9
  require("./styles/flexi.css");
10
10
  var _react = _interopRequireWildcard(require("react"));
11
11
  var _Map = _interopRequireDefault(require("./Map"));
12
+ var L = _interopRequireWildcard(require("leaflet"));
12
13
  var _reactLeaflet = require("react-leaflet");
13
14
  var _utils = require("../utils");
14
15
  var _reactDom = require("react-dom");
@@ -16,6 +17,7 @@ var _PricingPopup = _interopRequireDefault(require("./PricingPopup"));
16
17
  var _SelectQuantityPopup = _interopRequireDefault(require("./SelectQuantityPopup"));
17
18
  var _RemoveMultipleSeatsPopup = _interopRequireDefault(require("./RemoveMultipleSeatsPopup"));
18
19
  var _InvalidSeatsPopup = _interopRequireDefault(require("./InvalidSeatsPopup"));
20
+ var _constants = require("../utils/constants");
19
21
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
20
22
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
21
23
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
@@ -24,8 +26,6 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
24
26
  function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
25
27
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
26
28
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
27
- const SEATINGPLAN_MAX_RETRIES = 5;
28
- const BOOKING_MAX_RETRIES = 2;
29
29
  const SeatingPlan = _ref => {
30
30
  var _document, _document2, _document3;
31
31
  let {
@@ -147,7 +147,7 @@ const SeatingPlan = _ref => {
147
147
  }
148
148
  });
149
149
  if ((response === null || response === void 0 ? void 0 : response.status) === 429) {
150
- if (retryCount < BOOKING_MAX_RETRIES) {
150
+ if (retryCount < _constants.BOOKING_MAX_RETRIES) {
151
151
  setRetrying(prev => [...prev, s.ssId]);
152
152
  const delay = (0, _utils.getRetryDelay)(response);
153
153
  await new Promise(resolve => setTimeout(resolve, delay));
@@ -276,7 +276,7 @@ const SeatingPlan = _ref => {
276
276
  }
277
277
  });
278
278
  if (res.status === 429) {
279
- if (retryCount < BOOKING_MAX_RETRIES) {
279
+ if (retryCount < _constants.BOOKING_MAX_RETRIES) {
280
280
  setRetrying(prev => [...prev, seatToBook.seat.ssId]);
281
281
  const delay = (0, _utils.getRetryDelay)(res);
282
282
  await new Promise(resolve => setTimeout(resolve, delay));
@@ -455,7 +455,7 @@ const SeatingPlan = _ref => {
455
455
  }
456
456
  });
457
457
  if (response.status === 429) {
458
- if (retryCount >= SEATINGPLAN_MAX_RETRIES) {
458
+ if (retryCount >= _constants.SEATINGPLAN_MAX_RETRIES) {
459
459
  throw new Error("We're experiencing high demand. Please try again later.");
460
460
  }
461
461
  const delay = (0, _utils.getRetryDelay)(response);
@@ -484,13 +484,17 @@ const SeatingPlan = _ref => {
484
484
  paName: s.paName
485
485
  })));
486
486
  const img = new Image();
487
- const setupSeats = (height, width) => {
488
- const southwest = [0, 0];
489
- const northeast = [height * 0.015, width * 0.015];
487
+ const setupSeats = (h, w) => {
488
+ const lat1 = 0;
489
+ const lng1 = 0;
490
+ const lat2 = lat1 - _constants.SCALE;
491
+ const lng2 = lng1 + w / h * _constants.SCALE; // maintain aspect ratio
492
+ const southwest = [lat1, lng1];
493
+ const northeast = [lat2, lng2];
490
494
  setBounds([southwest, northeast]);
491
- setPosition([height * 0.005, width * 0.005]);
492
- setHeight(height * 0.5);
493
- setWidth(width * 0.5);
495
+ setPosition([h, w]);
496
+ setHeight(h);
497
+ setWidth(w);
494
498
  setSeats(data);
495
499
  if (data.preventOrphanedSeats && !isReload) {
496
500
  setSelectQuantityPopupOpen(true);
@@ -578,7 +582,7 @@ const SeatingPlan = _ref => {
578
582
  }) : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null), /*#__PURE__*/_react.default.createElement(_reactLeaflet.MapContainer, {
579
583
  zoomSnap: 0,
580
584
  zoomDelta: 1,
581
- center: (0, _utils.calculateCenterOfMap)(height, seats.seats),
585
+ center: bounds && new L.LatLngBounds(bounds).getCenter(),
582
586
  zoom: undefined,
583
587
  zoomControl: true,
584
588
  scrollWheelZoom: true,
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.SEAT_WIDTH = exports.SEATINGPLAN_MAX_RETRIES = exports.SCALE = exports.RADIUS = exports.ONE_DEG_LAT_IN_METERS = exports.BOOKING_MAX_RETRIES = void 0;
7
+ const SEAT_WIDTH = exports.SEAT_WIDTH = 20;
8
+ const RADIUS = exports.RADIUS = 8;
9
+ const SEATINGPLAN_MAX_RETRIES = exports.SEATINGPLAN_MAX_RETRIES = 5;
10
+ const BOOKING_MAX_RETRIES = exports.BOOKING_MAX_RETRIES = 2;
11
+ const SCALE = exports.SCALE = 0.1;
12
+ const ONE_DEG_LAT_IN_METERS = exports.ONE_DEG_LAT_IN_METERS = 111320;
@@ -3,8 +3,9 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.groupSeatsByPriceSection = exports.getValidSeats = exports.getSeatXy = exports.getSeatRadius = exports.getSeatCenterLatLng = exports.getRowSection = exports.getRetryDelay = exports.getNorthSeatLat = exports.getIsTouchScreen = exports.getInitialColor = exports.getAdjacentBookedSeats = exports.createsOrphan = exports.canSelectSingleSeatGivenOrphanRules = exports.calculateCenterOfMap = exports.NZDollar = void 0;
6
+ exports.groupSeatsByPriceSection = exports.getValidSeats = exports.getSeatCenterLatLng = exports.getRowSection = exports.getRetryDelay = exports.getIsTouchScreen = exports.getInitialColor = exports.getAdjacentBookedSeats = exports.createsOrphan = exports.canSelectSingleSeatGivenOrphanRules = exports.NZDollar = void 0;
7
7
  var _enums = require("./enums");
8
+ var _constants = require("./constants");
8
9
  const getIsTouchScreen = () => {
9
10
  let hasTouchScreen = false;
10
11
  if (typeof window !== "undefined") {
@@ -43,17 +44,6 @@ const getInitialColor = (s, price, loading, disabled, selected, greyedOut) => {
43
44
  };
44
45
  };
45
46
  exports.getInitialColor = getInitialColor;
46
- const calculateCenterOfMap = (height, seats, priceSectionIds) => {
47
- const filteredSeats = (seats === null || seats === void 0 ? void 0 : seats.filter(price => !priceSectionIds || priceSectionIds.includes(price.psId))) || [];
48
- const avgY = filteredSeats.reduce((acc, val) => {
49
- return acc + val.y / filteredSeats.length;
50
- }, 0);
51
- const avgX = filteredSeats.reduce((acc, val) => {
52
- return acc + val.x / filteredSeats.length;
53
- }, 0);
54
- return [height * 0.05 - avgY / (height > 800 ? height > 999 ? 3.5 : 3.3 : 3.35) - (height > 800 ? height > 999 ? height * 0.0201 : height * 0.0198 : height > 587 ? height * 0.0201 : height > 399 ? height * 0.02035 : height * 0.0207), avgX * 0.3 + 0.15];
55
- };
56
- exports.calculateCenterOfMap = calculateCenterOfMap;
57
47
  const NZDollar = exports.NZDollar = new Intl.NumberFormat("en-NZ", {
58
48
  style: "currency",
59
49
  currency: "NZD"
@@ -283,29 +273,19 @@ const groupSeatsByPriceSection = (seats, pricing, priceSectionIds) => {
283
273
  return groupedSeats;
284
274
  };
285
275
  exports.groupSeatsByPriceSection = groupSeatsByPriceSection;
286
- const getNorthSeatLat = (seat, height) => {
287
- return height / 33.33 - height / 33.33 * seat.y * 0.0105 + 1.4;
288
- };
289
- exports.getNorthSeatLat = getNorthSeatLat;
290
- const getSeatXy = (e, map) => {
291
- const latlng = e.target.getLatLng();
292
- const clickedSeatXy = map.latLngToContainerPoint(latlng);
293
- return clickedSeatXy;
294
- };
295
- exports.getSeatXy = getSeatXy;
296
- const getSeatRadius = (e, map) => {
297
- const latlng = e.target.getLatLng();
298
- const radius = e.target.getRadius();
299
- const point1 = map.latLngToLayerPoint(latlng);
300
- const point2 = map.latLngToLayerPoint([latlng.lat, latlng.lng + radius / 111320]); // Approx. conversion
301
- const pixelRadius = Math.abs(point2.x - point1.x);
302
- return pixelRadius;
303
- };
304
- exports.getSeatRadius = getSeatRadius;
305
- const getSeatCenterLatLng = (seat, isIcon, height) => {
276
+ const getSeatCenterLatLng = (seat, imgHeight, imgWidth, imgBounds) => {
277
+ const x = seat.x * _constants.SEAT_WIDTH + _constants.SEAT_WIDTH / 2;
278
+ const y = seat.y * _constants.SEAT_WIDTH + _constants.SEAT_WIDTH / 2;
279
+ const [lat1, lng1] = imgBounds[0];
280
+ const [lat2, lng2] = imgBounds[1];
281
+ const lat = lat1 + (lat2 - lat1) * (y / imgHeight);
282
+ const lng = lng1 + (lng2 - lng1) * (x / imgWidth);
283
+ const radius = Math.abs(lat1 + (lat2 - lat1) * (_constants.RADIUS / imgHeight) * _constants.ONE_DEG_LAT_IN_METERS); // Circle requires radius in meters
284
+
306
285
  return {
307
- lat: height * 0.05 - seat.y / (height > 800 ? height > 999 ? isIcon ? 3.5 : 3.45 : 3.3 : 3.35) - (height > 800 ? height > 999 ? height * 0.0201 : height * 0.0198 : height > 587 ? height * 0.0201 : height > 399 ? height * 0.02035 : height * 0.0207),
308
- lng: seat.x * 0.3 + 0.15
286
+ lat,
287
+ lng,
288
+ radius
309
289
  };
310
290
  };
311
291
  exports.getSeatCenterLatLng = getSeatCenterLatLng;
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.8.9",
5
+ "version": "1.8.10",
6
6
  "private": false,
7
7
  "keywords": [
8
8
  "iticket",