@open-tender/utils 0.5.52 → 0.5.53
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.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);
|
|
@@ -746,7 +753,6 @@ const validateCart = (cart, categories, soldOut, requestedAt) => {
|
|
|
746
753
|
const missingOptions = [];
|
|
747
754
|
const invalidOptions = [];
|
|
748
755
|
const newGroups = makeGroupsLookup(newItem);
|
|
749
|
-
console.log('newGroups');
|
|
750
756
|
// check if any required groups for the new item are missing from the old item
|
|
751
757
|
const newRequiredGroups = Object.values(newGroups).filter(i => i.min > 0);
|
|
752
758
|
const oldGroupIds = (_a = oldItem.groups) === null || _a === void 0 ? void 0 : _a.map(i => i.id);
|
|
@@ -772,7 +778,6 @@ const validateCart = (cart, categories, soldOut, requestedAt) => {
|
|
|
772
778
|
else {
|
|
773
779
|
const updatedOptions = group.options.map(option => {
|
|
774
780
|
let newOption = newGroup.options[option.id];
|
|
775
|
-
console.log('newOption', newOption);
|
|
776
781
|
if (!newOption) {
|
|
777
782
|
console.log('checking pos_ext_id for option match');
|
|
778
783
|
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.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);
|
|
@@ -710,7 +717,6 @@ export const validateCart = (cart, categories, soldOut, requestedAt) => {
|
|
|
710
717
|
const missingOptions = [];
|
|
711
718
|
const invalidOptions = [];
|
|
712
719
|
const newGroups = makeGroupsLookup(newItem);
|
|
713
|
-
console.log('newGroups');
|
|
714
720
|
// check if any required groups for the new item are missing from the old item
|
|
715
721
|
const newRequiredGroups = Object.values(newGroups).filter(i => i.min > 0);
|
|
716
722
|
const oldGroupIds = (_a = oldItem.groups) === null || _a === void 0 ? void 0 : _a.map(i => i.id);
|
|
@@ -736,7 +742,6 @@ export const validateCart = (cart, categories, soldOut, requestedAt) => {
|
|
|
736
742
|
else {
|
|
737
743
|
const updatedOptions = group.options.map(option => {
|
|
738
744
|
let newOption = newGroup.options[option.id];
|
|
739
|
-
console.log('newOption', newOption);
|
|
740
745
|
if (!newOption) {
|
|
741
746
|
console.log('checking pos_ext_id for option match');
|
|
742
747
|
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.53",
|
|
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
|
},
|