@open-tender/utils 0.4.24 → 0.4.25
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/cjs/hooks/useMenuItem.d.ts +1 -0
- package/dist/cjs/hooks/useMenuItem.js +2 -1
- package/dist/cjs/hooks/useModifier.d.ts +1 -0
- package/dist/cjs/hooks/useOrderItem.d.ts +1 -0
- package/dist/cjs/utils/cart.d.ts +2 -0
- package/dist/cjs/utils/cart.js +11 -1
- package/dist/cjs/utils/checkout.d.ts +6 -6
- package/dist/esm/hooks/useMenuItem.d.ts +1 -0
- package/dist/esm/hooks/useMenuItem.js +2 -1
- package/dist/esm/hooks/useModifier.d.ts +1 -0
- package/dist/esm/hooks/useOrderItem.d.ts +1 -0
- package/dist/esm/utils/cart.d.ts +2 -0
- package/dist/esm/utils/cart.js +11 -1
- package/dist/esm/utils/checkout.d.ts +6 -6
- package/package.json +2 -2
- package/dist/.DS_Store +0 -0
|
@@ -6,6 +6,7 @@ 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[];
|
|
9
10
|
auth: Auth | null;
|
|
10
11
|
favoriteId: number | null;
|
|
11
12
|
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 } = builtItem;
|
|
9
|
+
const { description, quantity, price, totalPrice, cals, totalCals, totalPoints, tags, allergens, groups, ingredients, totalAllergens } = 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,6 +45,7 @@ const useMenuItem = (builtItem, auth, lookup, cartId, displaySettings) => {
|
|
|
45
45
|
displayPrice,
|
|
46
46
|
displayCals,
|
|
47
47
|
totalPoints,
|
|
48
|
+
totalAllergens,
|
|
48
49
|
auth,
|
|
49
50
|
favoriteId,
|
|
50
51
|
isIncomplete,
|
|
@@ -43,6 +43,7 @@ export declare const useModifier: (group: CartItemGroup, option: CartItemOption,
|
|
|
43
43
|
shortDescription: string | null;
|
|
44
44
|
shortName: string;
|
|
45
45
|
slug: string;
|
|
46
|
+
totalAllergens: string[];
|
|
46
47
|
totalCals: number | null;
|
|
47
48
|
totalPoints: number | null;
|
|
48
49
|
totalPrice: number | null;
|
package/dist/cjs/utils/cart.d.ts
CHANGED
|
@@ -44,6 +44,7 @@ export declare const rehydrateCart: (menuItems: MenuItems, simpleCartItems: Simp
|
|
|
44
44
|
shortName: string;
|
|
45
45
|
slug: string;
|
|
46
46
|
tags: string[];
|
|
47
|
+
totalAllergens: string[];
|
|
47
48
|
totalCals: number | null;
|
|
48
49
|
totalPoints: number | null;
|
|
49
50
|
totalPrice: number | null;
|
|
@@ -130,6 +131,7 @@ export declare const combineCarts: (cart: Cart, guestCart: Cart, cartOwner: Cart
|
|
|
130
131
|
shortName: string;
|
|
131
132
|
slug: string;
|
|
132
133
|
tags: string[];
|
|
134
|
+
totalAllergens: string[];
|
|
133
135
|
totalCals: number | null;
|
|
134
136
|
totalPoints: number | null;
|
|
135
137
|
totalPrice: number | null;
|
package/dist/cjs/utils/cart.js
CHANGED
|
@@ -178,7 +178,15 @@ const calcPrices = (item) => {
|
|
|
178
178
|
const totalCals = item.cals || item.cals === 0
|
|
179
179
|
? item.quantity * (item.cals + optionsCals)
|
|
180
180
|
: null;
|
|
181
|
-
|
|
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 });
|
|
182
190
|
};
|
|
183
191
|
exports.calcPrices = calcPrices;
|
|
184
192
|
const checkSoldOut = (id, suspendUntil, soldOut = []) => {
|
|
@@ -225,6 +233,7 @@ const makeOrderItemGroups = (optionGroups, isEdit, soldOut = []) => {
|
|
|
225
233
|
shortName: o.short_name,
|
|
226
234
|
slug: o.slug,
|
|
227
235
|
tags: (0, helpers_1.convertStringToArray)(o.tags),
|
|
236
|
+
totalAllergens: [],
|
|
228
237
|
totalCals: null,
|
|
229
238
|
totalPoints: null,
|
|
230
239
|
totalPrice: null
|
|
@@ -279,6 +288,7 @@ const makeOrderItem = (item, isEdit, soldOut = [], simpleItem, hasPoints = false
|
|
|
279
288
|
similarItems: item.similar_items,
|
|
280
289
|
slug: item.slug,
|
|
281
290
|
tags: (0, helpers_1.convertStringToArray)(item.tags),
|
|
291
|
+
totalAllergens: [],
|
|
282
292
|
totalCals: null,
|
|
283
293
|
totalPoints: null,
|
|
284
294
|
totalPrice: null,
|
|
@@ -16,12 +16,12 @@ export declare const updateTenders: (tenders: CheckoutTenders, total: Money) =>
|
|
|
16
16
|
zip: string;
|
|
17
17
|
} | {
|
|
18
18
|
amount: string;
|
|
19
|
-
card_type
|
|
20
|
-
card_type_name
|
|
19
|
+
card_type?: import("@open-tender/types").CardType | undefined;
|
|
20
|
+
card_type_name?: import("@open-tender/types").CardTypeName | undefined;
|
|
21
21
|
customer_card_id: number;
|
|
22
|
-
is_default
|
|
23
|
-
last4
|
|
24
|
-
masked
|
|
22
|
+
is_default?: boolean | undefined;
|
|
23
|
+
last4?: string | undefined;
|
|
24
|
+
masked?: string | undefined;
|
|
25
25
|
tender_status?: import("@open-tender/types").TenderStatus | undefined;
|
|
26
26
|
tender_type: import("@open-tender/types").TenderType;
|
|
27
27
|
} | {
|
|
@@ -50,4 +50,4 @@ export declare const updateTenders: (tenders: CheckoutTenders, total: Money) =>
|
|
|
50
50
|
})[] | null;
|
|
51
51
|
export declare const makeCreditCardName: (creditCard: CreditCard) => string;
|
|
52
52
|
export declare const makeTenderName: (tender: OrderTender) => string;
|
|
53
|
-
export declare const makeCheckoutTenderName: (tender: CheckoutTender) => string;
|
|
53
|
+
export declare const makeCheckoutTenderName: (tender: CheckoutTender) => string | undefined;
|
|
@@ -6,6 +6,7 @@ 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[];
|
|
9
10
|
auth: Auth | null;
|
|
10
11
|
favoriteId: number | null;
|
|
11
12
|
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 } = builtItem;
|
|
6
|
+
const { description, quantity, price, totalPrice, cals, totalCals, totalPoints, tags, allergens, groups, ingredients, totalAllergens } = 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,6 +42,7 @@ export const useMenuItem = (builtItem, auth, lookup, cartId, displaySettings) =>
|
|
|
42
42
|
displayPrice,
|
|
43
43
|
displayCals,
|
|
44
44
|
totalPoints,
|
|
45
|
+
totalAllergens,
|
|
45
46
|
auth,
|
|
46
47
|
favoriteId,
|
|
47
48
|
isIncomplete,
|
|
@@ -43,6 +43,7 @@ export declare const useModifier: (group: CartItemGroup, option: CartItemOption,
|
|
|
43
43
|
shortDescription: string | null;
|
|
44
44
|
shortName: string;
|
|
45
45
|
slug: string;
|
|
46
|
+
totalAllergens: string[];
|
|
46
47
|
totalCals: number | null;
|
|
47
48
|
totalPoints: number | null;
|
|
48
49
|
totalPrice: number | null;
|
package/dist/esm/utils/cart.d.ts
CHANGED
|
@@ -44,6 +44,7 @@ export declare const rehydrateCart: (menuItems: MenuItems, simpleCartItems: Simp
|
|
|
44
44
|
shortName: string;
|
|
45
45
|
slug: string;
|
|
46
46
|
tags: string[];
|
|
47
|
+
totalAllergens: string[];
|
|
47
48
|
totalCals: number | null;
|
|
48
49
|
totalPoints: number | null;
|
|
49
50
|
totalPrice: number | null;
|
|
@@ -130,6 +131,7 @@ export declare const combineCarts: (cart: Cart, guestCart: Cart, cartOwner: Cart
|
|
|
130
131
|
shortName: string;
|
|
131
132
|
slug: string;
|
|
132
133
|
tags: string[];
|
|
134
|
+
totalAllergens: string[];
|
|
133
135
|
totalCals: number | null;
|
|
134
136
|
totalPoints: number | null;
|
|
135
137
|
totalPrice: number | null;
|
package/dist/esm/utils/cart.js
CHANGED
|
@@ -165,7 +165,15 @@ export const calcPrices = (item) => {
|
|
|
165
165
|
const totalCals = item.cals || item.cals === 0
|
|
166
166
|
? item.quantity * (item.cals + optionsCals)
|
|
167
167
|
: null;
|
|
168
|
-
|
|
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 });
|
|
169
177
|
};
|
|
170
178
|
export const checkSoldOut = (id, suspendUntil, soldOut = []) => {
|
|
171
179
|
if (soldOut.includes(id))
|
|
@@ -210,6 +218,7 @@ const makeOrderItemGroups = (optionGroups, isEdit, soldOut = []) => {
|
|
|
210
218
|
shortName: o.short_name,
|
|
211
219
|
slug: o.slug,
|
|
212
220
|
tags: convertStringToArray(o.tags),
|
|
221
|
+
totalAllergens: [],
|
|
213
222
|
totalCals: null,
|
|
214
223
|
totalPoints: null,
|
|
215
224
|
totalPrice: null
|
|
@@ -264,6 +273,7 @@ export const makeOrderItem = (item, isEdit, soldOut = [], simpleItem, hasPoints
|
|
|
264
273
|
similarItems: item.similar_items,
|
|
265
274
|
slug: item.slug,
|
|
266
275
|
tags: convertStringToArray(item.tags),
|
|
276
|
+
totalAllergens: [],
|
|
267
277
|
totalCals: null,
|
|
268
278
|
totalPoints: null,
|
|
269
279
|
totalPrice: null,
|
|
@@ -16,12 +16,12 @@ export declare const updateTenders: (tenders: CheckoutTenders, total: Money) =>
|
|
|
16
16
|
zip: string;
|
|
17
17
|
} | {
|
|
18
18
|
amount: string;
|
|
19
|
-
card_type
|
|
20
|
-
card_type_name
|
|
19
|
+
card_type?: import("@open-tender/types").CardType | undefined;
|
|
20
|
+
card_type_name?: import("@open-tender/types").CardTypeName | undefined;
|
|
21
21
|
customer_card_id: number;
|
|
22
|
-
is_default
|
|
23
|
-
last4
|
|
24
|
-
masked
|
|
22
|
+
is_default?: boolean | undefined;
|
|
23
|
+
last4?: string | undefined;
|
|
24
|
+
masked?: string | undefined;
|
|
25
25
|
tender_status?: import("@open-tender/types").TenderStatus | undefined;
|
|
26
26
|
tender_type: import("@open-tender/types").TenderType;
|
|
27
27
|
} | {
|
|
@@ -50,4 +50,4 @@ export declare const updateTenders: (tenders: CheckoutTenders, total: Money) =>
|
|
|
50
50
|
})[] | null;
|
|
51
51
|
export declare const makeCreditCardName: (creditCard: CreditCard) => string;
|
|
52
52
|
export declare const makeTenderName: (tender: OrderTender) => string;
|
|
53
|
-
export declare const makeCheckoutTenderName: (tender: CheckoutTender) => string;
|
|
53
|
+
export declare const makeCheckoutTenderName: (tender: CheckoutTender) => string | undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-tender/utils",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.25",
|
|
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.47",
|
|
40
40
|
"@reduxjs/toolkit": "^1.8.5",
|
|
41
41
|
"@types/google.maps": "^3.53.5",
|
|
42
42
|
"@types/jest": "^29.5.11",
|
package/dist/.DS_Store
DELETED
|
Binary file
|