@open-tender/utils 0.4.70 → 0.4.72
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 +2 -0
- package/dist/cjs/hooks/useModifier.d.ts +2 -0
- package/dist/cjs/hooks/useModifierGroup.d.ts +2 -0
- package/dist/cjs/hooks/useOrderItem.d.ts +2 -0
- package/dist/cjs/utils/cart.d.ts +4 -0
- package/dist/cjs/utils/cart.js +12 -5
- package/dist/cjs/utils/loyalty.js +1 -2
- package/dist/cjs/utils/menu.d.ts +4 -0
- package/dist/esm/hooks/useMenuItem.d.ts +2 -0
- package/dist/esm/hooks/useModifier.d.ts +2 -0
- package/dist/esm/hooks/useModifierGroup.d.ts +2 -0
- package/dist/esm/hooks/useOrderItem.d.ts +2 -0
- package/dist/esm/utils/cart.d.ts +4 -0
- package/dist/esm/utils/cart.js +12 -5
- package/dist/esm/utils/loyalty.js +1 -2
- package/dist/esm/utils/menu.d.ts +4 -0
- package/package.json +2 -2
|
@@ -54,4 +54,6 @@ export declare const useMenuItem: (builtItem: CartItem, auth: Auth | null, looku
|
|
|
54
54
|
tags_list?: import("@open-tender/types").MenuItemTags | undefined;
|
|
55
55
|
totalCals: number | null;
|
|
56
56
|
totalPrice: number | null;
|
|
57
|
+
itemShape: import("@open-tender/types").PizzaShape | null;
|
|
58
|
+
excludeFromBuilder: boolean;
|
|
57
59
|
};
|
|
@@ -50,4 +50,6 @@ export declare const useModifier: (group: CartItemGroup, option: CartItemOption,
|
|
|
50
50
|
totalCals: number | null;
|
|
51
51
|
totalPoints: number | null;
|
|
52
52
|
totalPrice: number | null;
|
|
53
|
+
itemShape: import("@open-tender/types").PizzaShape | null;
|
|
54
|
+
excludeFromBuilder: boolean;
|
|
53
55
|
};
|
|
@@ -12,4 +12,6 @@ export declare const useModifierGroup: (group: CartItemGroup, displaySettings?:
|
|
|
12
12
|
name: string;
|
|
13
13
|
options: import("@open-tender/types").CartItemOptions;
|
|
14
14
|
quantity: number;
|
|
15
|
+
itemShape: import("@open-tender/types").PizzaShape | null;
|
|
16
|
+
excludeFromBuilder: boolean;
|
|
15
17
|
};
|
|
@@ -45,4 +45,6 @@ export declare const useOrderItem: (orderItem: CartItem, favorite?: MenuItemFavo
|
|
|
45
45
|
totalCals: number | null;
|
|
46
46
|
totalPoints: number | null;
|
|
47
47
|
totalPrice: number | null;
|
|
48
|
+
itemShape: import("@open-tender/types").PizzaShape | null;
|
|
49
|
+
excludeFromBuilder: boolean;
|
|
48
50
|
};
|
package/dist/cjs/utils/cart.d.ts
CHANGED
|
@@ -51,6 +51,8 @@ export declare const rehydrateCart: (menuItems: MenuItems, simpleCartItems: Simp
|
|
|
51
51
|
totalCals: number | null;
|
|
52
52
|
totalPoints: number | null;
|
|
53
53
|
totalPrice: number | null;
|
|
54
|
+
itemShape: import("@open-tender/types").PizzaShape | null;
|
|
55
|
+
excludeFromBuilder: boolean;
|
|
54
56
|
}[];
|
|
55
57
|
cartCounts: Record<string, number>;
|
|
56
58
|
};
|
|
@@ -141,6 +143,8 @@ export declare const combineCarts: (cart: Cart, guestCart: Cart, cartOwner: Cart
|
|
|
141
143
|
totalCals: number | null;
|
|
142
144
|
totalPoints: number | null;
|
|
143
145
|
totalPrice: number | null;
|
|
146
|
+
itemShape: import("@open-tender/types").PizzaShape | null;
|
|
147
|
+
excludeFromBuilder: boolean;
|
|
144
148
|
}[];
|
|
145
149
|
export declare const makeItemImageUrl: (images: Images) => any;
|
|
146
150
|
export declare const makeDisplayItemGroups: (optionGroups: OrderItemGroups) => {
|
package/dist/cjs/utils/cart.js
CHANGED
|
@@ -199,8 +199,9 @@ const makeOrderItemGroups = (optionGroups, isEdit, soldOut = []) => {
|
|
|
199
199
|
if (!optionGroups)
|
|
200
200
|
return [];
|
|
201
201
|
const groups = optionGroups.map(g => {
|
|
202
|
+
var _a, _b;
|
|
202
203
|
const options = g.option_items.map(o => {
|
|
203
|
-
var _a;
|
|
204
|
+
var _a, _b, _c;
|
|
204
205
|
const isSoldOut = (0, exports.checkSoldOut)(o.id, o.suspend_until, soldOut);
|
|
205
206
|
const quantity = isSoldOut
|
|
206
207
|
? 0
|
|
@@ -239,7 +240,9 @@ const makeOrderItemGroups = (optionGroups, isEdit, soldOut = []) => {
|
|
|
239
240
|
totalAllergens: [],
|
|
240
241
|
totalCals: null,
|
|
241
242
|
totalPoints: null,
|
|
242
|
-
totalPrice: null
|
|
243
|
+
totalPrice: null,
|
|
244
|
+
itemShape: (_b = o.item_shape) !== null && _b !== void 0 ? _b : null,
|
|
245
|
+
excludeFromBuilder: (_c = o.exclude_from_builder) !== null && _c !== void 0 ? _c : false
|
|
243
246
|
};
|
|
244
247
|
return option;
|
|
245
248
|
});
|
|
@@ -254,14 +257,16 @@ const makeOrderItemGroups = (optionGroups, isEdit, soldOut = []) => {
|
|
|
254
257
|
min: g.min_options,
|
|
255
258
|
name: g.name,
|
|
256
259
|
options: options,
|
|
257
|
-
quantity: options.reduce((t, o) => t + o.quantity, 0)
|
|
260
|
+
quantity: options.reduce((t, o) => t + o.quantity, 0),
|
|
261
|
+
itemShape: (_a = g.item_shape) !== null && _a !== void 0 ? _a : null,
|
|
262
|
+
excludeFromBuilder: (_b = g.exclude_from_builder) !== null && _b !== void 0 ? _b : false
|
|
258
263
|
};
|
|
259
264
|
return group;
|
|
260
265
|
});
|
|
261
266
|
return groups;
|
|
262
267
|
};
|
|
263
268
|
const makeOrderItem = (item, isEdit, soldOut = [], simpleItem, hasPoints = false) => {
|
|
264
|
-
var _a;
|
|
269
|
+
var _a, _b, _c;
|
|
265
270
|
const groups = makeOrderItemGroups(item.option_groups, isEdit, soldOut);
|
|
266
271
|
const cals = ((_a = item.nutritional_info) === null || _a === void 0 ? void 0 : _a.calories)
|
|
267
272
|
? parseInt(item.nutritional_info.calories.toString())
|
|
@@ -301,7 +306,9 @@ const makeOrderItem = (item, isEdit, soldOut = [], simpleItem, hasPoints = false
|
|
|
301
306
|
totalCals: null,
|
|
302
307
|
totalPoints: null,
|
|
303
308
|
totalPrice: null,
|
|
304
|
-
upsellItems: item.upsell_items
|
|
309
|
+
upsellItems: item.upsell_items,
|
|
310
|
+
itemShape: (_b = item.item_shape) !== null && _b !== void 0 ? _b : null,
|
|
311
|
+
excludeFromBuilder: (_c = item.exclude_from_builder) !== null && _c !== void 0 ? _c : false
|
|
305
312
|
};
|
|
306
313
|
const pricedItem = (0, exports.calcPrices)(orderItem);
|
|
307
314
|
return pricedItem;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.roundPoints = void 0;
|
|
4
|
-
const helpers_1 = require("./helpers");
|
|
5
4
|
const roundPoints = (points) => {
|
|
6
5
|
if (!points)
|
|
7
6
|
return 0;
|
|
8
|
-
return parseInt((
|
|
7
|
+
return parseInt(parseFloat(points.toString()).toFixed(0));
|
|
9
8
|
};
|
|
10
9
|
exports.roundPoints = roundPoints;
|
package/dist/cjs/utils/menu.d.ts
CHANGED
|
@@ -49,6 +49,8 @@ export declare const makeOtherMenuSections: (displayedSections: MenuDisplayedSec
|
|
|
49
49
|
taxes: import("@open-tender/types").MenuItemTaxes;
|
|
50
50
|
temperature: import("@open-tender/types").Temperature;
|
|
51
51
|
upsell_items: number[];
|
|
52
|
+
item_shape: import("@open-tender/types").PizzaShape | null;
|
|
53
|
+
exclude_from_builder: boolean;
|
|
52
54
|
}[];
|
|
53
55
|
}[];
|
|
54
56
|
export declare const makeFlatCategories: (categories: MenuCategories) => {
|
|
@@ -92,6 +94,8 @@ export declare const makeFlatCategories: (categories: MenuCategories) => {
|
|
|
92
94
|
taxes: import("@open-tender/types").MenuItemTaxes;
|
|
93
95
|
temperature: import("@open-tender/types").Temperature;
|
|
94
96
|
upsell_items: number[];
|
|
97
|
+
item_shape: import("@open-tender/types").PizzaShape | null;
|
|
98
|
+
exclude_from_builder: boolean;
|
|
95
99
|
}[];
|
|
96
100
|
app_image_url: string | null;
|
|
97
101
|
appearance: import("@open-tender/types").MenuCategoryAppearance;
|
|
@@ -54,4 +54,6 @@ export declare const useMenuItem: (builtItem: CartItem, auth: Auth | null, looku
|
|
|
54
54
|
tags_list?: import("@open-tender/types").MenuItemTags | undefined;
|
|
55
55
|
totalCals: number | null;
|
|
56
56
|
totalPrice: number | null;
|
|
57
|
+
itemShape: import("@open-tender/types").PizzaShape | null;
|
|
58
|
+
excludeFromBuilder: boolean;
|
|
57
59
|
};
|
|
@@ -50,4 +50,6 @@ export declare const useModifier: (group: CartItemGroup, option: CartItemOption,
|
|
|
50
50
|
totalCals: number | null;
|
|
51
51
|
totalPoints: number | null;
|
|
52
52
|
totalPrice: number | null;
|
|
53
|
+
itemShape: import("@open-tender/types").PizzaShape | null;
|
|
54
|
+
excludeFromBuilder: boolean;
|
|
53
55
|
};
|
|
@@ -12,4 +12,6 @@ export declare const useModifierGroup: (group: CartItemGroup, displaySettings?:
|
|
|
12
12
|
name: string;
|
|
13
13
|
options: import("@open-tender/types").CartItemOptions;
|
|
14
14
|
quantity: number;
|
|
15
|
+
itemShape: import("@open-tender/types").PizzaShape | null;
|
|
16
|
+
excludeFromBuilder: boolean;
|
|
15
17
|
};
|
|
@@ -45,4 +45,6 @@ export declare const useOrderItem: (orderItem: CartItem, favorite?: MenuItemFavo
|
|
|
45
45
|
totalCals: number | null;
|
|
46
46
|
totalPoints: number | null;
|
|
47
47
|
totalPrice: number | null;
|
|
48
|
+
itemShape: import("@open-tender/types").PizzaShape | null;
|
|
49
|
+
excludeFromBuilder: boolean;
|
|
48
50
|
};
|
package/dist/esm/utils/cart.d.ts
CHANGED
|
@@ -51,6 +51,8 @@ export declare const rehydrateCart: (menuItems: MenuItems, simpleCartItems: Simp
|
|
|
51
51
|
totalCals: number | null;
|
|
52
52
|
totalPoints: number | null;
|
|
53
53
|
totalPrice: number | null;
|
|
54
|
+
itemShape: import("@open-tender/types").PizzaShape | null;
|
|
55
|
+
excludeFromBuilder: boolean;
|
|
54
56
|
}[];
|
|
55
57
|
cartCounts: Record<string, number>;
|
|
56
58
|
};
|
|
@@ -141,6 +143,8 @@ export declare const combineCarts: (cart: Cart, guestCart: Cart, cartOwner: Cart
|
|
|
141
143
|
totalCals: number | null;
|
|
142
144
|
totalPoints: number | null;
|
|
143
145
|
totalPrice: number | null;
|
|
146
|
+
itemShape: import("@open-tender/types").PizzaShape | null;
|
|
147
|
+
excludeFromBuilder: boolean;
|
|
144
148
|
}[];
|
|
145
149
|
export declare const makeItemImageUrl: (images: Images) => any;
|
|
146
150
|
export declare const makeDisplayItemGroups: (optionGroups: OrderItemGroups) => {
|
package/dist/esm/utils/cart.js
CHANGED
|
@@ -184,8 +184,9 @@ const makeOrderItemGroups = (optionGroups, isEdit, soldOut = []) => {
|
|
|
184
184
|
if (!optionGroups)
|
|
185
185
|
return [];
|
|
186
186
|
const groups = optionGroups.map(g => {
|
|
187
|
+
var _a, _b;
|
|
187
188
|
const options = g.option_items.map(o => {
|
|
188
|
-
var _a;
|
|
189
|
+
var _a, _b, _c;
|
|
189
190
|
const isSoldOut = checkSoldOut(o.id, o.suspend_until, soldOut);
|
|
190
191
|
const quantity = isSoldOut
|
|
191
192
|
? 0
|
|
@@ -224,7 +225,9 @@ const makeOrderItemGroups = (optionGroups, isEdit, soldOut = []) => {
|
|
|
224
225
|
totalAllergens: [],
|
|
225
226
|
totalCals: null,
|
|
226
227
|
totalPoints: null,
|
|
227
|
-
totalPrice: null
|
|
228
|
+
totalPrice: null,
|
|
229
|
+
itemShape: (_b = o.item_shape) !== null && _b !== void 0 ? _b : null,
|
|
230
|
+
excludeFromBuilder: (_c = o.exclude_from_builder) !== null && _c !== void 0 ? _c : false
|
|
228
231
|
};
|
|
229
232
|
return option;
|
|
230
233
|
});
|
|
@@ -239,14 +242,16 @@ const makeOrderItemGroups = (optionGroups, isEdit, soldOut = []) => {
|
|
|
239
242
|
min: g.min_options,
|
|
240
243
|
name: g.name,
|
|
241
244
|
options: options,
|
|
242
|
-
quantity: options.reduce((t, o) => t + o.quantity, 0)
|
|
245
|
+
quantity: options.reduce((t, o) => t + o.quantity, 0),
|
|
246
|
+
itemShape: (_a = g.item_shape) !== null && _a !== void 0 ? _a : null,
|
|
247
|
+
excludeFromBuilder: (_b = g.exclude_from_builder) !== null && _b !== void 0 ? _b : false
|
|
243
248
|
};
|
|
244
249
|
return group;
|
|
245
250
|
});
|
|
246
251
|
return groups;
|
|
247
252
|
};
|
|
248
253
|
export const makeOrderItem = (item, isEdit, soldOut = [], simpleItem, hasPoints = false) => {
|
|
249
|
-
var _a;
|
|
254
|
+
var _a, _b, _c;
|
|
250
255
|
const groups = makeOrderItemGroups(item.option_groups, isEdit, soldOut);
|
|
251
256
|
const cals = ((_a = item.nutritional_info) === null || _a === void 0 ? void 0 : _a.calories)
|
|
252
257
|
? parseInt(item.nutritional_info.calories.toString())
|
|
@@ -286,7 +291,9 @@ export const makeOrderItem = (item, isEdit, soldOut = [], simpleItem, hasPoints
|
|
|
286
291
|
totalCals: null,
|
|
287
292
|
totalPoints: null,
|
|
288
293
|
totalPrice: null,
|
|
289
|
-
upsellItems: item.upsell_items
|
|
294
|
+
upsellItems: item.upsell_items,
|
|
295
|
+
itemShape: (_b = item.item_shape) !== null && _b !== void 0 ? _b : null,
|
|
296
|
+
excludeFromBuilder: (_c = item.exclude_from_builder) !== null && _c !== void 0 ? _c : false
|
|
290
297
|
};
|
|
291
298
|
const pricedItem = calcPrices(orderItem);
|
|
292
299
|
return pricedItem;
|
package/dist/esm/utils/menu.d.ts
CHANGED
|
@@ -49,6 +49,8 @@ export declare const makeOtherMenuSections: (displayedSections: MenuDisplayedSec
|
|
|
49
49
|
taxes: import("@open-tender/types").MenuItemTaxes;
|
|
50
50
|
temperature: import("@open-tender/types").Temperature;
|
|
51
51
|
upsell_items: number[];
|
|
52
|
+
item_shape: import("@open-tender/types").PizzaShape | null;
|
|
53
|
+
exclude_from_builder: boolean;
|
|
52
54
|
}[];
|
|
53
55
|
}[];
|
|
54
56
|
export declare const makeFlatCategories: (categories: MenuCategories) => {
|
|
@@ -92,6 +94,8 @@ export declare const makeFlatCategories: (categories: MenuCategories) => {
|
|
|
92
94
|
taxes: import("@open-tender/types").MenuItemTaxes;
|
|
93
95
|
temperature: import("@open-tender/types").Temperature;
|
|
94
96
|
upsell_items: number[];
|
|
97
|
+
item_shape: import("@open-tender/types").PizzaShape | null;
|
|
98
|
+
exclude_from_builder: boolean;
|
|
95
99
|
}[];
|
|
96
100
|
app_image_url: string | null;
|
|
97
101
|
appearance: import("@open-tender/types").MenuCategoryAppearance;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-tender/utils",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.72",
|
|
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.98",
|
|
40
40
|
"@reduxjs/toolkit": "^1.8.5",
|
|
41
41
|
"@types/google.maps": "^3.53.5",
|
|
42
42
|
"@types/jest": "^29.5.11",
|