iticket-seatingplan-dev 1.7.5 → 1.7.7
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.
|
@@ -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;
|
package/dist/components/Map.js
CHANGED
|
@@ -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);
|
|
@@ -429,6 +430,7 @@ function SeatMap(_ref) {
|
|
|
429
430
|
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)) || [];
|
|
430
431
|
const hasSeatPrices = (seatPrices === null || seatPrices === void 0 ? void 0 : seatPrices.length) > 0;
|
|
431
432
|
const isSingleFlexi = seatPrices.length === 1 && !!seatPrices[0].pMax && !!seatPrices[0].pMin && seatPrices[0].pMax > seatPrices[0].pMin;
|
|
433
|
+
const isOrphanMode = seats.preventOrphanedSeats && desiredSeatQuantity > 0;
|
|
432
434
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
433
435
|
key: i
|
|
434
436
|
}, (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, {
|
|
@@ -450,9 +452,14 @@ function SeatMap(_ref) {
|
|
|
450
452
|
radius: 12000,
|
|
451
453
|
eventHandlers: {
|
|
452
454
|
click: e => {
|
|
455
|
+
// pos multi-select mode
|
|
453
456
|
if (mode === _utils.modes.DRAG || mode === _utils.modes.REMOVE || mode === _utils.modes.DRAW || selectedSeats.length > 0) {
|
|
454
457
|
map.closePopup();
|
|
455
|
-
|
|
458
|
+
return;
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
// orphan multi-select mode
|
|
462
|
+
if (isOrphanMode) {
|
|
456
463
|
map.closePopup();
|
|
457
464
|
if (s.s === _utils.statuses.USER_PENDING) {
|
|
458
465
|
const newSeatsToRemove = (0, _utils.getAdjacentBookedSeats)(s, seatsMap);
|
|
@@ -462,18 +469,36 @@ function SeatMap(_ref) {
|
|
|
462
469
|
setSeatsToRemove(newSeatsToRemove);
|
|
463
470
|
setRemoveMultipleSeatsPopupOpen(true);
|
|
464
471
|
}
|
|
465
|
-
|
|
472
|
+
return;
|
|
473
|
+
}
|
|
474
|
+
if (highlightedSeats.length > 0 && highlightedSeats.length === desiredSeatQuantity) {
|
|
466
475
|
if ((0, _utils.isTouchScreen)() && clickedSeat !== s.ssId) {
|
|
467
476
|
setClickedSeat(s.ssId);
|
|
468
477
|
} else {
|
|
469
|
-
|
|
470
|
-
|
|
478
|
+
const groupedSeats = (0, _utils.groupSeatsByPriceSection)(highlightedSeats, seats.pricing, priceSectionIds);
|
|
479
|
+
const priceages = Object.values(groupedSeats).flatMap(group => group.priceages.map(pa => pa.priceage));
|
|
480
|
+
if (priceages.length === 1 && (priceages[0].q === null || priceages[0].q >= desiredSeatQuantity) && !isSingleFlexi) {
|
|
481
|
+
batchAddTicketsToCart(highlightedSeats.map(s => ({
|
|
482
|
+
seat: s,
|
|
483
|
+
priceage: priceages[0]
|
|
484
|
+
})));
|
|
485
|
+
} else {
|
|
486
|
+
setSelectedSeats([...highlightedSeats]);
|
|
487
|
+
setPricingPopupOpen(true);
|
|
488
|
+
}
|
|
471
489
|
}
|
|
472
|
-
|
|
490
|
+
return;
|
|
491
|
+
}
|
|
492
|
+
if (greyedOutSeats.some(gs => gs.ssId === s.ssId)) {
|
|
473
493
|
setInvalidSeatsPopupOpen(true);
|
|
474
494
|
}
|
|
475
|
-
|
|
495
|
+
return;
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
// single select mode
|
|
499
|
+
if (mode === _utils.modes.SINGLE && hasSeatPrices) {
|
|
476
500
|
handleClickSeat(e, s);
|
|
501
|
+
return;
|
|
477
502
|
}
|
|
478
503
|
},
|
|
479
504
|
popupopen: popup => {
|
|
@@ -499,7 +524,8 @@ function SeatMap(_ref) {
|
|
|
499
524
|
} else {
|
|
500
525
|
setIsHoveringOnSeat(true);
|
|
501
526
|
setHoveredSeat(s);
|
|
502
|
-
|
|
527
|
+
setClickedSeat(s.ssId);
|
|
528
|
+
if (isOrphanMode && s.s === _utils.statuses.UNSOLD && mode === _utils.modes.SINGLE) {
|
|
503
529
|
const seatsToBook = (0, _utils.getValidSeats)(s, seatsMap, desiredSeatQuantity);
|
|
504
530
|
if (seatsToBook.valid) {
|
|
505
531
|
setHighlightedSeats(seatsToBook.seats);
|
|
@@ -537,11 +563,11 @@ function SeatMap(_ref) {
|
|
|
537
563
|
});
|
|
538
564
|
}
|
|
539
565
|
}
|
|
540
|
-
}, (0, _utils.isTouchScreen)() && /*#__PURE__*/_react.default.createElement(_reactLeaflet.Tooltip, {
|
|
566
|
+
}, (0, _utils.isTouchScreen)() && !isSingleFlexi && (seatPrices.length === 1 || isOrphanMode && highlightedSeats.length > 1) ? /*#__PURE__*/_react.default.createElement(_reactLeaflet.Tooltip, {
|
|
541
567
|
className: "mobile-tooltip",
|
|
542
568
|
direction: "top",
|
|
543
569
|
offset: [0, height * 0.03 + -60]
|
|
544
|
-
}, "Tap again to select these seats"), s.s === _utils.statuses.UNSOLD && hasSeatPrices ? /*#__PURE__*/_react.default.createElement(_reactLeaflet.Popup, {
|
|
570
|
+
}, "Tap again to select", " ", isOrphanMode && (highlightedSeats === null || highlightedSeats === void 0 ? void 0 : highlightedSeats.length) > 1 ? "these seats" : "this seat") : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null), s.s === _utils.statuses.UNSOLD && hasSeatPrices ? /*#__PURE__*/_react.default.createElement(_reactLeaflet.Popup, {
|
|
545
571
|
className: "ticket-popup popup-".concat(s.sId)
|
|
546
572
|
}, isSingleFlexi ? /*#__PURE__*/_react.default.createElement("div", {
|
|
547
573
|
className: "single-flexi"
|
|
@@ -212,48 +212,7 @@ function PricingPopup(_ref4) {
|
|
|
212
212
|
pricing,
|
|
213
213
|
priceSectionIds
|
|
214
214
|
} = _ref4;
|
|
215
|
-
const [seatGroupsToBook, setSeatGroupsToBook] = (0, _react.useState)(
|
|
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", {
|
package/dist/utils/helpers.js
CHANGED
|
@@ -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;
|