iticket-seatingplan-dev 1.2.0 → 1.2.1

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.
@@ -287,8 +287,26 @@ const SeatingPlan = _ref => {
287
287
  }));
288
288
  }
289
289
  }, [chosenSeat, processing]);
290
+ const calculateCenterOfMap = (height, seats) => {
291
+ const filteredSeats = seats.filter(price => price.psId === priceSectionId);
292
+ const avgY = filteredSeats.reduce((acc, val) => {
293
+ return acc + val.y / filteredSeats.length;
294
+ }, 0);
295
+ const avgX = filteredSeats.reduce((acc, val) => {
296
+ return acc + val.x / filteredSeats.length;
297
+ }, 0);
298
+ 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 * 0.0206), avgX * 0.3 + 0.15];
299
+ };
300
+ const determineZoom = seats => {
301
+ const filteredSeats = seats.filter(price => price.psId === priceSectionId);
302
+ const x = filteredSeats.map(fs => fs.x);
303
+ const y = filteredSeats.map(fs => fs.y);
304
+ const maxX = Math.max(...x) - Math.min(...x);
305
+ const maxY = Math.max(...y) - Math.min(...y);
306
+ console.log(maxX, maxY);
307
+ if (maxY > 67.5) return 4;else return 6;
308
+ };
290
309
 
291
- // console.log(height, width)
292
310
  // return seating plan
293
311
  return /*#__PURE__*/_react.default.createElement("div", {
294
312
  style: {
@@ -297,10 +315,14 @@ const SeatingPlan = _ref => {
297
315
  }
298
316
  }, error ? /*#__PURE__*/_react.default.createElement("div", {
299
317
  className: "loading"
300
- }, /*#__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, height, "xxx", width / height * 0.01, /*#__PURE__*/_react.default.createElement(_reactLeaflet.MapContainer, {
301
- whenReady: setMap,
302
- center: [height * 0.015, width * 0.015],
303
- zoom: 6,
318
+ }, /*#__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, /*#__PURE__*/_react.default.createElement(_reactLeaflet.MapContainer, {
319
+ whenReady: setMap
320
+ // center={[height * 0.015, width * 0.015]}
321
+ ,
322
+ center: calculateCenterOfMap(height, seats.seats)
323
+ // zoom={6}
324
+ ,
325
+ zoom: determineZoom(seats.seats),
304
326
  zoomControl: true,
305
327
  scrollWheelZoom: true,
306
328
  style: {
@@ -381,7 +403,7 @@ const SeatingPlan = _ref => {
381
403
  }
382
404
  }, /*#__PURE__*/_react.default.createElement("button", {
383
405
  title: "Re-centre Seating Plan",
384
- onClick: () => map.target.setView([height * 0.015, width * 0.015], 6),
406
+ onClick: () => map.target.setView(calculateCenterOfMap(height, seats.seats), determineZoom(seats.seats)),
385
407
  className: "leaflet-control-zoom-in",
386
408
  style: {
387
409
  border: 'none',
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.2.0",
5
+ "version": "1.2.1",
6
6
  "private": false,
7
7
  "keywords": [
8
8
  "iticket",