ordering-components-external 13.2.27 → 13.2.28

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 (14) hide show
  1. package/_bundles/{7.ordering-component.dae36acf064926687164.js → 7.ordering-component.9f95da66d085a4ee68c5.js} +1 -1
  2. package/_bundles/{ordering-component.dae36acf064926687164.js → ordering-component.9f95da66d085a4ee68c5.js} +2 -2
  3. package/_modules/components/ProductForm/index.js +24 -15
  4. package/package.json +1 -1
  5. package/src/components/ProductForm/index.js +9 -0
  6. /package/_bundles/{0.ordering-component.dae36acf064926687164.js → 0.ordering-component.9f95da66d085a4ee68c5.js} +0 -0
  7. /package/_bundles/{1.ordering-component.dae36acf064926687164.js → 1.ordering-component.9f95da66d085a4ee68c5.js} +0 -0
  8. /package/_bundles/{2.ordering-component.dae36acf064926687164.js → 2.ordering-component.9f95da66d085a4ee68c5.js} +0 -0
  9. /package/_bundles/{4.ordering-component.dae36acf064926687164.js → 4.ordering-component.9f95da66d085a4ee68c5.js} +0 -0
  10. /package/_bundles/{5.ordering-component.dae36acf064926687164.js → 5.ordering-component.9f95da66d085a4ee68c5.js} +0 -0
  11. /package/_bundles/{6.ordering-component.dae36acf064926687164.js → 6.ordering-component.9f95da66d085a4ee68c5.js} +0 -0
  12. /package/_bundles/{7.ordering-component.dae36acf064926687164.js.LICENSE.txt → 7.ordering-component.9f95da66d085a4ee68c5.js.LICENSE.txt} +0 -0
  13. /package/_bundles/{8.ordering-component.dae36acf064926687164.js → 8.ordering-component.9f95da66d085a4ee68c5.js} +0 -0
  14. /package/_bundles/{ordering-component.dae36acf064926687164.js.LICENSE.txt → ordering-component.9f95da66d085a4ee68c5.js.LICENSE.txt} +0 -0
@@ -7,7 +7,9 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.ProductForm = void 0;
8
8
  var _react = _interopRequireWildcard(require("react"));
9
9
  var _propTypes = _interopRequireDefault(require("prop-types"));
10
- var _moment = _interopRequireDefault(require("moment"));
10
+ var _moment2 = _interopRequireDefault(require("moment"));
11
+ var _dayjs = _interopRequireDefault(require("dayjs"));
12
+ var _utc = _interopRequireDefault(require("dayjs/plugin/utc"));
11
13
  var _OrderContext = require("../../contexts/OrderContext");
12
14
  var _ConfigContext = require("../../contexts/ConfigContext");
13
15
  var _ApiContext = require("../../contexts/ApiContext");
@@ -38,6 +40,7 @@ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r)
38
40
  function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
39
41
  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; } }
40
42
  function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
43
+ _dayjs.default.extend(_utc.default);
41
44
  var ProductForm = exports.ProductForm = function ProductForm(props) {
42
45
  var _props$product, _props$productCart, _orderState$carts, _product$product, _product$product2, _product$product3, _product$product4;
43
46
  var UIComponent = props.UIComponent,
@@ -400,13 +403,15 @@ var ProductForm = exports.ProductForm = function ProductForm(props) {
400
403
  return _ref.apply(this, arguments);
401
404
  };
402
405
  }();
403
-
406
+ var isValidMoment = function isValidMoment(date, format) {
407
+ return _dayjs.default.utc(date, format).format(format) === date;
408
+ };
404
409
  /**
405
410
  * Load product from API
406
411
  */
407
412
  var loadProductWithOptions = /*#__PURE__*/function () {
408
413
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
409
- var _orderState$options, source, parameters, _yield$ordering$busin, _yield$ordering$busin2, result, error;
414
+ var _orderState$options, _orderState$options2, _orderState$options3, source, parameters, _orderState$options4, _moment, _yield$ordering$busin, _yield$ordering$busin2, result, error;
410
415
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
411
416
  while (1) switch (_context2.prev = _context2.next) {
412
417
  case 0:
@@ -420,17 +425,21 @@ var ProductForm = exports.ProductForm = function ProductForm(props) {
420
425
  version: 'v2',
421
426
  type: ((_orderState$options = orderState.options) === null || _orderState$options === void 0 ? void 0 : _orderState$options.type) || 1
422
427
  };
423
- _context2.next = 7;
428
+ if ((_orderState$options2 = orderState.options) !== null && _orderState$options2 !== void 0 && _orderState$options2.moment && isValidMoment((_orderState$options3 = orderState.options) === null || _orderState$options3 === void 0 ? void 0 : _orderState$options3.moment, 'YYYY-MM-DD HH:mm:ss')) {
429
+ _moment = _dayjs.default.utc((_orderState$options4 = orderState.options) === null || _orderState$options4 === void 0 ? void 0 : _orderState$options4.moment, 'YYYY-MM-DD HH:mm:ss').local().unix();
430
+ parameters.timestamp = _moment;
431
+ }
432
+ _context2.next = 8;
424
433
  return ordering.businesses(props.businessId).categories(props.categoryId).products(props.productId).parameters(parameters).get({
425
434
  cancelToken: source
426
435
  });
427
- case 7:
436
+ case 8:
428
437
  _yield$ordering$busin = _context2.sent;
429
438
  _yield$ordering$busin2 = _yield$ordering$busin.content;
430
439
  result = _yield$ordering$busin2.result;
431
440
  error = _yield$ordering$busin2.error;
432
441
  if (error) {
433
- _context2.next = 14;
442
+ _context2.next = 15;
434
443
  break;
435
444
  }
436
445
  setProduct(_objectSpread(_objectSpread({}, product), {}, {
@@ -438,25 +447,25 @@ var ProductForm = exports.ProductForm = function ProductForm(props) {
438
447
  product: result
439
448
  }));
440
449
  return _context2.abrupt("return");
441
- case 14:
450
+ case 15:
442
451
  setProduct(_objectSpread(_objectSpread({}, product), {}, {
443
452
  loading: false,
444
453
  error: [result]
445
454
  }));
446
- _context2.next = 20;
455
+ _context2.next = 21;
447
456
  break;
448
- case 17:
449
- _context2.prev = 17;
457
+ case 18:
458
+ _context2.prev = 18;
450
459
  _context2.t0 = _context2["catch"](0);
451
460
  setProduct(_objectSpread(_objectSpread({}, product), {}, {
452
461
  loading: false,
453
462
  error: [_context2.t0.message]
454
463
  }));
455
- case 20:
464
+ case 21:
456
465
  case "end":
457
466
  return _context2.stop();
458
467
  }
459
- }, _callee2, null, [[0, 17]]);
468
+ }, _callee2, null, [[0, 18]]);
460
469
  }));
461
470
  return function loadProductWithOptions() {
462
471
  return _ref2.apply(this, arguments);
@@ -809,7 +818,7 @@ var ProductForm = exports.ProductForm = function ProductForm(props) {
809
818
  */
810
819
  var handleSave = /*#__PURE__*/function () {
811
820
  var _ref4 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(values) {
812
- var _JSON$parse, _product$product9, _cart$metafields, _cart$metafields$find, _errors, isMultiProduct, hasAlreadyCoupon, successful, _values$professional, _values$serviceTime, _orderState$options2, _props$productCart6, _props$productCart7, changes, currentProduct, _product$product0, updatedProfessional, duration, _props$productCart8, _props$productCart9;
821
+ var _JSON$parse, _product$product9, _cart$metafields, _cart$metafields$find, _errors, isMultiProduct, hasAlreadyCoupon, successful, _values$professional, _values$serviceTime, _orderState$options5, _props$productCart6, _props$productCart7, changes, currentProduct, _product$product0, updatedProfessional, duration, _props$productCart8, _props$productCart9;
813
822
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
814
823
  while (1) switch (_context3.prev = _context3.next) {
815
824
  case 0:
@@ -838,7 +847,7 @@ var ProductForm = exports.ProductForm = function ProductForm(props) {
838
847
  };
839
848
  currentProduct = !isService ? _objectSpread({}, productCart) : _objectSpread(_objectSpread({}, productCart), {}, {
840
849
  professional_id: values === null || values === void 0 || (_values$professional = values.professional) === null || _values$professional === void 0 ? void 0 : _values$professional.id,
841
- service_start: (_values$serviceTime = values === null || values === void 0 ? void 0 : values.serviceTime) !== null && _values$serviceTime !== void 0 ? _values$serviceTime : (_orderState$options2 = orderState.options) === null || _orderState$options2 === void 0 ? void 0 : _orderState$options2.moment
850
+ service_start: (_values$serviceTime = values === null || values === void 0 ? void 0 : values.serviceTime) !== null && _values$serviceTime !== void 0 ? _values$serviceTime : (_orderState$options5 = orderState.options) === null || _orderState$options5 === void 0 ? void 0 : _orderState$options5.moment
842
851
  });
843
852
  onSave(productCart, !((_props$productCart6 = props.productCart) !== null && _props$productCart6 !== void 0 && _props$productCart6.code));
844
853
  if ((_props$productCart7 = props.productCart) !== null && _props$productCart7 !== void 0 && _props$productCart7.code) {
@@ -879,7 +888,7 @@ var ProductForm = exports.ProductForm = function ProductForm(props) {
879
888
  duration = product === null || product === void 0 || (_product$product0 = product.product) === null || _product$product0 === void 0 ? void 0 : _product$product0.duration;
880
889
  updatedProfessional.busy_times.push({
881
890
  start: values === null || values === void 0 ? void 0 : values.serviceTime,
882
- end: (0, _moment.default)(values === null || values === void 0 ? void 0 : values.serviceTime).add(duration, 'minutes').format('YYYY-MM-DD HH:mm:ss'),
891
+ end: (0, _moment2.default)(values === null || values === void 0 ? void 0 : values.serviceTime).add(duration, 'minutes').format('YYYY-MM-DD HH:mm:ss'),
883
892
  duration: duration
884
893
  });
885
894
  handleUpdateProfessionals && handleUpdateProfessionals(updatedProfessional);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ordering-components-external",
3
- "version": "13.2.27",
3
+ "version": "13.2.28",
4
4
  "description": "Ordering Internal Dashboard",
5
5
  "main": "./_modules/index.js",
6
6
  "scripts": {
@@ -1,6 +1,8 @@
1
1
  import React, { useState, useEffect } from 'react'
2
2
  import PropTypes from 'prop-types'
3
3
  import moment from 'moment'
4
+ import dayjs from 'dayjs'
5
+ import utc from 'dayjs/plugin/utc'
4
6
  import { useOrder } from '../../contexts/OrderContext'
5
7
  import { useConfig } from '../../contexts/ConfigContext'
6
8
  import { useApi } from '../../contexts/ApiContext'
@@ -10,6 +12,8 @@ import { ToastType, useToast } from '../../contexts/ToastContext'
10
12
  import { useLanguage } from '../../contexts/LanguageContext'
11
13
  import { useWebsocket } from '../../contexts/WebsocketContext'
12
14
 
15
+ dayjs.extend(utc)
16
+
13
17
  export const ProductForm = (props) => {
14
18
  const {
15
19
  UIComponent,
@@ -265,6 +269,7 @@ export const ProductForm = (props) => {
265
269
  }
266
270
  }
267
271
 
272
+ const isValidMoment = (date, format) => dayjs.utc(date, format).format(format) === date
268
273
  /**
269
274
  * Load product from API
270
275
  */
@@ -277,6 +282,10 @@ export const ProductForm = (props) => {
277
282
  version: 'v2',
278
283
  type: orderState.options?.type || 1
279
284
  }
285
+ if (orderState.options?.moment && isValidMoment(orderState.options?.moment, 'YYYY-MM-DD HH:mm:ss')) {
286
+ const moment = dayjs.utc(orderState.options?.moment, 'YYYY-MM-DD HH:mm:ss').local().unix()
287
+ parameters.timestamp = moment
288
+ }
280
289
  const { content: { result, error } } = await ordering
281
290
  .businesses(props.businessId)
282
291
  .categories(props.categoryId)