iticket-seatingplan-dev 1.5.6 → 1.5.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,126 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = PricingPopup;
7
+ var _react = require("react");
8
+ var _utils = require("../utils");
9
+ var _encodedSvgs = require("./assets/encodedSvgs");
10
+ var _Flexi = _interopRequireDefault(require("./Flexi"));
11
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
12
+ 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; }
13
+ 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; }
14
+ 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; }
15
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
16
+ 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); }
17
+ const PriceSelect = _ref => {
18
+ let {
19
+ seatGroup,
20
+ seatPriceages,
21
+ updateSeatGroupPriceage
22
+ } = _ref;
23
+ const [flexiOpen, setFlexiOpen] = (0, _react.useState)(false);
24
+ const isSelectedPriceFlexi = !!seatGroup.priceage.pMax && !!seatGroup.priceage.pMin && seatGroup.priceage.pMax > seatGroup.priceage.pMin;
25
+ return /*#__PURE__*/React.createElement("div", {
26
+ className: "price-select"
27
+ }, /*#__PURE__*/React.createElement("select", {
28
+ onChange: e => {
29
+ const newPriceage = seatPriceages.find(p => p.paId.toString() === e.target.value);
30
+ updateSeatGroupPriceage(newPriceage);
31
+ },
32
+ value: seatGroup.priceage.paId
33
+ }, seatPriceages.map(price => /*#__PURE__*/React.createElement("option", {
34
+ key: price.paId,
35
+ disabled: price.is_available === false,
36
+ value: price.paId
37
+ }, "".concat(price.paName, " ").concat(_utils.NZDollar.format(price.paId === seatGroup.priceage.paId ? seatGroup.priceage.p : price.p)).concat(price.is_available === false ? " - Allocation exhausted" : "")))), isSelectedPriceFlexi && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("button", {
38
+ className: "flexi-button",
39
+ onClick: () => setFlexiOpen(true)
40
+ }, /*#__PURE__*/React.createElement("img", {
41
+ src: _encodedSvgs.flexiIcon,
42
+ height: "18px",
43
+ width: "18px"
44
+ }), /*#__PURE__*/React.createElement("span", null, "Edit FLEXi price")), flexiOpen && /*#__PURE__*/React.createElement("div", {
45
+ className: "flexi-popup",
46
+ role: "dialog",
47
+ "aria-modal": "true"
48
+ }, /*#__PURE__*/React.createElement(_Flexi.default, {
49
+ price: seatGroup.priceage,
50
+ onClose: () => setFlexiOpen(false),
51
+ onConfirm: value => {
52
+ const newPriceage = _objectSpread(_objectSpread({}, seatGroup.priceage), {}, {
53
+ p: value
54
+ });
55
+ updateSeatGroupPriceage(newPriceage);
56
+ },
57
+ buttonText: "Confirm"
58
+ }))));
59
+ };
60
+ function PricingPopup(_ref2) {
61
+ let {
62
+ cancelPriceSelect,
63
+ groupedSelectedSeats,
64
+ pricing,
65
+ priceSectionIds,
66
+ batchAddTicketsToCart
67
+ } = _ref2;
68
+ const [seatsToBook, setSeatsToBook] = (0, _react.useState)(groupedSelectedSeats);
69
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
70
+ className: "pricing-popup-backdrop",
71
+ onClick: cancelPriceSelect
72
+ }), /*#__PURE__*/React.createElement("div", {
73
+ className: "pricing-popup",
74
+ role: "dialog",
75
+ "aria-modal": "true"
76
+ }, /*#__PURE__*/React.createElement("div", {
77
+ className: "popup-header"
78
+ }, /*#__PURE__*/React.createElement("h3", null, "Choose prices"), /*#__PURE__*/React.createElement("button", {
79
+ className: "close-button",
80
+ "aria-label": "close popup",
81
+ onClick: cancelPriceSelect
82
+ }, /*#__PURE__*/React.createElement("img", {
83
+ src: _encodedSvgs.closeIcon,
84
+ alt: "close",
85
+ height: "20px",
86
+ width: "20px"
87
+ }))), /*#__PURE__*/React.createElement("div", {
88
+ className: "seat-list"
89
+ }, Object.entries(seatsToBook).map(_ref3 => {
90
+ let [id, seatGroup] = _ref3;
91
+ const seatPriceages = pricing.filter(price => (!priceSectionIds || priceSectionIds.includes(price.psId)) && price.psId === parseInt(id));
92
+ return /*#__PURE__*/React.createElement("div", {
93
+ key: id,
94
+ className: "seat-group"
95
+ }, /*#__PURE__*/React.createElement("div", {
96
+ className: "seat-group-header"
97
+ }, /*#__PURE__*/React.createElement("h4", null, seatGroup.seats[0].psName), /*#__PURE__*/React.createElement("p", null, "".concat(seatGroup.seats.length, " seat").concat(seatGroup.seats.length !== 1 ? "s" : ""))), /*#__PURE__*/React.createElement("p", {
98
+ className: "seat-names"
99
+ }, seatGroup.seats.map(s => "".concat(s.r, "-").concat(s.c)).sort().join(", ")), seatPriceages.filter(price => price.is_available !== false).length > 0 ? /*#__PURE__*/React.createElement(PriceSelect, {
100
+ seatGroup: seatGroup,
101
+ seatPriceages: seatPriceages,
102
+ updateSeatGroupPriceage: newPriceage => {
103
+ const newSeats = _objectSpread({}, seatsToBook);
104
+ newSeats[id].priceage = newPriceage;
105
+ setSeatsToBook(newSeats);
106
+ }
107
+ }) : /*#__PURE__*/React.createElement("p", {
108
+ className: "no-prices-available"
109
+ }, "Oops, looks like there are no prices available for this section."));
110
+ })), /*#__PURE__*/React.createElement("div", {
111
+ className: "buttons"
112
+ }, /*#__PURE__*/React.createElement("button", {
113
+ className: "cancel",
114
+ onClick: cancelPriceSelect
115
+ }, "Cancel"), /*#__PURE__*/React.createElement("button", {
116
+ className: "add-cart",
117
+ onClick: () => {
118
+ batchAddTicketsToCart(Object.values(seatsToBook).filter(v => !!v.priceage).flatMap(s => s.seats.map(seat => ({
119
+ seat,
120
+ priceage: s.priceage
121
+ }))));
122
+ cancelPriceSelect();
123
+ },
124
+ disabled: Object.values(seatsToBook).every(v => !v.priceage)
125
+ }, "Add to cart"))));
126
+ }