iticket-seatingplan-dev 0.0.3 → 0.0.6

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.
@@ -17,10 +17,12 @@ const SeatingPlan = _ref => {
17
17
  sessionId,
18
18
  showingId,
19
19
  priceAgeId,
20
+ priceSectionId,
20
21
  price,
21
22
  quantity,
22
23
  callbackFunction,
23
- apiKey
24
+ apiKey,
25
+ baseUrl
24
26
  } = _ref;
25
27
  const [position, setPosition] = (0, _react.useState)(null);
26
28
  const [height, setHeight] = (0, _react.useState)(0);
@@ -36,11 +38,12 @@ const SeatingPlan = _ref => {
36
38
  sold: '#95a5a6',
37
39
  reserved: '#95a5a6',
38
40
  pending: '#e74c3c',
39
- booked: '#e74c3c'
41
+ booked: '#e74c3c',
42
+ bookedWithDifferentPrice: '#fab1a0'
40
43
  };
41
44
  const setInitialColor = s => {
42
45
  return {
43
- fillColor: s.status === 1 ? statusColors.available : s.status === 4 ? statusColors.booked : statusColors.sold,
46
+ fillColor: s.status === 1 ? statusColors.available : s.status === 4 ? s.bookedPrice === price ? statusColors.booked : statusColors.bookedWithDifferentPrice : statusColors.sold,
44
47
  color: 'none',
45
48
  fillOpacity: 100
46
49
  };
@@ -82,6 +85,7 @@ const SeatingPlan = _ref => {
82
85
  }
83
86
  }).then(response => response.json()).then(response => {
84
87
  s.status = 4;
88
+ s.bookedPrice = price;
85
89
  e.target.setStyle({
86
90
  fillColor: statusColors.booked
87
91
  });
@@ -116,53 +120,69 @@ const SeatingPlan = _ref => {
116
120
  setProcessing(false);
117
121
  });
118
122
  } else {
119
- fetch("https://apim.iticket.co.nz/seatingplan/removeseat", {
120
- method: 'POST',
121
- body: JSON.stringify({
122
- basketKey: '',
123
- seatId: s.showingSeatId
124
- }),
125
- headers: {
126
- 'content-type': 'application/json',
127
- 'session-id': "ASP.NET_SessionId=".concat(sessionId),
128
- 'showingseat-id': s.showingSeatId
129
- }
130
- }).then(response => response.json()).then(response => {
131
- s.status = 1;
132
- e.target.setStyle({
133
- fillColor: statusColors.available
134
- });
135
- setBookedSeats(bookedSeats.filter(bs => bs.showingSeatId !== s.showingSeatId));
136
- setProcessing(false);
137
- }).catch(error => {
138
- e.target.setStyle({
139
- fillColor: statusColors.booked
123
+ if (s.bookedPrice === price) {
124
+ fetch("https://apim.iticket.co.nz/seatingplan/removeseat", {
125
+ method: 'POST',
126
+ body: JSON.stringify({
127
+ basketKey: '',
128
+ seatId: s.showingSeatId
129
+ }),
130
+ headers: {
131
+ 'content-type': 'application/json',
132
+ 'session-id': "ASP.NET_SessionId=".concat(sessionId),
133
+ 'showingseat-id': s.showingSeatId
134
+ }
135
+ }).then(response => response.json()).then(response => {
136
+ s.status = 1;
137
+ s.bookedPrice = null;
138
+ e.target.setStyle({
139
+ fillColor: statusColors.available
140
+ });
141
+ setBookedSeats(bookedSeats.filter(bs => bs.showingSeatId !== s.showingSeatId));
142
+ setProcessing(false);
143
+ }).catch(error => {
144
+ e.target.setStyle({
145
+ fillColor: statusColors.booked
146
+ });
147
+ const event = {
148
+ type: 'error',
149
+ details: {
150
+ error: {
151
+ code: 500,
152
+ message: 'Oops! Something went wrong. Please try again.'
153
+ }
154
+ }
155
+ };
156
+ callbackFunction(event);
157
+ setProcessing(false);
140
158
  });
159
+ } else {
141
160
  const event = {
142
161
  type: 'error',
143
162
  details: {
144
163
  error: {
145
- code: 500,
146
- message: 'Oops! Something went wrong. Please try again.'
164
+ code: 403,
165
+ message: "Unable to remove seat. Price specified does not match the selected seat price, please select $".concat(s.bookedPrice, " to be able to remove this seat.")
147
166
  }
148
167
  }
149
168
  };
150
169
  callbackFunction(event);
151
170
  setProcessing(false);
152
- });
171
+ }
153
172
  }
154
173
  };
174
+ // https://ecommerce-main-f0c3c0b.d2.zuplo.dev
155
175
  (0, _react.useEffect)(() => {
156
176
  if (!position && !error) {
157
- fetch("https://ecommerce-main-f0c3c0b.d2.zuplo.dev/ecommerce/v1/events/".concat(eventId, "/showings/").concat(showingUid, "/seats?priceage=").concat(priceAgeId), {
177
+ fetch("".concat(baseUrl, "/ecommerce/v1/events/").concat(eventId, "/showings/").concat(showingId, "/seats?priceage=").concat(priceAgeId), {
158
178
  headers: {
159
- 'session-id': sessionId,
179
+ basketId: sessionId,
160
180
  Authorization: "Bearer ".concat(apiKey)
161
181
  }
162
182
  }).then(response => response.json() || null).then(data => {
163
183
  const img = new Image();
164
184
  img.src = data.background;
165
- setBookedSeats(data.seats.filter(s => s.status === 4).map(s => ({
185
+ setBookedSeats(data.seats.filter(s => s.status === 4 && s.bookedPrice === price).map(s => ({
166
186
  showingSeatId: s.showingSeatId,
167
187
  rowName: s.rowName,
168
188
  columnName: s.columnName,
@@ -207,6 +227,7 @@ const SeatingPlan = _ref => {
207
227
  // return seating plan
208
228
  return /*#__PURE__*/_react.default.createElement("div", {
209
229
  style: {
230
+ width: '100%',
210
231
  height: '100%'
211
232
  }
212
233
  }, error ? /*#__PURE__*/_react.default.createElement("div", {
@@ -231,7 +252,7 @@ const SeatingPlan = _ref => {
231
252
  bounds: [[height * 0.03 - s.raw_y * 0.61 - 0.2, s.raw_x * 0.615 - 0.2], [height * 0.03 - s.raw_y * 0.61 + 0.2, s.raw_x * 0.615 + 0.2]],
232
253
  opacity: chosenSeat && chosenSeat.seat.showingSeatId === s.showingSeatId ? 100 : 0,
233
254
  zIndex: 10
234
- }), s.status === 6 ? /*#__PURE__*/_react.default.createElement(_reactLeaflet.ImageOverlay, {
255
+ }), !priceSectionId || s.priceSectionId === priceSectionId ? s.status === 6 ? /*#__PURE__*/_react.default.createElement(_reactLeaflet.ImageOverlay, {
235
256
  url: wheelchairSeat,
236
257
  bounds: [[height * 0.03 - s.raw_y * 0.61 - 0.17, s.raw_x * 0.615 - 0.17], [height * 0.03 - s.raw_y * 0.61 + 0.17, s.raw_x * 0.615 + 0.17]],
237
258
  zIndex: 10
@@ -249,7 +270,7 @@ const SeatingPlan = _ref => {
249
270
  }, /*#__PURE__*/_react.default.createElement(_reactLeaflet.Tooltip, {
250
271
  direction: 'top',
251
272
  offset: [0, height * 0.03 + -30]
252
- }, s.rowName + '-' + s.columnName))))) : /*#__PURE__*/_react.default.createElement("div", {
273
+ }, s.rowName + '-' + s.columnName, ' ', s.bookedPrice && s.bookedPrice !== price && "(Select $".concat(s.bookedPrice, " to remove from cart.)"))) : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null)))) : /*#__PURE__*/_react.default.createElement("div", {
253
274
  className: "loading"
254
275
  }, /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement("svg", {
255
276
  width: "105",
@@ -248,7 +248,7 @@ svg.leaflet-zoom-animated {
248
248
  /* cursors */
249
249
 
250
250
  .leaflet-interactive {
251
- cursor: pointer;
251
+ cursor: default;
252
252
  }
253
253
  .leaflet-grab {
254
254
  cursor: -webkit-grab;
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": "0.0.3",
5
+ "version": "0.0.6",
6
6
  "private": false,
7
7
  "keywords": [
8
8
  "iticket",
@@ -19,6 +19,11 @@
19
19
  "leaflet": "^1.9.3",
20
20
  "react-leaflet": "^4.2.1"
21
21
  },
22
+ "codependencies": {
23
+ "@babel/polyfill": "^7.12.1",
24
+ "leaflet": "^1.9.3",
25
+ "react-leaflet": "^4.2.1"
26
+ },
22
27
  "scripts": {
23
28
  "build": "rm -rf dist && NODE_ENV=production babel src/lib --out-dir dist --copy-files",
24
29
  "start": "react-scripts start"