@open-tender/utils 0.0.25 → 0.0.26

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,5 +1,6 @@
1
- import { CartItem, MenuCategories, MenuItem, SoldOut } from "@open-tender/types";
1
+ import { CartItem, FavoriteItem, Favorites, MenuCategories, MenuItem, SoldOut } from "@open-tender/types";
2
2
  export declare const makeMenuItemLookup: (categories: MenuCategories) => any;
3
3
  export declare const makeFeatured: (categories: MenuCategories) => any;
4
4
  export declare const makeMenuGroupsLookup: (menuItem: MenuItem) => any;
5
- export declare const makeRecents: (recents: Partial<CartItem>[], itemLookup: any, soldOut: SoldOut) => any;
5
+ export declare const makeRecents: (recents: Partial<CartItem & FavoriteItem>[], itemLookup: any, soldOut: SoldOut) => any;
6
+ export declare const makeFavorites: (favorites: Favorites, itemLookup: any, soldOut: SoldOut) => any;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.makeRecents = exports.makeMenuGroupsLookup = exports.makeFeatured = exports.makeMenuItemLookup = void 0;
3
+ exports.makeFavorites = exports.makeRecents = exports.makeMenuGroupsLookup = exports.makeFeatured = exports.makeMenuItemLookup = void 0;
4
4
  const makeMenuItemLookup = (categories) => {
5
5
  const cats = categories.reduce((arr, cat) => {
6
6
  return [...arr, cat, ...(cat.children || [])];
@@ -81,3 +81,16 @@ const makeRecents = (recents, itemLookup, soldOut) => {
81
81
  }, []);
82
82
  };
83
83
  exports.makeRecents = makeRecents;
84
+ const makeFavorites = (favorites, itemLookup, soldOut) => {
85
+ return favorites.reduce((arr, favorite) => {
86
+ var _a, _b;
87
+ if ((_a = favorite === null || favorite === void 0 ? void 0 : favorite.item) === null || _a === void 0 ? void 0 : _a.id) {
88
+ const menuItem = itemLookup[(_b = favorite === null || favorite === void 0 ? void 0 : favorite.item) === null || _b === void 0 ? void 0 : _b.id];
89
+ if (!menuItem)
90
+ return arr;
91
+ const isValid = validateFavorite(favorite.item, menuItem, soldOut);
92
+ return isValid ? [...arr, Object.assign(Object.assign({}, menuItem), { favorite })] : arr;
93
+ }
94
+ }, []);
95
+ };
96
+ exports.makeFavorites = makeFavorites;
@@ -1,5 +1,6 @@
1
- import { CartItem, MenuCategories, MenuItem, SoldOut } from "@open-tender/types";
1
+ import { CartItem, FavoriteItem, Favorites, MenuCategories, MenuItem, SoldOut } from "@open-tender/types";
2
2
  export declare const makeMenuItemLookup: (categories: MenuCategories) => any;
3
3
  export declare const makeFeatured: (categories: MenuCategories) => any;
4
4
  export declare const makeMenuGroupsLookup: (menuItem: MenuItem) => any;
5
- export declare const makeRecents: (recents: Partial<CartItem>[], itemLookup: any, soldOut: SoldOut) => any;
5
+ export declare const makeRecents: (recents: Partial<CartItem & FavoriteItem>[], itemLookup: any, soldOut: SoldOut) => any;
6
+ export declare const makeFavorites: (favorites: Favorites, itemLookup: any, soldOut: SoldOut) => any;
@@ -74,3 +74,15 @@ export const makeRecents = (recents, itemLookup, soldOut) => {
74
74
  }
75
75
  }, []);
76
76
  };
77
+ export const makeFavorites = (favorites, itemLookup, soldOut) => {
78
+ return favorites.reduce((arr, favorite) => {
79
+ var _a, _b;
80
+ if ((_a = favorite === null || favorite === void 0 ? void 0 : favorite.item) === null || _a === void 0 ? void 0 : _a.id) {
81
+ const menuItem = itemLookup[(_b = favorite === null || favorite === void 0 ? void 0 : favorite.item) === null || _b === void 0 ? void 0 : _b.id];
82
+ if (!menuItem)
83
+ return arr;
84
+ const isValid = validateFavorite(favorite.item, menuItem, soldOut);
85
+ return isValid ? [...arr, Object.assign(Object.assign({}, menuItem), { favorite })] : arr;
86
+ }
87
+ }, []);
88
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-tender/utils",
3
- "version": "0.0.25",
3
+ "version": "0.0.26",
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",