@open-tender/utils 0.0.28 → 0.0.30

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.
@@ -215,7 +215,7 @@ const calcPrices = (item) => {
215
215
  const groups = (_a = item.groups) === null || _a === void 0 ? void 0 : _a.map(g => {
216
216
  var _a;
217
217
  let groupQuantity = 0;
218
- const options = (_a = g.options) === null || _a === void 0 ? void 0 : _a.map(o => {
218
+ const options = (_a = g === null || g === void 0 ? void 0 : g.options) === null || _a === void 0 ? void 0 : _a.map(o => {
219
219
  var _a, _b, _c, _d, _e;
220
220
  const includedRemaining = Math.max(((_a = g.included) !== null && _a !== void 0 ? _a : 0) - groupQuantity, 0);
221
221
  const priceQuantity = Math.max(((_b = o.quantity) !== null && _b !== void 0 ? _b : 0) - includedRemaining, 0);
@@ -438,19 +438,18 @@ const makeItemSignature = (item) => {
438
438
  };
439
439
  exports.makeItemSignature = makeItemSignature;
440
440
  const makeCartItemSignature = (item) => {
441
- const optionIds = !item.groups
442
- ? []
443
- : item.groups
444
- .reduce((arr, group) => {
445
- var _a;
446
- const ids = (_a = group.options) === null || _a === void 0 ? void 0 : _a.filter(o => { var _a; return ((_a = o.quantity) !== null && _a !== void 0 ? _a : 0) > 0; }).reduce((optionsArr, o) => {
447
- const optionArr = new Array(o.quantity);
448
- optionArr.fill(o.id);
449
- return [...optionsArr, ...optionArr];
450
- }, []);
451
- return [...arr, ...(ids !== null && ids !== void 0 ? ids : [])];
452
- }, [])
453
- .sort((a, b) => a - b);
441
+ var _a;
442
+ const optionIds = ((_a = item.groups) !== null && _a !== void 0 ? _a : [])
443
+ .reduce((arr, group) => {
444
+ var _a;
445
+ const ids = (_a = group === null || group === void 0 ? void 0 : group.options) === null || _a === void 0 ? void 0 : _a.filter(o => { var _a; return ((_a = o.quantity) !== null && _a !== void 0 ? _a : 0) > 0; }).reduce((optionsArr, o) => {
446
+ const optionArr = new Array(o.quantity);
447
+ optionArr.fill(o.id);
448
+ return [...optionsArr, ...optionArr];
449
+ }, []);
450
+ return [...arr, ...(ids !== null && ids !== void 0 ? ids : [])];
451
+ }, [])
452
+ .sort((a, b) => a - b);
454
453
  const itemIds = [item.id, ...optionIds].join('.');
455
454
  const signature = `${itemIds}.${item.madeFor}.${item.notes}`;
456
455
  return signature;
@@ -609,7 +609,7 @@ const getFirstTime = (settings, serviceType, tz) => {
609
609
  };
610
610
  exports.getFirstTime = getFirstTime;
611
611
  const makeGroupOrderTime = (revenueCenter, serviceType, requestedAt) => {
612
- const { timezone } = revenueCenter;
612
+ const { timezone } = revenueCenter || {};
613
613
  const settings = revenueCenter.settings || revenueCenter;
614
614
  const tz = exports.timezoneMap[timezone !== null && timezone !== void 0 ? timezone : 'US/Eastern'];
615
615
  const { first_times, order_times, wait_times, group_ordering } = settings;
@@ -199,7 +199,7 @@ export const calcPrices = (item) => {
199
199
  const groups = (_a = item.groups) === null || _a === void 0 ? void 0 : _a.map(g => {
200
200
  var _a;
201
201
  let groupQuantity = 0;
202
- const options = (_a = g.options) === null || _a === void 0 ? void 0 : _a.map(o => {
202
+ const options = (_a = g === null || g === void 0 ? void 0 : g.options) === null || _a === void 0 ? void 0 : _a.map(o => {
203
203
  var _a, _b, _c, _d, _e;
204
204
  const includedRemaining = Math.max(((_a = g.included) !== null && _a !== void 0 ? _a : 0) - groupQuantity, 0);
205
205
  const priceQuantity = Math.max(((_b = o.quantity) !== null && _b !== void 0 ? _b : 0) - includedRemaining, 0);
@@ -413,19 +413,18 @@ export const makeItemSignature = (item) => {
413
413
  return [item.id, ...optionIds].join('.');
414
414
  };
415
415
  export const makeCartItemSignature = (item) => {
416
- const optionIds = !item.groups
417
- ? []
418
- : item.groups
419
- .reduce((arr, group) => {
420
- var _a;
421
- const ids = (_a = group.options) === null || _a === void 0 ? void 0 : _a.filter(o => { var _a; return ((_a = o.quantity) !== null && _a !== void 0 ? _a : 0) > 0; }).reduce((optionsArr, o) => {
422
- const optionArr = new Array(o.quantity);
423
- optionArr.fill(o.id);
424
- return [...optionsArr, ...optionArr];
425
- }, []);
426
- return [...arr, ...(ids !== null && ids !== void 0 ? ids : [])];
427
- }, [])
428
- .sort((a, b) => a - b);
416
+ var _a;
417
+ const optionIds = ((_a = item.groups) !== null && _a !== void 0 ? _a : [])
418
+ .reduce((arr, group) => {
419
+ var _a;
420
+ const ids = (_a = group === null || group === void 0 ? void 0 : group.options) === null || _a === void 0 ? void 0 : _a.filter(o => { var _a; return ((_a = o.quantity) !== null && _a !== void 0 ? _a : 0) > 0; }).reduce((optionsArr, o) => {
421
+ const optionArr = new Array(o.quantity);
422
+ optionArr.fill(o.id);
423
+ return [...optionsArr, ...optionArr];
424
+ }, []);
425
+ return [...arr, ...(ids !== null && ids !== void 0 ? ids : [])];
426
+ }, [])
427
+ .sort((a, b) => a - b);
429
428
  const itemIds = [item.id, ...optionIds].join('.');
430
429
  const signature = `${itemIds}.${item.madeFor}.${item.notes}`;
431
430
  return signature;
@@ -542,7 +542,7 @@ export const getFirstTime = (settings, serviceType, tz) => {
542
542
  return first_times[st];
543
543
  };
544
544
  export const makeGroupOrderTime = (revenueCenter, serviceType, requestedAt) => {
545
- const { timezone } = revenueCenter;
545
+ const { timezone } = revenueCenter || {};
546
546
  const settings = revenueCenter.settings || revenueCenter;
547
547
  const tz = timezoneMap[timezone !== null && timezone !== void 0 ? timezone : 'US/Eastern'];
548
548
  const { first_times, order_times, wait_times, group_ordering } = settings;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-tender/utils",
3
- "version": "0.0.28",
3
+ "version": "0.0.30",
4
4
  "description": "A library of utils for use with Open Tender applications that utilize our cloud-based Order API.",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "module": "./dist/esm/index.js",