@open-tender/utils 0.0.26 → 0.0.27
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 +1 -0
- package/dist/cjs/utils/cart.js +32 -1
- package/dist/esm/utils/cart.d.ts +1 -0
- package/dist/esm/utils/cart.js +30 -0
- package/package.json +1 -1
package/dist/cjs/utils/cart.d.ts
CHANGED
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.makeUpsellItems = exports.checkAmountRemaining = exports.prepareOrder = exports.getDefaultTip = exports.validateCart = exports.makeSimpleCart = exports.decrementItem = exports.incrementItem = exports.removeItem = exports.addItem = exports.calcCartCounts = exports.makeFullAddress = exports.makeOrderAddress = exports.makeFavoritesLookup = exports.makeUniqueDisplayItems = exports.makeDisplayItems = exports.makeDisplayItem = exports.makeDisplayItemGroups = exports.makeCartItemSignature = exports.makeItemSignature = exports.makeItemImageUrl = exports.combineCarts = exports.makeGuestLookup = exports.rehydrateCheckoutForm = exports.rehydrateCart = exports.rehydrateOrderItem = exports.makeOrderItem = exports.calcPrices = exports.makeRevenueCenterMsg = exports.makeNotAcceptingOrdersMsg = exports.makeOrderTypeName = exports.makeServiceTypeName = exports.makeOrderTypeFromParam = exports.convertStringToArray = exports.makeModifierNames = exports.getItemOptions = exports.formatDollars = exports.formatQuantity = exports.addCommas = exports.makeDisplayPrice = exports.displayPrice = void 0;
|
|
3
|
+
exports.calcNutrition = exports.makeUpsellItems = exports.checkAmountRemaining = exports.prepareOrder = exports.getDefaultTip = exports.validateCart = exports.makeSimpleCart = exports.decrementItem = exports.incrementItem = exports.removeItem = exports.addItem = exports.calcCartCounts = exports.makeFullAddress = exports.makeOrderAddress = exports.makeFavoritesLookup = exports.makeUniqueDisplayItems = exports.makeDisplayItems = exports.makeDisplayItem = exports.makeDisplayItemGroups = exports.makeCartItemSignature = exports.makeItemSignature = exports.makeItemImageUrl = exports.combineCarts = exports.makeGuestLookup = exports.rehydrateCheckoutForm = exports.rehydrateCart = exports.rehydrateOrderItem = exports.makeOrderItem = exports.calcPrices = exports.makeRevenueCenterMsg = exports.makeNotAcceptingOrdersMsg = exports.makeOrderTypeName = exports.makeServiceTypeName = exports.makeOrderTypeFromParam = exports.convertStringToArray = exports.makeModifierNames = exports.getItemOptions = exports.formatDollars = exports.formatQuantity = exports.addCommas = exports.makeDisplayPrice = exports.displayPrice = void 0;
|
|
4
4
|
const constants_1 = require("./constants");
|
|
5
5
|
const datetimes_1 = require("./datetimes");
|
|
6
6
|
const helpers_1 = require("./helpers");
|
|
@@ -860,3 +860,34 @@ const makeUpsellItems = (itemIds, itemLookup) => {
|
|
|
860
860
|
});
|
|
861
861
|
};
|
|
862
862
|
exports.makeUpsellItems = makeUpsellItems;
|
|
863
|
+
const nutritionKeys = [
|
|
864
|
+
'calories',
|
|
865
|
+
'cholesterol',
|
|
866
|
+
'dietary_fiber',
|
|
867
|
+
'protein',
|
|
868
|
+
'saturated_fat',
|
|
869
|
+
'sodium',
|
|
870
|
+
'sugars',
|
|
871
|
+
'total_carbs',
|
|
872
|
+
'total_fat',
|
|
873
|
+
'trans_fat',
|
|
874
|
+
];
|
|
875
|
+
const calcNutrition = (item) => {
|
|
876
|
+
const { nutritionalInfo, groups } = item;
|
|
877
|
+
let nutrition = nutritionalInfo ? Object.assign({}, nutritionalInfo) : {};
|
|
878
|
+
const options = groups.reduce((arr, g) => {
|
|
879
|
+
var _a, _b;
|
|
880
|
+
return [...arr, ...((_b = (_a = g.options) === null || _a === void 0 ? void 0 : _a.filter((o) => { var _a; return ((_a = o.quantity) !== null && _a !== void 0 ? _a : 0) > 0; })) !== null && _b !== void 0 ? _b : [])];
|
|
881
|
+
}, []);
|
|
882
|
+
options.forEach((o) => {
|
|
883
|
+
nutritionKeys === null || nutritionKeys === void 0 ? void 0 : nutritionKeys.forEach((key) => {
|
|
884
|
+
const optionVal = o.nutritionalInfo
|
|
885
|
+
? parseInt(o.nutritionalInfo[key]) || 0
|
|
886
|
+
: 0;
|
|
887
|
+
const itemVal = parseInt(nutrition[key]) || 0;
|
|
888
|
+
nutrition = Object.assign(Object.assign({}, nutrition), { [key]: itemVal + optionVal });
|
|
889
|
+
});
|
|
890
|
+
});
|
|
891
|
+
return nutrition;
|
|
892
|
+
};
|
|
893
|
+
exports.calcNutrition = calcNutrition;
|
package/dist/esm/utils/cart.d.ts
CHANGED
package/dist/esm/utils/cart.js
CHANGED
|
@@ -816,3 +816,33 @@ export const makeUpsellItems = (itemIds, itemLookup) => {
|
|
|
816
816
|
return (belowMin === null || belowMin === void 0 ? void 0 : belowMin.length) === 0;
|
|
817
817
|
});
|
|
818
818
|
};
|
|
819
|
+
const nutritionKeys = [
|
|
820
|
+
'calories',
|
|
821
|
+
'cholesterol',
|
|
822
|
+
'dietary_fiber',
|
|
823
|
+
'protein',
|
|
824
|
+
'saturated_fat',
|
|
825
|
+
'sodium',
|
|
826
|
+
'sugars',
|
|
827
|
+
'total_carbs',
|
|
828
|
+
'total_fat',
|
|
829
|
+
'trans_fat',
|
|
830
|
+
];
|
|
831
|
+
export const calcNutrition = (item) => {
|
|
832
|
+
const { nutritionalInfo, groups } = item;
|
|
833
|
+
let nutrition = nutritionalInfo ? Object.assign({}, nutritionalInfo) : {};
|
|
834
|
+
const options = groups.reduce((arr, g) => {
|
|
835
|
+
var _a, _b;
|
|
836
|
+
return [...arr, ...((_b = (_a = g.options) === null || _a === void 0 ? void 0 : _a.filter((o) => { var _a; return ((_a = o.quantity) !== null && _a !== void 0 ? _a : 0) > 0; })) !== null && _b !== void 0 ? _b : [])];
|
|
837
|
+
}, []);
|
|
838
|
+
options.forEach((o) => {
|
|
839
|
+
nutritionKeys === null || nutritionKeys === void 0 ? void 0 : nutritionKeys.forEach((key) => {
|
|
840
|
+
const optionVal = o.nutritionalInfo
|
|
841
|
+
? parseInt(o.nutritionalInfo[key]) || 0
|
|
842
|
+
: 0;
|
|
843
|
+
const itemVal = parseInt(nutrition[key]) || 0;
|
|
844
|
+
nutrition = Object.assign(Object.assign({}, nutrition), { [key]: itemVal + optionVal });
|
|
845
|
+
});
|
|
846
|
+
});
|
|
847
|
+
return nutrition;
|
|
848
|
+
};
|
package/package.json
CHANGED