@open-tender/utils 0.1.163 → 0.1.165

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, MenuItemsWithFavorites, SoldOut } from '@open-tender/types';
1
+ import { DisplayItems, Favorites, MenuCategories, MenuItem, MenuItems, 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) => MenuItemsWithFavorites;
6
- export declare const makeFavorites: (favorites: Favorites, itemLookup: Record<string, MenuItem>, soldOut: SoldOut) => MenuItemsWithFavorites;
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;
@@ -92,7 +92,7 @@ const makeFavorites = (favorites, itemLookup, soldOut) => {
92
92
  if (!menuItem)
93
93
  return arr;
94
94
  const isValid = validateFavorite(favorite.item, menuItem, soldOut);
95
- const favoriteSimple = { item: favorite.item, quantity: 1 };
95
+ const favoriteSimple = { item: Object.assign(Object.assign({}, favorite.item), { quantity: 1 }) };
96
96
  return isValid ? [...arr, Object.assign(Object.assign({}, menuItem), { favorite: favoriteSimple })] : arr;
97
97
  }
98
98
  else {
@@ -17,6 +17,7 @@ export declare const makeOtherMenuSections: (displayedSections: MenuDisplayedSec
17
17
  calories: number | null;
18
18
  description: string | null;
19
19
  dimensions: number[] | null;
20
+ favorite?: import("@open-tender/types").MenuItemFavorite | undefined;
20
21
  featured_position: number | null;
21
22
  id: number;
22
23
  increment: number;
@@ -57,6 +58,7 @@ export declare const makeFlatCategories: (categories: MenuCategories) => {
57
58
  calories: number | null;
58
59
  description: string | null;
59
60
  dimensions: number[] | null;
61
+ favorite?: import("@open-tender/types").MenuItemFavorite | undefined;
60
62
  featured_position: number | null;
61
63
  id: number;
62
64
  increment: number;
@@ -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, MenuItemsWithFavorites, SoldOut } from '@open-tender/types';
1
+ import { DisplayItems, Favorites, MenuCategories, MenuItem, MenuItems, 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) => MenuItemsWithFavorites;
6
- export declare const makeFavorites: (favorites: Favorites, itemLookup: Record<string, MenuItem>, soldOut: SoldOut) => MenuItemsWithFavorites;
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;
@@ -85,7 +85,7 @@ export const makeFavorites = (favorites, itemLookup, soldOut) => {
85
85
  if (!menuItem)
86
86
  return arr;
87
87
  const isValid = validateFavorite(favorite.item, menuItem, soldOut);
88
- const favoriteSimple = { item: favorite.item, quantity: 1 };
88
+ const favoriteSimple = { item: Object.assign(Object.assign({}, favorite.item), { quantity: 1 }) };
89
89
  return isValid ? [...arr, Object.assign(Object.assign({}, menuItem), { favorite: favoriteSimple })] : arr;
90
90
  }
91
91
  else {
@@ -17,6 +17,7 @@ export declare const makeOtherMenuSections: (displayedSections: MenuDisplayedSec
17
17
  calories: number | null;
18
18
  description: string | null;
19
19
  dimensions: number[] | null;
20
+ favorite?: import("@open-tender/types").MenuItemFavorite | undefined;
20
21
  featured_position: number | null;
21
22
  id: number;
22
23
  increment: number;
@@ -57,6 +58,7 @@ export declare const makeFlatCategories: (categories: MenuCategories) => {
57
58
  calories: number | null;
58
59
  description: string | null;
59
60
  dimensions: number[] | null;
61
+ favorite?: import("@open-tender/types").MenuItemFavorite | undefined;
60
62
  featured_position: number | null;
61
63
  id: number;
62
64
  increment: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-tender/utils",
3
- "version": "0.1.163",
3
+ "version": "0.1.165",
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.97",
57
+ "@open-tender/types": "^0.2.98",
58
58
  "@reduxjs/toolkit": "^1.8.5",
59
59
  "react": "^18.2.0"
60
60
  },