iticket-seatingplan-dev 0.0.4 → 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.
@@ -21,7 +21,8 @@ const SeatingPlan = _ref => {
21
21
  price,
22
22
  quantity,
23
23
  callbackFunction,
24
- apiKey
24
+ apiKey,
25
+ baseUrl
25
26
  } = _ref;
26
27
  const [position, setPosition] = (0, _react.useState)(null);
27
28
  const [height, setHeight] = (0, _react.useState)(0);
@@ -37,11 +38,12 @@ const SeatingPlan = _ref => {
37
38
  sold: '#95a5a6',
38
39
  reserved: '#95a5a6',
39
40
  pending: '#e74c3c',
40
- booked: '#e74c3c'
41
+ booked: '#e74c3c',
42
+ bookedWithDifferentPrice: '#fab1a0'
41
43
  };
42
44
  const setInitialColor = s => {
43
45
  return {
44
- 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,
45
47
  color: 'none',
46
48
  fillOpacity: 100
47
49
  };
@@ -83,6 +85,7 @@ const SeatingPlan = _ref => {
83
85
  }
84
86
  }).then(response => response.json()).then(response => {
85
87
  s.status = 4;
88
+ s.bookedPrice = price;
86
89
  e.target.setStyle({
87
90
  fillColor: statusColors.booked
88
91
  });
@@ -117,53 +120,69 @@ const SeatingPlan = _ref => {
117
120
  setProcessing(false);
118
121
  });
119
122
  } else {
120
- fetch("https://apim.iticket.co.nz/seatingplan/removeseat", {
121
- method: 'POST',
122
- body: JSON.stringify({
123
- basketKey: '',
124
- seatId: s.showingSeatId
125
- }),
126
- headers: {
127
- 'content-type': 'application/json',
128
- 'session-id': "ASP.NET_SessionId=".concat(sessionId),
129
- 'showingseat-id': s.showingSeatId
130
- }
131
- }).then(response => response.json()).then(response => {
132
- s.status = 1;
133
- e.target.setStyle({
134
- fillColor: statusColors.available
135
- });
136
- setBookedSeats(bookedSeats.filter(bs => bs.showingSeatId !== s.showingSeatId));
137
- setProcessing(false);
138
- }).catch(error => {
139
- e.target.setStyle({
140
- 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);
141
158
  });
159
+ } else {
142
160
  const event = {
143
161
  type: 'error',
144
162
  details: {
145
163
  error: {
146
- code: 500,
147
- 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.")
148
166
  }
149
167
  }
150
168
  };
151
169
  callbackFunction(event);
152
170
  setProcessing(false);
153
- });
171
+ }
154
172
  }
155
173
  };
174
+ // https://ecommerce-main-f0c3c0b.d2.zuplo.dev
156
175
  (0, _react.useEffect)(() => {
157
176
  if (!position && !error) {
158
- 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), {
159
178
  headers: {
160
- 'session-id': sessionId,
179
+ basketId: sessionId,
161
180
  Authorization: "Bearer ".concat(apiKey)
162
181
  }
163
182
  }).then(response => response.json() || null).then(data => {
164
183
  const img = new Image();
165
184
  img.src = data.background;
166
- setBookedSeats(data.seats.filter(s => s.status === 4).map(s => ({
185
+ setBookedSeats(data.seats.filter(s => s.status === 4 && s.bookedPrice === price).map(s => ({
167
186
  showingSeatId: s.showingSeatId,
168
187
  rowName: s.rowName,
169
188
  columnName: s.columnName,
@@ -208,6 +227,7 @@ const SeatingPlan = _ref => {
208
227
  // return seating plan
209
228
  return /*#__PURE__*/_react.default.createElement("div", {
210
229
  style: {
230
+ width: '100%',
211
231
  height: '100%'
212
232
  }
213
233
  }, error ? /*#__PURE__*/_react.default.createElement("div", {
@@ -250,7 +270,7 @@ const SeatingPlan = _ref => {
250
270
  }, /*#__PURE__*/_react.default.createElement(_reactLeaflet.Tooltip, {
251
271
  direction: 'top',
252
272
  offset: [0, height * 0.03 + -30]
253
- }, s.rowName + '-' + s.columnName)) : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null)))) : /*#__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", {
254
274
  className: "loading"
255
275
  }, /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement("svg", {
256
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.4",
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"