@licklist/design 0.71.18-dev.3 → 0.71.18-dev.4

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 (97) hide show
  1. package/dist/events/edit-event-modal/component/SelectEventProductSet/component/EditEventProductSet.js +1 -0
  2. package/dist/iframe/ProductWithModifierModal/ModifierSetModal/ProductWithModifierSetForm.d.ts +18 -0
  3. package/dist/iframe/ProductWithModifierModal/ModifierSetModal/ProductWithModifierSetForm.d.ts.map +1 -0
  4. package/dist/iframe/ProductWithModifierModal/ModifierSetModal/ProductWithModifierSetForm.js +281 -0
  5. package/dist/iframe/ProductWithModifierModal/ModifierSetModal/ProductWithModifierSetModal.d.ts +15 -0
  6. package/dist/iframe/ProductWithModifierModal/ModifierSetModal/ProductWithModifierSetModal.d.ts.map +1 -0
  7. package/dist/iframe/ProductWithModifierModal/ModifierSetModal/ProductWithModifierSetModal.js +89 -0
  8. package/dist/iframe/ProductWithModifierModal/ModifierSetModal/controll/ModifierSetControll.d.ts +16 -0
  9. package/dist/iframe/ProductWithModifierModal/ModifierSetModal/controll/ModifierSetControll.d.ts.map +1 -0
  10. package/dist/iframe/ProductWithModifierModal/ModifierSetModal/controll/ModifierSetControll.js +447 -0
  11. package/dist/iframe/ProductWithModifierModal/ModifierSetModal/controll/ProductControll.d.ts +12 -0
  12. package/dist/iframe/ProductWithModifierModal/ModifierSetModal/controll/ProductControll.d.ts.map +1 -0
  13. package/dist/iframe/ProductWithModifierModal/ModifierSetModal/controll/ProductControll.js +45 -0
  14. package/dist/iframe/ProductWithModifierModal/ModifierSetModal/index.d.ts +2 -0
  15. package/dist/iframe/ProductWithModifierModal/ModifierSetModal/index.d.ts.map +1 -0
  16. package/dist/iframe/ProductWithModifierModal/index.d.ts +2 -0
  17. package/dist/iframe/ProductWithModifierModal/index.d.ts.map +1 -0
  18. package/dist/iframe/event/ticket-description/TicketDescription.d.ts +2 -1
  19. package/dist/iframe/event/ticket-description/TicketDescription.d.ts.map +1 -1
  20. package/dist/iframe/event/ticket-description/TicketDescription.js +4 -3
  21. package/dist/iframe/order-process/components/BookingSummary/components/ProductSummary/ProductSummary.d.ts.map +1 -1
  22. package/dist/iframe/order-process/components/BookingSummary/components/ProductSummary/ProductSummary.js +29 -2
  23. package/dist/iframe/order-process/components/BookingSummary/utils/index.d.ts +4 -0
  24. package/dist/iframe/order-process/components/BookingSummary/utils/index.d.ts.map +1 -1
  25. package/dist/iframe/order-process/components/BookingSummary/utils/index.js +27 -2
  26. package/dist/iframe/order-process/components/CategoryProduct/CategoryProduct.d.ts.map +1 -1
  27. package/dist/iframe/order-process/components/CategoryProduct/CategoryProduct.js +106 -2
  28. package/dist/iframe/order-process/components/CategoryProduct/components/ProductQuantityInput/ProductQuantityInput.d.ts +3 -1
  29. package/dist/iframe/order-process/components/CategoryProduct/components/ProductQuantityInput/ProductQuantityInput.d.ts.map +1 -1
  30. package/dist/iframe/order-process/components/CategoryProduct/components/ProductQuantityInput/ProductQuantityInput.js +95 -1
  31. package/dist/iframe/order-process/components/CategoryProduct/components/ProductWithModifier/ProductWithModifier.d.ts +22 -0
  32. package/dist/iframe/order-process/components/CategoryProduct/components/ProductWithModifier/ProductWithModifier.d.ts.map +1 -0
  33. package/dist/iframe/order-process/components/CategoryProduct/components/ProductWithModifier/ProductWithModifier.js +62 -0
  34. package/dist/iframe/order-process/components/CategoryProduct/constants.d.ts +2 -0
  35. package/dist/iframe/order-process/components/CategoryProduct/constants.d.ts.map +1 -0
  36. package/dist/iframe/order-process/components/CategoryProduct/constants.js +4 -0
  37. package/dist/iframe/order-process/components/utils/useOnWindowUnmount.d.ts +6 -0
  38. package/dist/iframe/order-process/components/utils/useOnWindowUnmount.d.ts.map +1 -0
  39. package/dist/iframe/order-process/components/utils/useOnWindowUnmount.js +18 -0
  40. package/dist/iframe/payment/order-items-table/hooks/useTableData.d.ts.map +1 -1
  41. package/dist/iframe/payment/order-items-table/hooks/useTableData.js +83 -10
  42. package/dist/iframe/payment/order-items-table/utils/index.d.ts.map +1 -1
  43. package/dist/iframe/payment/order-items-table/utils/index.js +15 -0
  44. package/dist/iframe/payment/order-items-table/utils/paymentSummary.js +2 -2
  45. package/dist/product-set/form/ProductSetForm.d.ts +3 -1
  46. package/dist/product-set/form/ProductSetForm.d.ts.map +1 -1
  47. package/dist/product-set/form/ProductSetForm.js +6 -4
  48. package/dist/product-set/form/ProductsControl.d.ts.map +1 -1
  49. package/dist/product-set/form/ProductsControl.js +17 -5
  50. package/dist/product-set/form/context.d.ts +3 -1
  51. package/dist/product-set/form/context.d.ts.map +1 -1
  52. package/dist/product-set/form/context.js +2 -1
  53. package/dist/product-set/product/ProductControl.d.ts +8 -0
  54. package/dist/product-set/product/ProductControl.d.ts.map +1 -1
  55. package/dist/product-set/product/ProductControl.js +25 -1
  56. package/dist/product-set/utils/index.d.ts +88 -0
  57. package/dist/product-set/utils/index.d.ts.map +1 -1
  58. package/dist/product-set/utils/index.js +19 -1
  59. package/dist/sales/coupon/utils/index.d.ts +2 -1
  60. package/dist/sales/coupon/utils/index.d.ts.map +1 -1
  61. package/dist/styles/iframe-page/Page.scss +16 -0
  62. package/dist/styles/iframe-page/PageBody.scss +4 -0
  63. package/dist/styles/modals/Modals.scss +16 -0
  64. package/dist/styles/product-set/ProductSetForm.scss +10 -0
  65. package/dist/styles/sales/ManualBooking.scss +6 -0
  66. package/dist/styles/themes/bookedit/index.scss +14 -0
  67. package/package.json +6 -6
  68. package/src/iframe/ProductWithModifierModal/ModifierSetModal/ProductWithModifierSetForm.tsx +205 -0
  69. package/src/iframe/ProductWithModifierModal/ModifierSetModal/ProductWithModifierSetModal.tsx +75 -0
  70. package/src/iframe/ProductWithModifierModal/ModifierSetModal/controll/ModifierSetControll.tsx +471 -0
  71. package/src/iframe/ProductWithModifierModal/ModifierSetModal/controll/ProductControll.tsx +55 -0
  72. package/src/iframe/ProductWithModifierModal/ModifierSetModal/index.ts +1 -0
  73. package/src/iframe/ProductWithModifierModal/index.ts +1 -0
  74. package/src/iframe/event/ticket-description/TicketDescription.tsx +5 -3
  75. package/src/iframe/order-process/components/BookingSummary/components/ProductSummary/ProductSummary.tsx +32 -1
  76. package/src/iframe/order-process/components/BookingSummary/utils/index.ts +45 -1
  77. package/src/iframe/order-process/components/CategoryProduct/CategoryProduct.tsx +155 -75
  78. package/src/iframe/order-process/components/CategoryProduct/components/ProductQuantityInput/ProductQuantityInput.tsx +58 -1
  79. package/src/iframe/order-process/components/CategoryProduct/components/ProductWithModifier/ProductWithModifier.tsx +84 -0
  80. package/src/iframe/order-process/components/CategoryProduct/constants.ts +1 -0
  81. package/src/iframe/order-process/components/utils/useOnWindowUnmount.ts +25 -0
  82. package/src/iframe/payment/order-items-table/hooks/useTableData.tsx +84 -14
  83. package/src/iframe/payment/order-items-table/utils/index.ts +23 -0
  84. package/src/iframe/payment/order-items-table/utils/paymentSummary.tsx +2 -2
  85. package/src/product-set/form/ProductSetForm.tsx +11 -3
  86. package/src/product-set/form/ProductsControl.tsx +24 -15
  87. package/src/product-set/form/context.tsx +5 -0
  88. package/src/product-set/product/ProductControl.tsx +37 -1
  89. package/src/product-set/utils/index.ts +19 -0
  90. package/src/sales/coupon/utils/index.ts +5 -3
  91. package/src/styles/iframe-page/Page.scss +16 -0
  92. package/src/styles/iframe-page/PageBody.scss +4 -0
  93. package/src/styles/modals/Modals.scss +16 -0
  94. package/src/styles/product-set/ProductSetForm.scss +10 -0
  95. package/src/styles/sales/ManualBooking.scss +6 -0
  96. package/src/styles/themes/bookedit/index.scss +14 -0
  97. package/yarn.lock +171 -199
@@ -1,8 +1,12 @@
1
+ import { OrderModifierByProduct } from '@licklist/core/dist/DataMapper/Order/OrderModifiierByProduct';
1
2
  import { QuantityCheckProductInfo } from '@licklist/plugins/dist/types/Api/verifyStock';
2
3
  import { OrderItem } from '@licklist/plugins/dist/types/context/Iframe/orderItems';
3
4
  export declare const cartSumByOrderProducts: ({ orderProducts, isTotalSum, }: {
4
5
  orderProducts?: OrderItem[];
5
6
  isTotalSum?: boolean;
6
7
  }) => number;
8
+ export declare const getModifierName: (modifier: OrderModifierByProduct, isManualBooking: boolean) => string;
9
+ export declare const calculateTotalModifiersPrice: (orderModifiersSets: OrderModifierByProduct[]) => number;
10
+ export declare const getOrderProductModifiersPrice: (modifierFromProduct: OrderModifierByProduct) => number;
7
11
  export declare const getProductError: (productsWithErrors: QuantityCheckProductInfo[], productId: OrderItem["id"]) => string | undefined;
8
12
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/iframe/order-process/components/BookingSummary/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,8CAA8C,CAAA;AACvF,OAAO,EAAE,SAAS,EAAE,MAAM,wDAAwD,CAAA;AAElF,eAAO,MAAM,sBAAsB,mCAGhC;IACD,aAAa,CAAC,EAAE,SAAS,EAAE,CAAA;IAC3B,UAAU,CAAC,EAAE,OAAO,CAAA;CACrB,WAeA,CAAA;AAED,eAAO,MAAM,eAAe,uBACN,wBAAwB,EAAE,aACnC,SAAS,CAAC,IAAI,CAAC,KACzB,MAAM,GAAG,SAGA,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/iframe/order-process/components/BookingSummary/utils/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,sBAAsB,EACvB,MAAM,8DAA8D,CAAA;AACrE,OAAO,EAAE,wBAAwB,EAAE,MAAM,8CAA8C,CAAA;AACvF,OAAO,EAAE,SAAS,EAAE,MAAM,wDAAwD,CAAA;AAElF,eAAO,MAAM,sBAAsB,mCAGhC;IACD,aAAa,CAAC,EAAE,SAAS,EAAE,CAAA;IAC3B,UAAU,CAAC,EAAE,OAAO,CAAA;CACrB,WAmBA,CAAA;AAED,eAAO,MAAM,eAAe,aAChB,sBAAsB,mBACf,OAAO,WAMzB,CAAA;AAED,eAAO,MAAM,4BAA4B,uBACnB,sBAAsB,EAAE,WAUO,CAAA;AAErD,eAAO,MAAM,6BAA6B,wBACnB,sBAAsB,WAU5C,CAAA;AAED,eAAO,MAAM,eAAe,uBACN,wBAAwB,EAAE,aACnC,SAAS,CAAC,IAAI,CAAC,KACzB,MAAM,GAAG,SAGA,CAAA"}
@@ -5,10 +5,35 @@ var cartSumByOrderProducts = function(param) {
5
5
  }
6
6
  return orderProducts.reduce(function(prevSumValue, product) {
7
7
  if (!product) return 0;
8
+ var modifiersPrice = calculateTotalModifiersPrice(product === null || product === void 0 ? void 0 : product.orderModifiersSets);
8
9
  var price = isTotalSum ? product === null || product === void 0 ? void 0 : product.price : product.hasDeposit ? product === null || product === void 0 ? void 0 : product.deposit : product === null || product === void 0 ? void 0 : product.price;
9
- return prevSumValue + price * product.quantity;
10
+ return prevSumValue + price * product.quantity + modifiersPrice;
10
11
  }, 0);
11
12
  };
13
+ var getModifierName = function(modifier, isManualBooking) {
14
+ var modifierName = function(orderModifier) {
15
+ return !isManualBooking ? orderModifier === null || orderModifier === void 0 ? void 0 : orderModifier.name : orderModifier.modifier.name;
16
+ };
17
+ return "".concat(modifier.modifiers.map(function(item) {
18
+ return (item === null || item === void 0 ? void 0 : item.quantity) > 1 ? "".concat(item === null || item === void 0 ? void 0 : item.quantity, "x - ").concat(modifierName(item)) : modifierName(item);
19
+ }).join(', '));
20
+ };
21
+ var calculateTotalModifiersPrice = function(orderModifiersSets) {
22
+ return orderModifiersSets === null || orderModifiersSets === void 0 ? void 0 : orderModifiersSets.map(function(set) {
23
+ return set.modifiers.reduce(function(sum, modifier) {
24
+ return sum + modifier.price * modifier.quantity * set.productQuantity;
25
+ }, 0);
26
+ }).reduce(function(total, setTotal) {
27
+ return total + setTotal;
28
+ }, 0);
29
+ };
30
+ var getOrderProductModifiersPrice = function(modifierFromProduct) {
31
+ var modifiers = modifierFromProduct.modifiers, productQuantity = modifierFromProduct.productQuantity;
32
+ var modifiersPrices = modifiers.reduce(function(prevSumModifier, modifier) {
33
+ return prevSumModifier + modifier.price * modifier.quantity;
34
+ }, 0);
35
+ return modifiersPrices * productQuantity;
36
+ };
12
37
  var getProductError = function(productsWithErrors, productId) {
13
38
  var _productsWithErrors_find;
14
39
  return (_productsWithErrors_find = productsWithErrors.find(function(productWithError) {
@@ -16,4 +41,4 @@ var getProductError = function(productsWithErrors, productId) {
16
41
  })) === null || _productsWithErrors_find === void 0 ? void 0 : _productsWithErrors_find.message;
17
42
  };
18
43
 
19
- export { cartSumByOrderProducts, getProductError };
44
+ export { calculateTotalModifiersPrice, cartSumByOrderProducts, getModifierName, getOrderProductModifiersPrice, getProductError };
@@ -1 +1 @@
1
- {"version":3,"file":"CategoryProduct.d.ts","sourceRoot":"","sources":["../../../../../src/iframe/order-process/components/CategoryProduct/CategoryProduct.tsx"],"names":[],"mappings":"AAOA,OAAO,EAAE,wBAAwB,EAAE,MAAM,8CAA8C,CAAA;AACvF,OAAO,EACL,OAAO,EACP,eAAe,EAChB,MAAM,qDAAqD,CAAA;AAI5D,UAAU,oBAAoB;IAC5B,OAAO,EAAE,OAAO,CAAA;IAChB,QAAQ,EAAE,eAAe,CAAA;IACzB,oBAAoB,CAAC,EAAE,OAAO,CAAA;IAC9B,kBAAkB,CAAC,EAAE,wBAAwB,EAAE,CAAA;IAC/C,eAAe,CAAC,EAAE,wBAAwB,EAAE,CAAA;CAC7C;AAED,eAAO,MAAM,eAAe,sFAMzB,oBAAoB,4CA0KtB,CAAA"}
1
+ {"version":3,"file":"CategoryProduct.d.ts","sourceRoot":"","sources":["../../../../../src/iframe/order-process/components/CategoryProduct/CategoryProduct.tsx"],"names":[],"mappings":"AAOA,OAAO,EAAE,wBAAwB,EAAE,MAAM,8CAA8C,CAAA;AACvF,OAAO,EACL,OAAO,EACP,eAAe,EAChB,MAAM,qDAAqD,CAAA;AAU5D,UAAU,oBAAoB;IAC5B,OAAO,EAAE,OAAO,CAAA;IAChB,QAAQ,EAAE,eAAe,CAAA;IACzB,oBAAoB,CAAC,EAAE,OAAO,CAAA;IAC9B,kBAAkB,CAAC,EAAE,wBAAwB,EAAE,CAAA;IAC/C,eAAe,CAAC,EAAE,wBAAwB,EAAE,CAAA;CAC7C;AAED,eAAO,MAAM,eAAe,sFAMzB,oBAAoB,4CAoPtB,CAAA"}
@@ -1,14 +1,24 @@
1
- import { jsx, jsxs } from 'react/jsx-runtime';
2
- import { useMemo, useEffect } from 'react';
1
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
2
+ import { useState, useMemo, useEffect } from 'react';
3
3
  import { useFormContext, Controller } from 'react-hook-form';
4
4
  import clsx from 'clsx';
5
5
  import { useTranslation } from 'react-i18next';
6
6
  import { useIntl } from 'react-intl';
7
7
  import * as Config from '@licklist/core/dist/Config';
8
8
  import HookFormService from '@licklist/plugins/dist/services/Form/HookFormService';
9
+ import { ProductWithModifierSetModal } from '../../../ProductWithModifierModal/ModifierSetModal/ProductWithModifierSetModal.js';
9
10
  import { TicketDescription } from '../../../event/ticket-description/TicketDescription.js';
10
11
  import { ProductQuantityInput } from './components/ProductQuantityInput/ProductQuantityInput.js';
12
+ import { ProductWithModifier } from './components/ProductWithModifier/ProductWithModifier.js';
11
13
 
14
+ function _array_like_to_array(arr, len) {
15
+ if (len == null || len > arr.length) len = arr.length;
16
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
17
+ return arr2;
18
+ }
19
+ function _array_with_holes(arr) {
20
+ if (Array.isArray(arr)) return arr;
21
+ }
12
22
  function _define_property(obj, key, value) {
13
23
  if (key in obj) {
14
24
  Object.defineProperty(obj, key, {
@@ -22,6 +32,33 @@ function _define_property(obj, key, value) {
22
32
  }
23
33
  return obj;
24
34
  }
35
+ function _iterable_to_array_limit(arr, i) {
36
+ var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
37
+ if (_i == null) return;
38
+ var _arr = [];
39
+ var _n = true;
40
+ var _d = false;
41
+ var _s, _e;
42
+ try {
43
+ for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
44
+ _arr.push(_s.value);
45
+ if (i && _arr.length === i) break;
46
+ }
47
+ } catch (err) {
48
+ _d = true;
49
+ _e = err;
50
+ } finally{
51
+ try {
52
+ if (!_n && _i["return"] != null) _i["return"]();
53
+ } finally{
54
+ if (_d) throw _e;
55
+ }
56
+ }
57
+ return _arr;
58
+ }
59
+ function _non_iterable_rest() {
60
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
61
+ }
25
62
  function _object_spread(target) {
26
63
  for(var i = 1; i < arguments.length; i++){
27
64
  var source = arguments[i] != null ? arguments[i] : {};
@@ -61,6 +98,17 @@ function _object_spread_props(target, source) {
61
98
  }
62
99
  return target;
63
100
  }
101
+ function _sliced_to_array(arr, i) {
102
+ return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
103
+ }
104
+ function _unsupported_iterable_to_array(o, minLen) {
105
+ if (!o) return;
106
+ if (typeof o === "string") return _array_like_to_array(o, minLen);
107
+ var n = Object.prototype.toString.call(o).slice(8, -1);
108
+ if (n === "Object" && o.constructor) n = o.constructor.name;
109
+ if (n === "Map" || n === "Set") return Array.from(n);
110
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
111
+ }
64
112
  var CategoryProduct = function(param) {
65
113
  var product = param.product, category = param.category, _param_canExpandDescription = param.canExpandDescription, canExpandDescription = _param_canExpandDescription === void 0 ? true : _param_canExpandDescription, productsWithErrors = param.productsWithErrors, soldOutProducts = param.soldOutProducts;
66
114
  var formatNumber = useIntl().formatNumber;
@@ -69,6 +117,8 @@ var CategoryProduct = function(param) {
69
117
  'Validation'
70
118
  ]).t;
71
119
  var _useFormContext = useFormContext(), control = _useFormContext.control, clearErrors = _useFormContext.clearErrors, setError = _useFormContext.setError;
120
+ var _useState = _sliced_to_array(useState(undefined), 2), editOrderModifierIndex = _useState[0], setEditOrderModifierIndex = _useState[1];
121
+ var _useState1 = _sliced_to_array(useState(undefined), 2), modifierIndex = _useState1[0], setModifierIndex = _useState1[1];
72
122
  var hasDeposits = category.allowDeposits && (product === null || product === void 0 ? void 0 : product.deposit) < product.price;
73
123
  var productQuantityError = useMemo(function() {
74
124
  if (!productsWithErrors) {
@@ -143,6 +193,40 @@ var CategoryProduct = function(param) {
143
193
  },
144
194
  render: function(param) {
145
195
  var _param_field = param.field, onChange = _param_field.onChange, tmp = _param_field.value, productInfo = tmp === void 0 ? {} : tmp, ref = _param_field.ref, _param_fieldState = param.fieldState, invalid = _param_fieldState.invalid, error = _param_fieldState.error;
196
+ var _productInfo_orderModifiersSets;
197
+ var deleteOrderModifier = function(orderModifierIndex) {
198
+ var _productInfo_orderModifiersSets;
199
+ var removedOrderModifierIndex = (_productInfo_orderModifiersSets = productInfo.orderModifiersSets) === null || _productInfo_orderModifiersSets === void 0 ? void 0 : _productInfo_orderModifiersSets.filter(function(_, index) {
200
+ return index !== orderModifierIndex;
201
+ });
202
+ var productInfoWithRemove = _object_spread_props(_object_spread({}, productInfo), {
203
+ orderModifiersSets: removedOrderModifierIndex,
204
+ quantity: removedOrderModifierIndex.reduce(function(acc, product) {
205
+ return product.productQuantity + acc;
206
+ }, 0)
207
+ });
208
+ onChange(productInfoWithRemove);
209
+ };
210
+ var editOrderModifierSet = function(orderModifierIndex) {
211
+ var editOrderModifierIndex = productInfo.orderModifiersSets.find(function(_, index) {
212
+ setModifierIndex(index);
213
+ return index === orderModifierIndex;
214
+ });
215
+ setEditOrderModifierIndex(editOrderModifierIndex);
216
+ };
217
+ var onChangeWithModifierSets = function(value) {
218
+ var _productInfo_orderModifiersSets;
219
+ var editedOrderModifiersSets = (_productInfo_orderModifiersSets = productInfo.orderModifiersSets) === null || _productInfo_orderModifiersSets === void 0 ? void 0 : _productInfo_orderModifiersSets.filter(function(_, index) {
220
+ return index !== modifierIndex;
221
+ }).concat(value.orderModifiersSets);
222
+ onChange(_object_spread_props(_object_spread({}, value), {
223
+ orderModifiersSets: editedOrderModifiersSets,
224
+ quantity: editedOrderModifiersSets.reduce(function(acc, product) {
225
+ return product.productQuantity + acc;
226
+ }, 0)
227
+ }));
228
+ setEditOrderModifierIndex(undefined);
229
+ };
146
230
  return /*#__PURE__*/ jsxs("div", {
147
231
  id: String(product.id),
148
232
  className: "iframe-event__category-product",
@@ -194,6 +278,16 @@ var CategoryProduct = function(param) {
194
278
  })
195
279
  })
196
280
  }),
281
+ ((_productInfo_orderModifiersSets = productInfo.orderModifiersSets) === null || _productInfo_orderModifiersSets === void 0 ? void 0 : _productInfo_orderModifiersSets.length) > 0 && /*#__PURE__*/ jsx(Fragment, {
282
+ children: productInfo.orderModifiersSets.map(function(modifier, index) {
283
+ return /*#__PURE__*/ jsx(ProductWithModifier, {
284
+ modifier: modifier,
285
+ modifierKey: index,
286
+ editOrderModifierSet: editOrderModifierSet,
287
+ deleteOrderModifier: deleteOrderModifier
288
+ }, modifier.productQuantity.toString());
289
+ })
290
+ }),
197
291
  hasDeposits && (category === null || category === void 0 ? void 0 : category.remainderExpireAfter) > 0 && /*#__PURE__*/ jsx("div", {
198
292
  className: "mt-4",
199
293
  children: t('Design:payNowAndReminderDays', {
@@ -221,6 +315,16 @@ var CategoryProduct = function(param) {
221
315
  HookFormService.hasError(error, 'validate') && error.message
222
316
  ]
223
317
  })
318
+ }),
319
+ /*#__PURE__*/ jsx(ProductWithModifierSetModal, {
320
+ show: !!editOrderModifierIndex,
321
+ onHide: function() {
322
+ return setEditOrderModifierIndex(undefined);
323
+ },
324
+ editOrderModifier: editOrderModifierIndex,
325
+ onChange: onChangeWithModifierSets,
326
+ product: product,
327
+ category: category
224
328
  })
225
329
  ]
226
330
  });
@@ -1,6 +1,7 @@
1
1
  import { FieldValues, RefCallBack, UseFormClearErrors } from 'react-hook-form';
2
2
  import { Product, ProductCategory } from '@licklist/plugins/dist/types/context/sale/menuSteps';
3
- interface FormOrderItem {
3
+ import { OrderModifierByProduct } from '@licklist/core/dist/DataMapper/Order/OrderModifiierByProduct';
4
+ export interface FormOrderItem {
4
5
  id: number;
5
6
  name: string;
6
7
  price: number;
@@ -9,6 +10,7 @@ interface FormOrderItem {
9
10
  deposit?: number | null;
10
11
  quantity: number;
11
12
  capacity?: number | null;
13
+ orderModifiersSets?: OrderModifierByProduct[] | null;
12
14
  }
13
15
  interface ProductQuantityInputProps {
14
16
  product: Product;
@@ -1 +1 @@
1
- {"version":3,"file":"ProductQuantityInput.d.ts","sourceRoot":"","sources":["../../../../../../src/iframe/order-process/components/CategoryProduct/components/ProductQuantityInput/ProductQuantityInput.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AAC9E,OAAO,EACL,OAAO,EACP,eAAe,EAChB,MAAM,qDAAqD,CAAA;AAG5D,UAAU,aAAa;IACrB,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;IACb,iBAAiB,EAAE,MAAM,CAAA;IACzB,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACvB,QAAQ,EAAE,MAAM,CAAA;IAChB,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CACzB;AAED,UAAU,yBAAyB;IACjC,OAAO,EAAE,OAAO,CAAA;IAChB,QAAQ,EAAE,eAAe,CAAA;IACzB,WAAW,EAAE,kBAAkB,CAAC,WAAW,CAAC,CAAA;IAC5C,QAAQ,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAA;IACxC,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,WAAW,EAAE,WAAW,CAAA;IACxB,OAAO,EAAE,OAAO,CAAA;IAChB,WAAW,EAAE,aAAa,CAAA;CAC3B;AAED,eAAO,MAAM,oBAAoB,gGAQ9B,yBAAyB,4CAiE3B,CAAA"}
1
+ {"version":3,"file":"ProductQuantityInput.d.ts","sourceRoot":"","sources":["../../../../../../src/iframe/order-process/components/CategoryProduct/components/ProductQuantityInput/ProductQuantityInput.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AAC9E,OAAO,EACL,OAAO,EACP,eAAe,EAChB,MAAM,qDAAqD,CAAA;AAC5D,OAAO,EAAE,sBAAsB,EAAE,MAAM,8DAA8D,CAAA;AAKrG,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;IACb,iBAAiB,EAAE,MAAM,CAAA;IACzB,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACvB,QAAQ,EAAE,MAAM,CAAA;IAChB,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB,kBAAkB,CAAC,EAAE,sBAAsB,EAAE,GAAG,IAAI,CAAA;CACrD;AAED,UAAU,yBAAyB;IACjC,OAAO,EAAE,OAAO,CAAA;IAChB,QAAQ,EAAE,eAAe,CAAA;IACzB,WAAW,EAAE,kBAAkB,CAAC,WAAW,CAAC,CAAA;IAC5C,QAAQ,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAA;IACxC,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,WAAW,EAAE,WAAW,CAAA;IACxB,OAAO,EAAE,OAAO,CAAA;IAChB,WAAW,EAAE,aAAa,CAAA;CAC3B;AAED,eAAO,MAAM,oBAAoB,gGAQ9B,yBAAyB,4CAoH3B,CAAA"}
@@ -1,12 +1,62 @@
1
- import { jsx } from 'react/jsx-runtime';
1
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
2
+ import { useState } from 'react';
2
3
  import clsx from 'clsx';
3
4
  import { Button } from 'react-bootstrap';
5
+ import { isEmpty } from 'lodash';
4
6
  import { useTranslation } from 'react-i18next';
5
7
  import { NumberInput } from '../NumberInput/NumberInput.js';
8
+ import { ProductWithModifierSetModal } from '../../../../../ProductWithModifierModal/ModifierSetModal/ProductWithModifierSetModal.js';
6
9
 
10
+ function _array_like_to_array(arr, len) {
11
+ if (len == null || len > arr.length) len = arr.length;
12
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
13
+ return arr2;
14
+ }
15
+ function _array_with_holes(arr) {
16
+ if (Array.isArray(arr)) return arr;
17
+ }
18
+ function _iterable_to_array_limit(arr, i) {
19
+ var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
20
+ if (_i == null) return;
21
+ var _arr = [];
22
+ var _n = true;
23
+ var _d = false;
24
+ var _s, _e;
25
+ try {
26
+ for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
27
+ _arr.push(_s.value);
28
+ if (i && _arr.length === i) break;
29
+ }
30
+ } catch (err) {
31
+ _d = true;
32
+ _e = err;
33
+ } finally{
34
+ try {
35
+ if (!_n && _i["return"] != null) _i["return"]();
36
+ } finally{
37
+ if (_d) throw _e;
38
+ }
39
+ }
40
+ return _arr;
41
+ }
42
+ function _non_iterable_rest() {
43
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
44
+ }
45
+ function _sliced_to_array(arr, i) {
46
+ return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
47
+ }
48
+ function _unsupported_iterable_to_array(o, minLen) {
49
+ if (!o) return;
50
+ if (typeof o === "string") return _array_like_to_array(o, minLen);
51
+ var n = Object.prototype.toString.call(o).slice(8, -1);
52
+ if (n === "Object" && o.constructor) n = o.constructor.name;
53
+ if (n === "Map" || n === "Set") return Array.from(n);
54
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
55
+ }
7
56
  var ProductQuantityInput = function(param) {
8
57
  var product = param.product, category = param.category, _onChange = param.onChange, clearErrors = param.clearErrors, refCallback = param.refCallback, productInfo = param.productInfo, invalid = param.invalid;
9
58
  var t = useTranslation('Design').t;
59
+ var _useState = _sliced_to_array(useState(false), 2), open = _useState[0], handleOpenModal = _useState[1];
10
60
  var onChange = function(quantity) {
11
61
  _onChange({
12
62
  id: product.id,
@@ -14,17 +64,61 @@ var ProductQuantityInput = function(param) {
14
64
  deposit: product === null || product === void 0 ? void 0 : product.deposit,
15
65
  hasDeposit: category.allowDeposits && (product === null || product === void 0 ? void 0 : product.deposit) < product.price,
16
66
  price: product.price,
67
+ orderModifiersSets: [],
17
68
  productCategoryId: category.id,
18
69
  quantity: quantity,
19
70
  capacity: product === null || product === void 0 ? void 0 : product.capacity
20
71
  });
21
72
  };
73
+ var onChangeWithModifierSets = function(productOrder) {
74
+ var _productInfo_orderModifiersSets;
75
+ if (isEmpty(productInfo)) {
76
+ _onChange(productOrder);
77
+ return handleOpenModal(false);
78
+ }
79
+ _onChange({
80
+ id: productInfo.id,
81
+ name: productInfo.name,
82
+ deposit: productInfo === null || productInfo === void 0 ? void 0 : productInfo.deposit,
83
+ hasDeposit: productInfo.hasDeposit,
84
+ price: productInfo.price,
85
+ orderModifiersSets: (_productInfo_orderModifiersSets = productInfo.orderModifiersSets) === null || _productInfo_orderModifiersSets === void 0 ? void 0 : _productInfo_orderModifiersSets.concat(productOrder.orderModifiersSets),
86
+ productCategoryId: category.id,
87
+ quantity: productInfo.quantity + productOrder.quantity,
88
+ capacity: productInfo === null || productInfo === void 0 ? void 0 : productInfo.capacity
89
+ });
90
+ return handleOpenModal(false);
91
+ };
22
92
  if (product.isSoldOut) {
23
93
  return /*#__PURE__*/ jsx("div", {
24
94
  className: "iframe-event__sold-out-wrapper",
25
95
  children: t('Design:soldOut')
26
96
  });
27
97
  }
98
+ if (product.modifiersSet.length) {
99
+ return /*#__PURE__*/ jsxs(Fragment, {
100
+ children: [
101
+ /*#__PURE__*/ jsx(Button, {
102
+ ref: refCallback,
103
+ disabled: product.isSoldOut,
104
+ className: clsx("iframe-event__".concat((productInfo === null || productInfo === void 0 ? void 0 : productInfo.quantity) ? 'unselect-product' : 'select-product'), invalid && 'error'),
105
+ onClick: function() {
106
+ return handleOpenModal(true);
107
+ },
108
+ children: "+"
109
+ }),
110
+ /*#__PURE__*/ jsx(ProductWithModifierSetModal, {
111
+ show: open,
112
+ onHide: function() {
113
+ return handleOpenModal(false);
114
+ },
115
+ onChange: onChangeWithModifierSets,
116
+ product: product,
117
+ category: category
118
+ })
119
+ ]
120
+ });
121
+ }
28
122
  if ((product === null || product === void 0 ? void 0 : product.maxAmount) === 1) {
29
123
  return /*#__PURE__*/ jsx(Button, {
30
124
  ref: refCallback,
@@ -0,0 +1,22 @@
1
+ import { OrderModifierByProduct } from '@licklist/core/dist/DataMapper/Order/OrderModifiierByProduct';
2
+ export interface FormOrderItem {
3
+ id: number;
4
+ name: string;
5
+ price: number;
6
+ productCategoryId: number;
7
+ hasDeposit?: boolean;
8
+ deposit?: number | null;
9
+ quantity: number;
10
+ capacity?: number | null;
11
+ orderModifiersSets?: OrderModifierByProduct[] | null;
12
+ }
13
+ interface ProductQuantityInputProps {
14
+ modifier: OrderModifierByProduct;
15
+ modifierKey: number;
16
+ isManualBooking?: boolean;
17
+ deleteOrderModifier?: (order: number) => void;
18
+ editOrderModifierSet?: (order: number) => void;
19
+ }
20
+ export declare const ProductWithModifier: ({ modifier, modifierKey, isManualBooking, deleteOrderModifier, editOrderModifierSet, }: ProductQuantityInputProps) => import("react/jsx-runtime").JSX.Element;
21
+ export {};
22
+ //# sourceMappingURL=ProductWithModifier.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProductWithModifier.d.ts","sourceRoot":"","sources":["../../../../../../src/iframe/order-process/components/CategoryProduct/components/ProductWithModifier/ProductWithModifier.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,sBAAsB,EAAE,MAAM,8DAA8D,CAAA;AAMrG,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;IACb,iBAAiB,EAAE,MAAM,CAAA;IACzB,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACvB,QAAQ,EAAE,MAAM,CAAA;IAChB,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB,kBAAkB,CAAC,EAAE,sBAAsB,EAAE,GAAG,IAAI,CAAA;CACrD;AAED,UAAU,yBAAyB;IACjC,QAAQ,EAAE,sBAAsB,CAAA;IAChC,WAAW,EAAE,MAAM,CAAA;IACnB,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,mBAAmB,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;IAC7C,oBAAoB,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;CAC/C;AAED,eAAO,MAAM,mBAAmB,2FAM7B,yBAAyB,4CA8C3B,CAAA"}
@@ -0,0 +1,62 @@
1
+ import { jsxs, jsx } from 'react/jsx-runtime';
2
+ import { Button } from 'react-bootstrap';
3
+ import { useTranslation } from 'react-i18next';
4
+ import { FaTrashAlt } from 'react-icons/fa';
5
+ import { Config } from '@licklist/core';
6
+ import { useIntl } from 'react-intl';
7
+ import { getModifierName, getOrderProductModifiersPrice } from '../../../BookingSummary/utils/index.js';
8
+
9
+ var ProductWithModifier = function(param) {
10
+ var modifier = param.modifier, modifierKey = param.modifierKey, _param_isManualBooking = param.isManualBooking, isManualBooking = _param_isManualBooking === void 0 ? false : _param_isManualBooking, deleteOrderModifier = param.deleteOrderModifier, editOrderModifierSet = param.editOrderModifierSet;
11
+ var t = useTranslation('Design').t;
12
+ var formatNumber = useIntl().formatNumber;
13
+ var modifierName = getModifierName(modifier, isManualBooking);
14
+ var orderModifierDescription = "".concat(modifier.productQuantity);
15
+ var modifierPrice = getOrderProductModifiersPrice(modifier);
16
+ var fullModifiersPrice = formatNumber(modifierPrice, {
17
+ style: 'currency',
18
+ currency: Config.Currency.GBP
19
+ });
20
+ return /*#__PURE__*/ jsxs("div", {
21
+ className: "d-flex p-2 justify-content-between align-items-center",
22
+ children: [
23
+ /*#__PURE__*/ jsxs("div", {
24
+ className: "d-flex",
25
+ children: [
26
+ /*#__PURE__*/ jsx("p", {
27
+ className: "font-weight-bold pr-4",
28
+ children: "".concat(orderModifierDescription, " x")
29
+ }),
30
+ /*#__PURE__*/ jsx("p", {
31
+ children: modifierName ? " ".concat(modifierName) : t('withoutModifier')
32
+ })
33
+ ]
34
+ }),
35
+ isManualBooking ? /*#__PURE__*/ jsx("p", {
36
+ className: "price",
37
+ children: fullModifiersPrice
38
+ }) : /*#__PURE__*/ jsxs("div", {
39
+ children: [
40
+ /*#__PURE__*/ jsx(Button, {
41
+ className: "ml-2",
42
+ variant: "link",
43
+ onClick: function() {
44
+ return editOrderModifierSet(modifierKey);
45
+ },
46
+ children: t('customise')
47
+ }),
48
+ /*#__PURE__*/ jsx(Button, {
49
+ className: "ml-2",
50
+ variant: "link",
51
+ onClick: function() {
52
+ return deleteOrderModifier(modifierKey);
53
+ },
54
+ children: /*#__PURE__*/ jsx(FaTrashAlt, {})
55
+ })
56
+ ]
57
+ })
58
+ ]
59
+ }, modifierKey);
60
+ };
61
+
62
+ export { ProductWithModifier };
@@ -0,0 +1,2 @@
1
+ export declare const MAX_PRODUCT_NUMBER = 100000;
2
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../../src/iframe/order-process/components/CategoryProduct/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,kBAAkB,SAAS,CAAA"}
@@ -0,0 +1,4 @@
1
+ var MAX_PRODUCT_NUMBER = 100000 // max number
2
+ ;
3
+
4
+ export { MAX_PRODUCT_NUMBER };
@@ -0,0 +1,6 @@
1
+ export type UseOnWindowUnmountProps = {
2
+ onBeforeUnload: (event: Event) => void;
3
+ onPopState: (event: Event) => void;
4
+ };
5
+ export declare const useOnWindowUnmount: ({ onBeforeUnload, onPopState, }: UseOnWindowUnmountProps) => any;
6
+ //# sourceMappingURL=useOnWindowUnmount.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useOnWindowUnmount.d.ts","sourceRoot":"","sources":["../../../../../src/iframe/order-process/components/utils/useOnWindowUnmount.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,uBAAuB,GAAG;IACpC,cAAc,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAA;IACtC,UAAU,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAA;CACnC,CAAA;AAED,eAAO,MAAM,kBAAkB,oCAG5B,uBAAuB,QAczB,CAAA"}
@@ -0,0 +1,18 @@
1
+ import { useEffect } from 'react';
2
+
3
+ var useOnWindowUnmount = function(param) {
4
+ var onBeforeUnload = param.onBeforeUnload, onPopState = param.onPopState;
5
+ useEffect(function() {
6
+ window.history.pushState(null, '', window.location.pathname);
7
+ window.addEventListener('beforeunload', onBeforeUnload);
8
+ window.addEventListener('popstate', onPopState);
9
+ return function() {
10
+ window.removeEventListener('beforeunload', onBeforeUnload);
11
+ window.removeEventListener('popstate', onPopState);
12
+ };
13
+ // eslint-disable-next-line react-hooks/exhaustive-deps
14
+ }, []);
15
+ return null;
16
+ };
17
+
18
+ export { useOnWindowUnmount };
@@ -1 +1 @@
1
- {"version":3,"file":"useTableData.d.ts","sourceRoot":"","sources":["../../../../../src/iframe/payment/order-items-table/hooks/useTableData.tsx"],"names":[],"mappings":"AAUA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAEnD,OAAO,EAAE,oBAAoB,EAAe,MAAM,UAAU,CAAA;AAI5D,eAAO,MAAM,2BAA2B;;;;CAIvC,CAAA;AAED,eAAO,MAAM,YAAY,oEAKtB,oBAAoB;;;;;;;;;;IA8GtB,CAAA"}
1
+ {"version":3,"file":"useTableData.d.ts","sourceRoot":"","sources":["../../../../../src/iframe/payment/order-items-table/hooks/useTableData.tsx"],"names":[],"mappings":"AAWA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAEnD,OAAO,EAAE,oBAAoB,EAAe,MAAM,UAAU,CAAA;AAQ5D,eAAO,MAAM,2BAA2B;;;;CAIvC,CAAA;AAED,eAAO,MAAM,YAAY,oEAKtB,oBAAoB;;;;;;;;;;IA+KtB,CAAA"}