iticket-seatingplan-dev 1.8.4 → 1.8.5
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.
|
@@ -33,7 +33,7 @@ function Controls(_ref) {
|
|
|
33
33
|
isReloading,
|
|
34
34
|
onReload
|
|
35
35
|
} = _ref;
|
|
36
|
-
const [isLegendOpen, setIsLegendOpen] = (0, _react.useState)(
|
|
36
|
+
const [isLegendOpen, setIsLegendOpen] = (0, _react.useState)(true);
|
|
37
37
|
const map = (0, _reactLeaflet.useMap)();
|
|
38
38
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, preventOrphanedSeats && /*#__PURE__*/_react.default.createElement(_reactLeafletCustomControl.default, {
|
|
39
39
|
position: "topright"
|
|
@@ -24,8 +24,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
24
24
|
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
25
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
26
26
|
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
|
|
28
|
-
const BOOKING_MAX_RETRIES = 2;
|
|
27
|
+
const MAX_RETRIES = 5;
|
|
29
28
|
const SeatingPlan = _ref => {
|
|
30
29
|
var _document, _document2, _document3;
|
|
31
30
|
let {
|
|
@@ -68,7 +67,6 @@ const SeatingPlan = _ref => {
|
|
|
68
67
|
const [seatsToRemove, setSeatsToRemove] = (0, _react.useState)([]);
|
|
69
68
|
const [removeMultipleSeatsPopupOpen, setRemoveMultipleSeatsPopupOpen] = (0, _react.useState)(false);
|
|
70
69
|
const [invalidSeatsPopupOpen, setInvalidSeatsPopupOpen] = (0, _react.useState)(false);
|
|
71
|
-
const [retrying, setRetrying] = (0, _react.useState)([]);
|
|
72
70
|
const mapRef = (0, _react.useRef)(null);
|
|
73
71
|
const canMultiSelect = bookingMode === _utils.bookingModes.POS;
|
|
74
72
|
const apiUrl = "".concat(baseUrl, "/legacy/").concat(countryCode, "/shop/events/").concat(eventId, "/").concat(eventVenueId, "/showings/").concat(showingId, "/tickets/allocated/").concat(areaId);
|
|
@@ -85,36 +83,17 @@ const SeatingPlan = _ref => {
|
|
|
85
83
|
};
|
|
86
84
|
callbackFunction === null || callbackFunction === void 0 || callbackFunction(event);
|
|
87
85
|
};
|
|
88
|
-
const
|
|
89
|
-
if (seatIndex !== -1) {
|
|
90
|
-
setSeats(prev => {
|
|
91
|
-
const updatedSeats = _objectSpread({}, prev);
|
|
92
|
-
updatedSeats.seats[seatIndex] = newSeat;
|
|
93
|
-
return updatedSeats;
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
};
|
|
97
|
-
const setSeatsLoading = (seatsToUpdate, loading) => {
|
|
98
|
-
setSeats(prev => {
|
|
99
|
-
const updatedSeats = _objectSpread({}, prev);
|
|
100
|
-
seatsToUpdate.forEach(seat => {
|
|
101
|
-
const seatIndex = updatedSeats.seats.findIndex(s => s.ssId === seat.ssId);
|
|
102
|
-
if (seatIndex !== -1) {
|
|
103
|
-
updatedSeats.seats[seatIndex] = _objectSpread(_objectSpread({}, updatedSeats.seats[seatIndex]), {}, {
|
|
104
|
-
loading: loading
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
});
|
|
108
|
-
return updatedSeats;
|
|
109
|
-
});
|
|
110
|
-
};
|
|
111
|
-
const _addTicketToCart = async function addTicketToCart(s, priceage) {
|
|
86
|
+
const addTicketToCart = (s, priceage) => {
|
|
112
87
|
var _mapRef$current;
|
|
113
|
-
|
|
114
|
-
const seatIndex =
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
88
|
+
const updatedSeats = _objectSpread({}, seats);
|
|
89
|
+
const seatIndex = updatedSeats.seats.findIndex(seat => seat.ssId === s.ssId);
|
|
90
|
+
const setSeatLoading = loading => {
|
|
91
|
+
if (seatIndex !== -1) {
|
|
92
|
+
updatedSeats.seats[seatIndex].loading = loading;
|
|
93
|
+
setSeats(updatedSeats);
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
setSeatLoading(true);
|
|
118
97
|
const isSeatAvailable = (s.s === _utils.statuses.UNSOLD || s.s === _utils.statuses.USER_PENDING) && !(bookedSeats.length >= quantity && s.s === _utils.statuses.UNSOLD) && (priceage.q === null || priceage.q > 0);
|
|
119
98
|
if (!isSeatAvailable) {
|
|
120
99
|
if (bookedSeats.length >= quantity) {
|
|
@@ -126,224 +105,210 @@ const SeatingPlan = _ref => {
|
|
|
126
105
|
message: _utils.ERROR_MESSAGES.NO_ALLOCATION
|
|
127
106
|
});
|
|
128
107
|
}
|
|
129
|
-
|
|
130
|
-
loading: false
|
|
131
|
-
}));
|
|
108
|
+
setSeatLoading(false);
|
|
132
109
|
return;
|
|
133
110
|
}
|
|
134
111
|
(_mapRef$current = mapRef.current) === null || _mapRef$current === void 0 || (_mapRef$current = _mapRef$current.target) === null || _mapRef$current === void 0 || _mapRef$current.closePopup();
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
"basket-key": sessionId
|
|
147
|
-
}
|
|
148
|
-
});
|
|
149
|
-
if ((response === null || response === void 0 ? void 0 : response.status) === 429) {
|
|
150
|
-
if (retryCount < BOOKING_MAX_RETRIES) {
|
|
151
|
-
setRetrying(prev => [...prev, s.ssId]);
|
|
152
|
-
const delay = (0, _utils.getRetryDelay)(response);
|
|
153
|
-
await new Promise(resolve => setTimeout(resolve, delay));
|
|
154
|
-
return _addTicketToCart(s, priceage, retryCount + 1);
|
|
155
|
-
}
|
|
156
|
-
updateSeat(seatIndex, _objectSpread(_objectSpread({}, s), {}, {
|
|
157
|
-
loading: false
|
|
158
|
-
}));
|
|
159
|
-
setRetrying(prev => prev.filter(id => id !== s.ssId));
|
|
160
|
-
handleError({
|
|
161
|
-
code: 429,
|
|
162
|
-
message: _utils.ERROR_MESSAGES.MAX_RETRIES
|
|
163
|
-
});
|
|
164
|
-
return;
|
|
112
|
+
fetch(apiUrl, {
|
|
113
|
+
method: "POST",
|
|
114
|
+
body: JSON.stringify({
|
|
115
|
+
priceAgeId: priceage.paId,
|
|
116
|
+
seatId: s.ssId,
|
|
117
|
+
price: priceage.p,
|
|
118
|
+
connectedShowings: connectedShowings
|
|
119
|
+
}),
|
|
120
|
+
headers: {
|
|
121
|
+
"content-type": "application/json",
|
|
122
|
+
"basket-key": sessionId
|
|
165
123
|
}
|
|
166
|
-
|
|
167
|
-
if ((response === null || response === void 0 ? void 0 : response.status) === 403) {
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
124
|
+
}).then(response => {
|
|
125
|
+
if ((response === null || response === void 0 ? void 0 : response.status) === 403 || (response === null || response === void 0 ? void 0 : response.status) === 400) {
|
|
126
|
+
if (seatIndex !== -1) {
|
|
127
|
+
updatedSeats.seats[seatIndex] = _objectSpread(_objectSpread({}, s), {}, {
|
|
128
|
+
loading: false,
|
|
129
|
+
s: _utils.statuses.SOLD
|
|
130
|
+
});
|
|
131
|
+
setSeats(updatedSeats);
|
|
132
|
+
}
|
|
172
133
|
handleError({
|
|
173
134
|
code: 403,
|
|
174
|
-
message: _utils.ERROR_MESSAGES.
|
|
135
|
+
message: response.status === 400 ? _utils.ERROR_MESSAGES.INCOMPATIBLE_TICKETS : _utils.ERROR_MESSAGES.SEAT_UNAVAILABLE
|
|
175
136
|
});
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
if (!(response !== null && response !== void 0 && response.ok)) {
|
|
179
|
-
updateSeat(seatIndex, _objectSpread(_objectSpread({}, s), {}, {
|
|
180
|
-
loading: false
|
|
181
|
-
}));
|
|
137
|
+
} else if ((response === null || response === void 0 ? void 0 : response.status) === 429) {
|
|
138
|
+
setSeatLoading(false);
|
|
182
139
|
handleError({
|
|
183
|
-
code:
|
|
184
|
-
message:
|
|
140
|
+
code: 429,
|
|
141
|
+
message: _utils.ERROR_MESSAGES.SEAT_TAKEN
|
|
185
142
|
});
|
|
186
143
|
} else {
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
144
|
+
if (seatIndex !== -1) {
|
|
145
|
+
updatedSeats.seats[seatIndex] = _objectSpread(_objectSpread({}, s), {}, {
|
|
146
|
+
s: _utils.statuses.USER_PENDING,
|
|
147
|
+
bookedPrice: price,
|
|
148
|
+
loading: false
|
|
149
|
+
});
|
|
150
|
+
setSeats(updatedSeats);
|
|
151
|
+
}
|
|
152
|
+
setBookedSeats(prev => [...prev, {
|
|
153
|
+
ssId: s.ssId,
|
|
154
|
+
r: s.r,
|
|
155
|
+
c: s.c,
|
|
193
156
|
showingId: showingId,
|
|
194
157
|
pId: priceage.paId,
|
|
195
158
|
p: priceage.p,
|
|
196
159
|
paName: priceage.paName
|
|
197
|
-
}
|
|
160
|
+
}]);
|
|
198
161
|
const event = {
|
|
199
162
|
type: "cart-change-add",
|
|
200
|
-
details: [
|
|
163
|
+
details: [...bookedSeats, {
|
|
164
|
+
ssId: s.ssId,
|
|
165
|
+
r: s.r,
|
|
166
|
+
c: s.c,
|
|
201
167
|
showingId: showingId,
|
|
202
168
|
pId: priceage.paId,
|
|
203
169
|
p: priceage.p,
|
|
204
170
|
paName: priceage.paName
|
|
205
|
-
}
|
|
171
|
+
}]
|
|
206
172
|
};
|
|
207
173
|
callbackFunction === null || callbackFunction === void 0 || callbackFunction(event);
|
|
208
174
|
}
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
loading: false
|
|
212
|
-
}));
|
|
213
|
-
setRetrying(prev => prev.filter(id => id !== s.ssId));
|
|
175
|
+
}).catch(() => {
|
|
176
|
+
setSeatLoading(false);
|
|
214
177
|
handleError({
|
|
215
178
|
code: 500,
|
|
216
179
|
message: _utils.ERROR_MESSAGES.GENERIC_ERROR
|
|
217
180
|
});
|
|
218
|
-
}
|
|
181
|
+
}).finally(() => {
|
|
182
|
+
_initialFetch(true);
|
|
183
|
+
});
|
|
219
184
|
};
|
|
220
|
-
const removeTicketFromCart =
|
|
221
|
-
const
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
185
|
+
const removeTicketFromCart = (s, e) => {
|
|
186
|
+
const updatedSeats = _objectSpread({}, seats);
|
|
187
|
+
const seatIndex = updatedSeats.seats.findIndex(seat => seat.ssId === s.ssId);
|
|
188
|
+
const setSeatLoading = loading => {
|
|
189
|
+
if (seatIndex !== -1) {
|
|
190
|
+
updatedSeats.seats[seatIndex].loading = loading;
|
|
191
|
+
setSeats(updatedSeats);
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
setSeatLoading(true);
|
|
195
|
+
fetch("".concat(apiUrl, "/seat/").concat(s.ssId), {
|
|
196
|
+
method: "DELETE",
|
|
197
|
+
headers: {
|
|
198
|
+
"basket-key": sessionId
|
|
199
|
+
}
|
|
200
|
+
}).then(() => {
|
|
201
|
+
if (seatIndex !== -1) {
|
|
202
|
+
updatedSeats.seats[seatIndex] = _objectSpread(_objectSpread({}, s), {}, {
|
|
203
|
+
loading: false,
|
|
204
|
+
s: _utils.statuses.UNSOLD,
|
|
205
|
+
bookedPrice: null
|
|
206
|
+
});
|
|
207
|
+
setSeats(updatedSeats);
|
|
234
208
|
}
|
|
235
|
-
updateSeat(seatIndex, _objectSpread(_objectSpread({}, s), {}, {
|
|
236
|
-
loading: false,
|
|
237
|
-
s: _utils.statuses.UNSOLD,
|
|
238
|
-
bookedPrice: null
|
|
239
|
-
}));
|
|
240
209
|
setBookedSeats(prev => prev.filter(bs => bs.ssId !== s.ssId));
|
|
241
210
|
const event = {
|
|
242
211
|
type: "cart-change-remove",
|
|
243
212
|
details: bookedSeats.filter(bs => bs.ssId === s.ssId)
|
|
244
213
|
};
|
|
245
214
|
callbackFunction === null || callbackFunction === void 0 || callbackFunction(event);
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
215
|
+
}).catch(() => {
|
|
216
|
+
setSeatLoading(false);
|
|
217
|
+
e.target.setStyle({
|
|
218
|
+
fillColor: _utils.statusColors.booked
|
|
219
|
+
});
|
|
250
220
|
handleError({
|
|
251
221
|
code: 500,
|
|
252
222
|
message: _utils.ERROR_MESSAGES.GENERIC_ERROR
|
|
253
223
|
});
|
|
254
|
-
}
|
|
224
|
+
}).finally(() => {
|
|
225
|
+
_initialFetch(true);
|
|
226
|
+
});
|
|
255
227
|
};
|
|
256
228
|
const batchAddTicketsToCart = async seatsToBook => {
|
|
257
229
|
if (!canMultiSelect && !seats.preventOrphanedSeats || seatsToBook.length === 0) {
|
|
258
230
|
return;
|
|
259
231
|
}
|
|
260
|
-
|
|
261
|
-
const
|
|
262
|
-
const
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
method: "POST",
|
|
267
|
-
body: JSON.stringify({
|
|
268
|
-
priceAgeId: seatToBook.priceage.paId,
|
|
269
|
-
seatId: seatToBook.seat.ssId,
|
|
270
|
-
price: seatToBook.priceage.p,
|
|
271
|
-
connectedShowings: connectedShowings
|
|
272
|
-
}),
|
|
273
|
-
headers: {
|
|
274
|
-
"content-type": "application/json",
|
|
275
|
-
"basket-key": sessionId
|
|
276
|
-
}
|
|
277
|
-
});
|
|
278
|
-
if (res.status === 429) {
|
|
279
|
-
if (retryCount < BOOKING_MAX_RETRIES) {
|
|
280
|
-
setRetrying(prev => [...prev, seatToBook.seat.ssId]);
|
|
281
|
-
const delay = (0, _utils.getRetryDelay)(res);
|
|
282
|
-
await new Promise(resolve => setTimeout(resolve, delay));
|
|
283
|
-
return _tryBook(seatToBook, retryCount + 1);
|
|
284
|
-
} else {
|
|
285
|
-
throw new Error("429");
|
|
286
|
-
}
|
|
287
|
-
} else if (!res.ok) {
|
|
288
|
-
throw new Error("".concat(res.status));
|
|
232
|
+
const updatedSeats = _objectSpread({}, seats);
|
|
233
|
+
const seatIds = seatsToBook.map(s => s.seat.ssId);
|
|
234
|
+
const setSeatsLoading = loading => {
|
|
235
|
+
updatedSeats.seats.forEach(s => {
|
|
236
|
+
if (seatIds.includes(s.ssId)) {
|
|
237
|
+
s.loading = loading;
|
|
289
238
|
}
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
throw new Error("Booking failed for seat ".concat(seatToBook.seat.r, " ").concat(seatToBook.seat.c));
|
|
293
|
-
}
|
|
239
|
+
});
|
|
240
|
+
setSeats(updatedSeats);
|
|
294
241
|
};
|
|
242
|
+
setSeatsLoading(true);
|
|
243
|
+
const succeeded = [];
|
|
295
244
|
try {
|
|
296
|
-
for (const
|
|
297
|
-
|
|
245
|
+
for (const seat of seatsToBook) {
|
|
246
|
+
try {
|
|
247
|
+
const res = await fetch(apiUrl, {
|
|
248
|
+
method: "POST",
|
|
249
|
+
body: JSON.stringify({
|
|
250
|
+
priceAgeId: seat.priceage.paId,
|
|
251
|
+
seatId: seat.seat.ssId,
|
|
252
|
+
price: seat.priceage.p,
|
|
253
|
+
connectedShowings: connectedShowings
|
|
254
|
+
}),
|
|
255
|
+
headers: {
|
|
256
|
+
"content-type": "application/json",
|
|
257
|
+
"basket-key": sessionId
|
|
258
|
+
}
|
|
259
|
+
});
|
|
260
|
+
if (!res.ok) {
|
|
261
|
+
throw new Error("".concat(res.status));
|
|
262
|
+
}
|
|
263
|
+
succeeded.push(seat);
|
|
264
|
+
} catch (error) {
|
|
265
|
+
console.error("Failed to book seat ".concat(seat.seat.r, " ").concat(seat.seat.c, ":"), error);
|
|
266
|
+
throw new Error(error === "429" ? error : "Booking failed for seat ".concat(seat.seat.r, " ").concat(seat.seat.c));
|
|
267
|
+
}
|
|
298
268
|
}
|
|
299
|
-
setRetrying(prev => prev.filter(id => !seatsToBook.some(s => s.seat.ssId === id)));
|
|
300
269
|
setBookedSeats(prev => [...prev, ...seatsToBook.map(_ref2 => {
|
|
301
270
|
let {
|
|
302
271
|
seat,
|
|
303
272
|
priceage
|
|
304
273
|
} = _ref2;
|
|
305
|
-
return
|
|
274
|
+
return {
|
|
275
|
+
ssId: seat.ssId,
|
|
276
|
+
r: seat.r,
|
|
277
|
+
c: seat.c,
|
|
306
278
|
showingId: showingId,
|
|
307
279
|
pId: priceage.paId,
|
|
308
280
|
p: priceage.p,
|
|
309
281
|
paName: priceage.paName
|
|
310
|
-
}
|
|
282
|
+
};
|
|
311
283
|
})]);
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
const seatIndex = updatedSeats.seats.findIndex(s => s.ssId === seat.ssId);
|
|
319
|
-
if (seatIndex !== -1) {
|
|
320
|
-
updatedSeats.seats[seatIndex] = _objectSpread(_objectSpread({}, updatedSeats.seats[seatIndex]), {}, {
|
|
321
|
-
loading: false,
|
|
322
|
-
s: _utils.statuses.USER_PENDING,
|
|
323
|
-
bookedPrice: price
|
|
324
|
-
});
|
|
325
|
-
}
|
|
326
|
-
});
|
|
327
|
-
return updatedSeats;
|
|
284
|
+
updatedSeats.seats.forEach(s => {
|
|
285
|
+
if (seatIds.includes(s.ssId)) {
|
|
286
|
+
s.s = _utils.statuses.USER_PENDING;
|
|
287
|
+
s.bookedPrice = price;
|
|
288
|
+
s.loading = false;
|
|
289
|
+
}
|
|
328
290
|
});
|
|
291
|
+
setSeats(updatedSeats);
|
|
329
292
|
const event = {
|
|
330
293
|
type: "cart-change-add",
|
|
331
|
-
details: [...seatsToBook.map(
|
|
294
|
+
details: [...bookedSeats, ...seatsToBook.map(_ref3 => {
|
|
332
295
|
let {
|
|
333
296
|
seat,
|
|
334
297
|
priceage
|
|
335
|
-
} =
|
|
336
|
-
return
|
|
298
|
+
} = _ref3;
|
|
299
|
+
return {
|
|
300
|
+
ssId: seat.ssId,
|
|
301
|
+
r: seat.r,
|
|
302
|
+
c: seat.c,
|
|
337
303
|
showingId: showingId,
|
|
338
304
|
pId: priceage.paId,
|
|
339
305
|
p: priceage.p,
|
|
340
306
|
paName: priceage.paName
|
|
341
|
-
}
|
|
307
|
+
};
|
|
342
308
|
})]
|
|
343
309
|
};
|
|
344
310
|
callbackFunction === null || callbackFunction === void 0 || callbackFunction(event);
|
|
345
311
|
} catch (error) {
|
|
346
|
-
setRetrying(prev => prev.filter(id => !seatsToBook.some(s => s.seat.ssId === id)));
|
|
347
312
|
console.error("Failed to book seats:", error);
|
|
348
313
|
for (const seat of succeeded) {
|
|
349
314
|
await fetch("".concat(apiUrl, "/seat/").concat(seat.ssId), {
|
|
@@ -353,18 +318,27 @@ const SeatingPlan = _ref => {
|
|
|
353
318
|
}
|
|
354
319
|
});
|
|
355
320
|
}
|
|
356
|
-
setSeatsLoading(
|
|
321
|
+
setSeatsLoading(false);
|
|
357
322
|
handleError({
|
|
358
323
|
code: error === "429" ? 429 : 500,
|
|
359
|
-
message: _utils.ERROR_MESSAGES.GENERIC_ERROR
|
|
324
|
+
message: error === "429" ? _utils.ERROR_MESSAGES.SEAT_TAKEN : _utils.ERROR_MESSAGES.GENERIC_ERROR
|
|
360
325
|
});
|
|
326
|
+
} finally {
|
|
327
|
+
_initialFetch(true);
|
|
361
328
|
}
|
|
362
329
|
};
|
|
363
330
|
const batchRemoveTicketsFromCart = async seatsToRemove => {
|
|
364
331
|
if (!canMultiSelect && !seats.preventOrphanedSeats || seatsToRemove.length === 0) {
|
|
365
332
|
return;
|
|
366
333
|
}
|
|
367
|
-
|
|
334
|
+
const updatedSeats = _objectSpread({}, seats);
|
|
335
|
+
const seatIds = seatsToRemove.map(s => s.ssId);
|
|
336
|
+
updatedSeats.seats.forEach(s => {
|
|
337
|
+
if (seatIds.includes(s.ssId)) {
|
|
338
|
+
s.loading = true;
|
|
339
|
+
}
|
|
340
|
+
});
|
|
341
|
+
setSeats(updatedSeats);
|
|
368
342
|
const succeededIds = [];
|
|
369
343
|
try {
|
|
370
344
|
for (const seat of seatsToRemove) {
|
|
@@ -383,27 +357,23 @@ const SeatingPlan = _ref => {
|
|
|
383
357
|
console.error("Failed to remove seat ".concat(seat, ":"), error);
|
|
384
358
|
}
|
|
385
359
|
}
|
|
386
|
-
} catch (
|
|
360
|
+
} catch (_unused) {
|
|
387
361
|
handleError({
|
|
388
362
|
code: 500,
|
|
389
363
|
message: _utils.ERROR_MESSAGES.GENERIC_ERROR
|
|
390
364
|
});
|
|
391
365
|
}
|
|
392
366
|
setBookedSeats(prev => [...prev.filter(v => !succeededIds.includes(v.ssId))]);
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
loading: false,
|
|
400
|
-
s: succeededIds.includes(s.ssId) ? _utils.statuses.UNSOLD : s.s,
|
|
401
|
-
bookedPrice: null
|
|
402
|
-
});
|
|
367
|
+
updatedSeats.seats.forEach(s => {
|
|
368
|
+
if (seatIds.includes(s.ssId)) {
|
|
369
|
+
s.loading = false;
|
|
370
|
+
if (succeededIds.includes(s.ssId)) {
|
|
371
|
+
s.s = _utils.statuses.UNSOLD;
|
|
372
|
+
s.bookedPrice = null;
|
|
403
373
|
}
|
|
404
|
-
}
|
|
405
|
-
return updatedSeats;
|
|
374
|
+
}
|
|
406
375
|
});
|
|
376
|
+
setSeats(updatedSeats);
|
|
407
377
|
setSeatsToRemove([]);
|
|
408
378
|
if (succeededIds.length > 0) {
|
|
409
379
|
const event = {
|
|
@@ -412,6 +382,7 @@ const SeatingPlan = _ref => {
|
|
|
412
382
|
};
|
|
413
383
|
callbackFunction === null || callbackFunction === void 0 || callbackFunction(event);
|
|
414
384
|
}
|
|
385
|
+
_initialFetch(true);
|
|
415
386
|
};
|
|
416
387
|
const handleClickSeat = (e, s) => {
|
|
417
388
|
setChosenSeat({
|
|
@@ -431,7 +402,7 @@ const SeatingPlan = _ref => {
|
|
|
431
402
|
const availablePrices = ((_seats$pricing = seats.pricing) === null || _seats$pricing === void 0 ? void 0 : _seats$pricing.filter(price => (!priceSectionIds || priceSectionIds.includes(price.psId)) && s.psId === price.psId)) || [];
|
|
432
403
|
const isSingleFlexi = availablePrices.length === 1 && !!availablePrices[0].pMax && !!availablePrices[0].pMin && availablePrices[0].pMax > availablePrices[0].pMin;
|
|
433
404
|
if (availablePrices.length === 1 && !isSingleFlexi) {
|
|
434
|
-
|
|
405
|
+
addTicketToCart(s, availablePrices[0]);
|
|
435
406
|
}
|
|
436
407
|
} else {
|
|
437
408
|
removeTicketFromCart(s, e);
|
|
@@ -455,10 +426,10 @@ const SeatingPlan = _ref => {
|
|
|
455
426
|
}
|
|
456
427
|
});
|
|
457
428
|
if (response.status === 429) {
|
|
458
|
-
if (retryCount >=
|
|
429
|
+
if (retryCount >= MAX_RETRIES) {
|
|
459
430
|
throw new Error("We're experiencing high demand. Please try again later.");
|
|
460
431
|
}
|
|
461
|
-
const delay = (0, _utils.getRetryDelay)(response);
|
|
432
|
+
const delay = (0, _utils.getRetryDelay)(response, retryCount);
|
|
462
433
|
setInitialiseMessage("We're experiencing high demand. Please wait while we try again...");
|
|
463
434
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
464
435
|
return _initialFetch(isReload, retryCount + 1);
|
|
@@ -545,9 +516,7 @@ const SeatingPlan = _ref => {
|
|
|
545
516
|
pricing: seats.pricing,
|
|
546
517
|
priceSectionIds: priceSectionIds,
|
|
547
518
|
batchAddTicketsToCart: batchAddTicketsToCart
|
|
548
|
-
}) : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null),
|
|
549
|
-
className: "retrying"
|
|
550
|
-
}, "Looks like things are busy right now. Please wait while we continue to confirm your selection...") : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null), seats.preventOrphanedSeats && selectQuantityPopupOpen ? /*#__PURE__*/_react.default.createElement(_SelectQuantityPopup.default, {
|
|
519
|
+
}) : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null), seats.preventOrphanedSeats && selectQuantityPopupOpen ? /*#__PURE__*/_react.default.createElement(_SelectQuantityPopup.default, {
|
|
551
520
|
quantity: desiredSeatQuantity,
|
|
552
521
|
setQuantity: v => {
|
|
553
522
|
setDesiredSeatQuantity(v);
|
|
@@ -584,7 +553,7 @@ const SeatingPlan = _ref => {
|
|
|
584
553
|
setTicketPopupOpen: setTicketPopupOpen,
|
|
585
554
|
chosenSeat: chosenSeat,
|
|
586
555
|
bookedSeats: bookedSeats,
|
|
587
|
-
addTicketToCart:
|
|
556
|
+
addTicketToCart: addTicketToCart,
|
|
588
557
|
batchRemoveTicketsFromCart: batchRemoveTicketsFromCart,
|
|
589
558
|
isReloading: isReloading,
|
|
590
559
|
initialFetch: _initialFetch,
|
|
@@ -1597,22 +1597,6 @@ svg.leaflet-image-layer.leaflet-interactive path {
|
|
|
1597
1597
|
transform: translateX(-50%);
|
|
1598
1598
|
}
|
|
1599
1599
|
|
|
1600
|
-
.retrying {
|
|
1601
|
-
position: absolute;
|
|
1602
|
-
top: 10px;
|
|
1603
|
-
left: 50%;
|
|
1604
|
-
transform: translateX(-50%);
|
|
1605
|
-
background: white;
|
|
1606
|
-
border-radius: 5px;
|
|
1607
|
-
padding: 0.5rem;
|
|
1608
|
-
font-size: 0.875rem;
|
|
1609
|
-
color: #333;
|
|
1610
|
-
box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
|
|
1611
|
-
z-index: 1005;
|
|
1612
|
-
animation: fade-in 400ms;
|
|
1613
|
-
max-width: 50%;
|
|
1614
|
-
}
|
|
1615
|
-
|
|
1616
1600
|
/* Printing */
|
|
1617
1601
|
|
|
1618
1602
|
@media print {
|
package/dist/utils/enums.js
CHANGED
|
@@ -42,6 +42,5 @@ const ERROR_MESSAGES = exports.ERROR_MESSAGES = {
|
|
|
42
42
|
SEAT_TAKEN: "Someone else selected this first. Please try again",
|
|
43
43
|
GENERIC_ERROR: "Oops! Something went wrong. Please try again.",
|
|
44
44
|
MAX_QUANTITY: "Maximum ticket booking quantity specified reached.",
|
|
45
|
-
NO_ALLOCATION: "Allocation exhausted, please try another area or price."
|
|
46
|
-
MAX_RETRIES: "Looks like things are busy and we couldn't complete your request. Please try again."
|
|
45
|
+
NO_ALLOCATION: "Allocation exhausted, please try another area or price."
|
|
47
46
|
};
|
package/dist/utils/helpers.js
CHANGED
|
@@ -228,13 +228,15 @@ const getAdjacentBookedSeats = (seat, seatsMap) => {
|
|
|
228
228
|
return adjacentBookedSeats;
|
|
229
229
|
};
|
|
230
230
|
exports.getAdjacentBookedSeats = getAdjacentBookedSeats;
|
|
231
|
-
const getRetryDelay = response => {
|
|
231
|
+
const getRetryDelay = (response, attempt) => {
|
|
232
232
|
var _ref, _ref2, _response$headers$get;
|
|
233
233
|
const retryAfter = (_ref = (_ref2 = (_response$headers$get = response.headers.get("Retry-After")) !== null && _response$headers$get !== void 0 ? _response$headers$get : response.headers.get("retry-after")) !== null && _ref2 !== void 0 ? _ref2 : response.headers.get("rl-twm")) !== null && _ref !== void 0 ? _ref : "5";
|
|
234
|
-
|
|
234
|
+
if (retryAfter) {
|
|
235
|
+
return response.headers.get("rl-twm") ? Math.round(parseInt(retryAfter) * 60 * 1000) : parseInt(retryAfter) * 1000;
|
|
236
|
+
}
|
|
235
237
|
|
|
236
238
|
// adds jitter
|
|
237
|
-
return
|
|
239
|
+
return attempt + Math.random() * 1000;
|
|
238
240
|
};
|
|
239
241
|
exports.getRetryDelay = getRetryDelay;
|
|
240
242
|
const groupSeatsByPriceSection = (seats, pricing, priceSectionIds) => {
|