@open-tender/utils 0.1.162 → 0.1.164

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,5 @@
1
- import { CartCounts, Favorite, CartItem, ThemeMenuItemsContentDescription } from '@open-tender/types';
2
- export declare const useOrderItem: (orderItem: CartItem, favorite?: Favorite | null, allergenAlerts?: string[], cartCounts?: CartCounts, showCals?: boolean, showTags?: boolean, showAllergens?: boolean, showDesc?: ThemeMenuItemsContentDescription) => {
1
+ import { CartCounts, CartItem, ThemeMenuItemsContentDescription, MenuItemFavorite } from '@open-tender/types';
2
+ export declare const useOrderItem: (orderItem: CartItem, favorite?: MenuItemFavorite | null, allergenAlerts?: string[], cartCounts?: CartCounts, showCals?: boolean, showTags?: boolean, showAllergens?: boolean, showDesc?: ThemeMenuItemsContentDescription) => {
3
3
  displayDesc: string | null;
4
4
  displayTags: string[];
5
5
  displayAllergens: string[];
@@ -33,9 +33,11 @@ const useOrderItem = (orderItem, favorite = null, allergenAlerts = [], cartCount
33
33
  ? shortDescription
34
34
  : description;
35
35
  const optionNames = favorite
36
- ? favorite.item.groups
36
+ ? groups
37
37
  .reduce((arr, group) => {
38
- const names = group.options.map(o => o.name);
38
+ const names = group.options
39
+ .filter(o => o.quantity > 0)
40
+ .map(o => o.name);
39
41
  return [...arr, ...names];
40
42
  }, [])
41
43
  .join(', ')
@@ -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,5 +1,5 @@
1
- import { CartCounts, Favorite, CartItem, ThemeMenuItemsContentDescription } from '@open-tender/types';
2
- export declare const useOrderItem: (orderItem: CartItem, favorite?: Favorite | null, allergenAlerts?: string[], cartCounts?: CartCounts, showCals?: boolean, showTags?: boolean, showAllergens?: boolean, showDesc?: ThemeMenuItemsContentDescription) => {
1
+ import { CartCounts, CartItem, ThemeMenuItemsContentDescription, MenuItemFavorite } from '@open-tender/types';
2
+ export declare const useOrderItem: (orderItem: CartItem, favorite?: MenuItemFavorite | null, allergenAlerts?: string[], cartCounts?: CartCounts, showCals?: boolean, showTags?: boolean, showAllergens?: boolean, showDesc?: ThemeMenuItemsContentDescription) => {
3
3
  displayDesc: string | null;
4
4
  displayTags: string[];
5
5
  displayAllergens: string[];
@@ -30,9 +30,11 @@ export const useOrderItem = (orderItem, favorite = null, allergenAlerts = [], ca
30
30
  ? shortDescription
31
31
  : description;
32
32
  const optionNames = favorite
33
- ? favorite.item.groups
33
+ ? groups
34
34
  .reduce((arr, group) => {
35
- const names = group.options.map(o => o.name);
35
+ const names = group.options
36
+ .filter(o => o.quantity > 0)
37
+ .map(o => o.name);
36
38
  return [...arr, ...names];
37
39
  }, [])
38
40
  .join(', ')
@@ -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.164",
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
  },