@open-tender/utils 0.4.74 → 0.4.75
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
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) => {
|
|
2
|
+
export declare const useOrderItem: (orderItem: CartItem, favorite?: MenuItemFavorite | null, allergenAlerts?: string[], cartCounts?: CartCounts, showCals?: boolean, showTags?: boolean, showAllergens?: boolean, showDesc?: ThemeMenuItemsContentDescription, tagsAllert?: string[]) => {
|
|
3
3
|
displayDesc: string | null;
|
|
4
4
|
displayTags: string[];
|
|
5
5
|
displayAllergens: string[];
|
|
@@ -8,6 +8,7 @@ export declare const useOrderItem: (orderItem: CartItem, favorite?: MenuItemFavo
|
|
|
8
8
|
isIncomplete: boolean;
|
|
9
9
|
isSoldOut: boolean;
|
|
10
10
|
allergenAlert: string | null;
|
|
11
|
+
tagsAlert: string | null;
|
|
11
12
|
hasSelections: boolean;
|
|
12
13
|
sizeOnly: boolean | undefined;
|
|
13
14
|
cartCount: number;
|
|
@@ -2,13 +2,15 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useOrderItem = void 0;
|
|
4
4
|
const utils_1 = require("../utils");
|
|
5
|
-
const useOrderItem = (orderItem, favorite = null, allergenAlerts = [], cartCounts = {}, showCals = false, showTags = false, showAllergens = false, showDesc = 'SHOW') => {
|
|
5
|
+
const useOrderItem = (orderItem, favorite = null, allergenAlerts = [], cartCounts = {}, showCals = false, showTags = false, showAllergens = false, showDesc = 'SHOW', tagsAllert = []) => {
|
|
6
6
|
const { description, shortDescription, quantity, price, totalPrice, cals, totalCals, tags, allergens, groups, isSoldOut } = orderItem;
|
|
7
7
|
const cartCount = cartCounts[orderItem.id] || 0;
|
|
8
8
|
const displayTags = showTags && tags.length ? tags : [];
|
|
9
9
|
const displayAllergens = showAllergens && allergens.length ? allergens : [];
|
|
10
10
|
const contains = allergens.filter(allergen => allergenAlerts.includes(allergen));
|
|
11
11
|
const allergenAlert = contains.length ? `${contains.join(', ')}` : null;
|
|
12
|
+
const containsTags = tags.filter(tag => tagsAllert.includes(tag));
|
|
13
|
+
const tagsAlert = containsTags.length ? `${containsTags.join(', ')}` : null;
|
|
12
14
|
const sizeGroup = groups.find(i => i.isSize);
|
|
13
15
|
const sizeOnly = sizeGroup && groups.length === 1;
|
|
14
16
|
const defaultOption = !sizeGroup
|
|
@@ -47,6 +49,7 @@ const useOrderItem = (orderItem, favorite = null, allergenAlerts = [], cartCount
|
|
|
47
49
|
isIncomplete,
|
|
48
50
|
isSoldOut,
|
|
49
51
|
allergenAlert,
|
|
52
|
+
tagsAlert,
|
|
50
53
|
hasSelections,
|
|
51
54
|
sizeOnly,
|
|
52
55
|
cartCount });
|
|
@@ -1,5 +1,5 @@
|
|
|
1
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) => {
|
|
2
|
+
export declare const useOrderItem: (orderItem: CartItem, favorite?: MenuItemFavorite | null, allergenAlerts?: string[], cartCounts?: CartCounts, showCals?: boolean, showTags?: boolean, showAllergens?: boolean, showDesc?: ThemeMenuItemsContentDescription, tagsAllert?: string[]) => {
|
|
3
3
|
displayDesc: string | null;
|
|
4
4
|
displayTags: string[];
|
|
5
5
|
displayAllergens: string[];
|
|
@@ -8,6 +8,7 @@ export declare const useOrderItem: (orderItem: CartItem, favorite?: MenuItemFavo
|
|
|
8
8
|
isIncomplete: boolean;
|
|
9
9
|
isSoldOut: boolean;
|
|
10
10
|
allergenAlert: string | null;
|
|
11
|
+
tagsAlert: string | null;
|
|
11
12
|
hasSelections: boolean;
|
|
12
13
|
sizeOnly: boolean | undefined;
|
|
13
14
|
cartCount: number;
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { formatDollars, getItemOptions, hasGroupsBelowMin } from '../utils';
|
|
2
|
-
export const useOrderItem = (orderItem, favorite = null, allergenAlerts = [], cartCounts = {}, showCals = false, showTags = false, showAllergens = false, showDesc = 'SHOW') => {
|
|
2
|
+
export const useOrderItem = (orderItem, favorite = null, allergenAlerts = [], cartCounts = {}, showCals = false, showTags = false, showAllergens = false, showDesc = 'SHOW', tagsAllert = []) => {
|
|
3
3
|
const { description, shortDescription, quantity, price, totalPrice, cals, totalCals, tags, allergens, groups, isSoldOut } = orderItem;
|
|
4
4
|
const cartCount = cartCounts[orderItem.id] || 0;
|
|
5
5
|
const displayTags = showTags && tags.length ? tags : [];
|
|
6
6
|
const displayAllergens = showAllergens && allergens.length ? allergens : [];
|
|
7
7
|
const contains = allergens.filter(allergen => allergenAlerts.includes(allergen));
|
|
8
8
|
const allergenAlert = contains.length ? `${contains.join(', ')}` : null;
|
|
9
|
+
const containsTags = tags.filter(tag => tagsAllert.includes(tag));
|
|
10
|
+
const tagsAlert = containsTags.length ? `${containsTags.join(', ')}` : null;
|
|
9
11
|
const sizeGroup = groups.find(i => i.isSize);
|
|
10
12
|
const sizeOnly = sizeGroup && groups.length === 1;
|
|
11
13
|
const defaultOption = !sizeGroup
|
|
@@ -44,6 +46,7 @@ export const useOrderItem = (orderItem, favorite = null, allergenAlerts = [], ca
|
|
|
44
46
|
isIncomplete,
|
|
45
47
|
isSoldOut,
|
|
46
48
|
allergenAlert,
|
|
49
|
+
tagsAlert,
|
|
47
50
|
hasSelections,
|
|
48
51
|
sizeOnly,
|
|
49
52
|
cartCount });
|
package/package.json
CHANGED