@open-tender/utils 0.1.162 → 0.1.163

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.
@@ -1,6 +1,6 @@
1
- import { DisplayItems, Favorites, MenuCategories, MenuItem, MenuItems, SoldOut } from '@open-tender/types';
1
+ import { DisplayItems, Favorites, MenuCategories, MenuItem, MenuItemsWithFavorites, SoldOut } from '@open-tender/types';
2
2
  export declare const makeMenuItemLookup: (categories: MenuCategories) => any;
3
3
  export declare const makeFeatured: (categories: MenuCategories) => MenuItem[];
4
4
  export declare const makeMenuGroupsLookup: (menuItem: MenuItem) => any;
5
- export declare const makeRecents: (recents: DisplayItems, itemLookup: Record<string, MenuItem>, soldOut: SoldOut) => MenuItems;
6
- export declare const makeFavorites: (favorites: Favorites, itemLookup: Record<string, MenuItem>, soldOut: SoldOut) => MenuItems;
5
+ export declare const makeRecents: (recents: DisplayItems, itemLookup: Record<string, MenuItem>, soldOut: SoldOut) => MenuItemsWithFavorites;
6
+ export declare const makeFavorites: (favorites: Favorites, itemLookup: Record<string, MenuItem>, soldOut: SoldOut) => MenuItemsWithFavorites;
@@ -61,7 +61,6 @@ const validateFavorite = (item, menuItem, soldOut) => {
61
61
  });
62
62
  return missingGroups.length || missingOptions.length ? false : true;
63
63
  };
64
- // TODO: refactor to remove favorite from menu item
65
64
  const makeRecents = (recents, itemLookup, soldOut) => {
66
65
  return recents.reduce((arr, item) => {
67
66
  if (item.id) {
@@ -85,7 +84,6 @@ const makeRecents = (recents, itemLookup, soldOut) => {
85
84
  }, []);
86
85
  };
87
86
  exports.makeRecents = makeRecents;
88
- // TODO: refactor to remove favorite from menu item
89
87
  const makeFavorites = (favorites, itemLookup, soldOut) => {
90
88
  return favorites.reduce((arr, favorite) => {
91
89
  var _a, _b;
@@ -94,7 +92,8 @@ const makeFavorites = (favorites, itemLookup, soldOut) => {
94
92
  if (!menuItem)
95
93
  return arr;
96
94
  const isValid = validateFavorite(favorite.item, menuItem, soldOut);
97
- return isValid ? [...arr, Object.assign(Object.assign({}, menuItem), { favorite })] : arr;
95
+ const favoriteSimple = { item: favorite.item, quantity: 1 };
96
+ return isValid ? [...arr, Object.assign(Object.assign({}, menuItem), { favorite: favoriteSimple })] : arr;
98
97
  }
99
98
  else {
100
99
  return arr;
@@ -1,6 +1,6 @@
1
- import { DisplayItems, Favorites, MenuCategories, MenuItem, MenuItems, SoldOut } from '@open-tender/types';
1
+ import { DisplayItems, Favorites, MenuCategories, MenuItem, MenuItemsWithFavorites, SoldOut } from '@open-tender/types';
2
2
  export declare const makeMenuItemLookup: (categories: MenuCategories) => any;
3
3
  export declare const makeFeatured: (categories: MenuCategories) => MenuItem[];
4
4
  export declare const makeMenuGroupsLookup: (menuItem: MenuItem) => any;
5
- export declare const makeRecents: (recents: DisplayItems, itemLookup: Record<string, MenuItem>, soldOut: SoldOut) => MenuItems;
6
- export declare const makeFavorites: (favorites: Favorites, itemLookup: Record<string, MenuItem>, soldOut: SoldOut) => MenuItems;
5
+ export declare const makeRecents: (recents: DisplayItems, itemLookup: Record<string, MenuItem>, soldOut: SoldOut) => MenuItemsWithFavorites;
6
+ export declare const makeFavorites: (favorites: Favorites, itemLookup: Record<string, MenuItem>, soldOut: SoldOut) => MenuItemsWithFavorites;
@@ -55,7 +55,6 @@ const validateFavorite = (item, menuItem, soldOut) => {
55
55
  });
56
56
  return missingGroups.length || missingOptions.length ? false : true;
57
57
  };
58
- // TODO: refactor to remove favorite from menu item
59
58
  export const makeRecents = (recents, itemLookup, soldOut) => {
60
59
  return recents.reduce((arr, item) => {
61
60
  if (item.id) {
@@ -78,7 +77,6 @@ export const makeRecents = (recents, itemLookup, soldOut) => {
78
77
  }
79
78
  }, []);
80
79
  };
81
- // TODO: refactor to remove favorite from menu item
82
80
  export const makeFavorites = (favorites, itemLookup, soldOut) => {
83
81
  return favorites.reduce((arr, favorite) => {
84
82
  var _a, _b;
@@ -87,7 +85,8 @@ export const makeFavorites = (favorites, itemLookup, soldOut) => {
87
85
  if (!menuItem)
88
86
  return arr;
89
87
  const isValid = validateFavorite(favorite.item, menuItem, soldOut);
90
- return isValid ? [...arr, Object.assign(Object.assign({}, menuItem), { favorite })] : arr;
88
+ const favoriteSimple = { item: favorite.item, quantity: 1 };
89
+ return isValid ? [...arr, Object.assign(Object.assign({}, menuItem), { favorite: favoriteSimple })] : arr;
91
90
  }
92
91
  else {
93
92
  return arr;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-tender/utils",
3
- "version": "0.1.162",
3
+ "version": "0.1.163",
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",
@@ -54,7 +54,7 @@
54
54
  "typescript": "^4.8.2"
55
55
  },
56
56
  "peerDependencies": {
57
- "@open-tender/types": "^0.2.95",
57
+ "@open-tender/types": "^0.2.97",
58
58
  "@reduxjs/toolkit": "^1.8.5",
59
59
  "react": "^18.2.0"
60
60
  },