@open-tender/utils 0.5.51 → 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;
@@ -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
- const simpleOption = simpleGroup.options[option.id];
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);
@@ -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;
@@ -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
- const simpleOption = simpleGroup.options[option.id];
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);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-tender/utils",
3
- "version": "0.5.51",
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.163",
60
+ "@open-tender/types": "^0.4.167",
61
61
  "@reduxjs/toolkit": "^1.8.5",
62
62
  "react": "^18.2.0"
63
63
  },