@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 +0 -0
- package/dist/cjs/hooks/useMenuItem.d.ts +0 -1
- package/dist/cjs/hooks/useMenuItem.js +1 -2
- package/dist/cjs/hooks/useModifier.d.ts +0 -1
- package/dist/cjs/hooks/useOrderItem.d.ts +0 -1
- package/dist/cjs/utils/cart.d.ts +0 -2
- package/dist/cjs/utils/cart.js +1 -9
- package/dist/esm/hooks/useMenuItem.d.ts +0 -1
- package/dist/esm/hooks/useMenuItem.js +1 -2
- package/dist/esm/hooks/useModifier.d.ts +0 -1
- package/dist/esm/hooks/useOrderItem.d.ts +0 -1
- package/dist/esm/utils/cart.d.ts +0 -2
- package/dist/esm/utils/cart.js +1 -9
- package/package.json +2 -2
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
|
|
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,
|
package/dist/cjs/utils/cart.d.ts
CHANGED
|
@@ -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) => {
|
package/dist/cjs/utils/cart.js
CHANGED
|
@@ -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
|
-
|
|
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
|
|
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,
|
package/dist/esm/utils/cart.d.ts
CHANGED
|
@@ -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) => {
|
package/dist/esm/utils/cart.js
CHANGED
|
@@ -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
|
-
|
|
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.
|
|
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.
|
|
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",
|