@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({},
|
|
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 }));
|
package/dist/cjs/utils/cart.d.ts
CHANGED
package/dist/cjs/utils/cart.js
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
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({},
|
|
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 }));
|
package/dist/esm/utils/cart.d.ts
CHANGED
package/dist/esm/utils/cart.js
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
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