@open-tender/utils 0.4.94 → 0.4.96
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.js
CHANGED
|
@@ -97,7 +97,10 @@ exports.makeUpsellItemIds = makeUpsellItemIds;
|
|
|
97
97
|
const makeUpsellItemsForCart = (categories, cartIds, soldOut) => {
|
|
98
98
|
const itemLookup = (0, favorites_1.makeMenuItemLookup)(categories);
|
|
99
99
|
const menuItems = cartIds.map(id => itemLookup[id]).filter(Boolean);
|
|
100
|
-
const upsellItemIds = menuItems.reduce((arr, i) =>
|
|
100
|
+
const upsellItemIds = menuItems.reduce((arr, i) => {
|
|
101
|
+
const upsellsItems = i.upsell_items.slice(0, cartIds.length > 2 ? 2 : undefined);
|
|
102
|
+
return [...arr, ...upsellsItems];
|
|
103
|
+
}, []);
|
|
101
104
|
const uniqueIds = Array.from(new Set(upsellItemIds));
|
|
102
105
|
const itemIds = uniqueIds.filter(id => !cartIds.includes(id) && !soldOut.includes(id));
|
|
103
106
|
return (0, exports.makeUpsellItems)(itemIds, itemLookup);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import { Money, TPLSPointsShopReward } from '@open-tender/types';
|
|
1
|
+
import { LoyaltyReward, Money, TPLSPointsShopReward } from '@open-tender/types';
|
|
2
2
|
export declare const roundPoints: (points?: number | Money | null) => number;
|
|
3
3
|
export declare const getIsPointShowRewardExpired: (item: TPLSPointsShopReward) => boolean;
|
|
4
|
+
export declare const getIsLoyaltyRewardExpired: (item: LoyaltyReward) => boolean;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getIsPointShowRewardExpired = exports.roundPoints = void 0;
|
|
3
|
+
exports.getIsLoyaltyRewardExpired = exports.getIsPointShowRewardExpired = exports.roundPoints = void 0;
|
|
4
4
|
const datetimes_1 = require("./datetimes");
|
|
5
5
|
const roundPoints = (points) => {
|
|
6
6
|
if (!points || isNaN(Number(points)))
|
|
@@ -13,3 +13,8 @@ const getIsPointShowRewardExpired = (item) => {
|
|
|
13
13
|
return end_date ? (0, datetimes_1.dateStrToDate)(end_date) < new Date() : false;
|
|
14
14
|
};
|
|
15
15
|
exports.getIsPointShowRewardExpired = getIsPointShowRewardExpired;
|
|
16
|
+
const getIsLoyaltyRewardExpired = (item) => {
|
|
17
|
+
const { expires_at } = item;
|
|
18
|
+
return expires_at ? (0, datetimes_1.dateStrToDate)(expires_at) < new Date() : false;
|
|
19
|
+
};
|
|
20
|
+
exports.getIsLoyaltyRewardExpired = getIsLoyaltyRewardExpired;
|
package/dist/esm/utils/cart.js
CHANGED
|
@@ -87,7 +87,10 @@ export const makeUpsellItemIds = (item, cartIds, soldOut) => {
|
|
|
87
87
|
export const makeUpsellItemsForCart = (categories, cartIds, soldOut) => {
|
|
88
88
|
const itemLookup = makeMenuItemLookup(categories);
|
|
89
89
|
const menuItems = cartIds.map(id => itemLookup[id]).filter(Boolean);
|
|
90
|
-
const upsellItemIds = menuItems.reduce((arr, i) =>
|
|
90
|
+
const upsellItemIds = menuItems.reduce((arr, i) => {
|
|
91
|
+
const upsellsItems = i.upsell_items.slice(0, cartIds.length > 2 ? 2 : undefined);
|
|
92
|
+
return [...arr, ...upsellsItems];
|
|
93
|
+
}, []);
|
|
91
94
|
const uniqueIds = Array.from(new Set(upsellItemIds));
|
|
92
95
|
const itemIds = uniqueIds.filter(id => !cartIds.includes(id) && !soldOut.includes(id));
|
|
93
96
|
return makeUpsellItems(itemIds, itemLookup);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import { Money, TPLSPointsShopReward } from '@open-tender/types';
|
|
1
|
+
import { LoyaltyReward, Money, TPLSPointsShopReward } from '@open-tender/types';
|
|
2
2
|
export declare const roundPoints: (points?: number | Money | null) => number;
|
|
3
3
|
export declare const getIsPointShowRewardExpired: (item: TPLSPointsShopReward) => boolean;
|
|
4
|
+
export declare const getIsLoyaltyRewardExpired: (item: LoyaltyReward) => boolean;
|
|
@@ -8,3 +8,7 @@ export const getIsPointShowRewardExpired = (item) => {
|
|
|
8
8
|
const { end_date } = item;
|
|
9
9
|
return end_date ? dateStrToDate(end_date) < new Date() : false;
|
|
10
10
|
};
|
|
11
|
+
export const getIsLoyaltyRewardExpired = (item) => {
|
|
12
|
+
const { expires_at } = item;
|
|
13
|
+
return expires_at ? dateStrToDate(expires_at) < new Date() : false;
|
|
14
|
+
};
|
package/package.json
CHANGED