@open-tender/utils 0.4.30 → 0.4.32
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/LICENSE.md +21 -21
- package/README.md +2 -2
- package/dist/cjs/__tests__/utils/helpers.test.d.ts +1 -1
- package/dist/cjs/__tests__/utils/helpers.test.js +96 -96
- package/dist/cjs/__tests__/utils/theme.test.d.ts +1 -1
- package/dist/cjs/__tests__/utils/theme.test.js +37 -37
- package/dist/cjs/hooks/index.d.ts +35 -35
- package/dist/cjs/hooks/index.js +38 -38
- package/dist/cjs/hooks/types.d.ts +4 -4
- package/dist/cjs/hooks/types.js +2 -2
- package/dist/cjs/hooks/useAccordion.d.ts +22 -22
- package/dist/cjs/hooks/useAccordion.js +56 -56
- package/dist/cjs/hooks/useAddressForm.d.ts +12 -12
- package/dist/cjs/hooks/useAddressForm.js +83 -83
- package/dist/cjs/hooks/useAllergenForm.d.ts +10 -10
- package/dist/cjs/hooks/useAllergenForm.js +58 -58
- package/dist/cjs/hooks/useBuilder.d.ts +14 -14
- package/dist/cjs/hooks/useBuilder.js +144 -144
- package/dist/cjs/hooks/useCartGuestForm.d.ts +12 -12
- package/dist/cjs/hooks/useCartGuestForm.js +58 -58
- package/dist/cjs/hooks/useCartPoints.d.ts +13 -13
- package/dist/cjs/hooks/useCartPoints.js +74 -74
- package/dist/cjs/hooks/useCommunicationPreferences.js +1 -1
- package/dist/cjs/hooks/useCreditCard.d.ts +13 -13
- package/dist/cjs/hooks/useCreditCard.js +63 -63
- package/dist/cjs/hooks/useCreditCardForm.d.ts +10 -10
- package/dist/cjs/hooks/useCreditCardForm.js +71 -71
- package/dist/cjs/hooks/useCurbside.d.ts +9 -9
- package/dist/cjs/hooks/useCurbside.js +39 -39
- package/dist/cjs/hooks/useDineInForm.d.ts +11 -11
- package/dist/cjs/hooks/useDineInForm.js +56 -56
- package/dist/cjs/hooks/useDonationForm.d.ts +28 -28
- package/dist/cjs/hooks/useDonationForm.js +172 -172
- package/dist/cjs/hooks/useFirstTimes.d.ts +18 -18
- package/dist/cjs/hooks/useFirstTimes.js +81 -81
- package/dist/cjs/hooks/useGiftCardAssignForm.d.ts +14 -14
- package/dist/cjs/hooks/useGiftCardAssignForm.js +57 -57
- package/dist/cjs/hooks/useGiftCardAssignOtherForm.d.ts +14 -14
- package/dist/cjs/hooks/useGiftCardAssignOtherForm.js +50 -50
- package/dist/cjs/hooks/useGiftCardForm.d.ts +12 -12
- package/dist/cjs/hooks/useGiftCardForm.js +74 -74
- package/dist/cjs/hooks/useGiftCardsForm.d.ts +31 -31
- package/dist/cjs/hooks/useGiftCardsForm.js +195 -195
- package/dist/cjs/hooks/useGuestCheckoutForm.d.ts +21 -21
- package/dist/cjs/hooks/useGuestCheckoutForm.js +89 -89
- package/dist/cjs/hooks/useGuestForm.d.ts +12 -12
- package/dist/cjs/hooks/useGuestForm.js +60 -60
- package/dist/cjs/hooks/useImage.d.ts +5 -5
- package/dist/cjs/hooks/useImage.js +33 -33
- package/dist/cjs/hooks/useLoginForm.d.ts +12 -12
- package/dist/cjs/hooks/useLoginForm.js +67 -67
- package/dist/cjs/hooks/useMenuItem.d.ts +57 -55
- package/dist/cjs/hooks/useMenuItem.js +67 -67
- package/dist/cjs/hooks/useModifier.d.ts +53 -51
- package/dist/cjs/hooks/useModifier.js +72 -72
- package/dist/cjs/hooks/useModifierGroup.d.ts +15 -15
- package/dist/cjs/hooks/useModifierGroup.js +17 -17
- package/dist/cjs/hooks/useOneTimePasscodeForm.d.ts +16 -16
- package/dist/cjs/hooks/useOneTimePasscodeForm.js +87 -87
- package/dist/cjs/hooks/useOrderFulfillmentForm.d.ts +11 -11
- package/dist/cjs/hooks/useOrderFulfillmentForm.js +65 -65
- package/dist/cjs/hooks/useOrderItem.d.ts +48 -46
- package/dist/cjs/hooks/useOrderItem.js +54 -54
- package/dist/cjs/hooks/useOrderRating.d.ts +10 -10
- package/dist/cjs/hooks/useOrderRating.js +34 -34
- package/dist/cjs/hooks/useOrderRatingForm.d.ts +11 -11
- package/dist/cjs/hooks/useOrderRatingForm.js +35 -35
- package/dist/cjs/hooks/useProfileForm.d.ts +15 -15
- package/dist/cjs/hooks/useProfileForm.js +116 -116
- package/dist/cjs/hooks/useResetPasswordForm.d.ts +12 -12
- package/dist/cjs/hooks/useResetPasswordForm.js +77 -77
- package/dist/cjs/hooks/useSendResetForm.d.ts +14 -14
- package/dist/cjs/hooks/useSendResetForm.js +57 -57
- package/dist/cjs/hooks/useSignUpForm.d.ts +20 -20
- package/dist/cjs/hooks/useSignUpForm.js +151 -151
- package/dist/cjs/hooks/useSignUpGuestForm.d.ts +23 -23
- package/dist/cjs/hooks/useSignUpGuestForm.js +122 -113
- package/dist/cjs/hooks/useSigninForm.d.ts +12 -12
- package/dist/cjs/hooks/useSigninForm.js +66 -66
- package/dist/cjs/index.d.ts +2 -2
- package/dist/cjs/index.js +5 -5
- package/dist/cjs/utils/cards.d.ts +20 -20
- package/dist/cjs/utils/cards.js +155 -155
- package/dist/cjs/utils/cart.d.ts +202 -198
- package/dist/cjs/utils/cart.js +909 -905
- package/dist/cjs/utils/checkout.d.ts +55 -55
- package/dist/cjs/utils/checkout.js +125 -125
- package/dist/cjs/utils/constants.d.ts +43 -43
- package/dist/cjs/utils/constants.js +58 -58
- package/dist/cjs/utils/customer.d.ts +4 -4
- package/dist/cjs/utils/customer.js +34 -34
- package/dist/cjs/utils/datetimes.d.ts +99 -99
- package/dist/cjs/utils/datetimes.js +601 -601
- package/dist/cjs/utils/errors.d.ts +51 -51
- package/dist/cjs/utils/errors.js +191 -191
- package/dist/cjs/utils/favorites.d.ts +10 -10
- package/dist/cjs/utils/favorites.js +119 -119
- package/dist/cjs/utils/googleMaps.d.ts +14 -14
- package/dist/cjs/utils/googleMaps.js +30 -30
- package/dist/cjs/utils/helpers.d.ts +63 -63
- package/dist/cjs/utils/helpers.js +244 -244
- package/dist/cjs/utils/index.d.ts +19 -19
- package/dist/cjs/utils/index.js +23 -23
- package/dist/cjs/utils/keypad.d.ts +9 -9
- package/dist/cjs/utils/keypad.js +105 -105
- package/dist/cjs/utils/maps.d.ts +226 -226
- package/dist/cjs/utils/maps.js +334 -334
- package/dist/cjs/utils/menu.d.ts +117 -113
- package/dist/cjs/utils/menu.js +82 -82
- package/dist/cjs/utils/orders.d.ts +21 -21
- package/dist/cjs/utils/orders.js +202 -202
- package/dist/cjs/utils/pizzaBuilder.d.ts +10 -10
- package/dist/cjs/utils/pizzaBuilder.js +43 -43
- package/dist/cjs/utils/refunds.d.ts +35 -35
- package/dist/cjs/utils/refunds.js +98 -98
- package/dist/cjs/utils/revenueCenters.d.ts +11 -11
- package/dist/cjs/utils/revenueCenters.js +125 -125
- package/dist/cjs/utils/rewards.d.ts +4 -4
- package/dist/cjs/utils/rewards.js +106 -106
- package/dist/cjs/utils/theme.d.ts +27 -27
- package/dist/cjs/utils/theme.js +266 -266
- package/dist/cjs/utils/version.d.ts +4 -4
- package/dist/cjs/utils/version.js +38 -38
- package/dist/esm/__tests__/utils/helpers.test.d.ts +1 -1
- package/dist/esm/__tests__/utils/helpers.test.js +94 -94
- package/dist/esm/__tests__/utils/theme.test.d.ts +1 -1
- package/dist/esm/__tests__/utils/theme.test.js +35 -35
- package/dist/esm/hooks/index.d.ts +35 -35
- package/dist/esm/hooks/index.js +35 -35
- package/dist/esm/hooks/types.d.ts +4 -4
- package/dist/esm/hooks/types.js +1 -1
- package/dist/esm/hooks/useAccordion.d.ts +22 -22
- package/dist/esm/hooks/useAccordion.js +52 -52
- package/dist/esm/hooks/useAddressForm.d.ts +12 -12
- package/dist/esm/hooks/useAddressForm.js +79 -79
- package/dist/esm/hooks/useAllergenForm.d.ts +10 -10
- package/dist/esm/hooks/useAllergenForm.js +54 -54
- package/dist/esm/hooks/useBuilder.d.ts +14 -14
- package/dist/esm/hooks/useBuilder.js +140 -140
- package/dist/esm/hooks/useCartGuestForm.d.ts +12 -12
- package/dist/esm/hooks/useCartGuestForm.js +54 -54
- package/dist/esm/hooks/useCartPoints.d.ts +13 -13
- package/dist/esm/hooks/useCartPoints.js +70 -70
- package/dist/esm/hooks/useCommunicationPreferences.js +1 -1
- package/dist/esm/hooks/useCreditCard.d.ts +13 -13
- package/dist/esm/hooks/useCreditCard.js +59 -59
- package/dist/esm/hooks/useCreditCardForm.d.ts +10 -10
- package/dist/esm/hooks/useCreditCardForm.js +67 -67
- package/dist/esm/hooks/useCurbside.d.ts +9 -9
- package/dist/esm/hooks/useCurbside.js +35 -35
- package/dist/esm/hooks/useDineInForm.d.ts +11 -11
- package/dist/esm/hooks/useDineInForm.js +52 -52
- package/dist/esm/hooks/useDonationForm.d.ts +28 -28
- package/dist/esm/hooks/useDonationForm.js +168 -168
- package/dist/esm/hooks/useFirstTimes.d.ts +18 -18
- package/dist/esm/hooks/useFirstTimes.js +77 -77
- package/dist/esm/hooks/useGiftCardAssignForm.d.ts +14 -14
- package/dist/esm/hooks/useGiftCardAssignForm.js +53 -53
- package/dist/esm/hooks/useGiftCardAssignOtherForm.d.ts +14 -14
- package/dist/esm/hooks/useGiftCardAssignOtherForm.js +46 -46
- package/dist/esm/hooks/useGiftCardForm.d.ts +12 -12
- package/dist/esm/hooks/useGiftCardForm.js +70 -70
- package/dist/esm/hooks/useGiftCardsForm.d.ts +31 -31
- package/dist/esm/hooks/useGiftCardsForm.js +191 -191
- package/dist/esm/hooks/useGuestCheckoutForm.d.ts +21 -21
- package/dist/esm/hooks/useGuestCheckoutForm.js +85 -85
- package/dist/esm/hooks/useGuestForm.d.ts +12 -12
- package/dist/esm/hooks/useGuestForm.js +56 -56
- package/dist/esm/hooks/useImage.d.ts +5 -5
- package/dist/esm/hooks/useImage.js +29 -29
- package/dist/esm/hooks/useLoginForm.d.ts +12 -12
- package/dist/esm/hooks/useLoginForm.js +63 -63
- package/dist/esm/hooks/useMenuItem.d.ts +57 -55
- package/dist/esm/hooks/useMenuItem.js +63 -63
- package/dist/esm/hooks/useModifier.d.ts +53 -51
- package/dist/esm/hooks/useModifier.js +68 -68
- package/dist/esm/hooks/useModifierGroup.d.ts +15 -15
- package/dist/esm/hooks/useModifierGroup.js +13 -13
- package/dist/esm/hooks/useOneTimePasscodeForm.d.ts +16 -16
- package/dist/esm/hooks/useOneTimePasscodeForm.js +83 -83
- package/dist/esm/hooks/useOrderFulfillmentForm.d.ts +11 -11
- package/dist/esm/hooks/useOrderFulfillmentForm.js +61 -61
- package/dist/esm/hooks/useOrderItem.d.ts +48 -46
- package/dist/esm/hooks/useOrderItem.js +50 -50
- package/dist/esm/hooks/useOrderRating.d.ts +10 -10
- package/dist/esm/hooks/useOrderRating.js +30 -30
- package/dist/esm/hooks/useOrderRatingForm.d.ts +11 -11
- package/dist/esm/hooks/useOrderRatingForm.js +31 -31
- package/dist/esm/hooks/useProfileForm.d.ts +15 -15
- package/dist/esm/hooks/useProfileForm.js +112 -112
- package/dist/esm/hooks/useResetPasswordForm.d.ts +12 -12
- package/dist/esm/hooks/useResetPasswordForm.js +73 -73
- package/dist/esm/hooks/useSendResetForm.d.ts +14 -14
- package/dist/esm/hooks/useSendResetForm.js +53 -53
- package/dist/esm/hooks/useSignUpForm.d.ts +20 -20
- package/dist/esm/hooks/useSignUpForm.js +147 -147
- package/dist/esm/hooks/useSignUpGuestForm.d.ts +23 -23
- package/dist/esm/hooks/useSignUpGuestForm.js +118 -109
- package/dist/esm/hooks/useSigninForm.d.ts +12 -12
- package/dist/esm/hooks/useSigninForm.js +62 -62
- package/dist/esm/index.d.ts +2 -2
- package/dist/esm/index.js +2 -2
- package/dist/esm/utils/cards.d.ts +20 -20
- package/dist/esm/utils/cards.js +146 -146
- package/dist/esm/utils/cart.d.ts +202 -198
- package/dist/esm/utils/cart.js +868 -864
- package/dist/esm/utils/checkout.d.ts +55 -55
- package/dist/esm/utils/checkout.js +117 -117
- package/dist/esm/utils/constants.d.ts +43 -43
- package/dist/esm/utils/constants.js +55 -55
- package/dist/esm/utils/customer.d.ts +4 -4
- package/dist/esm/utils/customer.js +29 -29
- package/dist/esm/utils/datetimes.d.ts +99 -99
- package/dist/esm/utils/datetimes.js +531 -531
- package/dist/esm/utils/errors.d.ts +51 -51
- package/dist/esm/utils/errors.js +180 -180
- package/dist/esm/utils/favorites.d.ts +10 -10
- package/dist/esm/utils/favorites.js +109 -109
- package/dist/esm/utils/googleMaps.d.ts +14 -14
- package/dist/esm/utils/googleMaps.js +26 -26
- package/dist/esm/utils/helpers.d.ts +63 -63
- package/dist/esm/utils/helpers.js +205 -205
- package/dist/esm/utils/index.d.ts +19 -19
- package/dist/esm/utils/index.js +20 -20
- package/dist/esm/utils/keypad.d.ts +9 -9
- package/dist/esm/utils/keypad.js +97 -97
- package/dist/esm/utils/maps.d.ts +226 -226
- package/dist/esm/utils/maps.js +316 -316
- package/dist/esm/utils/menu.d.ts +117 -113
- package/dist/esm/utils/menu.js +74 -74
- package/dist/esm/utils/orders.d.ts +21 -21
- package/dist/esm/utils/orders.js +185 -185
- package/dist/esm/utils/pizzaBuilder.d.ts +10 -10
- package/dist/esm/utils/pizzaBuilder.js +38 -38
- package/dist/esm/utils/refunds.d.ts +35 -35
- package/dist/esm/utils/refunds.js +90 -90
- package/dist/esm/utils/revenueCenters.d.ts +11 -11
- package/dist/esm/utils/revenueCenters.js +115 -115
- package/dist/esm/utils/rewards.d.ts +4 -4
- package/dist/esm/utils/rewards.js +100 -100
- package/dist/esm/utils/theme.d.ts +27 -27
- package/dist/esm/utils/theme.js +254 -254
- package/dist/esm/utils/version.d.ts +4 -4
- package/dist/esm/utils/version.js +34 -34
- package/package.json +69 -68
|
@@ -1,109 +1,109 @@
|
|
|
1
|
-
import { makeUniqueDisplayItems } from './cart';
|
|
2
|
-
export const makeMenuItemLookup = (categories) => {
|
|
3
|
-
const cats = categories.reduce((arr, cat) => {
|
|
4
|
-
return [...arr, cat, ...(cat.children || [])];
|
|
5
|
-
}, []);
|
|
6
|
-
return cats.reduce((obj, category) => {
|
|
7
|
-
const items = category.items.reduce((o, i) => (Object.assign(Object.assign({}, o), { [i.id]: i })), {});
|
|
8
|
-
return Object.assign(Object.assign({}, obj), items);
|
|
9
|
-
}, {});
|
|
10
|
-
};
|
|
11
|
-
export const makeFeatured = (categories) => {
|
|
12
|
-
const flatCategories = categories.reduce((arr, cat) => {
|
|
13
|
-
return [...arr, cat, ...(cat.children || [])];
|
|
14
|
-
}, []);
|
|
15
|
-
const featured = flatCategories.reduce((arr, category) => {
|
|
16
|
-
const items = category.items.filter(i => i.featured_position);
|
|
17
|
-
return [...arr, ...items];
|
|
18
|
-
}, []);
|
|
19
|
-
return featured.sort((a, b) => { var _a, _b; return ((_a = a.featured_position) !== null && _a !== void 0 ? _a : 0) - ((_b = b.featured_position) !== null && _b !== void 0 ? _b : 0); });
|
|
20
|
-
};
|
|
21
|
-
export const makeMenuGroupsLookup = (menuItem) => {
|
|
22
|
-
if (!menuItem.option_groups)
|
|
23
|
-
return {};
|
|
24
|
-
return menuItem.option_groups.reduce((grpObj, i) => {
|
|
25
|
-
const options = i.option_items.reduce((optObj, o) => {
|
|
26
|
-
var _a;
|
|
27
|
-
optObj[(_a = o.id) !== null && _a !== void 0 ? _a : 0] = o;
|
|
28
|
-
return optObj;
|
|
29
|
-
}, {});
|
|
30
|
-
grpObj[i.id] = Object.assign(Object.assign({}, i), { options });
|
|
31
|
-
return grpObj;
|
|
32
|
-
}, {});
|
|
33
|
-
};
|
|
34
|
-
const validateFavorite = (item, menuItem, soldOut) => {
|
|
35
|
-
const groupsLookup = makeMenuGroupsLookup(menuItem);
|
|
36
|
-
const missingGroups = [];
|
|
37
|
-
const missingOptions = [];
|
|
38
|
-
item.groups.forEach(group => {
|
|
39
|
-
var _a;
|
|
40
|
-
if (group.id) {
|
|
41
|
-
const menuItemGroup = groupsLookup[group.id];
|
|
42
|
-
if (menuItemGroup) {
|
|
43
|
-
(_a = group === null || group === void 0 ? void 0 : group.options) === null || _a === void 0 ? void 0 : _a.forEach(option => {
|
|
44
|
-
if (option.id) {
|
|
45
|
-
const menuItemOption = menuItemGroup.options[option.id];
|
|
46
|
-
if (!menuItemOption || soldOut.includes(option.id)) {
|
|
47
|
-
missingOptions.push(option);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
else {
|
|
53
|
-
missingGroups.push(group);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
return missingGroups.length || missingOptions.length ? false : true;
|
|
58
|
-
};
|
|
59
|
-
export const makeRecents = (recents, itemLookup, soldOut) => {
|
|
60
|
-
return recents.reduce((arr, item) => {
|
|
61
|
-
if (item.id) {
|
|
62
|
-
const menuItem = itemLookup[item.id];
|
|
63
|
-
if (!menuItem)
|
|
64
|
-
return arr;
|
|
65
|
-
const isValid = validateFavorite(item, menuItem, soldOut);
|
|
66
|
-
if (!isValid)
|
|
67
|
-
return arr;
|
|
68
|
-
const favorite = { item };
|
|
69
|
-
return isValid
|
|
70
|
-
? [
|
|
71
|
-
...arr,
|
|
72
|
-
Object.assign(Object.assign({}, menuItem), { favorite: { item: Object.assign(Object.assign({}, favorite.item), { quantity: 1 }) } })
|
|
73
|
-
]
|
|
74
|
-
: arr;
|
|
75
|
-
}
|
|
76
|
-
else {
|
|
77
|
-
return arr;
|
|
78
|
-
}
|
|
79
|
-
}, []);
|
|
80
|
-
};
|
|
81
|
-
export const makeRecentItems = (categories, soldOut, orders) => {
|
|
82
|
-
if (!orders.length)
|
|
83
|
-
return [];
|
|
84
|
-
const displayItems = makeUniqueDisplayItems(orders);
|
|
85
|
-
const itemLookup = makeMenuItemLookup(categories);
|
|
86
|
-
return makeRecents(displayItems, itemLookup, soldOut);
|
|
87
|
-
};
|
|
88
|
-
export const makeFavorites = (favorites, itemLookup, soldOut) => {
|
|
89
|
-
return favorites.reduce((arr, favorite) => {
|
|
90
|
-
var _a, _b;
|
|
91
|
-
if ((_a = favorite === null || favorite === void 0 ? void 0 : favorite.item) === null || _a === void 0 ? void 0 : _a.id) {
|
|
92
|
-
const menuItem = itemLookup[(_b = favorite === null || favorite === void 0 ? void 0 : favorite.item) === null || _b === void 0 ? void 0 : _b.id];
|
|
93
|
-
if (!menuItem)
|
|
94
|
-
return arr;
|
|
95
|
-
const isValid = validateFavorite(favorite.item, menuItem, soldOut);
|
|
96
|
-
const favoriteSimple = { item: Object.assign(Object.assign({}, favorite.item), { quantity: 1 }) };
|
|
97
|
-
return isValid ? [...arr, Object.assign(Object.assign({}, menuItem), { favorite: favoriteSimple })] : arr;
|
|
98
|
-
}
|
|
99
|
-
else {
|
|
100
|
-
return arr;
|
|
101
|
-
}
|
|
102
|
-
}, []);
|
|
103
|
-
};
|
|
104
|
-
export const makeFavoriteItems = (categories, soldOut, favorites) => {
|
|
105
|
-
if (!favorites.length)
|
|
106
|
-
return [];
|
|
107
|
-
const itemLookup = makeMenuItemLookup(categories);
|
|
108
|
-
return makeFavorites(favorites, itemLookup, soldOut);
|
|
109
|
-
};
|
|
1
|
+
import { makeUniqueDisplayItems } from './cart';
|
|
2
|
+
export const makeMenuItemLookup = (categories) => {
|
|
3
|
+
const cats = categories.reduce((arr, cat) => {
|
|
4
|
+
return [...arr, cat, ...(cat.children || [])];
|
|
5
|
+
}, []);
|
|
6
|
+
return cats.reduce((obj, category) => {
|
|
7
|
+
const items = category.items.reduce((o, i) => (Object.assign(Object.assign({}, o), { [i.id]: i })), {});
|
|
8
|
+
return Object.assign(Object.assign({}, obj), items);
|
|
9
|
+
}, {});
|
|
10
|
+
};
|
|
11
|
+
export const makeFeatured = (categories) => {
|
|
12
|
+
const flatCategories = categories.reduce((arr, cat) => {
|
|
13
|
+
return [...arr, cat, ...(cat.children || [])];
|
|
14
|
+
}, []);
|
|
15
|
+
const featured = flatCategories.reduce((arr, category) => {
|
|
16
|
+
const items = category.items.filter(i => i.featured_position);
|
|
17
|
+
return [...arr, ...items];
|
|
18
|
+
}, []);
|
|
19
|
+
return featured.sort((a, b) => { var _a, _b; return ((_a = a.featured_position) !== null && _a !== void 0 ? _a : 0) - ((_b = b.featured_position) !== null && _b !== void 0 ? _b : 0); });
|
|
20
|
+
};
|
|
21
|
+
export const makeMenuGroupsLookup = (menuItem) => {
|
|
22
|
+
if (!menuItem.option_groups)
|
|
23
|
+
return {};
|
|
24
|
+
return menuItem.option_groups.reduce((grpObj, i) => {
|
|
25
|
+
const options = i.option_items.reduce((optObj, o) => {
|
|
26
|
+
var _a;
|
|
27
|
+
optObj[(_a = o.id) !== null && _a !== void 0 ? _a : 0] = o;
|
|
28
|
+
return optObj;
|
|
29
|
+
}, {});
|
|
30
|
+
grpObj[i.id] = Object.assign(Object.assign({}, i), { options });
|
|
31
|
+
return grpObj;
|
|
32
|
+
}, {});
|
|
33
|
+
};
|
|
34
|
+
const validateFavorite = (item, menuItem, soldOut) => {
|
|
35
|
+
const groupsLookup = makeMenuGroupsLookup(menuItem);
|
|
36
|
+
const missingGroups = [];
|
|
37
|
+
const missingOptions = [];
|
|
38
|
+
item.groups.forEach(group => {
|
|
39
|
+
var _a;
|
|
40
|
+
if (group.id) {
|
|
41
|
+
const menuItemGroup = groupsLookup[group.id];
|
|
42
|
+
if (menuItemGroup) {
|
|
43
|
+
(_a = group === null || group === void 0 ? void 0 : group.options) === null || _a === void 0 ? void 0 : _a.forEach(option => {
|
|
44
|
+
if (option.id) {
|
|
45
|
+
const menuItemOption = menuItemGroup.options[option.id];
|
|
46
|
+
if (!menuItemOption || soldOut.includes(option.id)) {
|
|
47
|
+
missingOptions.push(option);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
missingGroups.push(group);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
return missingGroups.length || missingOptions.length ? false : true;
|
|
58
|
+
};
|
|
59
|
+
export const makeRecents = (recents, itemLookup, soldOut) => {
|
|
60
|
+
return recents.reduce((arr, item) => {
|
|
61
|
+
if (item.id) {
|
|
62
|
+
const menuItem = itemLookup[item.id];
|
|
63
|
+
if (!menuItem)
|
|
64
|
+
return arr;
|
|
65
|
+
const isValid = validateFavorite(item, menuItem, soldOut);
|
|
66
|
+
if (!isValid)
|
|
67
|
+
return arr;
|
|
68
|
+
const favorite = { item };
|
|
69
|
+
return isValid
|
|
70
|
+
? [
|
|
71
|
+
...arr,
|
|
72
|
+
Object.assign(Object.assign({}, menuItem), { favorite: { item: Object.assign(Object.assign({}, favorite.item), { quantity: 1 }) } })
|
|
73
|
+
]
|
|
74
|
+
: arr;
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
return arr;
|
|
78
|
+
}
|
|
79
|
+
}, []);
|
|
80
|
+
};
|
|
81
|
+
export const makeRecentItems = (categories, soldOut, orders) => {
|
|
82
|
+
if (!orders.length)
|
|
83
|
+
return [];
|
|
84
|
+
const displayItems = makeUniqueDisplayItems(orders);
|
|
85
|
+
const itemLookup = makeMenuItemLookup(categories);
|
|
86
|
+
return makeRecents(displayItems, itemLookup, soldOut);
|
|
87
|
+
};
|
|
88
|
+
export const makeFavorites = (favorites, itemLookup, soldOut) => {
|
|
89
|
+
return favorites.reduce((arr, favorite) => {
|
|
90
|
+
var _a, _b;
|
|
91
|
+
if ((_a = favorite === null || favorite === void 0 ? void 0 : favorite.item) === null || _a === void 0 ? void 0 : _a.id) {
|
|
92
|
+
const menuItem = itemLookup[(_b = favorite === null || favorite === void 0 ? void 0 : favorite.item) === null || _b === void 0 ? void 0 : _b.id];
|
|
93
|
+
if (!menuItem)
|
|
94
|
+
return arr;
|
|
95
|
+
const isValid = validateFavorite(favorite.item, menuItem, soldOut);
|
|
96
|
+
const favoriteSimple = { item: Object.assign(Object.assign({}, favorite.item), { quantity: 1 }) };
|
|
97
|
+
return isValid ? [...arr, Object.assign(Object.assign({}, menuItem), { favorite: favoriteSimple })] : arr;
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
return arr;
|
|
101
|
+
}
|
|
102
|
+
}, []);
|
|
103
|
+
};
|
|
104
|
+
export const makeFavoriteItems = (categories, soldOut, favorites) => {
|
|
105
|
+
if (!favorites.length)
|
|
106
|
+
return [];
|
|
107
|
+
const itemLookup = makeMenuItemLookup(categories);
|
|
108
|
+
return makeFavorites(favorites, itemLookup, soldOut);
|
|
109
|
+
};
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
/// <reference types="google.maps" />
|
|
2
|
-
export interface AddressName {
|
|
3
|
-
long_name: string;
|
|
4
|
-
short_name: string;
|
|
5
|
-
}
|
|
6
|
-
export declare const makeAddress: (place: google.maps.places.PlaceResult) => {
|
|
7
|
-
street: string;
|
|
8
|
-
city: string;
|
|
9
|
-
state: string;
|
|
10
|
-
postal_code: string;
|
|
11
|
-
lat: number;
|
|
12
|
-
lng: number;
|
|
13
|
-
formatted_address: string | undefined;
|
|
14
|
-
} | null;
|
|
1
|
+
/// <reference types="google.maps" />
|
|
2
|
+
export interface AddressName {
|
|
3
|
+
long_name: string;
|
|
4
|
+
short_name: string;
|
|
5
|
+
}
|
|
6
|
+
export declare const makeAddress: (place: google.maps.places.PlaceResult) => {
|
|
7
|
+
street: string;
|
|
8
|
+
city: string;
|
|
9
|
+
state: string;
|
|
10
|
+
postal_code: string;
|
|
11
|
+
lat: number;
|
|
12
|
+
lng: number;
|
|
13
|
+
formatted_address: string | undefined;
|
|
14
|
+
} | null;
|
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
const makeComponents = (components) => {
|
|
2
|
-
const result = components === null || components === void 0 ? void 0 : components.reduce((obj, i) => {
|
|
3
|
-
return Object.assign(Object.assign({}, obj), { [i.types[0]]: { long_name: i.long_name, short_name: i.short_name } });
|
|
4
|
-
}, {});
|
|
5
|
-
return result;
|
|
6
|
-
};
|
|
7
|
-
export const makeAddress = (place) => {
|
|
8
|
-
var _a, _b;
|
|
9
|
-
const { address_components, formatted_address, geometry } = place;
|
|
10
|
-
const components = makeComponents(address_components);
|
|
11
|
-
if (!components)
|
|
12
|
-
return null;
|
|
13
|
-
const { street_number, route, locality: city, sublocality_level_1: subcity, administrative_area_level_1: state, postal_code: postalCode } = components;
|
|
14
|
-
const streetNumber = street_number ? street_number.short_name : '';
|
|
15
|
-
const street = route ? route.long_name : '';
|
|
16
|
-
const addressCity = city || subcity;
|
|
17
|
-
return {
|
|
18
|
-
street: `${streetNumber} ${street}`.trim(),
|
|
19
|
-
city: addressCity ? addressCity.long_name : '',
|
|
20
|
-
state: state ? state.short_name : '',
|
|
21
|
-
postal_code: postalCode ? postalCode.short_name : '',
|
|
22
|
-
lat: ((_a = geometry === null || geometry === void 0 ? void 0 : geometry.location) === null || _a === void 0 ? void 0 : _a.lat()) || 0,
|
|
23
|
-
lng: ((_b = geometry === null || geometry === void 0 ? void 0 : geometry.location) === null || _b === void 0 ? void 0 : _b.lng()) || 0,
|
|
24
|
-
formatted_address
|
|
25
|
-
};
|
|
26
|
-
};
|
|
1
|
+
const makeComponents = (components) => {
|
|
2
|
+
const result = components === null || components === void 0 ? void 0 : components.reduce((obj, i) => {
|
|
3
|
+
return Object.assign(Object.assign({}, obj), { [i.types[0]]: { long_name: i.long_name, short_name: i.short_name } });
|
|
4
|
+
}, {});
|
|
5
|
+
return result;
|
|
6
|
+
};
|
|
7
|
+
export const makeAddress = (place) => {
|
|
8
|
+
var _a, _b;
|
|
9
|
+
const { address_components, formatted_address, geometry } = place;
|
|
10
|
+
const components = makeComponents(address_components);
|
|
11
|
+
if (!components)
|
|
12
|
+
return null;
|
|
13
|
+
const { street_number, route, locality: city, sublocality_level_1: subcity, administrative_area_level_1: state, postal_code: postalCode } = components;
|
|
14
|
+
const streetNumber = street_number ? street_number.short_name : '';
|
|
15
|
+
const street = route ? route.long_name : '';
|
|
16
|
+
const addressCity = city || subcity;
|
|
17
|
+
return {
|
|
18
|
+
street: `${streetNumber} ${street}`.trim(),
|
|
19
|
+
city: addressCity ? addressCity.long_name : '',
|
|
20
|
+
state: state ? state.short_name : '',
|
|
21
|
+
postal_code: postalCode ? postalCode.short_name : '',
|
|
22
|
+
lat: ((_a = geometry === null || geometry === void 0 ? void 0 : geometry.location) === null || _a === void 0 ? void 0 : _a.lat()) || 0,
|
|
23
|
+
lng: ((_b = geometry === null || geometry === void 0 ? void 0 : geometry.location) === null || _b === void 0 ? void 0 : _b.lng()) || 0,
|
|
24
|
+
formatted_address
|
|
25
|
+
};
|
|
26
|
+
};
|
|
@@ -1,63 +1,63 @@
|
|
|
1
|
-
import { Announcements, CheckoutFormCustomer, ContentImages, DateString, Images, RequestError, RequestStatus } from '@open-tender/types';
|
|
2
|
-
export declare const isString: (str: any) => boolean;
|
|
3
|
-
export declare const isObject: (obj: any) => boolean;
|
|
4
|
-
export declare const isEmpty: (obj?: object | null) => boolean;
|
|
5
|
-
export declare const isNum: (s: string) => boolean;
|
|
6
|
-
/**
|
|
7
|
-
* @deprecated please use `containsAll` or `containsAny` instead
|
|
8
|
-
* @returns true if first argument contains any of the values in the second argument
|
|
9
|
-
*/
|
|
10
|
-
export declare const contains: (arr: Array<any> | string, values: Array<any>) => boolean;
|
|
11
|
-
/**
|
|
12
|
-
* @returns true if first argument contains any of the values in the second argument
|
|
13
|
-
*/
|
|
14
|
-
export declare const containsAny: <T>(arr: T[], values: T[]) => boolean;
|
|
15
|
-
/**
|
|
16
|
-
* @returns true if first argument contains all of the values of the second argument
|
|
17
|
-
*/
|
|
18
|
-
export declare const containsAll: <T>(arr: T[], values: T[]) => boolean;
|
|
19
|
-
export declare const slugify: (text: string) => string;
|
|
20
|
-
export declare const stripTags: (s: string) => string;
|
|
21
|
-
export declare const serialize: (obj: Record<string | number, string | number | boolean>) => string;
|
|
22
|
-
export declare const capitalize: (s: string) => string;
|
|
23
|
-
export declare const cleanPhone: (phone: string) => string;
|
|
24
|
-
export declare const makePhone: (phone: string) => string;
|
|
25
|
-
export declare const validatePhone: (phone: string) => boolean;
|
|
26
|
-
export declare const makeBirthDate: (birthDate: string) => string | null;
|
|
27
|
-
export declare const slashesToDashes: (birthDate: string) => DateString | null;
|
|
28
|
-
export declare const dashesToSlashes: (birthDate?: string | null) => string | null;
|
|
29
|
-
export declare const validateEmail: (email: string) => boolean;
|
|
30
|
-
export declare const checkEmpty: (data: Record<string | number, unknown>) => boolean;
|
|
31
|
-
export declare const checkGuestData: (data: CheckoutFormCustomer, email: string) => {
|
|
32
|
-
guestData: {
|
|
33
|
-
first_name: string | undefined;
|
|
34
|
-
last_name: string | undefined;
|
|
35
|
-
phone: string | undefined;
|
|
36
|
-
email: string;
|
|
37
|
-
};
|
|
38
|
-
guestIncomplete: boolean;
|
|
39
|
-
};
|
|
40
|
-
export declare const checkNotFound: (errors: Record<string, string>) => boolean | null;
|
|
41
|
-
export declare const makeRandomNumberString: () => string;
|
|
42
|
-
export declare const getWidth: () => number;
|
|
43
|
-
export declare const getHeight: () => number;
|
|
44
|
-
export declare const makeImageMap: (images: Images) => {
|
|
45
|
-
APP_IMAGE?: string | undefined;
|
|
46
|
-
LARGE_IMAGE?: string | undefined;
|
|
47
|
-
SMALL_IMAGE?: string | undefined;
|
|
48
|
-
};
|
|
49
|
-
export declare const makeImageUrl: (images: ContentImages, isMobile: boolean) => string | null | undefined;
|
|
50
|
-
export declare const makeSlides: (items: Announcements, isMobile: boolean) => Announcements | null;
|
|
51
|
-
export declare const displayPrice: (price: string) => string;
|
|
52
|
-
export declare const addCommas: (x: number, d?: number) => string;
|
|
53
|
-
export declare const formatQuantity: (n: string) => string;
|
|
54
|
-
export declare const formatPercentage: (n: string, d?: number) => string;
|
|
55
|
-
export declare const formatDollars: (str: string, space?: string, decimals?: number) => string;
|
|
56
|
-
export declare const convertStringToArray: (str: string | null) => string[];
|
|
57
|
-
export declare const hasEntities: <T extends unknown[]>(reducer: {
|
|
58
|
-
entities: T | null;
|
|
59
|
-
loading: RequestStatus;
|
|
60
|
-
error: RequestError;
|
|
61
|
-
}) => number | false;
|
|
62
|
-
export declare const range: (start: number, end?: number, step?: number) => number[];
|
|
63
|
-
export declare const sample: <T>(collection: T[]) => T | undefined;
|
|
1
|
+
import { Announcements, CheckoutFormCustomer, ContentImages, DateString, Images, RequestError, RequestStatus } from '@open-tender/types';
|
|
2
|
+
export declare const isString: (str: any) => boolean;
|
|
3
|
+
export declare const isObject: (obj: any) => boolean;
|
|
4
|
+
export declare const isEmpty: (obj?: object | null) => boolean;
|
|
5
|
+
export declare const isNum: (s: string) => boolean;
|
|
6
|
+
/**
|
|
7
|
+
* @deprecated please use `containsAll` or `containsAny` instead
|
|
8
|
+
* @returns true if first argument contains any of the values in the second argument
|
|
9
|
+
*/
|
|
10
|
+
export declare const contains: (arr: Array<any> | string, values: Array<any>) => boolean;
|
|
11
|
+
/**
|
|
12
|
+
* @returns true if first argument contains any of the values in the second argument
|
|
13
|
+
*/
|
|
14
|
+
export declare const containsAny: <T>(arr: T[], values: T[]) => boolean;
|
|
15
|
+
/**
|
|
16
|
+
* @returns true if first argument contains all of the values of the second argument
|
|
17
|
+
*/
|
|
18
|
+
export declare const containsAll: <T>(arr: T[], values: T[]) => boolean;
|
|
19
|
+
export declare const slugify: (text: string) => string;
|
|
20
|
+
export declare const stripTags: (s: string) => string;
|
|
21
|
+
export declare const serialize: (obj: Record<string | number, string | number | boolean>) => string;
|
|
22
|
+
export declare const capitalize: (s: string) => string;
|
|
23
|
+
export declare const cleanPhone: (phone: string) => string;
|
|
24
|
+
export declare const makePhone: (phone: string) => string;
|
|
25
|
+
export declare const validatePhone: (phone: string) => boolean;
|
|
26
|
+
export declare const makeBirthDate: (birthDate: string) => string | null;
|
|
27
|
+
export declare const slashesToDashes: (birthDate: string) => DateString | null;
|
|
28
|
+
export declare const dashesToSlashes: (birthDate?: string | null) => string | null;
|
|
29
|
+
export declare const validateEmail: (email: string) => boolean;
|
|
30
|
+
export declare const checkEmpty: (data: Record<string | number, unknown>) => boolean;
|
|
31
|
+
export declare const checkGuestData: (data: CheckoutFormCustomer, email: string) => {
|
|
32
|
+
guestData: {
|
|
33
|
+
first_name: string | undefined;
|
|
34
|
+
last_name: string | undefined;
|
|
35
|
+
phone: string | undefined;
|
|
36
|
+
email: string;
|
|
37
|
+
};
|
|
38
|
+
guestIncomplete: boolean;
|
|
39
|
+
};
|
|
40
|
+
export declare const checkNotFound: (errors: Record<string, string>) => boolean | null;
|
|
41
|
+
export declare const makeRandomNumberString: () => string;
|
|
42
|
+
export declare const getWidth: () => number;
|
|
43
|
+
export declare const getHeight: () => number;
|
|
44
|
+
export declare const makeImageMap: (images: Images) => {
|
|
45
|
+
APP_IMAGE?: string | undefined;
|
|
46
|
+
LARGE_IMAGE?: string | undefined;
|
|
47
|
+
SMALL_IMAGE?: string | undefined;
|
|
48
|
+
};
|
|
49
|
+
export declare const makeImageUrl: (images: ContentImages, isMobile: boolean) => string | null | undefined;
|
|
50
|
+
export declare const makeSlides: (items: Announcements, isMobile: boolean) => Announcements | null;
|
|
51
|
+
export declare const displayPrice: (price: string) => string;
|
|
52
|
+
export declare const addCommas: (x: number, d?: number) => string;
|
|
53
|
+
export declare const formatQuantity: (n: string) => string;
|
|
54
|
+
export declare const formatPercentage: (n: string, d?: number) => string;
|
|
55
|
+
export declare const formatDollars: (str: string, space?: string, decimals?: number) => string;
|
|
56
|
+
export declare const convertStringToArray: (str: string | null) => string[];
|
|
57
|
+
export declare const hasEntities: <T extends unknown[]>(reducer: {
|
|
58
|
+
entities: T | null;
|
|
59
|
+
loading: RequestStatus;
|
|
60
|
+
error: RequestError;
|
|
61
|
+
}) => number | false;
|
|
62
|
+
export declare const range: (start: number, end?: number, step?: number) => number[];
|
|
63
|
+
export declare const sample: <T>(collection: T[]) => T | undefined;
|