@open-tender/utils 0.0.10 → 0.0.11

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.
@@ -93,6 +93,7 @@ export declare const calcPrices: (item: Partial<CartItem>) => {
93
93
  signature?: string | undefined;
94
94
  isDefault?: number | boolean | undefined;
95
95
  isSoldOut?: boolean | undefined;
96
+ favorite?: import("@open-tender/types").Favorite | undefined;
96
97
  };
97
98
  export declare const makeOrderItem: (item: MenuItem, isEdit?: boolean, soldOut?: Array<SoldOut>, simpleItem?: Partial<CartItem>, hasPoints?: boolean) => {
98
99
  groups: {
@@ -172,6 +173,7 @@ export declare const makeOrderItem: (item: MenuItem, isEdit?: boolean, soldOut?:
172
173
  signature?: string | undefined;
173
174
  isDefault?: number | boolean | undefined;
174
175
  isSoldOut?: boolean | undefined;
176
+ favorite?: import("@open-tender/types").Favorite | undefined;
175
177
  };
176
178
  export declare const rehydrateOrderItem: (menuItem: MenuItem, simpleCartItem: Partial<CartItem>) => Partial<CartItem>;
177
179
  export declare const rehydrateCart: (menuItems: MenuItems, simpleCartItems: Array<Partial<CartItem>>) => {
@@ -216,6 +218,7 @@ export declare const rehydrateCart: (menuItems: MenuItems, simpleCartItems: Arra
216
218
  signature?: string | undefined;
217
219
  isDefault?: number | boolean | undefined;
218
220
  isSoldOut?: boolean | undefined;
221
+ favorite?: import("@open-tender/types").Favorite | undefined;
219
222
  }[];
220
223
  cartCounts: any;
221
224
  };
@@ -285,6 +288,7 @@ export declare const combineCarts: (cart: Cart, guestCart: Array<GuestItem>, car
285
288
  signature?: string | undefined;
286
289
  isDefault?: number | boolean | undefined;
287
290
  isSoldOut?: boolean | undefined;
291
+ favorite?: import("@open-tender/types").Favorite | undefined;
288
292
  } | {
289
293
  madeFor: string;
290
294
  cart_guest_id?: number | null | undefined;
@@ -321,12 +325,12 @@ export declare const decrementItem: (cart: Cart, index: number) => {
321
325
  };
322
326
  export declare const makeSimpleCart: (cart: OrderCart) => {
323
327
  id: number;
324
- quantity: number;
328
+ quantity: number | undefined;
325
329
  groups: {
326
330
  id: number | undefined;
327
331
  options: {
328
332
  id: number;
329
- quantity: number;
333
+ quantity: number | undefined;
330
334
  }[];
331
335
  }[] | undefined;
332
336
  made_for: string;
@@ -411,6 +415,7 @@ export declare const validateCart: (cart: OrderCart, categories: MenuCategories,
411
415
  signature?: string | undefined;
412
416
  isDefault?: number | boolean | undefined;
413
417
  isSoldOut?: boolean | undefined;
418
+ favorite?: import("@open-tender/types").Favorite | undefined;
414
419
  } | null)[];
415
420
  errors: {
416
421
  missingItems: OrderItem[];
@@ -672,7 +672,7 @@ const validateCart = (cart, categories, soldOut) => {
672
672
  const missingItems = [];
673
673
  const invalidItems = [];
674
674
  let newCart = cart.map(oldItem => {
675
- var _a, _b;
675
+ var _a, _b, _c, _d;
676
676
  const newItem = itemLookup[oldItem.id];
677
677
  if (!newItem || soldOut.includes(oldItem.id)) {
678
678
  missingItems.push(oldItem);
@@ -753,8 +753,8 @@ const validateCart = (cart, categories, soldOut) => {
753
753
  else {
754
754
  // check to see if this item's quantity is below the min or
755
755
  // above the max from the current menu
756
- if ((newItem.max && oldItem.quantity > newItem.max) ||
757
- (newItem.min && oldItem.quantity < newItem.min)) {
756
+ if ((newItem.max && ((_c = oldItem.quantity) !== null && _c !== void 0 ? _c : 0) > newItem.max) ||
757
+ (newItem.min && ((_d = oldItem.quantity) !== null && _d !== void 0 ? _d : 0) < newItem.min)) {
758
758
  invalidItems.push(oldItem);
759
759
  return null;
760
760
  }
@@ -71,14 +71,14 @@ const makeNetOrder = (order, refunds) => {
71
71
  refunds.forEach(refund => {
72
72
  const lookup = (0, exports.makeRefundLookup)(refund);
73
73
  copy.cart.forEach((i) => {
74
- var _a, _b, _c, _d;
74
+ var _a, _b, _c, _d, _e;
75
75
  const item = lookup.cart[(_a = i.line_no) !== null && _a !== void 0 ? _a : 0];
76
76
  if (item) {
77
- i.quantity -= (_b = item.quantity) !== null && _b !== void 0 ? _b : 0;
78
- i.price_total = adjustAmount(i.price_total, (_c = item.price_total) !== null && _c !== void 0 ? _c : '0.0');
77
+ i.quantity = (_c = ((_b = i.quantity) !== null && _b !== void 0 ? _b : 0) - item.quantity) !== null && _c !== void 0 ? _c : 0;
78
+ i.price_total = adjustAmount(i.price_total, (_d = item.price_total) !== null && _d !== void 0 ? _d : '0.0');
79
79
  }
80
80
  if (i.quantity === 0) {
81
- (_d = i.groups) === null || _d === void 0 ? void 0 : _d.forEach(group => group.options.forEach(option => {
81
+ (_e = i.groups) === null || _e === void 0 ? void 0 : _e.forEach(group => group.options.forEach(option => {
82
82
  option.quantity = 0;
83
83
  option.price_total = '0.00';
84
84
  }));
@@ -93,6 +93,7 @@ export declare const calcPrices: (item: Partial<CartItem>) => {
93
93
  signature?: string | undefined;
94
94
  isDefault?: number | boolean | undefined;
95
95
  isSoldOut?: boolean | undefined;
96
+ favorite?: import("@open-tender/types").Favorite | undefined;
96
97
  };
97
98
  export declare const makeOrderItem: (item: MenuItem, isEdit?: boolean, soldOut?: Array<SoldOut>, simpleItem?: Partial<CartItem>, hasPoints?: boolean) => {
98
99
  groups: {
@@ -172,6 +173,7 @@ export declare const makeOrderItem: (item: MenuItem, isEdit?: boolean, soldOut?:
172
173
  signature?: string | undefined;
173
174
  isDefault?: number | boolean | undefined;
174
175
  isSoldOut?: boolean | undefined;
176
+ favorite?: import("@open-tender/types").Favorite | undefined;
175
177
  };
176
178
  export declare const rehydrateOrderItem: (menuItem: MenuItem, simpleCartItem: Partial<CartItem>) => Partial<CartItem>;
177
179
  export declare const rehydrateCart: (menuItems: MenuItems, simpleCartItems: Array<Partial<CartItem>>) => {
@@ -216,6 +218,7 @@ export declare const rehydrateCart: (menuItems: MenuItems, simpleCartItems: Arra
216
218
  signature?: string | undefined;
217
219
  isDefault?: number | boolean | undefined;
218
220
  isSoldOut?: boolean | undefined;
221
+ favorite?: import("@open-tender/types").Favorite | undefined;
219
222
  }[];
220
223
  cartCounts: any;
221
224
  };
@@ -285,6 +288,7 @@ export declare const combineCarts: (cart: Cart, guestCart: Array<GuestItem>, car
285
288
  signature?: string | undefined;
286
289
  isDefault?: number | boolean | undefined;
287
290
  isSoldOut?: boolean | undefined;
291
+ favorite?: import("@open-tender/types").Favorite | undefined;
288
292
  } | {
289
293
  madeFor: string;
290
294
  cart_guest_id?: number | null | undefined;
@@ -321,12 +325,12 @@ export declare const decrementItem: (cart: Cart, index: number) => {
321
325
  };
322
326
  export declare const makeSimpleCart: (cart: OrderCart) => {
323
327
  id: number;
324
- quantity: number;
328
+ quantity: number | undefined;
325
329
  groups: {
326
330
  id: number | undefined;
327
331
  options: {
328
332
  id: number;
329
- quantity: number;
333
+ quantity: number | undefined;
330
334
  }[];
331
335
  }[] | undefined;
332
336
  made_for: string;
@@ -411,6 +415,7 @@ export declare const validateCart: (cart: OrderCart, categories: MenuCategories,
411
415
  signature?: string | undefined;
412
416
  isDefault?: number | boolean | undefined;
413
417
  isSoldOut?: boolean | undefined;
418
+ favorite?: import("@open-tender/types").Favorite | undefined;
414
419
  } | null)[];
415
420
  errors: {
416
421
  missingItems: OrderItem[];
@@ -633,7 +633,7 @@ export const validateCart = (cart, categories, soldOut) => {
633
633
  const missingItems = [];
634
634
  const invalidItems = [];
635
635
  let newCart = cart.map(oldItem => {
636
- var _a, _b;
636
+ var _a, _b, _c, _d;
637
637
  const newItem = itemLookup[oldItem.id];
638
638
  if (!newItem || soldOut.includes(oldItem.id)) {
639
639
  missingItems.push(oldItem);
@@ -714,8 +714,8 @@ export const validateCart = (cart, categories, soldOut) => {
714
714
  else {
715
715
  // check to see if this item's quantity is below the min or
716
716
  // above the max from the current menu
717
- if ((newItem.max && oldItem.quantity > newItem.max) ||
718
- (newItem.min && oldItem.quantity < newItem.min)) {
717
+ if ((newItem.max && ((_c = oldItem.quantity) !== null && _c !== void 0 ? _c : 0) > newItem.max) ||
718
+ (newItem.min && ((_d = oldItem.quantity) !== null && _d !== void 0 ? _d : 0) < newItem.min)) {
719
719
  invalidItems.push(oldItem);
720
720
  return null;
721
721
  }
@@ -64,14 +64,14 @@ export const makeNetOrder = (order, refunds) => {
64
64
  refunds.forEach(refund => {
65
65
  const lookup = makeRefundLookup(refund);
66
66
  copy.cart.forEach((i) => {
67
- var _a, _b, _c, _d;
67
+ var _a, _b, _c, _d, _e;
68
68
  const item = lookup.cart[(_a = i.line_no) !== null && _a !== void 0 ? _a : 0];
69
69
  if (item) {
70
- i.quantity -= (_b = item.quantity) !== null && _b !== void 0 ? _b : 0;
71
- i.price_total = adjustAmount(i.price_total, (_c = item.price_total) !== null && _c !== void 0 ? _c : '0.0');
70
+ i.quantity = (_c = ((_b = i.quantity) !== null && _b !== void 0 ? _b : 0) - item.quantity) !== null && _c !== void 0 ? _c : 0;
71
+ i.price_total = adjustAmount(i.price_total, (_d = item.price_total) !== null && _d !== void 0 ? _d : '0.0');
72
72
  }
73
73
  if (i.quantity === 0) {
74
- (_d = i.groups) === null || _d === void 0 ? void 0 : _d.forEach(group => group.options.forEach(option => {
74
+ (_e = i.groups) === null || _e === void 0 ? void 0 : _e.forEach(group => group.options.forEach(option => {
75
75
  option.quantity = 0;
76
76
  option.price_total = '0.00';
77
77
  }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-tender/utils",
3
- "version": "0.0.10",
3
+ "version": "0.0.11",
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",
@@ -57,7 +57,7 @@
57
57
  "react": "^18.2.0"
58
58
  },
59
59
  "dependencies": {
60
- "@open-tender/types": "^0.0.46",
60
+ "@open-tender/types": "^0.0.62",
61
61
  "date-fns": "^2.29.3",
62
62
  "date-fns-tz": "^1.3.7",
63
63
  "react-native-responsive-screen": "^1.4.2",