iticket-seatingplan-dev 2.0.2 → 2.0.3
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.
- package/dist/components/Control.js +75 -0
- package/dist/components/Controls.js +7 -7
- package/dist/components/Map.js +22 -23
- package/dist/components/SeatingPlan.js +39 -18
- package/dist/components/styles/index.css +3 -2
- package/dist/utils/constants.js +12 -0
- package/dist/utils/helpers.js +14 -34
- package/package.json +5 -6
|
@@ -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;
|
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = Controls;
|
|
7
|
-
var
|
|
7
|
+
var _Control = _interopRequireDefault(require("./Control"));
|
|
8
8
|
var _reactLeafletDraw = require("react-leaflet-draw");
|
|
9
9
|
var _reactLeaflet = require("react-leaflet");
|
|
10
10
|
var _react = _interopRequireWildcard(require("react"));
|
|
@@ -35,7 +35,7 @@ function Controls(_ref) {
|
|
|
35
35
|
} = _ref;
|
|
36
36
|
const [isLegendOpen, setIsLegendOpen] = (0, _react.useState)(true);
|
|
37
37
|
const map = (0, _reactLeaflet.useMap)();
|
|
38
|
-
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, preventOrphanedSeats && /*#__PURE__*/_react.default.createElement(
|
|
38
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, preventOrphanedSeats && /*#__PURE__*/_react.default.createElement(_Control.default, {
|
|
39
39
|
position: "topright"
|
|
40
40
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
41
41
|
className: "extra-controls seat-quantity-control"
|
|
@@ -49,7 +49,7 @@ function Controls(_ref) {
|
|
|
49
49
|
height: "16px",
|
|
50
50
|
width: "16px",
|
|
51
51
|
strokeWidth: "2"
|
|
52
|
-
})))), /*#__PURE__*/_react.default.createElement(
|
|
52
|
+
})))), /*#__PURE__*/_react.default.createElement(_Control.default, {
|
|
53
53
|
position: "bottomright"
|
|
54
54
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
55
55
|
className: "legendBox"
|
|
@@ -90,7 +90,7 @@ function Controls(_ref) {
|
|
|
90
90
|
src: _encodedSvgs.userIcon,
|
|
91
91
|
width: 15,
|
|
92
92
|
height: 15
|
|
93
|
-
}), /*#__PURE__*/_react.default.createElement("p", null, "membership seats"))) : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null)))), /*#__PURE__*/_react.default.createElement(
|
|
93
|
+
}), /*#__PURE__*/_react.default.createElement("p", null, "membership seats"))) : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null)))), /*#__PURE__*/_react.default.createElement(_Control.default, {
|
|
94
94
|
position: "topleft"
|
|
95
95
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
96
96
|
className: "extra-controls"
|
|
@@ -120,7 +120,7 @@ function Controls(_ref) {
|
|
|
120
120
|
style: {
|
|
121
121
|
height: "17px"
|
|
122
122
|
}
|
|
123
|
-
})))), /*#__PURE__*/_react.default.createElement(
|
|
123
|
+
})))), /*#__PURE__*/_react.default.createElement(_Control.default, {
|
|
124
124
|
position: "topleft"
|
|
125
125
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
126
126
|
className: "extra-controls full-screen-control"
|
|
@@ -135,7 +135,7 @@ function Controls(_ref) {
|
|
|
135
135
|
style: {
|
|
136
136
|
height: "24px"
|
|
137
137
|
}
|
|
138
|
-
})))), canMultiSelect && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(
|
|
138
|
+
})))), canMultiSelect && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_Control.default, {
|
|
139
139
|
position: "bottomleft"
|
|
140
140
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
141
141
|
className: "extra-controls multi-select-control"
|
|
@@ -215,7 +215,7 @@ function Controls(_ref) {
|
|
|
215
215
|
onMounted: drawInstance => {
|
|
216
216
|
drawRef.current = drawInstance;
|
|
217
217
|
}
|
|
218
|
-
}))), /*#__PURE__*/_react.default.createElement(
|
|
218
|
+
}))), /*#__PURE__*/_react.default.createElement(_Control.default, {
|
|
219
219
|
position: "topright"
|
|
220
220
|
}, /*#__PURE__*/_react.default.createElement("button", {
|
|
221
221
|
title: "Close full screen",
|
package/dist/components/Map.js
CHANGED
|
@@ -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,19 +80,14 @@ 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
|
|
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:
|
|
87
|
+
center: latlng
|
|
92
88
|
})];
|
|
93
89
|
})), [seats.seats, height, priceSectionIds]);
|
|
94
|
-
const isOrphanMode = (seats === null || seats === void 0 ? void 0 : seats.preventOrphanedSeats) && desiredSeatQuantity > 0;
|
|
90
|
+
const isOrphanMode = (seats === null || seats === void 0 ? void 0 : seats.preventOrphanedSeats) && desiredSeatQuantity > 0 && mode === _utils.modes.SINGLE;
|
|
95
91
|
const isTouchScreen = (0, _utils.getIsTouchScreen)();
|
|
96
92
|
|
|
97
93
|
// L.drawLocal.draw.toolbar.buttons.rectangle = "Box select";
|
|
@@ -123,7 +119,7 @@ function SeatMap(_ref) {
|
|
|
123
119
|
} else if (mode === _utils.modes.REMOVE) {
|
|
124
120
|
const seatsToRemove = [];
|
|
125
121
|
selectedSeats.forEach(seat => {
|
|
126
|
-
if (!seatsToRemove.
|
|
122
|
+
if (!seatsToRemove.some(s => s.ssId === seat.ssId) && seat.s === _utils.statuses.USER_PENDING) {
|
|
127
123
|
seatsToRemove.push(seat);
|
|
128
124
|
}
|
|
129
125
|
});
|
|
@@ -227,7 +223,7 @@ function SeatMap(_ref) {
|
|
|
227
223
|
lng: seat.x
|
|
228
224
|
};
|
|
229
225
|
const latlng = [seatCenter.lat, seatCenter.lng];
|
|
230
|
-
if (boxBounds.contains(latlng) && !seatsToBook.
|
|
226
|
+
if (boxBounds.contains(latlng) && !seatsToBook.some(s => s.ssId === seat.ssId) && seat.s === _utils.statuses.UNSOLD) {
|
|
231
227
|
seatsToBook.push(seat);
|
|
232
228
|
}
|
|
233
229
|
});
|
|
@@ -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:
|
|
292
|
-
xy: (
|
|
287
|
+
offset: _constants.RADIUS,
|
|
288
|
+
xy: map.latLngToContainerPoint(e.target.getLatLng())
|
|
293
289
|
}));
|
|
294
290
|
handleHighlightSeats(e, s);
|
|
295
291
|
setIsHoveringOnSeat(true);
|
|
@@ -328,7 +324,7 @@ function SeatMap(_ref) {
|
|
|
328
324
|
}
|
|
329
325
|
};
|
|
330
326
|
const onMouseDown = (0, _react.useCallback)((s, hasSeatPrices) => {
|
|
331
|
-
if ((mode === _utils.modes.DRAG || mode === _utils.modes.REMOVE) && canMultiSelect && hasSeatPrices && !selectedSeats.
|
|
327
|
+
if ((mode === _utils.modes.DRAG || mode === _utils.modes.REMOVE) && canMultiSelect && hasSeatPrices && !selectedSeats.some(seat => seat.ssId === s.ssId) && s.s === (mode === _utils.modes.DRAG ? _utils.statuses.UNSOLD : _utils.statuses.USER_PENDING)) {
|
|
332
328
|
setSelectedSeats(prev => [...prev, s]);
|
|
333
329
|
}
|
|
334
330
|
}, [mode, canMultiSelect, selectedSeats, setSelectedSeats]);
|
|
@@ -339,7 +335,7 @@ function SeatMap(_ref) {
|
|
|
339
335
|
if (hideTooltipTimeoutRef.current) {
|
|
340
336
|
clearTimeout(hideTooltipTimeoutRef.current);
|
|
341
337
|
}
|
|
342
|
-
if ((mode === _utils.modes.DRAG || mode === _utils.modes.REMOVE) && isDragging && canMultiSelect && hasSeatPrices && !selectedSeats.
|
|
338
|
+
if ((mode === _utils.modes.DRAG || mode === _utils.modes.REMOVE) && isDragging && canMultiSelect && hasSeatPrices && !selectedSeats.some(seat => seat.ssId === s.ssId) && s.s === (mode === _utils.modes.DRAG ? _utils.statuses.UNSOLD : _utils.statuses.USER_PENDING)) {
|
|
343
339
|
setSelectedSeats(prev => [...prev, s]);
|
|
344
340
|
return;
|
|
345
341
|
}
|
|
@@ -371,7 +367,7 @@ function SeatMap(_ref) {
|
|
|
371
367
|
infoVisible: false
|
|
372
368
|
}));
|
|
373
369
|
}
|
|
374
|
-
if ((highlightedSeats === null || highlightedSeats === void 0 ? void 0 : highlightedSeats.length) > 0) {
|
|
370
|
+
if ((highlightedSeats === null || highlightedSeats === void 0 ? void 0 : highlightedSeats.length) > 0 && mode === _utils.modes.SINGLE) {
|
|
375
371
|
setHighlightedSeats([]);
|
|
376
372
|
}
|
|
377
373
|
}, 400);
|
|
@@ -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:
|
|
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:
|
|
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:
|
|
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:
|
|
476
|
+
bounds: iconBounds,
|
|
478
477
|
zIndex: 10
|
|
479
478
|
}) : /*#__PURE__*/_react.default.createElement(_reactLeaflet.Circle, {
|
|
480
479
|
center: [seatCenter.lat, seatCenter.lng],
|
|
481
|
-
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:
|
|
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)) && (isOrphanMode ? isHoveringOnSeat : true), greyedOutSeats.some(gs => gs.ssId === s.ssId)),
|
|
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 {
|
|
@@ -44,7 +44,15 @@ const SeatingPlan = _ref => {
|
|
|
44
44
|
connectedShowings,
|
|
45
45
|
areaName,
|
|
46
46
|
promoCode,
|
|
47
|
-
bookingMode = _utils.bookingModes.SHOPSITE
|
|
47
|
+
bookingMode = _utils.bookingModes.SHOPSITE,
|
|
48
|
+
theme = {
|
|
49
|
+
accent: "#6366f1",
|
|
50
|
+
accentDark: "#3730a3",
|
|
51
|
+
accentLight: "#e0e7ff",
|
|
52
|
+
flexiAccent: "#e32664",
|
|
53
|
+
flexiAccentDark: "#ffd3e2",
|
|
54
|
+
flexiAccentLight: "#be003f"
|
|
55
|
+
}
|
|
48
56
|
} = _ref;
|
|
49
57
|
const [initialiseMessage, setInitialiseMessage] = (0, _react.useState)("Initialising seating plan...");
|
|
50
58
|
const [isReloading, setIsReloading] = (0, _react.useState)(false);
|
|
@@ -147,7 +155,7 @@ const SeatingPlan = _ref => {
|
|
|
147
155
|
}
|
|
148
156
|
});
|
|
149
157
|
if ((response === null || response === void 0 ? void 0 : response.status) === 429) {
|
|
150
|
-
if (retryCount < BOOKING_MAX_RETRIES) {
|
|
158
|
+
if (retryCount < _constants.BOOKING_MAX_RETRIES) {
|
|
151
159
|
setRetrying(prev => [...prev, s.ssId]);
|
|
152
160
|
const delay = (0, _utils.getRetryDelay)(response);
|
|
153
161
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
@@ -276,7 +284,7 @@ const SeatingPlan = _ref => {
|
|
|
276
284
|
}
|
|
277
285
|
});
|
|
278
286
|
if (res.status === 429) {
|
|
279
|
-
if (retryCount < BOOKING_MAX_RETRIES) {
|
|
287
|
+
if (retryCount < _constants.BOOKING_MAX_RETRIES) {
|
|
280
288
|
setRetrying(prev => [...prev, seatToBook.seat.ssId]);
|
|
281
289
|
const delay = (0, _utils.getRetryDelay)(res);
|
|
282
290
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
@@ -455,7 +463,7 @@ const SeatingPlan = _ref => {
|
|
|
455
463
|
}
|
|
456
464
|
});
|
|
457
465
|
if (response.status === 429) {
|
|
458
|
-
if (retryCount >= SEATINGPLAN_MAX_RETRIES) {
|
|
466
|
+
if (retryCount >= _constants.SEATINGPLAN_MAX_RETRIES) {
|
|
459
467
|
throw new Error("We're experiencing high demand. Please try again later.");
|
|
460
468
|
}
|
|
461
469
|
const delay = (0, _utils.getRetryDelay)(response);
|
|
@@ -484,13 +492,17 @@ const SeatingPlan = _ref => {
|
|
|
484
492
|
paName: s.paName
|
|
485
493
|
})));
|
|
486
494
|
const img = new Image();
|
|
487
|
-
const setupSeats = (
|
|
488
|
-
const
|
|
489
|
-
const
|
|
495
|
+
const setupSeats = (h, w) => {
|
|
496
|
+
const lat1 = 0;
|
|
497
|
+
const lng1 = 0;
|
|
498
|
+
const lat2 = lat1 - _constants.SCALE;
|
|
499
|
+
const lng2 = lng1 + w / h * _constants.SCALE; // maintain aspect ratio
|
|
500
|
+
const southwest = [lat1, lng1];
|
|
501
|
+
const northeast = [lat2, lng2];
|
|
490
502
|
setBounds([southwest, northeast]);
|
|
491
|
-
setPosition([
|
|
492
|
-
setHeight(
|
|
493
|
-
setWidth(
|
|
503
|
+
setPosition([h, w]);
|
|
504
|
+
setHeight(h);
|
|
505
|
+
setWidth(w);
|
|
494
506
|
setSeats(data);
|
|
495
507
|
if (data.preventOrphanedSeats && !isReload) {
|
|
496
508
|
setSelectQuantityPopupOpen(true);
|
|
@@ -536,19 +548,28 @@ const SeatingPlan = _ref => {
|
|
|
536
548
|
// in full screen mode, render the map in the body, otherwise render in the seating-plan-root div
|
|
537
549
|
const mapContainer = mounted && (isFullScreen ? (_document = document) === null || _document === void 0 ? void 0 : _document.body : (_document2 = document) === null || _document2 === void 0 ? void 0 : _document2.getElementById("seating-plan-root"));
|
|
538
550
|
const backdropContainer = mounted && ((_document3 = document) === null || _document3 === void 0 ? void 0 : _document3.body);
|
|
539
|
-
|
|
540
|
-
|
|
551
|
+
const themeStyles = {
|
|
552
|
+
"--accent": theme.accent,
|
|
553
|
+
"--accent-dark": theme.accentDark,
|
|
554
|
+
"--accent-light": theme.accentLight,
|
|
555
|
+
"--flexi-accent": theme.flexiAccent,
|
|
556
|
+
"--flexi-accent-light": theme.flexiAccentLight,
|
|
557
|
+
"--flexi-accent-dark": theme.flexiAccentDark
|
|
558
|
+
};
|
|
541
559
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
|
|
542
560
|
className: "seating-plan-root",
|
|
543
|
-
id: "seating-plan-root"
|
|
561
|
+
id: "seating-plan-root",
|
|
562
|
+
style: themeStyles
|
|
544
563
|
}, error ? /*#__PURE__*/_react.default.createElement("div", {
|
|
545
564
|
className: "loading"
|
|
546
565
|
}, /*#__PURE__*/_react.default.createElement("h1", null, "OOPS!"), /*#__PURE__*/_react.default.createElement("div", null, error.response.data.message)) : position && area === areaId ? /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, backdropContainer && /*#__PURE__*/(0, _reactDom.createPortal)(/*#__PURE__*/_react.default.createElement("div", {
|
|
547
566
|
className: "seating-plan-backdrop ".concat(isFullScreen ? "full-screen" : ""),
|
|
548
|
-
onClick: () => setIsFullScreen(false)
|
|
567
|
+
onClick: () => setIsFullScreen(false),
|
|
568
|
+
style: themeStyles
|
|
549
569
|
}), backdropContainer), mapContainer && /*#__PURE__*/(0, _reactDom.createPortal)(/*#__PURE__*/_react.default.createElement("div", {
|
|
550
570
|
className: "seating-plan-container ".concat(isFullScreen ? "full-screen" : ""),
|
|
551
|
-
"data-mode": mode
|
|
571
|
+
"data-mode": mode,
|
|
572
|
+
style: themeStyles
|
|
552
573
|
}, pricingPopupOpen && seats && seats.pricing && (canMultiSelect || seats.preventOrphanedSeats) ? /*#__PURE__*/_react.default.createElement(_PricingPopup.default, {
|
|
553
574
|
onClose: () => {
|
|
554
575
|
setPricingPopupOpen(false);
|
|
@@ -578,7 +599,7 @@ const SeatingPlan = _ref => {
|
|
|
578
599
|
}) : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null), /*#__PURE__*/_react.default.createElement(_reactLeaflet.MapContainer, {
|
|
579
600
|
zoomSnap: 0,
|
|
580
601
|
zoomDelta: 1,
|
|
581
|
-
center:
|
|
602
|
+
center: bounds && new L.LatLngBounds(bounds).getCenter(),
|
|
582
603
|
zoom: undefined,
|
|
583
604
|
zoomControl: true,
|
|
584
605
|
scrollWheelZoom: true,
|
|
@@ -27,12 +27,12 @@ button {
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
.seating-plan-container {
|
|
30
|
-
--accent: rgb(99 102 241);
|
|
30
|
+
/* --accent: rgb(99 102 241);
|
|
31
31
|
--accent-dark: rgb(55 48 163);
|
|
32
32
|
--accent-light: rgb(224 231 255);
|
|
33
33
|
--flexi-accent: rgb(227 38 100);
|
|
34
34
|
--flexi-accent-light: rgb(255 211 226);
|
|
35
|
-
--flexi-accent-dark: rgb(190 0 63);
|
|
35
|
+
--flexi-accent-dark: rgb(190 0 63); */
|
|
36
36
|
font-family: inherit;
|
|
37
37
|
}
|
|
38
38
|
|
|
@@ -42,6 +42,7 @@ button {
|
|
|
42
42
|
border-radius: 3px;
|
|
43
43
|
text-align: left;
|
|
44
44
|
backdrop-filter: blur(2px);
|
|
45
|
+
color: #333;
|
|
45
46
|
}
|
|
46
47
|
|
|
47
48
|
.legend-header {
|
|
@@ -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;
|
package/dist/utils/helpers.js
CHANGED
|
@@ -3,8 +3,9 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.groupSeatsByPriceSection = exports.getValidSeats = exports.
|
|
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
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
const
|
|
291
|
-
const
|
|
292
|
-
const
|
|
293
|
-
|
|
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
|
|
308
|
-
lng
|
|
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": "2.0.
|
|
5
|
+
"version": "2.0.3",
|
|
6
6
|
"private": false,
|
|
7
7
|
"keywords": [
|
|
8
8
|
"iticket",
|
|
@@ -18,12 +18,11 @@
|
|
|
18
18
|
"@babel/polyfill": "^7.12.1",
|
|
19
19
|
"@types/leaflet": "^1.9.14",
|
|
20
20
|
"@types/leaflet-draw": "^1.0.11",
|
|
21
|
-
"leaflet": "^1.9.
|
|
21
|
+
"leaflet": "^1.9.4",
|
|
22
22
|
"leaflet-draw": "^1.0.4",
|
|
23
|
-
"react": "^
|
|
24
|
-
"react-dom": "^
|
|
25
|
-
"react-leaflet": "^
|
|
26
|
-
"react-leaflet-custom-control": "^1.3.5",
|
|
23
|
+
"react": "^19.0.0",
|
|
24
|
+
"react-dom": "^19.0.0",
|
|
25
|
+
"react-leaflet": "^5.0.0-rc.2",
|
|
27
26
|
"react-leaflet-draw": "^0.20.4",
|
|
28
27
|
"react-scripts": "^5.0.1"
|
|
29
28
|
},
|