iticket-seatingplan-dev 2.0.17 → 2.0.18

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.
@@ -191,7 +191,7 @@ function Controls(_ref) {
191
191
  className: "leaflet-control-zoom-in single-button"
192
192
  }, /*#__PURE__*/_react.default.createElement("span", null)))), /*#__PURE__*/_react.default.createElement(_reactLeaflet.FeatureGroup, {
193
193
  ref: drawLayersRef
194
- }, /*#__PURE__*/_react.default.createElement(_reactLeafletDraw.EditControl, {
194
+ }, drawLayersRef.current && /*#__PURE__*/_react.default.createElement(_reactLeafletDraw.EditControl, {
195
195
  position: "bottomleft",
196
196
  onCreated: handleDrawBox,
197
197
  onDrawStart: () => {
@@ -210,7 +210,8 @@ function Controls(_ref) {
210
210
  },
211
211
  edit: {
212
212
  edit: false,
213
- remove: false
213
+ remove: false,
214
+ featureGroup: drawLayersRef.current
214
215
  },
215
216
  onMounted: drawInstance => {
216
217
  drawRef.current = drawInstance;
@@ -299,7 +299,7 @@ function SeatMap(_ref) {
299
299
  }
300
300
  if (highlightedSeats.length === desiredSeatQuantity) {
301
301
  setClickedSeat(null);
302
- const groupedSeats = (0, _utils.groupSeatsByPriceSection)(highlightedSeats, seats.pricing, priceSectionIds);
302
+ const groupedSeats = (0, _utils.groupSeatsByPriceSection)(highlightedSeats, bookedSeats, seats.pricing, priceSectionIds);
303
303
  const priceages = Object.values(groupedSeats).flatMap(group => group.priceages.map(pa => pa.priceage));
304
304
  if (priceages.length === 1 && (priceages[0].q === null || priceages[0].q >= desiredSeatQuantity) && !isSingleFlexi) {
305
305
  batchAddTicketsToCart(highlightedSeats.map(s => ({
@@ -436,7 +436,12 @@ function SeatMap(_ref) {
436
436
  lng: s.x,
437
437
  radius: 110
438
438
  };
439
- 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
+ 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)) || []).map(p => {
440
+ const bookedQty = bookedSeats.filter(bs => bs.pId === p.paId && bs.psId === s.psId).length;
441
+ return _objectSpread(_objectSpread({}, p), {}, {
442
+ q: p.q === null ? null : Math.max(p.q - bookedQty, 0)
443
+ });
444
+ });
440
445
  const hasSeatPrices = (seatPrices === null || seatPrices === void 0 ? void 0 : seatPrices.length) > 0;
441
446
  const isSingleFlexi = seatPrices.length === 1 && !!seatPrices[0].pMax && !!seatPrices[0].pMin && seatPrices[0].pMax > seatPrices[0].pMin;
442
447
  const radiusInDeg = seatCenter.radius / _constants.ONE_DEG_LAT_IN_METERS;
@@ -208,11 +208,12 @@ function PricingPopup(_ref4) {
208
208
  let {
209
209
  onClose,
210
210
  selectedSeats,
211
+ bookedSeats,
211
212
  batchAddTicketsToCart,
212
213
  pricing,
213
214
  priceSectionIds
214
215
  } = _ref4;
215
- const [seatGroupsToBook, setSeatGroupsToBook] = (0, _react.useState)(() => (0, _utils.groupSeatsByPriceSection)(selectedSeats, pricing, priceSectionIds));
216
+ const [seatGroupsToBook, setSeatGroupsToBook] = (0, _react.useState)(() => (0, _utils.groupSeatsByPriceSection)(selectedSeats, bookedSeats, pricing, priceSectionIds));
216
217
  const updateSeatGroupPriceage = (priceage, qty) => {
217
218
  const newSeatGroupsToBook = _objectSpread({}, seatGroupsToBook);
218
219
  const group = newSeatGroupsToBook[priceage.psId];
@@ -561,16 +561,23 @@ const SeatingPlan = _ref => {
561
561
  throw new Error("Something went wrong. Please try again or contact support.");
562
562
  }
563
563
  }
564
- setBookedSeats(data.seats.filter(s => s.s === _utils.statuses.USER_PENDING && s.bookedPrice === price).map(s => ({
565
- ssId: s.ssId,
566
- r: s.r,
567
- c: s.c,
568
- showingId: showingId,
569
- p: s.p,
570
- //price || s.defaultPrice,
571
- pId: s.pId,
572
- paName: s.paName
573
- })));
564
+
565
+ // setBookedSeats(
566
+ // data.seats
567
+ // .filter(
568
+ // (s) => s.s === statuses.USER_PENDING && s.bookedPrice === price,
569
+ // )
570
+ // .map((s) => ({
571
+ // ssId: s.ssId,
572
+ // r: s.r,
573
+ // c: s.c,
574
+ // showingId: showingId,
575
+ // p: s.p, //price || s.defaultPrice,
576
+ // pId: s.pId,
577
+ // paName: s.paName,
578
+ // })),
579
+ // );
580
+
574
581
  const img = new Image();
575
582
  const setupSeats = (h, w) => {
576
583
  const lat1 = 0;
@@ -656,6 +663,7 @@ const SeatingPlan = _ref => {
656
663
  setSelectedSeats([]);
657
664
  },
658
665
  selectedSeats: selectedSeats,
666
+ bookedSeats: bookedSeats,
659
667
  pricing: seats.pricing,
660
668
  priceSectionIds: priceSectionIds,
661
669
  batchAddTicketsToCart: batchAddTicketsToCart
@@ -6,6 +6,11 @@ Object.defineProperty(exports, "__esModule", {
6
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
8
  var _constants = require("./constants");
9
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
10
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
11
+ 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; }
12
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
13
+ 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); }
9
14
  const getIsTouchScreen = () => {
10
15
  let hasTouchScreen = false;
11
16
  if (typeof window !== "undefined") {
@@ -228,12 +233,18 @@ const getRetryDelay = response => {
228
233
  return delay + Math.random() * 1000;
229
234
  };
230
235
  exports.getRetryDelay = getRetryDelay;
231
- const groupSeatsByPriceSection = (seats, pricing, priceSectionIds) => {
236
+ const groupSeatsByPriceSection = (seats, bookedSeats, pricing, priceSectionIds) => {
232
237
  const groupedSeats = seats.reduce((acc, curr) => {
233
238
  if (curr.psId) {
234
239
  const priceages = pricing.filter(price => price.psId === curr.psId && (!priceSectionIds || priceSectionIds.includes(price.psId)));
235
- const availablePriceages = priceages.filter(p => p.q === null || p.q > 0);
236
- const soldOutPriceages = priceages.filter(p => p.q === 0);
240
+ const adjustedPriceages = priceages.map(p => {
241
+ const bookedQty = bookedSeats.filter(s => s.pId === p.paId && s.psId === curr.psId).length;
242
+ return _objectSpread(_objectSpread({}, p), {}, {
243
+ q: p.q !== null ? Math.max(p.q - bookedQty, 0) : null
244
+ });
245
+ });
246
+ const availablePriceages = adjustedPriceages.filter(p => p.q === null || p.q > 0);
247
+ const soldOutPriceages = adjustedPriceages.filter(p => p.q === 0);
237
248
  const numSeats = seats.filter(s => s.psId === curr.psId).length;
238
249
  if (!acc[curr.psId]) {
239
250
  let qtyFilled = 0;
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": "2.0.17",
5
+ "version": "2.0.18",
6
6
  "private": false,
7
7
  "keywords": [
8
8
  "iticket",
@@ -20,10 +20,10 @@
20
20
  "@types/leaflet-draw": "^1.0.11",
21
21
  "leaflet": "^1.9.4",
22
22
  "leaflet-draw": "^1.0.4",
23
- "react": "^19.0.0",
24
- "react-dom": "^19.0.0",
25
- "react-leaflet": "^5.0.0-rc.2",
26
- "react-leaflet-draw": "^0.20.4",
23
+ "react": "^19.2.1",
24
+ "react-dom": "^19.2.1",
25
+ "react-leaflet": "^5.0.0",
26
+ "react-leaflet-draw": "0.20.3",
27
27
  "react-scripts": "^5.0.1"
28
28
  },
29
29
  "codependencies": {
@@ -58,4 +58,4 @@
58
58
  "@types/react-dom": "^18.3.1",
59
59
  "typescript": "^5.7.2"
60
60
  }
61
- }
61
+ }