@open-tender/utils 0.4.14 → 0.4.16
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/utils/cart.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Cart, CartItem, CartItemGroups, CartLevels, CartItemOption, CartOwner, CheckoutConfig, CheckoutFormAddress, CheckoutFormCustomer, CheckoutPromoCodes, CheckoutTenders, DisplayItem, DisplayItems, Favorites, GroupOrderGuest, GroupOrderGuests, MenuCategories, MenuItem, MenuItems, Money, NutritionalInfo, NutritionalInfoCalcs, Order, OrderCreate, OrderCreateDiscounts, OrderCreateSurcharges, OrderData, OrderItem, OrderItemGroups, Orders, SimpleCart, SimpleCartGroups, SimpleCartItem, SoldOut, Images, CartErrors, BaseItem, FavoritesLookup } from '@open-tender/types';
|
|
2
2
|
export declare const getItemOptions: <T extends BaseItem>(item: T) => BaseItem[];
|
|
3
3
|
export declare const makeModifierNames: <T extends BaseItem>(item: T) => string;
|
|
4
|
+
export declare const makeModifierNamesForGroups: (groups: CartItemGroups) => string;
|
|
4
5
|
export declare const hasGroupsBelowMin: (option: CartItemOption | null, groups: CartItemGroups) => boolean;
|
|
5
6
|
export declare const makeModifierGroups: (groups: CartItemGroups) => [CartItemGroups, CartLevels];
|
|
6
7
|
export declare const makeUpsellItems: (itemIds: number[], itemLookup: Record<string, MenuItem>) => (CartItemOption | CartItem)[];
|
package/dist/cjs/utils/cart.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.makeDeviceType = exports.checkAmountRemaining = exports.prepareOrder = exports.getDefaultTip = exports.validateCart = exports.makeSimpleCart = exports.decrementItem = exports.incrementItem = exports.removeItem = exports.addItem = exports.makeCartItemSignature = exports.makeItemSignature = exports.makeFavoritesLookup = exports.makeUniqueDisplayItems = exports.makeDisplayItems = exports.makeDisplayItem = exports.makeDisplayItemGroups = exports.makeItemImageUrl = exports.combineCarts = exports.compareCarts = exports.makeGuestLookup = exports.rehydrateCheckoutForm = exports.rehydrateCart = exports.rehydrateOrderItem = exports.calcCartCounts = exports.makeOrderItem = exports.checkSoldOut = exports.calcPrices = exports.calcNutritionalInfo = exports.calcNutrition = exports.makeUpsellItemsForCart = exports.makeUpsellItemIds = exports.makeUpsellItems = exports.makeModifierGroups = exports.hasGroupsBelowMin = exports.makeModifierNames = exports.getItemOptions = void 0;
|
|
3
|
+
exports.makeDeviceType = exports.checkAmountRemaining = exports.prepareOrder = exports.getDefaultTip = exports.validateCart = exports.makeSimpleCart = exports.decrementItem = exports.incrementItem = exports.removeItem = exports.addItem = exports.makeCartItemSignature = exports.makeItemSignature = exports.makeFavoritesLookup = exports.makeUniqueDisplayItems = exports.makeDisplayItems = exports.makeDisplayItem = exports.makeDisplayItemGroups = exports.makeItemImageUrl = exports.combineCarts = exports.compareCarts = exports.makeGuestLookup = exports.rehydrateCheckoutForm = exports.rehydrateCart = exports.rehydrateOrderItem = exports.calcCartCounts = exports.makeOrderItem = exports.checkSoldOut = exports.calcPrices = exports.calcNutritionalInfo = exports.calcNutrition = exports.makeUpsellItemsForCart = exports.makeUpsellItemIds = exports.makeUpsellItems = exports.makeModifierGroups = exports.hasGroupsBelowMin = exports.makeModifierNamesForGroups = exports.makeModifierNames = exports.getItemOptions = void 0;
|
|
4
4
|
const types_1 = require("@open-tender/types");
|
|
5
5
|
const helpers_1 = require("./helpers");
|
|
6
6
|
const favorites_1 = require("./favorites");
|
|
@@ -27,6 +27,22 @@ const makeModifierNames = (item) => {
|
|
|
27
27
|
.join(', ');
|
|
28
28
|
};
|
|
29
29
|
exports.makeModifierNames = makeModifierNames;
|
|
30
|
+
const makeModifierNamesForGroups = (groups) => {
|
|
31
|
+
return groups
|
|
32
|
+
.map(group => group.options.filter(option => option.quantity > 0))
|
|
33
|
+
.reduce((arr, i) => [...arr, ...i], [])
|
|
34
|
+
.map(i => {
|
|
35
|
+
const optionNames = (0, exports.makeModifierNamesForGroups)(i.groups);
|
|
36
|
+
const name = optionNames ? `${i.name} (${optionNames})` : i.name;
|
|
37
|
+
return Object.assign(Object.assign({}, i), { name });
|
|
38
|
+
})
|
|
39
|
+
.map(option => option.name)
|
|
40
|
+
.join(', ');
|
|
41
|
+
};
|
|
42
|
+
exports.makeModifierNamesForGroups = makeModifierNamesForGroups;
|
|
43
|
+
// export const makeModifierNames = <T extends BaseItem>(item: T): string => {
|
|
44
|
+
// return makeModifierNamesForGroups(item.groups)
|
|
45
|
+
// }
|
|
30
46
|
const hasGroupsBelowMin = (option, groups) => {
|
|
31
47
|
if (!groups || !groups.length)
|
|
32
48
|
return false;
|
|
@@ -44,19 +44,19 @@ const makeDiscountServiceType = (serviceType) => {
|
|
|
44
44
|
case 'DELIVERY':
|
|
45
45
|
return 'Delivery only';
|
|
46
46
|
default:
|
|
47
|
-
return
|
|
47
|
+
return '';
|
|
48
48
|
}
|
|
49
49
|
};
|
|
50
50
|
const makeDiscountOrderType = (orderType) => {
|
|
51
51
|
switch (orderType) {
|
|
52
52
|
case 'OLO':
|
|
53
|
-
return
|
|
53
|
+
return '';
|
|
54
54
|
case 'CATERING':
|
|
55
55
|
return 'Catering only';
|
|
56
56
|
case 'MERCH':
|
|
57
57
|
return 'Merch only';
|
|
58
58
|
default:
|
|
59
|
-
return
|
|
59
|
+
return '';
|
|
60
60
|
}
|
|
61
61
|
};
|
|
62
62
|
const makeChannelType = (channelType) => {
|
|
@@ -70,7 +70,7 @@ const makeChannelType = (channelType) => {
|
|
|
70
70
|
case 'KIOSK':
|
|
71
71
|
return 'Kiosk Only!';
|
|
72
72
|
default:
|
|
73
|
-
return
|
|
73
|
+
return '';
|
|
74
74
|
}
|
|
75
75
|
};
|
|
76
76
|
const makeLimitations = (item) => {
|
|
@@ -78,8 +78,8 @@ const makeLimitations = (item) => {
|
|
|
78
78
|
const serviceType = makeDiscountServiceType(service_type);
|
|
79
79
|
const orderType = makeDiscountOrderType(order_type);
|
|
80
80
|
const channelType = channel_type && makeChannelType(channel_type);
|
|
81
|
-
const comma = serviceType && orderType ? ', ' :
|
|
82
|
-
const dash = (serviceType || orderType) && channelType ? ' - ' :
|
|
81
|
+
const comma = serviceType && orderType ? ', ' : '';
|
|
82
|
+
const dash = (serviceType || orderType) && channelType ? ' - ' : '';
|
|
83
83
|
if (serviceType || orderType || channelType) {
|
|
84
84
|
return `
|
|
85
85
|
${serviceType}
|
package/dist/esm/utils/cart.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Cart, CartItem, CartItemGroups, CartLevels, CartItemOption, CartOwner, CheckoutConfig, CheckoutFormAddress, CheckoutFormCustomer, CheckoutPromoCodes, CheckoutTenders, DisplayItem, DisplayItems, Favorites, GroupOrderGuest, GroupOrderGuests, MenuCategories, MenuItem, MenuItems, Money, NutritionalInfo, NutritionalInfoCalcs, Order, OrderCreate, OrderCreateDiscounts, OrderCreateSurcharges, OrderData, OrderItem, OrderItemGroups, Orders, SimpleCart, SimpleCartGroups, SimpleCartItem, SoldOut, Images, CartErrors, BaseItem, FavoritesLookup } from '@open-tender/types';
|
|
2
2
|
export declare const getItemOptions: <T extends BaseItem>(item: T) => BaseItem[];
|
|
3
3
|
export declare const makeModifierNames: <T extends BaseItem>(item: T) => string;
|
|
4
|
+
export declare const makeModifierNamesForGroups: (groups: CartItemGroups) => string;
|
|
4
5
|
export declare const hasGroupsBelowMin: (option: CartItemOption | null, groups: CartItemGroups) => boolean;
|
|
5
6
|
export declare const makeModifierGroups: (groups: CartItemGroups) => [CartItemGroups, CartLevels];
|
|
6
7
|
export declare const makeUpsellItems: (itemIds: number[], itemLookup: Record<string, MenuItem>) => (CartItemOption | CartItem)[];
|
package/dist/esm/utils/cart.js
CHANGED
|
@@ -22,6 +22,21 @@ export const makeModifierNames = (item) => {
|
|
|
22
22
|
.map(option => option.name)
|
|
23
23
|
.join(', ');
|
|
24
24
|
};
|
|
25
|
+
export const makeModifierNamesForGroups = (groups) => {
|
|
26
|
+
return groups
|
|
27
|
+
.map(group => group.options.filter(option => option.quantity > 0))
|
|
28
|
+
.reduce((arr, i) => [...arr, ...i], [])
|
|
29
|
+
.map(i => {
|
|
30
|
+
const optionNames = makeModifierNamesForGroups(i.groups);
|
|
31
|
+
const name = optionNames ? `${i.name} (${optionNames})` : i.name;
|
|
32
|
+
return Object.assign(Object.assign({}, i), { name });
|
|
33
|
+
})
|
|
34
|
+
.map(option => option.name)
|
|
35
|
+
.join(', ');
|
|
36
|
+
};
|
|
37
|
+
// export const makeModifierNames = <T extends BaseItem>(item: T): string => {
|
|
38
|
+
// return makeModifierNamesForGroups(item.groups)
|
|
39
|
+
// }
|
|
25
40
|
export const hasGroupsBelowMin = (option, groups) => {
|
|
26
41
|
if (!groups || !groups.length)
|
|
27
42
|
return false;
|
|
@@ -40,19 +40,19 @@ const makeDiscountServiceType = (serviceType) => {
|
|
|
40
40
|
case 'DELIVERY':
|
|
41
41
|
return 'Delivery only';
|
|
42
42
|
default:
|
|
43
|
-
return
|
|
43
|
+
return '';
|
|
44
44
|
}
|
|
45
45
|
};
|
|
46
46
|
const makeDiscountOrderType = (orderType) => {
|
|
47
47
|
switch (orderType) {
|
|
48
48
|
case 'OLO':
|
|
49
|
-
return
|
|
49
|
+
return '';
|
|
50
50
|
case 'CATERING':
|
|
51
51
|
return 'Catering only';
|
|
52
52
|
case 'MERCH':
|
|
53
53
|
return 'Merch only';
|
|
54
54
|
default:
|
|
55
|
-
return
|
|
55
|
+
return '';
|
|
56
56
|
}
|
|
57
57
|
};
|
|
58
58
|
const makeChannelType = (channelType) => {
|
|
@@ -66,7 +66,7 @@ const makeChannelType = (channelType) => {
|
|
|
66
66
|
case 'KIOSK':
|
|
67
67
|
return 'Kiosk Only!';
|
|
68
68
|
default:
|
|
69
|
-
return
|
|
69
|
+
return '';
|
|
70
70
|
}
|
|
71
71
|
};
|
|
72
72
|
export const makeLimitations = (item) => {
|
|
@@ -74,8 +74,8 @@ export const makeLimitations = (item) => {
|
|
|
74
74
|
const serviceType = makeDiscountServiceType(service_type);
|
|
75
75
|
const orderType = makeDiscountOrderType(order_type);
|
|
76
76
|
const channelType = channel_type && makeChannelType(channel_type);
|
|
77
|
-
const comma = serviceType && orderType ? ', ' :
|
|
78
|
-
const dash = (serviceType || orderType) && channelType ? ' - ' :
|
|
77
|
+
const comma = serviceType && orderType ? ', ' : '';
|
|
78
|
+
const dash = (serviceType || orderType) && channelType ? ' - ' : '';
|
|
79
79
|
if (serviceType || orderType || channelType) {
|
|
80
80
|
return `
|
|
81
81
|
${serviceType}
|
package/package.json
CHANGED