iticket-seatingplan-dev 1.0.33 → 1.0.35

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.
@@ -7,6 +7,8 @@ exports.default = void 0;
7
7
  require("./styles/index.css");
8
8
  var _react = _interopRequireWildcard(require("react"));
9
9
  var _reactLeaflet = require("react-leaflet");
10
+ var _reactLeafletCustomControl = _interopRequireDefault(require("react-leaflet-custom-control"));
11
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
12
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
11
13
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
12
14
  const wheelchairSeat = require('.//assets/wheelchair.png');
@@ -29,6 +31,8 @@ const SeatingPlan = _ref => {
29
31
  baseUrl,
30
32
  countryCode
31
33
  } = _ref;
34
+ const [initialiseMessage, setInitialiseMessage] = (0, _react.useState)('Initialising seating plan...');
35
+ const [isReloading, setIsReloading] = (0, _react.useState)(false);
32
36
  const [map, setMap] = (0, _react.useState)();
33
37
  const [position, setPosition] = (0, _react.useState)(null);
34
38
  const [height, setHeight] = (0, _react.useState)(0);
@@ -68,7 +72,6 @@ const SeatingPlan = _ref => {
68
72
  'basket-key': sessionId
69
73
  }
70
74
  }).then(response => {
71
- console.log(response);
72
75
  if ((response === null || response === void 0 ? void 0 : response.status) === 403) {
73
76
  chosenSeat.circle.target.setStyle({
74
77
  fillColor: statusColors.sold
@@ -102,7 +105,6 @@ const SeatingPlan = _ref => {
102
105
  setProcessing(false);
103
106
  } else {
104
107
  {
105
- console.log('rrrrrrrrr', response);
106
108
  s.s = 4;
107
109
  s.bookedPrice = price;
108
110
  chosenSeat.circle.target.setStyle({
@@ -197,42 +199,60 @@ const SeatingPlan = _ref => {
197
199
  removeTicketFromCart(s, e);
198
200
  }
199
201
  };
200
- // https://ecommerce-main-f0c3c0b.d2.zuplo.dev
201
- (0, _react.useEffect)(() => {
202
- if (!position && !error) {
203
- fetch( // `http://localhost:3155/api/legacy/shop/events/4230/4639/showings/102359/tickets/allocated/1603`,
204
- "".concat(baseUrl, "/legacy/").concat(countryCode, "/shop/events/").concat(eventId, "/").concat(eventVenueId, "/showings/").concat(showingId, "/tickets/allocated/").concat(areaId), {
205
- headers: {
206
- 'basket-key': sessionId,
207
- Authorization: "Bearer ".concat(apiKey)
208
- }
209
- }).then(response => response.json() || null).then(data => {
210
- const img = new Image();
211
- img.src = data.background;
212
- console.log(data.background);
213
- setBookedSeats(data.seats.filter(s => s.s === 4 && s.bookedPrice === price).map(s => ({
214
- showingSeatId: s.ssId,
215
- rowName: s.r,
216
- columnName: s.c,
217
- showingId: showingId,
218
- price: price || s.defaultPrice,
219
- priceAgeName: s.priceAgeName
220
- })));
221
- img.onload = () => {
222
- setHeight(img.height * 0.5);
223
- setWidth(img.width * 0.5);
224
- setPosition([img.height * 0.005, img.width * 0.005]);
225
- setSeats(data);
226
- };
227
- }).catch(error => {
228
- setError({
229
- response: {
230
- data: {
231
- message: 'Invalid API Key or unauthorized URL'
232
- }
202
+ const initialFetch = function initialFetch() {
203
+ let isReload = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
204
+ if (isReload) {
205
+ setIsReloading(true);
206
+ }
207
+ setInitialiseMessage('Initialising seating plan...');
208
+ fetch( // `http://localhost:3155/api/legacy/shop/events/4230/4639/showings/102359/tickets/allocated/1603`,
209
+ "".concat(baseUrl, "/legacy/").concat(countryCode, "/shop/events/").concat(eventId, "/").concat(eventVenueId, "/showings/").concat(showingId, "/tickets/allocated/").concat(areaId), {
210
+ headers: {
211
+ 'basket-key': sessionId,
212
+ Authorization: "Bearer ".concat(apiKey)
213
+ }
214
+ }).then(async response => {
215
+ const data = await response.json();
216
+ data.retryAfter = response.headers.get('Retry-After');
217
+ return data;
218
+ }).then(data => {
219
+ if (data.status === 429) {
220
+ setInitialiseMessage("Looks like it's busy. Standby. Trying again in ".concat(data.retryAfter, " second").concat(data.retryAfter > 1 ? 's' : '', "."));
221
+ return setTimeout(initialFetch, data.retryAfter * 1000);
222
+ }
223
+ const img = new Image();
224
+ img.src = data.background;
225
+ setBookedSeats(data.seats.filter(s => s.s === 4 && s.bookedPrice === price).map(s => ({
226
+ showingSeatId: s.ssId,
227
+ rowName: s.r,
228
+ columnName: s.c,
229
+ showingId: showingId,
230
+ price: price || s.defaultPrice,
231
+ priceAgeName: s.priceAgeName
232
+ })));
233
+ img.onload = () => {
234
+ setHeight(img.height * 0.5);
235
+ setWidth(img.width * 0.5);
236
+ setPosition([img.height * 0.005, img.width * 0.005]);
237
+ setSeats(data);
238
+ };
239
+ map && map.target.setView([height * 0.015, width * 0.015], 5);
240
+ setIsReloading(false);
241
+ }).catch(error => {
242
+ console.log(error);
243
+ setError({
244
+ response: {
245
+ data: {
246
+ message: 'Invalid API Key or unauthorized URL'
233
247
  }
234
- });
248
+ }
235
249
  });
250
+ setIsReloading(false);
251
+ });
252
+ };
253
+ (0, _react.useEffect)(() => {
254
+ if (!position && !error) {
255
+ initialFetch();
236
256
  }
237
257
  }, [position]);
238
258
  (0, _react.useEffect)(() => {
@@ -265,12 +285,57 @@ const SeatingPlan = _ref => {
265
285
  whenReady: setMap,
266
286
  center: [height * 0.015, width * 0.015],
267
287
  zoom: 5,
288
+ zoomControl: true,
268
289
  scrollWheelZoom: true,
269
290
  style: {
270
291
  minHeight: '500px',
271
292
  height: '100%'
272
293
  }
273
- }, /*#__PURE__*/_react.default.createElement(_reactLeaflet.ImageOverlay, {
294
+ }, /*#__PURE__*/_react.default.createElement(_reactLeafletCustomControl.default, {
295
+ position: "topleft"
296
+ }, /*#__PURE__*/_react.default.createElement("div", {
297
+ style: {
298
+ display: 'flex',
299
+ flexDirection: 'column',
300
+ border: '2px solid rgba(0,0,0,0.2)',
301
+ borderRadius: '3px'
302
+ }
303
+ }, /*#__PURE__*/_react.default.createElement("button", {
304
+ title: "Re-centre Seating Plan",
305
+ onClick: () => map.target.setView([height * 0.015, width * 0.015], 5),
306
+ className: "leaflet-control-zoom-in",
307
+ style: {
308
+ border: 'none',
309
+ borderRadius: '3px 3px 0 0',
310
+ background: '#fff',
311
+ padding: '3px 6px',
312
+ cursor: 'pointer'
313
+ }
314
+ }, /*#__PURE__*/_react.default.createElement("img", {
315
+ src: "https://www.iticket.com.au/assets/images/fit-icon.jpg",
316
+ style: {
317
+ height: '17px'
318
+ }
319
+ })), /*#__PURE__*/_react.default.createElement("button", {
320
+ title: "Reload Seating Plan",
321
+ onClick: () => initialFetch(true),
322
+ className: "leaflet-control-zoom-in",
323
+ style: {
324
+ border: 'none',
325
+ borderRadius: '0 0 3px 3px',
326
+ borderTop: '1px solid gray',
327
+ background: '#fff',
328
+ padding: '3px 6px',
329
+ cursor: 'pointer',
330
+ background: isReloading ? 'rgb(0, 230, 64)' : '#fff'
331
+ }
332
+ }, /*#__PURE__*/_react.default.createElement("img", {
333
+ className: isReloading ? 'rotate' : '',
334
+ src: "https://www.iticket.com.au/assets/images/refresh.png",
335
+ style: {
336
+ height: '17px'
337
+ }
338
+ })))), /*#__PURE__*/_react.default.createElement(_reactLeaflet.ImageOverlay, {
274
339
  url: seats.background,
275
340
  bounds: [[0, 0], [height * 0.03, width * 0.03]],
276
341
  zIndex: 10
@@ -460,7 +525,7 @@ const SeatingPlan = _ref => {
460
525
  style: {
461
526
  marginTop: '2rem'
462
527
  }
463
- }, "Initialising seating plan...")));
528
+ }, initialiseMessage)));
464
529
  };
465
530
  var _default = SeatingPlan;
466
531
  exports.default = _default;
@@ -7,6 +7,19 @@
7
7
  -moz-osx-font-smoothing: grayscale;
8
8
  } */
9
9
 
10
+ .rotate {
11
+ animation: rotation 2s infinite linear;
12
+ }
13
+
14
+ @keyframes rotation {
15
+ from {
16
+ transform: rotate(0deg);
17
+ }
18
+ to {
19
+ transform: rotate(-359deg);
20
+ }
21
+ }
22
+
10
23
  .priceage:hover {
11
24
  background: #ecf0f1;
12
25
  border: 1px solid #ecf0f1 !important;
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": "1.0.33",
5
+ "version": "1.0.35",
6
6
  "private": false,
7
7
  "keywords": [
8
8
  "iticket",