@open-tender/utils 0.4.23 → 0.4.24

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.
package/dist/.DS_Store ADDED
Binary file
@@ -6,7 +6,6 @@ export declare const useMenuItem: (builtItem: CartItem, auth: Auth | null, looku
6
6
  displayPrice: string;
7
7
  displayCals: number | null;
8
8
  totalPoints: number | null;
9
- totalAllergens: string[] | undefined;
10
9
  auth: Auth | null;
11
10
  favoriteId: number | null;
12
11
  isIncomplete: boolean;
@@ -6,7 +6,7 @@ const useMenuItem = (builtItem, auth, lookup, cartId, displaySettings) => {
6
6
  const signature = (0, utils_1.makeItemSignature)(builtItem);
7
7
  const favoriteId = lookup && signature ? lookup[signature] : null;
8
8
  const { calories: showCals = false, tags: showTags = false, allergens: showAllergens = false, madeFor: showMadeFor = true, notes: showNotes = true } = displaySettings || {};
9
- const { description, quantity, price, totalPrice, cals, totalCals, totalPoints, tags, allergens, groups, ingredients, totalAllergens } = builtItem;
9
+ const { description, quantity, price, totalPrice, cals, totalCals, totalPoints, tags, allergens, groups, ingredients } = builtItem;
10
10
  const hasTags = showTags && Array.isArray(tags) && tags.length ? true : false;
11
11
  const hasAllergens = showAllergens && Array.isArray(allergens) && allergens.length ? true : false;
12
12
  const hasTagsAllergens = hasTags || hasAllergens ? true : false;
@@ -45,7 +45,6 @@ const useMenuItem = (builtItem, auth, lookup, cartId, displaySettings) => {
45
45
  displayPrice,
46
46
  displayCals,
47
47
  totalPoints,
48
- totalAllergens,
49
48
  auth,
50
49
  favoriteId,
51
50
  isIncomplete,
@@ -46,5 +46,4 @@ export declare const useModifier: (group: CartItemGroup, option: CartItemOption,
46
46
  totalCals: number | null;
47
47
  totalPoints: number | null;
48
48
  totalPrice: number | null;
49
- totalAllergens?: string[] | undefined;
50
49
  };
@@ -41,5 +41,4 @@ export declare const useOrderItem: (orderItem: CartItem, favorite?: MenuItemFavo
41
41
  totalCals: number | null;
42
42
  totalPoints: number | null;
43
43
  totalPrice: number | null;
44
- totalAllergens?: string[] | undefined;
45
44
  };
@@ -47,7 +47,6 @@ export declare const rehydrateCart: (menuItems: MenuItems, simpleCartItems: Simp
47
47
  totalCals: number | null;
48
48
  totalPoints: number | null;
49
49
  totalPrice: number | null;
50
- totalAllergens?: string[] | undefined;
51
50
  }[];
52
51
  cartCounts: Record<string, number>;
53
52
  };
@@ -134,7 +133,6 @@ export declare const combineCarts: (cart: Cart, guestCart: Cart, cartOwner: Cart
134
133
  totalCals: number | null;
135
134
  totalPoints: number | null;
136
135
  totalPrice: number | null;
137
- totalAllergens?: string[] | undefined;
138
136
  }[];
139
137
  export declare const makeItemImageUrl: (images: Images) => any;
140
138
  export declare const makeDisplayItemGroups: (optionGroups: OrderItemGroups) => {
@@ -178,15 +178,7 @@ const calcPrices = (item) => {
178
178
  const totalCals = item.cals || item.cals === 0
179
179
  ? item.quantity * (item.cals + optionsCals)
180
180
  : null;
181
- const nonSizeGroups = groups ? groups.filter(i => !i.isSize) : null;
182
- const currentOptions = nonSizeGroups
183
- ? (0, exports.getItemOptions)(Object.assign(Object.assign({}, item), { groups: nonSizeGroups }))
184
- : [];
185
- const modifiersAllergens = currentOptions.reduce((t, o) => {
186
- return [...t, ...o.allergens];
187
- }, []);
188
- const totalAllergens = [...new Set(item.allergens.concat(modifiersAllergens))];
189
- return Object.assign(Object.assign({}, item), { groups, totalPrice, totalPoints, totalCals, totalAllergens });
181
+ return Object.assign(Object.assign({}, item), { groups, totalPrice, totalPoints, totalCals });
190
182
  };
191
183
  exports.calcPrices = calcPrices;
192
184
  const checkSoldOut = (id, suspendUntil, soldOut = []) => {
@@ -6,7 +6,6 @@ export declare const useMenuItem: (builtItem: CartItem, auth: Auth | null, looku
6
6
  displayPrice: string;
7
7
  displayCals: number | null;
8
8
  totalPoints: number | null;
9
- totalAllergens: string[] | undefined;
10
9
  auth: Auth | null;
11
10
  favoriteId: number | null;
12
11
  isIncomplete: boolean;
@@ -3,7 +3,7 @@ export const useMenuItem = (builtItem, auth, lookup, cartId, displaySettings) =>
3
3
  const signature = makeItemSignature(builtItem);
4
4
  const favoriteId = lookup && signature ? lookup[signature] : null;
5
5
  const { calories: showCals = false, tags: showTags = false, allergens: showAllergens = false, madeFor: showMadeFor = true, notes: showNotes = true } = displaySettings || {};
6
- const { description, quantity, price, totalPrice, cals, totalCals, totalPoints, tags, allergens, groups, ingredients, totalAllergens } = builtItem;
6
+ const { description, quantity, price, totalPrice, cals, totalCals, totalPoints, tags, allergens, groups, ingredients } = builtItem;
7
7
  const hasTags = showTags && Array.isArray(tags) && tags.length ? true : false;
8
8
  const hasAllergens = showAllergens && Array.isArray(allergens) && allergens.length ? true : false;
9
9
  const hasTagsAllergens = hasTags || hasAllergens ? true : false;
@@ -42,7 +42,6 @@ export const useMenuItem = (builtItem, auth, lookup, cartId, displaySettings) =>
42
42
  displayPrice,
43
43
  displayCals,
44
44
  totalPoints,
45
- totalAllergens,
46
45
  auth,
47
46
  favoriteId,
48
47
  isIncomplete,
@@ -46,5 +46,4 @@ export declare const useModifier: (group: CartItemGroup, option: CartItemOption,
46
46
  totalCals: number | null;
47
47
  totalPoints: number | null;
48
48
  totalPrice: number | null;
49
- totalAllergens?: string[] | undefined;
50
49
  };
@@ -41,5 +41,4 @@ export declare const useOrderItem: (orderItem: CartItem, favorite?: MenuItemFavo
41
41
  totalCals: number | null;
42
42
  totalPoints: number | null;
43
43
  totalPrice: number | null;
44
- totalAllergens?: string[] | undefined;
45
44
  };
@@ -47,7 +47,6 @@ export declare const rehydrateCart: (menuItems: MenuItems, simpleCartItems: Simp
47
47
  totalCals: number | null;
48
48
  totalPoints: number | null;
49
49
  totalPrice: number | null;
50
- totalAllergens?: string[] | undefined;
51
50
  }[];
52
51
  cartCounts: Record<string, number>;
53
52
  };
@@ -134,7 +133,6 @@ export declare const combineCarts: (cart: Cart, guestCart: Cart, cartOwner: Cart
134
133
  totalCals: number | null;
135
134
  totalPoints: number | null;
136
135
  totalPrice: number | null;
137
- totalAllergens?: string[] | undefined;
138
136
  }[];
139
137
  export declare const makeItemImageUrl: (images: Images) => any;
140
138
  export declare const makeDisplayItemGroups: (optionGroups: OrderItemGroups) => {
@@ -165,15 +165,7 @@ export const calcPrices = (item) => {
165
165
  const totalCals = item.cals || item.cals === 0
166
166
  ? item.quantity * (item.cals + optionsCals)
167
167
  : null;
168
- const nonSizeGroups = groups ? groups.filter(i => !i.isSize) : null;
169
- const currentOptions = nonSizeGroups
170
- ? getItemOptions(Object.assign(Object.assign({}, item), { groups: nonSizeGroups }))
171
- : [];
172
- const modifiersAllergens = currentOptions.reduce((t, o) => {
173
- return [...t, ...o.allergens];
174
- }, []);
175
- const totalAllergens = [...new Set(item.allergens.concat(modifiersAllergens))];
176
- return Object.assign(Object.assign({}, item), { groups, totalPrice, totalPoints, totalCals, totalAllergens });
168
+ return Object.assign(Object.assign({}, item), { groups, totalPrice, totalPoints, totalCals });
177
169
  };
178
170
  export const checkSoldOut = (id, suspendUntil, soldOut = []) => {
179
171
  if (soldOut.includes(id))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-tender/utils",
3
- "version": "0.4.23",
3
+ "version": "0.4.24",
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",
@@ -36,7 +36,7 @@
36
36
  "private": false,
37
37
  "devDependencies": {
38
38
  "@emotion/react": "^11.10.4",
39
- "@open-tender/types": "^0.4.34",
39
+ "@open-tender/types": "^0.4.46",
40
40
  "@reduxjs/toolkit": "^1.8.5",
41
41
  "@types/google.maps": "^3.53.5",
42
42
  "@types/jest": "^29.5.11",