@open-tender/utils 0.5.52 → 0.5.54
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.
|
@@ -60,6 +60,7 @@ export declare const useProfileForm: (profile: Customer | null, loading: Request
|
|
|
60
60
|
on?: boolean | undefined;
|
|
61
61
|
onChange?: import("react").ChangeEventHandler<HTMLInputElement> | undefined;
|
|
62
62
|
type: string;
|
|
63
|
+
error?: string | null | undefined;
|
|
63
64
|
} | {
|
|
64
65
|
disabled: boolean | undefined;
|
|
65
66
|
error?: string | null | undefined;
|
package/dist/cjs/utils/cart.d.ts
CHANGED
package/dist/cjs/utils/cart.js
CHANGED
|
@@ -346,6 +346,7 @@ const makeSimpleGroupsLookup = (groups) => {
|
|
|
346
346
|
const options = g.options.reduce((optObj, o) => {
|
|
347
347
|
optObj[o.id] = {
|
|
348
348
|
quantity: o.quantity,
|
|
349
|
+
pos_ext_id: o.pos_ext_id || null,
|
|
349
350
|
groupsLookup: makeSimpleGroupsLookup(o.groups)
|
|
350
351
|
};
|
|
351
352
|
return optObj;
|
|
@@ -361,7 +362,13 @@ const rehydrateGroups = (groups, groupsLookup) => {
|
|
|
361
362
|
const simpleGroup = groupsLookup[group.id];
|
|
362
363
|
if (simpleGroup) {
|
|
363
364
|
group.options.forEach(option => {
|
|
364
|
-
|
|
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
372
|
if (simpleOption) {
|
|
366
373
|
option.quantity = simpleOption.quantity;
|
|
367
374
|
option.groups = rehydrateGroups(option.groups, simpleOption.groupsLookup);
|
|
@@ -673,6 +680,7 @@ const makeSimpleGroups = (groups) => {
|
|
|
673
680
|
.map(o => ({
|
|
674
681
|
id: o.id,
|
|
675
682
|
quantity: o.quantity,
|
|
683
|
+
pos_ext_id: o.pos_ext_id,
|
|
676
684
|
groups: makeSimpleGroups(o.groups || [])
|
|
677
685
|
}));
|
|
678
686
|
return { id: g.id, options: options };
|
|
@@ -746,7 +754,6 @@ const validateCart = (cart, categories, soldOut, requestedAt) => {
|
|
|
746
754
|
const missingOptions = [];
|
|
747
755
|
const invalidOptions = [];
|
|
748
756
|
const newGroups = makeGroupsLookup(newItem);
|
|
749
|
-
console.log('newGroups');
|
|
750
757
|
// check if any required groups for the new item are missing from the old item
|
|
751
758
|
const newRequiredGroups = Object.values(newGroups).filter(i => i.min > 0);
|
|
752
759
|
const oldGroupIds = (_a = oldItem.groups) === null || _a === void 0 ? void 0 : _a.map(i => i.id);
|
|
@@ -772,7 +779,6 @@ const validateCart = (cart, categories, soldOut, requestedAt) => {
|
|
|
772
779
|
else {
|
|
773
780
|
const updatedOptions = group.options.map(option => {
|
|
774
781
|
let newOption = newGroup.options[option.id];
|
|
775
|
-
console.log('newOption', newOption);
|
|
776
782
|
if (!newOption) {
|
|
777
783
|
console.log('checking pos_ext_id for option match');
|
|
778
784
|
const allOptions = Object.values(newGroup.options);
|
|
@@ -60,6 +60,7 @@ export declare const useProfileForm: (profile: Customer | null, loading: Request
|
|
|
60
60
|
on?: boolean | undefined;
|
|
61
61
|
onChange?: import("react").ChangeEventHandler<HTMLInputElement> | undefined;
|
|
62
62
|
type: string;
|
|
63
|
+
error?: string | null | undefined;
|
|
63
64
|
} | {
|
|
64
65
|
disabled: boolean | undefined;
|
|
65
66
|
error?: string | null | undefined;
|
package/dist/esm/utils/cart.d.ts
CHANGED
package/dist/esm/utils/cart.js
CHANGED
|
@@ -329,6 +329,7 @@ const makeSimpleGroupsLookup = (groups) => {
|
|
|
329
329
|
const options = g.options.reduce((optObj, o) => {
|
|
330
330
|
optObj[o.id] = {
|
|
331
331
|
quantity: o.quantity,
|
|
332
|
+
pos_ext_id: o.pos_ext_id || null,
|
|
332
333
|
groupsLookup: makeSimpleGroupsLookup(o.groups)
|
|
333
334
|
};
|
|
334
335
|
return optObj;
|
|
@@ -344,7 +345,13 @@ const rehydrateGroups = (groups, groupsLookup) => {
|
|
|
344
345
|
const simpleGroup = groupsLookup[group.id];
|
|
345
346
|
if (simpleGroup) {
|
|
346
347
|
group.options.forEach(option => {
|
|
347
|
-
|
|
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
355
|
if (simpleOption) {
|
|
349
356
|
option.quantity = simpleOption.quantity;
|
|
350
357
|
option.groups = rehydrateGroups(option.groups, simpleOption.groupsLookup);
|
|
@@ -638,6 +645,7 @@ const makeSimpleGroups = (groups) => {
|
|
|
638
645
|
.map(o => ({
|
|
639
646
|
id: o.id,
|
|
640
647
|
quantity: o.quantity,
|
|
648
|
+
pos_ext_id: o.pos_ext_id,
|
|
641
649
|
groups: makeSimpleGroups(o.groups || [])
|
|
642
650
|
}));
|
|
643
651
|
return { id: g.id, options: options };
|
|
@@ -710,7 +718,6 @@ export const validateCart = (cart, categories, soldOut, requestedAt) => {
|
|
|
710
718
|
const missingOptions = [];
|
|
711
719
|
const invalidOptions = [];
|
|
712
720
|
const newGroups = makeGroupsLookup(newItem);
|
|
713
|
-
console.log('newGroups');
|
|
714
721
|
// check if any required groups for the new item are missing from the old item
|
|
715
722
|
const newRequiredGroups = Object.values(newGroups).filter(i => i.min > 0);
|
|
716
723
|
const oldGroupIds = (_a = oldItem.groups) === null || _a === void 0 ? void 0 : _a.map(i => i.id);
|
|
@@ -736,7 +743,6 @@ export const validateCart = (cart, categories, soldOut, requestedAt) => {
|
|
|
736
743
|
else {
|
|
737
744
|
const updatedOptions = group.options.map(option => {
|
|
738
745
|
let newOption = newGroup.options[option.id];
|
|
739
|
-
console.log('newOption', newOption);
|
|
740
746
|
if (!newOption) {
|
|
741
747
|
console.log('checking pos_ext_id for option match');
|
|
742
748
|
const allOptions = Object.values(newGroup.options);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-tender/utils",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.54",
|
|
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.167",
|
|
61
61
|
"@reduxjs/toolkit": "^1.8.5",
|
|
62
62
|
"react": "^18.2.0"
|
|
63
63
|
},
|