ordering-components-external 13.0.40 → 13.0.42

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.
Files changed (23) hide show
  1. package/_bundles/{7.ordering-component.fa62c57788358b5b80ae.js → 7.ordering-component.fc9b575bea137f9e1b1d.js} +1 -1
  2. package/_bundles/ordering-component.fc9b575bea137f9e1b1d.js +2 -0
  3. package/_modules/components/Checkout/index.js +28 -21
  4. package/_modules/components/MultiCheckout/index.js +21 -14
  5. package/_modules/components/ProductItemAccordion/index.js +94 -0
  6. package/_modules/index.js +7 -0
  7. package/_modules/native/index.js +7 -0
  8. package/native/index.js +2 -0
  9. package/package.json +1 -1
  10. package/src/components/Checkout/index.js +4 -0
  11. package/src/components/MultiCheckout/index.js +4 -0
  12. package/src/components/ProductItemAccordion/index.js +72 -0
  13. package/src/index.js +2 -0
  14. package/_bundles/ordering-component.fa62c57788358b5b80ae.js +0 -2
  15. /package/_bundles/{0.ordering-component.fa62c57788358b5b80ae.js → 0.ordering-component.fc9b575bea137f9e1b1d.js} +0 -0
  16. /package/_bundles/{1.ordering-component.fa62c57788358b5b80ae.js → 1.ordering-component.fc9b575bea137f9e1b1d.js} +0 -0
  17. /package/_bundles/{2.ordering-component.fa62c57788358b5b80ae.js → 2.ordering-component.fc9b575bea137f9e1b1d.js} +0 -0
  18. /package/_bundles/{4.ordering-component.fa62c57788358b5b80ae.js → 4.ordering-component.fc9b575bea137f9e1b1d.js} +0 -0
  19. /package/_bundles/{5.ordering-component.fa62c57788358b5b80ae.js → 5.ordering-component.fc9b575bea137f9e1b1d.js} +0 -0
  20. /package/_bundles/{6.ordering-component.fa62c57788358b5b80ae.js → 6.ordering-component.fc9b575bea137f9e1b1d.js} +0 -0
  21. /package/_bundles/{7.ordering-component.fa62c57788358b5b80ae.js.LICENSE.txt → 7.ordering-component.fc9b575bea137f9e1b1d.js.LICENSE.txt} +0 -0
  22. /package/_bundles/{8.ordering-component.fa62c57788358b5b80ae.js → 8.ordering-component.fc9b575bea137f9e1b1d.js} +0 -0
  23. /package/_bundles/{ordering-component.fa62c57788358b5b80ae.js.LICENSE.txt → ordering-component.fc9b575bea137f9e1b1d.js.LICENSE.txt} +0 -0
@@ -276,6 +276,13 @@ var Checkout = exports.Checkout = function Checkout(props) {
276
276
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
277
277
  while (1) switch (_context2.prev = _context2.next) {
278
278
  case 0:
279
+ if (!placing) {
280
+ _context2.next = 3;
281
+ break;
282
+ }
283
+ showToast(_ToastContext.ToastType.Info, t('CART_IN_PROGRESS', 'Cart in progress'));
284
+ return _context2.abrupt("return");
285
+ case 3:
279
286
  paymethodData = paymethodSelected === null || paymethodSelected === void 0 ? void 0 : paymethodSelected.data;
280
287
  if (paymethodSelected !== null && paymethodSelected !== void 0 && paymethodSelected.paymethod && ['stripe', 'stripe_connect', 'stripe_direct'].includes(paymethodSelected === null || paymethodSelected === void 0 || (_paymethodSelected$pa5 = paymethodSelected.paymethod) === null || _paymethodSelected$pa5 === void 0 ? void 0 : _paymethodSelected$pa5.gateway)) {
281
288
  paymethodData = {
@@ -298,75 +305,75 @@ var Checkout = exports.Checkout = function Checkout(props) {
298
305
  });
299
306
  }
300
307
  if (!handleCustomClick) {
301
- _context2.next = 9;
308
+ _context2.next = 12;
302
309
  break;
303
310
  }
304
311
  handleCustomClick(payload, paymethodSelected, cart);
305
312
  return _context2.abrupt("return");
306
- case 9:
313
+ case 12:
307
314
  if (cart) {
308
- _context2.next = 11;
315
+ _context2.next = 14;
309
316
  break;
310
317
  }
311
318
  return _context2.abrupt("return");
312
- case 11:
319
+ case 14:
313
320
  payload = _objectSpread(_objectSpread(_objectSpread({}, payload), payloadProps), {}, {
314
321
  paymethod_data: _objectSpread(_objectSpread({}, paymethodData), paymentOptions)
315
322
  });
316
323
  setPlacing(true);
317
- _context2.next = 15;
324
+ _context2.next = 18;
318
325
  return onChangeSpot();
319
- case 15:
326
+ case 18:
320
327
  if (paymethodsWithoutSaveCard.includes(paymethodSelected === null || paymethodSelected === void 0 || (_paymethodSelected$pa6 = paymethodSelected.paymethod) === null || _paymethodSelected$pa6 === void 0 ? void 0 : _paymethodSelected$pa6.gateway)) {
321
328
  delete payload.paymethod_data;
322
329
  }
323
- _context2.next = 18;
330
+ _context2.next = 21;
324
331
  return placeCart(cart.uuid, payload);
325
- case 18:
332
+ case 21:
326
333
  result = _context2.sent;
327
334
  if (!(result !== null && result !== void 0 && result.error || !result)) {
328
- _context2.next = 27;
335
+ _context2.next = 30;
329
336
  break;
330
337
  }
331
338
  setErrors(result === null || result === void 0 ? void 0 : result.result);
332
339
  if (!(dismissPlatformPay && (paymethodSelected === null || paymethodSelected === void 0 || (_paymethodSelected$pa7 = paymethodSelected.paymethod) === null || _paymethodSelected$pa7 === void 0 ? void 0 : _paymethodSelected$pa7.gateway) === 'apple_pay')) {
333
- _context2.next = 24;
340
+ _context2.next = 27;
334
341
  break;
335
342
  }
336
- _context2.next = 24;
343
+ _context2.next = 27;
337
344
  return dismissPlatformPay();
338
- case 24:
345
+ case 27:
339
346
  refreshOrderOptions();
340
347
  setPlacing(false);
341
348
  return _context2.abrupt("return");
342
- case 27:
349
+ case 30:
343
350
  cartResult = result === null || result === void 0 ? void 0 : result.result;
344
351
  if (!((cartResult === null || cartResult === void 0 || (_cartResult$paymethod = cartResult.paymethod_data) === null || _cartResult$paymethod === void 0 ? void 0 : _cartResult$paymethod.status) === 2 && actionsBeforePlace)) {
345
- _context2.next = 31;
352
+ _context2.next = 34;
346
353
  break;
347
354
  }
348
- _context2.next = 31;
355
+ _context2.next = 34;
349
356
  return actionsBeforePlace(paymethodSelected, result.result);
350
- case 31:
357
+ case 34:
351
358
  if (!(confirmPayment && (result === null || result === void 0 || (_result$result = result.result) === null || _result$result === void 0 || (_result$result = _result$result.paymethod_data) === null || _result$result === void 0 ? void 0 : _result$result.gateway) === 'apple_pay')) {
352
- _context2.next = 37;
359
+ _context2.next = 40;
353
360
  break;
354
361
  }
355
- _context2.next = 34;
362
+ _context2.next = 37;
356
363
  return confirmPayment(result === null || result === void 0 || (_result$result2 = result.result) === null || _result$result2 === void 0 || (_result$result2 = _result$result2.paymethod_data) === null || _result$result2 === void 0 || (_result$result2 = _result$result2.result) === null || _result$result2 === void 0 ? void 0 : _result$result2.client_secret);
357
- case 34:
364
+ case 37:
358
365
  _yield$confirmPayment = _context2.sent;
359
366
  confirmApplePayError = _yield$confirmPayment.error;
360
367
  if (confirmApplePayError) {
361
368
  setErrors(confirmApplePayError);
362
369
  }
363
- case 37:
370
+ case 40:
364
371
  if (paymethodsWithoutSaveCard.includes(cartResult === null || cartResult === void 0 || (_cartResult$paymethod2 = cartResult.paymethod_data) === null || _cartResult$paymethod2 === void 0 ? void 0 : _cartResult$paymethod2.gateway) && cartResult !== null && cartResult !== void 0 && (_cartResult$paymethod3 = cartResult.paymethod_data) !== null && _cartResult$paymethod3 !== void 0 && (_cartResult$paymethod3 = _cartResult$paymethod3.result) !== null && _cartResult$paymethod3 !== void 0 && _cartResult$paymethod3.hash && (cartResult === null || cartResult === void 0 || (_cartResult$paymethod4 = cartResult.paymethod_data) === null || _cartResult$paymethod4 === void 0 ? void 0 : _cartResult$paymethod4.status) === 2 && !payloadProps.isNative) {
365
372
  handleConfirmCredomaticPage(cartResult, paymethodSelected);
366
373
  }
367
374
  setPlacing(false);
368
375
  onPlaceOrderClick && onPlaceOrderClick(payload, paymethodSelected, cartResult);
369
- case 40:
376
+ case 43:
370
377
  case "end":
371
378
  return _context2.stop();
372
379
  }
@@ -152,6 +152,13 @@ var MultiCheckout = exports.MultiCheckout = function MultiCheckout(props) {
152
152
  return _regeneratorRuntime().wrap(function _callee$(_context) {
153
153
  while (1) switch (_context.prev = _context.next) {
154
154
  case 0:
155
+ if (!placing) {
156
+ _context.next = 3;
157
+ break;
158
+ }
159
+ showToast(_ToastContext.ToastType.Info, t('CART_IN_PROGRESS', 'Cart in progress'));
160
+ return _context.abrupt("return");
161
+ case 3:
155
162
  paymethodData = paymethodSelected === null || paymethodSelected === void 0 ? void 0 : paymethodSelected.paymethod_data;
156
163
  if (paymethodSelected !== null && paymethodSelected !== void 0 && paymethodSelected.paymethod_data && ['stripe', 'stripe_connect', 'stripe_direct'].includes(paymethodSelected === null || paymethodSelected === void 0 || (_paymethodSelected$pa = paymethodSelected.paymethod) === null || _paymethodSelected$pa === void 0 ? void 0 : _paymethodSelected$pa.gateway)) {
157
164
  paymethodData = JSON.stringify({
@@ -178,27 +185,27 @@ var MultiCheckout = exports.MultiCheckout = function MultiCheckout(props) {
178
185
  });
179
186
  }
180
187
  setPlacing(true);
181
- _context.next = 9;
188
+ _context.next = 12;
182
189
  return placeMultiCarts(payload, cartUuid);
183
- case 9:
190
+ case 12:
184
191
  _yield$placeMultiCart = _context.sent;
185
192
  error = _yield$placeMultiCart.error;
186
193
  result = _yield$placeMultiCart.result;
187
194
  if (!error) {
188
- _context.next = 14;
195
+ _context.next = 17;
189
196
  break;
190
197
  }
191
198
  return _context.abrupt("return");
192
- case 14:
199
+ case 17:
193
200
  if (!((result === null || result === void 0 || (_result$paymethod_dat = result.paymethod_data) === null || _result$paymethod_dat === void 0 ? void 0 : _result$paymethod_dat.status) === 2 && actionsBeforePlace)) {
194
- _context.next = 17;
201
+ _context.next = 20;
195
202
  break;
196
203
  }
197
- _context.next = 17;
204
+ _context.next = 20;
198
205
  return actionsBeforePlace(paymethodSelected, result);
199
- case 17:
206
+ case 20:
200
207
  if (!(confirmPayment && (paymethodSelected === null || paymethodSelected === void 0 ? void 0 : paymethodSelected.gateway) === 'global_apple_pay')) {
201
- _context.next = 27;
208
+ _context.next = 30;
202
209
  break;
203
210
  }
204
211
  paymentEvent = result === null || result === void 0 || (_result$payment_event = result.payment_events) === null || _result$payment_event === void 0 ? void 0 : _result$payment_event.find(function (event) {
@@ -206,28 +213,28 @@ var MultiCheckout = exports.MultiCheckout = function MultiCheckout(props) {
206
213
  return event === null || event === void 0 || (_event$data = event.data) === null || _event$data === void 0 || (_event$data = _event$data.extra) === null || _event$data === void 0 ? void 0 : _event$data.client_secret;
207
214
  });
208
215
  if (!(paymentEvent !== null && paymentEvent !== void 0 && (_paymentEvent$data = paymentEvent.data) !== null && _paymentEvent$data !== void 0 && (_paymentEvent$data = _paymentEvent$data.extra) !== null && _paymentEvent$data !== void 0 && _paymentEvent$data.client_secret)) {
209
- _context.next = 25;
216
+ _context.next = 28;
210
217
  break;
211
218
  }
212
- _context.next = 22;
219
+ _context.next = 25;
213
220
  return confirmPayment(paymentEvent === null || paymentEvent === void 0 || (_paymentEvent$data2 = paymentEvent.data) === null || _paymentEvent$data2 === void 0 || (_paymentEvent$data2 = _paymentEvent$data2.extra) === null || _paymentEvent$data2 === void 0 ? void 0 : _paymentEvent$data2.client_secret);
214
- case 22:
221
+ case 25:
215
222
  _yield$confirmPayment = _context.sent;
216
223
  confirmApplePayError = _yield$confirmPayment.error;
217
224
  if (confirmApplePayError !== null && confirmApplePayError !== void 0 && confirmApplePayError.message || confirmApplePayError !== null && confirmApplePayError !== void 0 && confirmApplePayError.localizedMessage) {
218
225
  showToast(_ToastContext.ToastType.Error, (confirmApplePayError === null || confirmApplePayError === void 0 ? void 0 : confirmApplePayError.message) || (confirmApplePayError === null || confirmApplePayError === void 0 ? void 0 : confirmApplePayError.localizedMessage));
219
226
  }
220
- case 25:
227
+ case 28:
221
228
  setPlacing(false);
222
229
  if (!error) {
223
230
  onPlaceOrderClick && onPlaceOrderClick(result);
224
231
  }
225
- case 27:
232
+ case 30:
226
233
  setPlacing(false);
227
234
  if (!error) {
228
235
  onPlaceOrderClick && onPlaceOrderClick(result);
229
236
  }
230
- case 29:
237
+ case 32:
231
238
  case "end":
232
239
  return _context.stop();
233
240
  }
@@ -0,0 +1,94 @@
1
+ "use strict";
2
+
3
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.ProductItemAccordion = void 0;
8
+ var _react = _interopRequireDefault(require("react"));
9
+ var _propTypes = _interopRequireDefault(require("prop-types"));
10
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
12
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
13
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
14
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
15
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
16
+ 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); }
17
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
18
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
19
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
20
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
21
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
22
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
23
+ /**
24
+ * Component to render product ingredient
25
+ */
26
+ var ProductItemAccordion = exports.ProductItemAccordion = function ProductItemAccordion(props) {
27
+ var UIComponent = props.UIComponent,
28
+ product = props.product,
29
+ isCartProduct = props.isCartProduct;
30
+
31
+ /**
32
+ * Run productInfo to sort product options
33
+ */
34
+ var productInfo = function productInfo() {
35
+ var _product$options;
36
+ var options = JSON.parse(JSON.stringify(Object.values((_product$options = product.options) !== null && _product$options !== void 0 ? _product$options : {})));
37
+ var extraGroups = options.reduce(function (acc, option) {
38
+ var _option$extra$rank, _option$extra;
39
+ var extraRank = (_option$extra$rank = option === null || option === void 0 || (_option$extra = option.extra) === null || _option$extra === void 0 ? void 0 : _option$extra.rank) !== null && _option$extra$rank !== void 0 ? _option$extra$rank : option === null || option === void 0 ? void 0 : option.rank;
40
+ acc[extraRank] = acc[extraRank] || [];
41
+ acc[extraRank].push(option);
42
+ return acc;
43
+ }, {});
44
+ var sortedExtraGroups = Object.entries(extraGroups).sort(function (_ref, _ref2) {
45
+ var _ref3 = _slicedToArray(_ref, 1),
46
+ rankA = _ref3[0];
47
+ var _ref4 = _slicedToArray(_ref2, 1),
48
+ rankB = _ref4[0];
49
+ return rankA - rankB;
50
+ });
51
+ sortedExtraGroups.forEach(function (_ref5) {
52
+ var _ref6 = _slicedToArray(_ref5, 2),
53
+ _ = _ref6[0],
54
+ group = _ref6[1];
55
+ group.sort(function (a, b) {
56
+ return a.rank - b.rank;
57
+ });
58
+ });
59
+ options = sortedExtraGroups.flatMap(function (_ref7) {
60
+ var _ref8 = _slicedToArray(_ref7, 2),
61
+ group = _ref8[1];
62
+ return group;
63
+ });
64
+ if (isCartProduct) {
65
+ var _product$ingredients;
66
+ var ingredients = JSON.parse(JSON.stringify(Object.values((_product$ingredients = product.ingredients) !== null && _product$ingredients !== void 0 ? _product$ingredients : {})));
67
+ options = options.map(function (option) {
68
+ var _option$suboptions;
69
+ option.suboptions = Object.values((_option$suboptions = option.suboptions) !== null && _option$suboptions !== void 0 ? _option$suboptions : {});
70
+ return option;
71
+ });
72
+ return _objectSpread(_objectSpread({}, productInfo), {}, {
73
+ ingredients: ingredients,
74
+ options: options
75
+ });
76
+ }
77
+ return _objectSpread(_objectSpread({}, product), {}, {
78
+ options: options
79
+ });
80
+ };
81
+ return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, UIComponent && /*#__PURE__*/_react.default.createElement(UIComponent, _extends({}, props, {
82
+ productInfo: productInfo()
83
+ })));
84
+ };
85
+ ProductItemAccordion.propTypes = {
86
+ /**
87
+ * UI Component, this must be containt all graphic elements and use parent props
88
+ */
89
+ UIComponent: _propTypes.default.elementType,
90
+ /**
91
+ * product object to render UI
92
+ */
93
+ product: _propTypes.default.object.isRequired
94
+ };
package/_modules/index.js CHANGED
@@ -771,6 +771,12 @@ Object.defineProperty(exports, "ProductIngredient", {
771
771
  return _ProductIngredient.ProductIngredient;
772
772
  }
773
773
  });
774
+ Object.defineProperty(exports, "ProductItemAccordion", {
775
+ enumerable: true,
776
+ get: function get() {
777
+ return _ProductItemAccordion.ProductItemAccordion;
778
+ }
779
+ });
774
780
  Object.defineProperty(exports, "ProductOption", {
775
781
  enumerable: true,
776
782
  get: function get() {
@@ -1247,6 +1253,7 @@ var _ProductForm = require("./components/ProductForm");
1247
1253
  var _ProductShare = require("./components/ProductShare");
1248
1254
  var _ProductImages = require("./components/ProductImages");
1249
1255
  var _ProductIngredient = require("./components/ProductIngredient");
1256
+ var _ProductItemAccordion = require("./components/ProductItemAccordion");
1250
1257
  var _ProductOption = require("./components/ProductOption");
1251
1258
  var _ProductOptionSuboption = require("./components/ProductOptionSuboption");
1252
1259
  var _ProductsList = require("./components/ProductsList");
@@ -513,6 +513,12 @@ Object.defineProperty(exports, "ProductIngredient", {
513
513
  return _ProductIngredient.ProductIngredient;
514
514
  }
515
515
  });
516
+ Object.defineProperty(exports, "ProductItemAccordion", {
517
+ enumerable: true,
518
+ get: function get() {
519
+ return _ProductItemAccordion.ProductItemAccordion;
520
+ }
521
+ });
516
522
  Object.defineProperty(exports, "ProductOption", {
517
523
  enumerable: true,
518
524
  get: function get() {
@@ -901,6 +907,7 @@ var _PhoneAutocomplete = require("../src/components/PhoneAutocomplete");
901
907
  var _ProductForm = require("../src/components/ProductForm");
902
908
  var _ProductImages = require("../src/components/ProductImages");
903
909
  var _ProductIngredient = require("../src/components/ProductIngredient");
910
+ var _ProductItemAccordion = require("../src/components/ProductItemAccordion");
904
911
  var _ProductOption = require("../src/components/ProductOption");
905
912
  var _ProductOptionSuboption = require("../src/components/ProductOptionSuboption");
906
913
  var _ProductsList = require("../src/components/ProductsList");
package/native/index.js CHANGED
@@ -62,6 +62,7 @@ import { PhoneAutocomplete } from '../src/components/PhoneAutocomplete'
62
62
  import { ProductForm } from '../src/components/ProductForm'
63
63
  import { ProductImages } from '../src/components/ProductImages'
64
64
  import { ProductIngredient } from '../src/components/ProductIngredient'
65
+ import { ProductItemAccordion } from '../src/components/ProductItemAccordion'
65
66
  import { ProductOption } from '../src/components/ProductOption'
66
67
  import { ProductOptionSuboption } from '../src/components/ProductOptionSuboption'
67
68
  import { ProductsList } from '../src/components/ProductsList'
@@ -176,6 +177,7 @@ export {
176
177
  ProductForm,
177
178
  ProductImages,
178
179
  ProductIngredient,
180
+ ProductItemAccordion,
179
181
  ProductOption,
180
182
  ProductOptionSuboption,
181
183
  ProductsList,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ordering-components-external",
3
- "version": "13.0.40",
3
+ "version": "13.0.42",
4
4
  "description": "Ordering Internal Dashboard",
5
5
  "main": "./_modules/index.js",
6
6
  "scripts": {
@@ -150,6 +150,10 @@ export const Checkout = (props) => {
150
150
  * Method to handle click on Place order
151
151
  */
152
152
  const handlerClickPlaceOrder = async (paymentOptions, payloadProps, confirmPayment, dismissPlatformPay) => {
153
+ if (placing) {
154
+ showToast(ToastType.Info, t('CART_IN_PROGRESS', 'Cart in progress'))
155
+ return
156
+ }
153
157
  let paymethodData = paymethodSelected?.data
154
158
  if (paymethodSelected?.paymethod && ['stripe', 'stripe_connect', 'stripe_direct'].includes(paymethodSelected?.paymethod?.gateway)) {
155
159
  paymethodData = {
@@ -56,6 +56,10 @@ export const MultiCheckout = (props) => {
56
56
  const totalCartsFee = openCarts?.length && openCarts?.filter(cart => cart?.status !== 1 && cart?.valid)?.reduce((total, cart) => { return total + (cart?.delivery_price_with_discount) }, 0)
57
57
 
58
58
  const handleGroupPlaceOrder = async (confirmPayment) => {
59
+ if (placing) {
60
+ showToast(ToastType.Info, t('CART_IN_PROGRESS', 'Cart in progress'))
61
+ return
62
+ }
59
63
  let paymethodData = paymethodSelected?.paymethod_data
60
64
  if (paymethodSelected?.paymethod_data && ['stripe', 'stripe_connect', 'stripe_direct'].includes(paymethodSelected?.paymethod?.gateway)) {
61
65
  paymethodData = JSON.stringify({
@@ -0,0 +1,72 @@
1
+ import React from 'react'
2
+ import PropTypes from 'prop-types'
3
+
4
+ /**
5
+ * Component to render product ingredient
6
+ */
7
+ export const ProductItemAccordion = (props) => {
8
+ const {
9
+ UIComponent,
10
+ product,
11
+ isCartProduct
12
+ } = props
13
+
14
+ /**
15
+ * Run productInfo to sort product options
16
+ */
17
+ const productInfo = () => {
18
+ let options = JSON.parse(JSON.stringify(Object.values(product.options ?? {})))
19
+ const extraGroups = options.reduce((acc, option) => {
20
+ const extraRank = option?.extra?.rank ?? option?.rank
21
+ acc[extraRank] = acc[extraRank] || []
22
+ acc[extraRank].push(option)
23
+ return acc
24
+ }, {})
25
+
26
+ const sortedExtraGroups = Object.entries(extraGroups).sort(([rankA], [rankB]) => rankA - rankB)
27
+
28
+ sortedExtraGroups.forEach(([_, group]) => {
29
+ group.sort((a, b) => a.rank - b.rank)
30
+ })
31
+
32
+ options = sortedExtraGroups.flatMap(([, group]) => group)
33
+
34
+ if (isCartProduct) {
35
+ const ingredients = JSON.parse(JSON.stringify(Object.values(product.ingredients ?? {})))
36
+ options = options.map(option => {
37
+ option.suboptions = Object.values(option.suboptions ?? {})
38
+ return option
39
+ })
40
+ return {
41
+ ...productInfo,
42
+ ingredients,
43
+ options
44
+ }
45
+ }
46
+ return { ...product, options }
47
+ }
48
+
49
+ return (
50
+ <>
51
+ {
52
+ UIComponent && (
53
+ <UIComponent
54
+ {...props}
55
+ productInfo={productInfo()}
56
+ />
57
+ )
58
+ }
59
+ </>
60
+ )
61
+ }
62
+
63
+ ProductItemAccordion.propTypes = {
64
+ /**
65
+ * UI Component, this must be containt all graphic elements and use parent props
66
+ */
67
+ UIComponent: PropTypes.elementType,
68
+ /**
69
+ * product object to render UI
70
+ */
71
+ product: PropTypes.object.isRequired
72
+ }
package/src/index.js CHANGED
@@ -60,6 +60,7 @@ import { ProductForm } from './components/ProductForm'
60
60
  import { ProductShare } from './components/ProductShare'
61
61
  import { ProductImages } from './components/ProductImages'
62
62
  import { ProductIngredient } from './components/ProductIngredient'
63
+ import { ProductItemAccordion } from './components/ProductItemAccordion'
63
64
  import { ProductOption } from './components/ProductOption'
64
65
  import { ProductOptionSuboption } from './components/ProductOptionSuboption'
65
66
  import { ProductsList } from './components/ProductsList'
@@ -236,6 +237,7 @@ export {
236
237
  ProductShare,
237
238
  ProductImages,
238
239
  ProductIngredient,
240
+ ProductItemAccordion,
239
241
  ProductOption,
240
242
  ProductOptionSuboption,
241
243
  ProductsList,