@open-tender/utils 0.5.55 → 0.5.57

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.
@@ -28,7 +28,7 @@ const useBuilder = (orderItem, orderTimeoutCallback) => {
28
28
  setItem(Object.assign(Object.assign({}, item), { madeFor }));
29
29
  };
30
30
  const setNotes = (notes) => {
31
- setItem(Object.assign(Object.assign({}, item), { notes }));
31
+ setItem(prevItem => (Object.assign(Object.assign({}, prevItem), { notes })));
32
32
  };
33
33
  const setMadeForNotes = (madeFor, notes) => {
34
34
  setItem(Object.assign(Object.assign({}, item), { madeFor, notes }));
@@ -200,7 +200,6 @@ export declare const makeSimpleCart: <C extends {
200
200
  }, K extends {
201
201
  id: number;
202
202
  quantity: number;
203
- pos_ext_id?: string | null | undefined;
204
203
  groups: T[];
205
204
  }>(cart: C) => {
206
205
  id: number;
@@ -362,13 +362,7 @@ const rehydrateGroups = (groups, groupsLookup) => {
362
362
  const simpleGroup = groupsLookup[group.id];
363
363
  if (simpleGroup) {
364
364
  group.options.forEach(option => {
365
- let simpleOption = simpleGroup.options[option.id];
366
- if (!simpleOption && option.pos_ext_id) {
367
- const matchingOption = Object.values(simpleGroup.options).find(o => o.pos_ext_id === option.pos_ext_id);
368
- if (matchingOption) {
369
- simpleOption = matchingOption;
370
- }
371
- }
365
+ const simpleOption = simpleGroup.options[option.id];
372
366
  if (simpleOption) {
373
367
  option.quantity = simpleOption.quantity;
374
368
  option.groups = rehydrateGroups(option.groups, simpleOption.groupsLookup);
@@ -400,7 +394,6 @@ const rehydrateCart = (menuItems, simpleCartItems, soldOut = []) => {
400
394
  });
401
395
  const cart = orderItems.map((i, index) => (Object.assign(Object.assign({}, i), { index })));
402
396
  const cartCounts = (0, exports.calcCartCounts)(cart);
403
- console.log('rehydrated cart', cart);
404
397
  return { cart, cartCounts };
405
398
  };
406
399
  exports.rehydrateCart = rehydrateCart;
@@ -681,7 +674,6 @@ const makeSimpleGroups = (groups) => {
681
674
  .map(o => ({
682
675
  id: o.id,
683
676
  quantity: o.quantity,
684
- pos_ext_id: o.pos_ext_id,
685
677
  groups: makeSimpleGroups(o.groups || [])
686
678
  }));
687
679
  return { id: g.id, options: options };
@@ -779,15 +771,7 @@ const validateCart = (cart, categories, soldOut, requestedAt) => {
779
771
  }
780
772
  else {
781
773
  const updatedOptions = group.options.map(option => {
782
- let newOption = newGroup.options[option.id];
783
- if (!newOption) {
784
- console.log('checking pos_ext_id for option match');
785
- const allOptions = Object.values(newGroup.options);
786
- const matchingOption = allOptions.find(o => o.pos_ext_id === option.pos_ext_id);
787
- console.log(allOptions, option, matchingOption);
788
- if (matchingOption)
789
- newOption = matchingOption;
790
- }
774
+ const newOption = newGroup.options[option.id];
791
775
  // check to see if any OLD options aren't avaiilable on the current menu
792
776
  // or if any of the options are currently sold out
793
777
  if (!newOption ||
@@ -25,7 +25,7 @@ export const useBuilder = (orderItem, orderTimeoutCallback) => {
25
25
  setItem(Object.assign(Object.assign({}, item), { madeFor }));
26
26
  };
27
27
  const setNotes = (notes) => {
28
- setItem(Object.assign(Object.assign({}, item), { notes }));
28
+ setItem(prevItem => (Object.assign(Object.assign({}, prevItem), { notes })));
29
29
  };
30
30
  const setMadeForNotes = (madeFor, notes) => {
31
31
  setItem(Object.assign(Object.assign({}, item), { madeFor, notes }));
@@ -200,7 +200,6 @@ export declare const makeSimpleCart: <C extends {
200
200
  }, K extends {
201
201
  id: number;
202
202
  quantity: number;
203
- pos_ext_id?: string | null | undefined;
204
203
  groups: T[];
205
204
  }>(cart: C) => {
206
205
  id: number;
@@ -345,13 +345,7 @@ const rehydrateGroups = (groups, groupsLookup) => {
345
345
  const simpleGroup = groupsLookup[group.id];
346
346
  if (simpleGroup) {
347
347
  group.options.forEach(option => {
348
- let simpleOption = simpleGroup.options[option.id];
349
- if (!simpleOption && option.pos_ext_id) {
350
- const matchingOption = Object.values(simpleGroup.options).find(o => o.pos_ext_id === option.pos_ext_id);
351
- if (matchingOption) {
352
- simpleOption = matchingOption;
353
- }
354
- }
348
+ const simpleOption = simpleGroup.options[option.id];
355
349
  if (simpleOption) {
356
350
  option.quantity = simpleOption.quantity;
357
351
  option.groups = rehydrateGroups(option.groups, simpleOption.groupsLookup);
@@ -382,7 +376,6 @@ export const rehydrateCart = (menuItems, simpleCartItems, soldOut = []) => {
382
376
  });
383
377
  const cart = orderItems.map((i, index) => (Object.assign(Object.assign({}, i), { index })));
384
378
  const cartCounts = calcCartCounts(cart);
385
- console.log('rehydrated cart', cart);
386
379
  return { cart, cartCounts };
387
380
  };
388
381
  // TODO: maybe refactor
@@ -646,7 +639,6 @@ const makeSimpleGroups = (groups) => {
646
639
  .map(o => ({
647
640
  id: o.id,
648
641
  quantity: o.quantity,
649
- pos_ext_id: o.pos_ext_id,
650
642
  groups: makeSimpleGroups(o.groups || [])
651
643
  }));
652
644
  return { id: g.id, options: options };
@@ -743,15 +735,7 @@ export const validateCart = (cart, categories, soldOut, requestedAt) => {
743
735
  }
744
736
  else {
745
737
  const updatedOptions = group.options.map(option => {
746
- let newOption = newGroup.options[option.id];
747
- if (!newOption) {
748
- console.log('checking pos_ext_id for option match');
749
- const allOptions = Object.values(newGroup.options);
750
- const matchingOption = allOptions.find(o => o.pos_ext_id === option.pos_ext_id);
751
- console.log(allOptions, option, matchingOption);
752
- if (matchingOption)
753
- newOption = matchingOption;
754
- }
738
+ const newOption = newGroup.options[option.id];
755
739
  // check to see if any OLD options aren't avaiilable on the current menu
756
740
  // or if any of the options are currently sold out
757
741
  if (!newOption ||
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-tender/utils",
3
- "version": "0.5.55",
3
+ "version": "0.5.57",
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",