@tapcart/mobile-components 0.8.52 → 0.8.53
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.
|
@@ -17,8 +17,8 @@ export declare const getVariablesVariantPrice: ({ variantPrice, variantCompareAt
|
|
|
17
17
|
currency: string;
|
|
18
18
|
isSale: boolean;
|
|
19
19
|
};
|
|
20
|
-
export declare const isVariablesOrderLevelDiscount: (code: string, cart: CartState) => boolean;
|
|
21
|
-
export declare const isVariablesLineItemDiscount: (code: string, cart: CartState) => boolean;
|
|
20
|
+
export declare const isVariablesOrderLevelDiscount: (code: string, cart: CartState | null) => boolean;
|
|
21
|
+
export declare const isVariablesLineItemDiscount: (code: string, cart: CartState | null) => boolean;
|
|
22
22
|
export type VariablesCalculatedData = {
|
|
23
23
|
orderAndLineItemDiscounts: CartCalculatedDiscount[];
|
|
24
24
|
appliedGiftCards: CartCalculatedAppliedGiftCard[];
|
|
@@ -31,5 +31,5 @@ export type VariablesCalculatedData = {
|
|
|
31
31
|
totalSavedAmount: number;
|
|
32
32
|
};
|
|
33
33
|
export declare const DEFAULT_VARIABLES_CALCULATED_DATA: VariablesCalculatedData;
|
|
34
|
-
export declare const getVariablesCalculatedCartData: (cart: CartState) => VariablesCalculatedData;
|
|
34
|
+
export declare const getVariablesCalculatedCartData: (cart: CartState | null) => VariablesCalculatedData;
|
|
35
35
|
//# sourceMappingURL=variablesCart.util.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"variablesCart.util.d.ts","sourceRoot":"","sources":["../../lib/variablesCart.util.ts"],"names":[],"mappings":"AACA,OAAO,EACL,SAAS,EACT,sBAAsB,EACtB,6BAA6B,EAO9B,MAAM,kBAAkB,CAAA;AAEzB,eAAO,MAAM,wBAAwB;kBAOrB,MAAM;2BACG,MAAM;cACnB,MAAM;kBACF,MAAM;;0BAEA;YAChB,gBAAgB,CAAC,EAAE,MAAM,CAAA;YACzB,KAAK,EAAE,MAAM,CAAA;YACb,cAAc,CAAC,EAAE,MAAM,CAAA;SACxB,EAAE;;;;;;;CA4BN,CAAA;
|
|
1
|
+
{"version":3,"file":"variablesCart.util.d.ts","sourceRoot":"","sources":["../../lib/variablesCart.util.ts"],"names":[],"mappings":"AACA,OAAO,EACL,SAAS,EACT,sBAAsB,EACtB,6BAA6B,EAO9B,MAAM,kBAAkB,CAAA;AAEzB,eAAO,MAAM,wBAAwB;kBAOrB,MAAM;2BACG,MAAM;cACnB,MAAM;kBACF,MAAM;;0BAEA;YAChB,gBAAgB,CAAC,EAAE,MAAM,CAAA;YACzB,KAAK,EAAE,MAAM,CAAA;YACb,cAAc,CAAC,EAAE,MAAM,CAAA;SACxB,EAAE;;;;;;;CA4BN,CAAA;AAyED,eAAO,MAAM,6BAA6B,SAClC,MAAM,QACN,SAAS,GAAG,IAAI,YAUvB,CAAA;AAED,eAAO,MAAM,2BAA2B,SAChC,MAAM,QACN,SAAS,GAAG,IAAI,YAUvB,CAAA;AA2KD,MAAM,MAAM,uBAAuB,GAAG;IACpC,yBAAyB,EAAE,sBAAsB,EAAE,CAAA;IACnD,gBAAgB,EAAE,6BAA6B,EAAE,CAAA;IACjD,cAAc,EAAE,OAAO,CAAA;IACvB,oBAAoB,EAAE,MAAM,CAAA;IAC5B,oBAAoB,EAAE,MAAM,CAAA;IAC5B,WAAW,EAAE,MAAM,CAAA;IACnB,mBAAmB,EAAE,MAAM,CAAA;IAC3B,oBAAoB,EAAE,MAAM,CAAA;IAC5B,gBAAgB,EAAE,MAAM,CAAA;CACzB,CAAA;AAED,eAAO,MAAM,iCAAiC,EAAE,uBAU/C,CAAA;AAED,eAAO,MAAM,8BAA8B,SACnC,SAAS,GAAG,IAAI,KACrB,uBAmCF,CAAA"}
|
|
@@ -25,6 +25,9 @@ export const getVariablesVariantPrice = ({ variantPrice, variantCompareAtPrice,
|
|
|
25
25
|
};
|
|
26
26
|
};
|
|
27
27
|
const getOrderLevelDiscounts = (cart) => {
|
|
28
|
+
// Handle null cart gracefully - the shopping cart state can be null sometimes
|
|
29
|
+
if (!cart)
|
|
30
|
+
return [];
|
|
28
31
|
// CartState doesn't have discountAllocations directly
|
|
29
32
|
// Need to check if cart has discountAllocations property
|
|
30
33
|
const discountAllocations = cart === null || cart === void 0 ? void 0 : cart.discountAllocations;
|
|
@@ -64,8 +67,11 @@ const getOrderLevelDiscounts = (cart) => {
|
|
|
64
67
|
}));
|
|
65
68
|
};
|
|
66
69
|
const getShippingDiscounts = (cart) => {
|
|
70
|
+
// Handle null cart gracefully - the shopping cart state can be null sometimes
|
|
71
|
+
if (!cart)
|
|
72
|
+
return [];
|
|
67
73
|
// CartState doesn't have discountAllocations directly
|
|
68
|
-
const discountAllocations = cart.discountAllocations;
|
|
74
|
+
const discountAllocations = cart === null || cart === void 0 ? void 0 : cart.discountAllocations;
|
|
69
75
|
if (!discountAllocations)
|
|
70
76
|
return [];
|
|
71
77
|
return discountAllocations
|
|
@@ -80,14 +86,23 @@ const getShippingDiscounts = (cart) => {
|
|
|
80
86
|
});
|
|
81
87
|
};
|
|
82
88
|
export const isVariablesOrderLevelDiscount = (code, cart) => {
|
|
89
|
+
// Handle null cart gracefully - return false if cart is null
|
|
90
|
+
if (!cart)
|
|
91
|
+
return false;
|
|
83
92
|
const orderLevelDiscounts = getOrderLevelDiscounts(cart);
|
|
84
93
|
return orderLevelDiscounts.some((discount) => (discount.id || "").toUpperCase() === (code || "").toUpperCase());
|
|
85
94
|
};
|
|
86
95
|
export const isVariablesLineItemDiscount = (code, cart) => {
|
|
96
|
+
// Handle null cart gracefully - return false if cart is null
|
|
97
|
+
if (!cart)
|
|
98
|
+
return false;
|
|
87
99
|
const lineItemDiscounts = getLineItemDiscounts(cart);
|
|
88
100
|
return lineItemDiscounts.some((discount) => (discount.id || "").toUpperCase() === (code || "").toUpperCase());
|
|
89
101
|
};
|
|
90
102
|
const getAppliedGiftCards = (cart) => {
|
|
103
|
+
// Handle null cart gracefully - the shopping cart state can be null sometimes
|
|
104
|
+
if (!cart)
|
|
105
|
+
return [];
|
|
91
106
|
// Access appliedGiftCards directly from CartState
|
|
92
107
|
const appliedGiftCards = cart === null || cart === void 0 ? void 0 : cart.appliedGiftCards;
|
|
93
108
|
if (!appliedGiftCards ||
|
|
@@ -105,6 +120,9 @@ const getAppliedGiftCards = (cart) => {
|
|
|
105
120
|
};
|
|
106
121
|
const getSalesAmount = (cart) => {
|
|
107
122
|
var _a;
|
|
123
|
+
// Handle null cart gracefully - the shopping cart state can be null sometimes
|
|
124
|
+
if (!cart)
|
|
125
|
+
return 0;
|
|
108
126
|
return (_a = cart === null || cart === void 0 ? void 0 : cart.items) === null || _a === void 0 ? void 0 : _a.reduce((acc, item) => {
|
|
109
127
|
var _a, _b;
|
|
110
128
|
// Get price and compareAtPrice directly from the CartItem
|
|
@@ -140,6 +158,9 @@ const getSalesAmount = (cart) => {
|
|
|
140
158
|
};
|
|
141
159
|
const getLineItemDiscounts = (cart) => {
|
|
142
160
|
var _a;
|
|
161
|
+
// Handle null cart gracefully - the shopping cart state can be null sometimes
|
|
162
|
+
if (!cart)
|
|
163
|
+
return [];
|
|
143
164
|
const discountMap = ((cart === null || cart === void 0 ? void 0 : cart.items) || []).reduce((acc, item) => {
|
|
144
165
|
var _a;
|
|
145
166
|
(_a = item === null || item === void 0 ? void 0 : item.discounts) === null || _a === void 0 ? void 0 : _a.forEach((discount) => {
|
|
@@ -174,7 +195,11 @@ const getGiftCardsTotalAmount = (appliedGiftCards) => {
|
|
|
174
195
|
return appliedGiftCards === null || appliedGiftCards === void 0 ? void 0 : appliedGiftCards.reduce((acc, giftCard) => acc + +giftCard.amount, 0);
|
|
175
196
|
};
|
|
176
197
|
const getTotalCompareAtPrice = (cart) => {
|
|
177
|
-
|
|
198
|
+
var _a;
|
|
199
|
+
// Handle null cart gracefully - the shopping cart state can be null sometimes
|
|
200
|
+
if (!cart)
|
|
201
|
+
return 0;
|
|
202
|
+
return (_a = cart === null || cart === void 0 ? void 0 : cart.items) === null || _a === void 0 ? void 0 : _a.reduce((acc, item) => {
|
|
178
203
|
// Get compareAtPrice directly from the CartItem
|
|
179
204
|
const itemCompareAtPrice = item.compareAtPrice ||
|
|
180
205
|
(item.price ? parseFloat(item.price.toString()) : 0);
|
|
@@ -196,6 +221,9 @@ const getTotalDiscountedPrice = (totalCompareAtPrice, discountsTotalAmount, sale
|
|
|
196
221
|
return isNaN(total) ? 0 : Math.max(0, total);
|
|
197
222
|
};
|
|
198
223
|
const getTotalSavedAmount = (cart) => {
|
|
224
|
+
// Handle null cart gracefully - the shopping cart state can be null sometimes
|
|
225
|
+
if (!cart)
|
|
226
|
+
return 0;
|
|
199
227
|
const salesAmount = getSalesAmount(cart);
|
|
200
228
|
const totalDiscountsAmount = getDiscountsTotalAmount(getOrderLevelDiscounts(cart).concat(getLineItemDiscounts(cart)));
|
|
201
229
|
const totalGiftCardsAmount = getGiftCardsTotalAmount(getAppliedGiftCards(cart));
|
|
@@ -214,6 +242,10 @@ export const DEFAULT_VARIABLES_CALCULATED_DATA = {
|
|
|
214
242
|
totalSavedAmount: 0,
|
|
215
243
|
};
|
|
216
244
|
export const getVariablesCalculatedCartData = (cart) => {
|
|
245
|
+
// Handle null cart gracefully - return default data to prevent crashes
|
|
246
|
+
if (!cart) {
|
|
247
|
+
return DEFAULT_VARIABLES_CALCULATED_DATA;
|
|
248
|
+
}
|
|
217
249
|
const orderAndLineItemDiscounts = getOrderLevelDiscounts(cart).concat(getLineItemDiscounts(cart));
|
|
218
250
|
const appliedGiftCards = getAppliedGiftCards(cart);
|
|
219
251
|
const isFreeShipping = getShippingDiscounts(cart).length > 0;
|
package/dist/styles.css
CHANGED
|
@@ -2189,10 +2189,6 @@ video {
|
|
|
2189
2189
|
.text-textColors-strikethroughPriceText {
|
|
2190
2190
|
color: var(--textColors-strikethroughPriceText);
|
|
2191
2191
|
}
|
|
2192
|
-
.text-white {
|
|
2193
|
-
--tw-text-opacity: 1;
|
|
2194
|
-
color: rgb(255 255 255 / var(--tw-text-opacity, 1));
|
|
2195
|
-
}
|
|
2196
2192
|
.underline {
|
|
2197
2193
|
text-decoration-line: underline;
|
|
2198
2194
|
}
|