@open-tender/utils 0.5.56 → 0.5.58
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);
|
|
@@ -382,7 +376,6 @@ const rehydrateOrderItem = (menuItem, simpleCartItem, soldOut = [], requestedAt
|
|
|
382
376
|
const orderItem = (0, exports.makeOrderItem)(menuItem, true, soldOut, simpleCartItem, undefined, requestedAt);
|
|
383
377
|
orderItem.quantity = simpleCartItem.quantity || 1;
|
|
384
378
|
const groupsLookup = makeSimpleGroupsLookup(simpleCartItem.groups);
|
|
385
|
-
console.log('groupsLookup', simpleCartItem.groups, groupsLookup);
|
|
386
379
|
if (groupsLookup) {
|
|
387
380
|
orderItem.groups = rehydrateGroups(orderItem.groups, groupsLookup);
|
|
388
381
|
}
|
|
@@ -401,7 +394,6 @@ const rehydrateCart = (menuItems, simpleCartItems, soldOut = []) => {
|
|
|
401
394
|
});
|
|
402
395
|
const cart = orderItems.map((i, index) => (Object.assign(Object.assign({}, i), { index })));
|
|
403
396
|
const cartCounts = (0, exports.calcCartCounts)(cart);
|
|
404
|
-
console.log('rehydrated cart', cart);
|
|
405
397
|
return { cart, cartCounts };
|
|
406
398
|
};
|
|
407
399
|
exports.rehydrateCart = rehydrateCart;
|
|
@@ -682,7 +674,6 @@ const makeSimpleGroups = (groups) => {
|
|
|
682
674
|
.map(o => ({
|
|
683
675
|
id: o.id,
|
|
684
676
|
quantity: o.quantity,
|
|
685
|
-
pos_ext_id: o.pos_ext_id,
|
|
686
677
|
groups: makeSimpleGroups(o.groups || [])
|
|
687
678
|
}));
|
|
688
679
|
return { id: g.id, options: options };
|
|
@@ -780,15 +771,7 @@ const validateCart = (cart, categories, soldOut, requestedAt) => {
|
|
|
780
771
|
}
|
|
781
772
|
else {
|
|
782
773
|
const updatedOptions = group.options.map(option => {
|
|
783
|
-
|
|
784
|
-
if (!newOption) {
|
|
785
|
-
console.log('checking pos_ext_id for option match');
|
|
786
|
-
const allOptions = Object.values(newGroup.options);
|
|
787
|
-
const matchingOption = allOptions.find(o => o.pos_ext_id === option.pos_ext_id);
|
|
788
|
-
console.log(allOptions, option, matchingOption);
|
|
789
|
-
if (matchingOption)
|
|
790
|
-
newOption = matchingOption;
|
|
791
|
-
}
|
|
774
|
+
const newOption = newGroup.options[option.id];
|
|
792
775
|
// check to see if any OLD options aren't avaiilable on the current menu
|
|
793
776
|
// or if any of the options are currently sold out
|
|
794
777
|
if (!newOption ||
|
|
@@ -802,6 +785,12 @@ const validateCart = (cart, categories, soldOut, requestedAt) => {
|
|
|
802
785
|
// ignore the option increment setting for the time being
|
|
803
786
|
if ((newOption.max && option.quantity > newOption.max) ||
|
|
804
787
|
(newOption.min && option.quantity < newOption.min)) {
|
|
788
|
+
console.log('[validateCart] Option mismatch details:', {
|
|
789
|
+
oldOption: option,
|
|
790
|
+
newOption,
|
|
791
|
+
soldOut,
|
|
792
|
+
requestedAt
|
|
793
|
+
});
|
|
805
794
|
invalidOptions.push(option);
|
|
806
795
|
return option;
|
|
807
796
|
}
|
|
@@ -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);
|
|
@@ -365,7 +359,6 @@ export const rehydrateOrderItem = (menuItem, simpleCartItem, soldOut = [], reque
|
|
|
365
359
|
const orderItem = makeOrderItem(menuItem, true, soldOut, simpleCartItem, undefined, requestedAt);
|
|
366
360
|
orderItem.quantity = simpleCartItem.quantity || 1;
|
|
367
361
|
const groupsLookup = makeSimpleGroupsLookup(simpleCartItem.groups);
|
|
368
|
-
console.log('groupsLookup', simpleCartItem.groups, groupsLookup);
|
|
369
362
|
if (groupsLookup) {
|
|
370
363
|
orderItem.groups = rehydrateGroups(orderItem.groups, groupsLookup);
|
|
371
364
|
}
|
|
@@ -383,7 +376,6 @@ export const rehydrateCart = (menuItems, simpleCartItems, soldOut = []) => {
|
|
|
383
376
|
});
|
|
384
377
|
const cart = orderItems.map((i, index) => (Object.assign(Object.assign({}, i), { index })));
|
|
385
378
|
const cartCounts = calcCartCounts(cart);
|
|
386
|
-
console.log('rehydrated cart', cart);
|
|
387
379
|
return { cart, cartCounts };
|
|
388
380
|
};
|
|
389
381
|
// TODO: maybe refactor
|
|
@@ -647,7 +639,6 @@ const makeSimpleGroups = (groups) => {
|
|
|
647
639
|
.map(o => ({
|
|
648
640
|
id: o.id,
|
|
649
641
|
quantity: o.quantity,
|
|
650
|
-
pos_ext_id: o.pos_ext_id,
|
|
651
642
|
groups: makeSimpleGroups(o.groups || [])
|
|
652
643
|
}));
|
|
653
644
|
return { id: g.id, options: options };
|
|
@@ -744,15 +735,7 @@ export const validateCart = (cart, categories, soldOut, requestedAt) => {
|
|
|
744
735
|
}
|
|
745
736
|
else {
|
|
746
737
|
const updatedOptions = group.options.map(option => {
|
|
747
|
-
|
|
748
|
-
if (!newOption) {
|
|
749
|
-
console.log('checking pos_ext_id for option match');
|
|
750
|
-
const allOptions = Object.values(newGroup.options);
|
|
751
|
-
const matchingOption = allOptions.find(o => o.pos_ext_id === option.pos_ext_id);
|
|
752
|
-
console.log(allOptions, option, matchingOption);
|
|
753
|
-
if (matchingOption)
|
|
754
|
-
newOption = matchingOption;
|
|
755
|
-
}
|
|
738
|
+
const newOption = newGroup.options[option.id];
|
|
756
739
|
// check to see if any OLD options aren't avaiilable on the current menu
|
|
757
740
|
// or if any of the options are currently sold out
|
|
758
741
|
if (!newOption ||
|
|
@@ -766,6 +749,12 @@ export const validateCart = (cart, categories, soldOut, requestedAt) => {
|
|
|
766
749
|
// ignore the option increment setting for the time being
|
|
767
750
|
if ((newOption.max && option.quantity > newOption.max) ||
|
|
768
751
|
(newOption.min && option.quantity < newOption.min)) {
|
|
752
|
+
console.log('[validateCart] Option mismatch details:', {
|
|
753
|
+
oldOption: option,
|
|
754
|
+
newOption,
|
|
755
|
+
soldOut,
|
|
756
|
+
requestedAt
|
|
757
|
+
});
|
|
769
758
|
invalidOptions.push(option);
|
|
770
759
|
return option;
|
|
771
760
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-tender/utils",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.58",
|
|
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
|
"typescript": "^4.8.2"
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|
|
60
|
-
"@open-tender/types": "^0.4.
|
|
60
|
+
"@open-tender/types": "^0.4.171",
|
|
61
61
|
"@reduxjs/toolkit": "^1.8.5",
|
|
62
62
|
"react": "^18.2.0"
|
|
63
63
|
},
|