@tapcart/mobile-components 0.10.3 → 0.11.1
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/components/ui/loading-spinner.d.ts +12 -0
- package/dist/components/ui/loading-spinner.d.ts.map +1 -0
- package/dist/components/ui/loading-spinner.js +25 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/lib/utils.d.ts +32 -6
- package/dist/lib/utils.d.ts.map +1 -1
- package/dist/lib/utils.js +114 -12
- package/dist/styles.css +7 -15
- package/dist/tests/addItemToWishlist/addItemToWishlist.test.d.ts +2 -0
- package/dist/tests/addItemToWishlist/addItemToWishlist.test.d.ts.map +1 -0
- package/dist/tests/addItemToWishlist/addItemToWishlist.test.js +198 -0
- package/dist/tests/removeItemFromWishlists/removeItemFromWishlists.test.d.ts +2 -0
- package/dist/tests/removeItemFromWishlists/removeItemFromWishlists.test.d.ts.map +1 -0
- package/dist/tests/removeItemFromWishlists/removeItemFromWishlists.test.js +123 -0
- package/package.json +1 -1
- package/dist/lib/utils.wishlist.test.d.ts +0 -2
- package/dist/lib/utils.wishlist.test.d.ts.map +0 -1
- package/dist/lib/utils.wishlist.test.js +0 -108
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export interface LoadingSpinnerProps {
|
|
3
|
+
iconColor?: string;
|
|
4
|
+
size?: number;
|
|
5
|
+
opacity?: number;
|
|
6
|
+
show?: boolean;
|
|
7
|
+
showBackground?: boolean;
|
|
8
|
+
className?: string;
|
|
9
|
+
style?: React.CSSProperties;
|
|
10
|
+
}
|
|
11
|
+
export declare const LoadingSpinner: ({ iconColor, size, opacity, show, showBackground, className, style, }: LoadingSpinnerProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
12
|
+
//# sourceMappingURL=loading-spinner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loading-spinner.d.ts","sourceRoot":"","sources":["../../../components/ui/loading-spinner.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,MAAM,WAAW,mBAAmB;IAClC,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAA;CAC5B;AAED,eAAO,MAAM,cAAc,0EAQxB,mBAAmB,mDAkDrB,CAAA"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from "../../lib/utils";
|
|
3
|
+
import React from "react";
|
|
4
|
+
export const LoadingSpinner = ({ iconColor = "#000000", size = 16, opacity = 0.7, show = false, showBackground = false, className, style, }) => {
|
|
5
|
+
const [showLoadingSpinner, setShowLoadingSpinner] = React.useState(show);
|
|
6
|
+
const [isAnimatingOut, setIsAnimatingOut] = React.useState(false);
|
|
7
|
+
React.useEffect(() => {
|
|
8
|
+
if (!show) {
|
|
9
|
+
setIsAnimatingOut(true);
|
|
10
|
+
setTimeout(() => {
|
|
11
|
+
setShowLoadingSpinner(false);
|
|
12
|
+
setIsAnimatingOut(false);
|
|
13
|
+
}, 300); // Match animation duration
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
setShowLoadingSpinner(true);
|
|
17
|
+
setIsAnimatingOut(false);
|
|
18
|
+
}
|
|
19
|
+
}, [show]);
|
|
20
|
+
if (!showLoadingSpinner)
|
|
21
|
+
return null;
|
|
22
|
+
return (_jsx("div", Object.assign({ className: cn("absolute inset-0 flex items-center justify-center z-20", isAnimatingOut ? "animate-fadeOut" : "animate-fadeIn", {
|
|
23
|
+
"bg-white bg-opacity-70 rounded-full": showBackground,
|
|
24
|
+
}, className), style: style }, { children: _jsx("svg", Object.assign({ width: `${size}pt`, height: `${size}pt`, viewBox: "0 0 100 100", xmlns: "http://www.w3.org/2000/svg", className: "animate-spin m-2", style: { opacity } }, { children: _jsxs("g", Object.assign({ fill: iconColor }, { children: [_jsx("path", { d: "m49.105 0c-2.8555 0-5.1719 2.3164-5.1719 5.1719v17.242c0 2.8555 2.3164 5.1719 5.1719 5.1719s5.1758-2.3164 5.1758-5.1719v-17.242c0-2.8555-2.3203-5.1719-5.1758-5.1719z" }), _jsx("path", { d: "m49.105 72.414c-2.8555 0-5.1719 2.3164-5.1719 5.1719v17.242c0 2.8555 2.3164 5.1719 5.1719 5.1719s5.1719-2.3164 5.1719-5.1719v-17.242c0.003906-2.8555-2.3164-5.1719-5.1719-5.1719z" }), _jsx("path", { d: "m28.691 31.727l-14.93-8.6211c-2.4766-1.4258-5.6367-0.57812-7.0664 1.8945-1.4258 2.4766-0.58203 5.6406 1.8945 7.0703l14.93 8.6211c2.4727 1.4258 5.6367 0.57812 7.0664-1.8984 1.4297-2.4727 0.57812-5.6367-1.8945-7.0664z" }), _jsx("path", { d: "m91.402 67.934l-14.93-8.6211c-2.4727-1.4258-5.6367-0.57812-7.0664 1.8945-1.4258 2.4766-0.57812 5.6406 1.8945 7.0703l14.93 8.6211c2.4766 1.4258 5.6406 0.57812 7.0703-1.8984 1.4219-2.4727 0.57422-5.6367-1.8984-7.0664z" }), _jsx("path", { d: "m23.52 59.312l-14.93 8.6211c-2.4727 1.4258-3.3203 4.5938-1.8945 7.0664 1.4258 2.4727 4.5938 3.3281 7.0664 1.8945l14.93-8.6172c2.4727-1.4258 3.3203-4.5938 1.8945-7.0703-1.4258-2.4727-4.5938-3.3203-7.0664-1.8945z" }), _jsx("path", { d: "m76.477 40.691l14.93-8.6211c2.4766-1.4297 3.3242-4.5977 1.8945-7.0742-1.4258-2.4727-4.5938-3.3203-7.0703-1.8906l-14.93 8.6211c-2.4727 1.4258-3.3203 4.5898-1.8945 7.0664 1.4297 2.4805 4.5977 3.3281 7.0703 1.8984z" })] })) })) })));
|
|
25
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { cn, cva, getColor, getBackgroundAndPaddingStyle, getBorderStyle, getBorderSidesStyle, getTextStyle, getVerticalAlignmentStyle, getBackgroundAndSpacingStyle, getIdFromGid, productGidFromId, variantGidFromId, getPaddingStyle, getMarginStyle, getVerticalAlignment, mapFlexToAlignment, formatRelativeTime, stringRatioToInt, getOverlayStyle, throttleFunction, getDestinationHandler, getProductGidsFromIds, getVariantGidsFromIds, getBadgesForProductFn, createCollectionImageMap, isFavoriteIntegrationEnabled, getEnabledWishlistIntegration, supportsMultipleWishlists,
|
|
1
|
+
export { cn, cva, getColor, getBackgroundAndPaddingStyle, getBorderStyle, getBorderSidesStyle, getTextStyle, getVerticalAlignmentStyle, getBackgroundAndSpacingStyle, getIdFromGid, productGidFromId, variantGidFromId, getPaddingStyle, getMarginStyle, getVerticalAlignment, mapFlexToAlignment, formatRelativeTime, stringRatioToInt, getOverlayStyle, throttleFunction, getDestinationHandler, getProductGidsFromIds, getVariantGidsFromIds, getBadgesForProductFn, createCollectionImageMap, isFavoriteIntegrationEnabled, getEnabledWishlistIntegration, supportsMultipleWishlists, getWishlistAddItemNavigation, getLoyaltyButtonProps, getSpaceBetween, getGridSpacing, pluralize, getInputPlaceholderTextProps, parsePhoneNumber, addItemToWishlist, removeItemFromWishlists, } from "./lib/utils";
|
|
2
2
|
export type { WishlistEntryMatch } from "./lib/utils";
|
|
3
3
|
export * from "./lib/cart.util";
|
|
4
4
|
export * from "./lib/variablesCart.util";
|
|
@@ -43,6 +43,7 @@ export * from "./components/ui/Input/input";
|
|
|
43
43
|
export * from "./components/ui/label";
|
|
44
44
|
export * from "./components/ui/line-item-text-icons";
|
|
45
45
|
export * from "./components/ui/loading-dots";
|
|
46
|
+
export * from "./components/ui/loading-spinner";
|
|
46
47
|
export * from "./components/ui/money";
|
|
47
48
|
export * from "./components/ui/portal";
|
|
48
49
|
export * from "./components/ui/price";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,EAAE,EACF,GAAG,EACH,QAAQ,EACR,4BAA4B,EAC5B,cAAc,EACd,mBAAmB,EACnB,YAAY,EACZ,yBAAyB,EACzB,4BAA4B,EAC5B,YAAY,EACZ,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,EACf,cAAc,EACd,oBAAoB,EACpB,kBAAkB,EAClB,kBAAkB,EAClB,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,qBAAqB,EACrB,qBAAqB,EACrB,qBAAqB,EACrB,qBAAqB,EACrB,wBAAwB,EACxB,4BAA4B,EAC5B,6BAA6B,EAC7B,yBAAyB,EACzB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,EAAE,EACF,GAAG,EACH,QAAQ,EACR,4BAA4B,EAC5B,cAAc,EACd,mBAAmB,EACnB,YAAY,EACZ,yBAAyB,EACzB,4BAA4B,EAC5B,YAAY,EACZ,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,EACf,cAAc,EACd,oBAAoB,EACpB,kBAAkB,EAClB,kBAAkB,EAClB,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,qBAAqB,EACrB,qBAAqB,EACrB,qBAAqB,EACrB,qBAAqB,EACrB,wBAAwB,EACxB,4BAA4B,EAC5B,6BAA6B,EAC7B,yBAAyB,EACzB,4BAA4B,EAC5B,qBAAqB,EACrB,eAAe,EACf,cAAc,EACd,SAAS,EACT,4BAA4B,EAC5B,gBAAgB,EAChB,iBAAiB,EACjB,uBAAuB,GACxB,MAAM,aAAa,CAAA;AACpB,YAAY,EAAE,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ndPaddingStyle, getBorderStyle, getBorderSidesStyle, getTextStyle, getVerticalAlignmentStyle, getBackgroundAndSpacingStyle, getIdFromGid, productGidFromId, variantGidFromId, getPaddingStyle, getMarginStyle, getVerticalAlignment, mapFlexToAlignment, formatRelativeTime, stringRatioToInt, getOverlayStyle, throttleFunction, getDestinationHandler, getProductGidsFromIds, getVariantGidsFromIds, getBadgesForProductFn, createCollectionImageMap, isFavoriteIntegrationEnabled, getEnabledWishlistIntegration, supportsMultipleWishlists,
|
|
2
|
+
export { cn, cva, getColor, getBackgroundAndPaddingStyle, getBorderStyle, getBorderSidesStyle, getTextStyle, getVerticalAlignmentStyle, getBackgroundAndSpacingStyle, getIdFromGid, productGidFromId, variantGidFromId, getPaddingStyle, getMarginStyle, getVerticalAlignment, mapFlexToAlignment, formatRelativeTime, stringRatioToInt, getOverlayStyle, throttleFunction, getDestinationHandler, getProductGidsFromIds, getVariantGidsFromIds, getBadgesForProductFn, createCollectionImageMap, isFavoriteIntegrationEnabled, getEnabledWishlistIntegration, supportsMultipleWishlists, getWishlistAddItemNavigation, getLoyaltyButtonProps, getSpaceBetween, getGridSpacing, pluralize, getInputPlaceholderTextProps, parsePhoneNumber, addItemToWishlist, removeItemFromWishlists, } from "./lib/utils";
|
|
3
3
|
export * from "./lib/cart.util";
|
|
4
4
|
export * from "./lib/variablesCart.util";
|
|
5
5
|
export * from "./lib/isTapcartVersion20.util";
|
|
@@ -43,6 +43,7 @@ export * from "./components/ui/Input/input";
|
|
|
43
43
|
export * from "./components/ui/label";
|
|
44
44
|
export * from "./components/ui/line-item-text-icons";
|
|
45
45
|
export * from "./components/ui/loading-dots";
|
|
46
|
+
export * from "./components/ui/loading-spinner";
|
|
46
47
|
export * from "./components/ui/money";
|
|
47
48
|
export * from "./components/ui/portal";
|
|
48
49
|
export * from "./components/ui/price";
|
package/dist/lib/utils.d.ts
CHANGED
|
@@ -1139,16 +1139,10 @@ type WishlistEntryItem = {
|
|
|
1139
1139
|
productId?: string | null;
|
|
1140
1140
|
variantId?: string | null;
|
|
1141
1141
|
};
|
|
1142
|
-
type WishlistSummary = {
|
|
1143
|
-
id?: string | null;
|
|
1144
|
-
_id?: string | null;
|
|
1145
|
-
items?: WishlistEntryItem[] | null;
|
|
1146
|
-
};
|
|
1147
1142
|
export type WishlistEntryMatch = {
|
|
1148
1143
|
wishlistId: string | null;
|
|
1149
1144
|
item: WishlistEntryItem;
|
|
1150
1145
|
};
|
|
1151
|
-
export declare const findWishlistEntry: (wishlists: WishlistSummary[] | null | undefined, productId?: string | null, variantId?: string | null) => WishlistEntryMatch | null;
|
|
1152
1146
|
export declare const pluralize: (word: string, count?: number, inclusive?: boolean) => string;
|
|
1153
1147
|
export declare const getInputPlaceholderTextProps: (placeholderText: TextStyle) => {
|
|
1154
1148
|
placeholderTextColor: Color;
|
|
@@ -1158,6 +1152,38 @@ export declare const getInputPlaceholderTextProps: (placeholderText: TextStyle)
|
|
|
1158
1152
|
placeholderFont: string;
|
|
1159
1153
|
placeholderFontWeight: string | number;
|
|
1160
1154
|
};
|
|
1155
|
+
/**
|
|
1156
|
+
* Adds an item to the wishlist. Depending on merchant integrations or if variants exist or if logged in drawer functionality is involved
|
|
1157
|
+
* @param Tapcart
|
|
1158
|
+
* @param integrations
|
|
1159
|
+
* @param product
|
|
1160
|
+
* @param selectedVariantId
|
|
1161
|
+
*/
|
|
1162
|
+
export declare const addItemToWishlist: ({ Tapcart, integrations, product, selectedVariantId, }: {
|
|
1163
|
+
Tapcart: any;
|
|
1164
|
+
integrations: Integrations;
|
|
1165
|
+
product: {
|
|
1166
|
+
id: string;
|
|
1167
|
+
variants?: any[] | undefined;
|
|
1168
|
+
};
|
|
1169
|
+
selectedVariantId?: string | undefined;
|
|
1170
|
+
}) => Promise<boolean>;
|
|
1171
|
+
/**
|
|
1172
|
+
* Removes an item from all wishlists by product ID.
|
|
1173
|
+
*
|
|
1174
|
+
* @param {Object} params - The parameters for the function.
|
|
1175
|
+
* @param {any} params.Tapcart - The Tapcart instance.
|
|
1176
|
+
* @param {string} params.productId - The ID of the product to remove.
|
|
1177
|
+
* @returns {Promise<{ id: string; variantId: string; productId: string }[]>} - An array of removed wishlist entries.
|
|
1178
|
+
*/
|
|
1179
|
+
export declare const removeItemFromWishlists: ({ Tapcart, productId, }: {
|
|
1180
|
+
Tapcart: any;
|
|
1181
|
+
productId: string;
|
|
1182
|
+
}) => Promise<{
|
|
1183
|
+
id: string;
|
|
1184
|
+
variantId: string;
|
|
1185
|
+
productId: string;
|
|
1186
|
+
}[]>;
|
|
1161
1187
|
export type Badge = {
|
|
1162
1188
|
id: string;
|
|
1163
1189
|
horizontalPosition: string;
|
package/dist/lib/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../lib/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,WAAW,EACX,4BAA4B,EAC5B,yBAAyB,EACzB,UAAU,EACV,eAAe,EACf,OAAO,EACP,QAAQ,EACR,gBAAgB,EACjB,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAAE,UAAU,EAAQ,MAAM,MAAM,CAAA;AAMvC,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;AAErC,eAAO,MAAM,gBAAgB,UAAW,MAAM,YAAY,MAAM,gCACrC,CAAA;AAE3B,MAAM,MAAM,KAAK,GAAG;IAAE,IAAI,EAAE,QAAQ,GAAG,WAAW,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAA;AAEnE,wBAAgB,EAAE,CAAC,GAAG,MAAM,EAAE,UAAU,EAAE,UAEzC;AAED,eAAO,MAAM,eAAe,UAc3B,CAAA;AAED,eAAO,MAAM,uBAAuB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM,CAAA;AAMjE,OAAO,EAAE,GAAG,EAAE,MAAM,0BAA0B,CAAA;AAI9C,eAAO,MAAM,QAAQ,gBAAiB,KAAK,GAAG,S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C,SAAS,GAAG,UAAU,CAAC,EAAE,CAAA;CACvC,CAAA;AAoDD,eAAO,MAAM,kBAAkB,UACtB,UAAU,WACR,GAAG,KACX,OAyBF,CAAA"}
|
package/dist/lib/utils.js
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
1
10
|
import { clsx } from "clsx";
|
|
2
11
|
import dayjs from "dayjs";
|
|
3
12
|
import relativeTime from "dayjs/plugin/relativeTime";
|
|
@@ -302,13 +311,6 @@ export const createCollectionImageMap = (collections) => {
|
|
|
302
311
|
return imageMap;
|
|
303
312
|
}, {});
|
|
304
313
|
};
|
|
305
|
-
export const isFavoriteIntegrationEnabled = (integrations) => {
|
|
306
|
-
return integrations.some((integration) => (integration.name === "tapcart-wishlist" ||
|
|
307
|
-
integration.name === "grove-wishlist" ||
|
|
308
|
-
integration.name === "tapcart-wishlist-api" ||
|
|
309
|
-
integration.name === "swym") &&
|
|
310
|
-
integration.enabled);
|
|
311
|
-
};
|
|
312
314
|
const WISHLIST_INTEGRATION_NAMES = new Set([
|
|
313
315
|
"tapcart-wishlist",
|
|
314
316
|
"tapcart-wishlist-v2",
|
|
@@ -316,6 +318,9 @@ const WISHLIST_INTEGRATION_NAMES = new Set([
|
|
|
316
318
|
"grove-wishlist",
|
|
317
319
|
"swym",
|
|
318
320
|
]);
|
|
321
|
+
export const isFavoriteIntegrationEnabled = (integrations) => {
|
|
322
|
+
return integrations.some((integration) => WISHLIST_INTEGRATION_NAMES.has(integration.name) && integration.enabled);
|
|
323
|
+
};
|
|
319
324
|
export const getEnabledWishlistIntegration = (integrations) => {
|
|
320
325
|
if (!Array.isArray(integrations))
|
|
321
326
|
return null;
|
|
@@ -363,10 +368,11 @@ const normalizeShopifyId = (id) => {
|
|
|
363
368
|
const normalized = getIdFromGid(id);
|
|
364
369
|
return normalized || id;
|
|
365
370
|
};
|
|
366
|
-
|
|
371
|
+
const findWishlistEntries = (wishlists, productId, variantId) => {
|
|
367
372
|
if (!productId || !Array.isArray(wishlists) || wishlists.length === 0) {
|
|
368
|
-
return
|
|
373
|
+
return [];
|
|
369
374
|
}
|
|
375
|
+
const wishlistEntries = [];
|
|
370
376
|
const normalizedProductId = normalizeShopifyId(productId);
|
|
371
377
|
for (const wishlist of wishlists) {
|
|
372
378
|
const items = Array.isArray(wishlist === null || wishlist === void 0 ? void 0 : wishlist.items) ? wishlist.items : [];
|
|
@@ -386,13 +392,13 @@ export const findWishlistEntry = (wishlists, productId, variantId) => {
|
|
|
386
392
|
if (!variantMatches)
|
|
387
393
|
continue;
|
|
388
394
|
}
|
|
389
|
-
|
|
395
|
+
wishlistEntries.push({
|
|
390
396
|
wishlistId: (wishlist === null || wishlist === void 0 ? void 0 : wishlist.id) || (wishlist === null || wishlist === void 0 ? void 0 : wishlist._id) || null,
|
|
391
397
|
item,
|
|
392
|
-
};
|
|
398
|
+
});
|
|
393
399
|
}
|
|
394
400
|
}
|
|
395
|
-
return
|
|
401
|
+
return wishlistEntries;
|
|
396
402
|
};
|
|
397
403
|
export const pluralize = (word, count, inclusive) => {
|
|
398
404
|
return Pluralize(word, count, inclusive);
|
|
@@ -411,6 +417,102 @@ export const getInputPlaceholderTextProps = (placeholderText) => {
|
|
|
411
417
|
: placeholderText.font.weight,
|
|
412
418
|
};
|
|
413
419
|
};
|
|
420
|
+
/**
|
|
421
|
+
* Adds an item to the wishlist. Depending on merchant integrations or if variants exist or if logged in drawer functionality is involved
|
|
422
|
+
* @param Tapcart
|
|
423
|
+
* @param integrations
|
|
424
|
+
* @param product
|
|
425
|
+
* @param selectedVariantId
|
|
426
|
+
*/
|
|
427
|
+
export const addItemToWishlist = ({ Tapcart, integrations, product, selectedVariantId, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
428
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
429
|
+
const isAuthenticated = !!((_b = (_a = Tapcart === null || Tapcart === void 0 ? void 0 : Tapcart.variables) === null || _a === void 0 ? void 0 : _a.customer) === null || _b === void 0 ? void 0 : _b.id);
|
|
430
|
+
const defaultWishListId = ((_e = (_d = (_c = Tapcart === null || Tapcart === void 0 ? void 0 : Tapcart.variables) === null || _c === void 0 ? void 0 : _c.wishlists) === null || _d === void 0 ? void 0 : _d[0]) === null || _e === void 0 ? void 0 : _e.id) || "Default Wishlist";
|
|
431
|
+
const wishlistIntegration = getEnabledWishlistIntegration(integrations);
|
|
432
|
+
if (!wishlistIntegration) {
|
|
433
|
+
// If no wishlist integration adding is not possible
|
|
434
|
+
return false;
|
|
435
|
+
}
|
|
436
|
+
const supportsMultipleLists = supportsMultipleWishlists(wishlistIntegration);
|
|
437
|
+
if (!product || !(product === null || product === void 0 ? void 0 : product.id)) {
|
|
438
|
+
console.error("Product is missing");
|
|
439
|
+
return false;
|
|
440
|
+
}
|
|
441
|
+
if (!Tapcart) {
|
|
442
|
+
console.error("Tapcart instance is missing");
|
|
443
|
+
return false;
|
|
444
|
+
}
|
|
445
|
+
try {
|
|
446
|
+
const shouldOpenDrawer = supportsMultipleLists ||
|
|
447
|
+
((product === null || product === void 0 ? void 0 : product.variants) && ((_f = product === null || product === void 0 ? void 0 : product.variants) === null || _f === void 0 ? void 0 : _f.length) > 1) ||
|
|
448
|
+
!isAuthenticated;
|
|
449
|
+
if (shouldOpenDrawer) {
|
|
450
|
+
Tapcart === null || Tapcart === void 0 ? void 0 : Tapcart.action("screen/open", getWishlistAddItemNavigation(getIdFromGid(product === null || product === void 0 ? void 0 : product.id), isAuthenticated));
|
|
451
|
+
return false;
|
|
452
|
+
}
|
|
453
|
+
const variantId = selectedVariantId || ((_h = (_g = product === null || product === void 0 ? void 0 : product.variants) === null || _g === void 0 ? void 0 : _g[0]) === null || _h === void 0 ? void 0 : _h.id);
|
|
454
|
+
if (!variantId) {
|
|
455
|
+
console.error("Missing variant id for wishlist add");
|
|
456
|
+
return false;
|
|
457
|
+
}
|
|
458
|
+
const result = yield Tapcart.action("wishlist/item/add", {
|
|
459
|
+
productId: getIdFromGid(product === null || product === void 0 ? void 0 : product.id),
|
|
460
|
+
variantId: getIdFromGid(variantId),
|
|
461
|
+
wishlistId: defaultWishListId,
|
|
462
|
+
});
|
|
463
|
+
return result;
|
|
464
|
+
}
|
|
465
|
+
catch (error) {
|
|
466
|
+
console.error("Failed to add to wishlist", error);
|
|
467
|
+
}
|
|
468
|
+
return false;
|
|
469
|
+
});
|
|
470
|
+
/**
|
|
471
|
+
* Removes an item from all wishlists by product ID.
|
|
472
|
+
*
|
|
473
|
+
* @param {Object} params - The parameters for the function.
|
|
474
|
+
* @param {any} params.Tapcart - The Tapcart instance.
|
|
475
|
+
* @param {string} params.productId - The ID of the product to remove.
|
|
476
|
+
* @returns {Promise<{ id: string; variantId: string; productId: string }[]>} - An array of removed wishlist entries.
|
|
477
|
+
*/
|
|
478
|
+
export const removeItemFromWishlists = ({ Tapcart, productId, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
479
|
+
var _j, _k, _l, _m;
|
|
480
|
+
if (!Tapcart) {
|
|
481
|
+
console.error("Tapcart instance is missing");
|
|
482
|
+
return [];
|
|
483
|
+
}
|
|
484
|
+
const removedWishlistEntries = [];
|
|
485
|
+
try {
|
|
486
|
+
const wishlistEntries = findWishlistEntries((_j = Tapcart === null || Tapcart === void 0 ? void 0 : Tapcart.variables) === null || _j === void 0 ? void 0 : _j.wishlists, productId);
|
|
487
|
+
// Remove all wishlist entries for the product
|
|
488
|
+
for (const wishlistEntry of wishlistEntries) {
|
|
489
|
+
if (!((_k = wishlistEntry === null || wishlistEntry === void 0 ? void 0 : wishlistEntry.item) === null || _k === void 0 ? void 0 : _k.variantId)) {
|
|
490
|
+
console.error("Missing variant id for wishlist removal");
|
|
491
|
+
continue;
|
|
492
|
+
}
|
|
493
|
+
if (!(wishlistEntry === null || wishlistEntry === void 0 ? void 0 : wishlistEntry.wishlistId)) {
|
|
494
|
+
console.error("Missing wishlist id for wishlist removal");
|
|
495
|
+
continue;
|
|
496
|
+
}
|
|
497
|
+
const result = yield Tapcart.action("wishlist/item/remove", {
|
|
498
|
+
productId,
|
|
499
|
+
variantId: getIdFromGid((_l = wishlistEntry === null || wishlistEntry === void 0 ? void 0 : wishlistEntry.item) === null || _l === void 0 ? void 0 : _l.variantId),
|
|
500
|
+
wishlistId: getIdFromGid(wishlistEntry === null || wishlistEntry === void 0 ? void 0 : wishlistEntry.wishlistId),
|
|
501
|
+
});
|
|
502
|
+
if (result) {
|
|
503
|
+
removedWishlistEntries.push({
|
|
504
|
+
id: getIdFromGid(wishlistEntry === null || wishlistEntry === void 0 ? void 0 : wishlistEntry.wishlistId),
|
|
505
|
+
variantId: getIdFromGid((_m = wishlistEntry === null || wishlistEntry === void 0 ? void 0 : wishlistEntry.item) === null || _m === void 0 ? void 0 : _m.variantId),
|
|
506
|
+
productId,
|
|
507
|
+
});
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
catch (error) {
|
|
512
|
+
console.error("Failed to remove from wishlist", error);
|
|
513
|
+
}
|
|
514
|
+
return removedWishlistEntries;
|
|
515
|
+
});
|
|
414
516
|
export const getBadgesForProductFn = (badgeConfig = {}, productTags = []) => {
|
|
415
517
|
const badgePositions = ["below", "bottom", "top"];
|
|
416
518
|
const badgesCombined = [];
|
package/dist/styles.css
CHANGED
|
@@ -778,9 +778,6 @@ video {
|
|
|
778
778
|
.top-\[50\%\] {
|
|
779
779
|
top: 50%;
|
|
780
780
|
}
|
|
781
|
-
.z-0 {
|
|
782
|
-
z-index: 0;
|
|
783
|
-
}
|
|
784
781
|
.z-10 {
|
|
785
782
|
z-index: 10;
|
|
786
783
|
}
|
|
@@ -880,15 +877,15 @@ video {
|
|
|
880
877
|
.mb-6 {
|
|
881
878
|
margin-bottom: 1.5rem;
|
|
882
879
|
}
|
|
880
|
+
.ml-0 {
|
|
881
|
+
margin-left: 0px;
|
|
882
|
+
}
|
|
883
883
|
.ml-1 {
|
|
884
884
|
margin-left: 0.25rem;
|
|
885
885
|
}
|
|
886
886
|
.ml-2 {
|
|
887
887
|
margin-left: 0.5rem;
|
|
888
888
|
}
|
|
889
|
-
.ml-4 {
|
|
890
|
-
margin-left: 1rem;
|
|
891
|
-
}
|
|
892
889
|
.ml-auto {
|
|
893
890
|
margin-left: auto;
|
|
894
891
|
}
|
|
@@ -970,9 +967,6 @@ video {
|
|
|
970
967
|
.hidden {
|
|
971
968
|
display: none;
|
|
972
969
|
}
|
|
973
|
-
.aspect-\[2\/3\] {
|
|
974
|
-
aspect-ratio: 2/3;
|
|
975
|
-
}
|
|
976
970
|
.aspect-productImages {
|
|
977
971
|
aspect-ratio: var(--productImage-aspectRatio);
|
|
978
972
|
}
|
|
@@ -1112,9 +1106,6 @@ video {
|
|
|
1112
1106
|
.w-1\/2 {
|
|
1113
1107
|
width: 50%;
|
|
1114
1108
|
}
|
|
1115
|
-
.w-1\/3 {
|
|
1116
|
-
width: 33.333333%;
|
|
1117
|
-
}
|
|
1118
1109
|
.w-1\/4 {
|
|
1119
1110
|
width: 25%;
|
|
1120
1111
|
}
|
|
@@ -1139,9 +1130,6 @@ video {
|
|
|
1139
1130
|
.w-2\/3 {
|
|
1140
1131
|
width: 66.666667%;
|
|
1141
1132
|
}
|
|
1142
|
-
.w-2\/5 {
|
|
1143
|
-
width: 40%;
|
|
1144
|
-
}
|
|
1145
1133
|
.w-20 {
|
|
1146
1134
|
width: 5rem;
|
|
1147
1135
|
}
|
|
@@ -2373,6 +2361,10 @@ video {
|
|
|
2373
2361
|
--tw-drop-shadow: drop-shadow(0 3px 1px 0 rgba(0,0,0,1));
|
|
2374
2362
|
filter: var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow);
|
|
2375
2363
|
}
|
|
2364
|
+
.grayscale {
|
|
2365
|
+
--tw-grayscale: grayscale(100%);
|
|
2366
|
+
filter: var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow);
|
|
2367
|
+
}
|
|
2376
2368
|
.filter {
|
|
2377
2369
|
filter: var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow);
|
|
2378
2370
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"addItemToWishlist.test.d.ts","sourceRoot":"","sources":["../../../tests/addItemToWishlist/addItemToWishlist.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { addItemToWishlist } from "../../lib/utils";
|
|
11
|
+
describe("addItemToWishlist", () => {
|
|
12
|
+
let Tapcart;
|
|
13
|
+
let integrations;
|
|
14
|
+
let product;
|
|
15
|
+
let consoleErrorSpy;
|
|
16
|
+
beforeEach(() => {
|
|
17
|
+
jest.clearAllMocks();
|
|
18
|
+
consoleErrorSpy = jest.spyOn(console, "error").mockImplementation();
|
|
19
|
+
Tapcart = {
|
|
20
|
+
action: jest.fn().mockResolvedValue(true),
|
|
21
|
+
variables: {
|
|
22
|
+
customer: { id: "customer-123" },
|
|
23
|
+
wishlists: [
|
|
24
|
+
{
|
|
25
|
+
id: "gid://shopify/Wishlist/primary",
|
|
26
|
+
},
|
|
27
|
+
],
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
integrations = [
|
|
31
|
+
{
|
|
32
|
+
name: "tapcart-wishlist",
|
|
33
|
+
enabled: true,
|
|
34
|
+
multiwishlist: false,
|
|
35
|
+
},
|
|
36
|
+
];
|
|
37
|
+
product = {
|
|
38
|
+
id: "gid://shopify/Product/123",
|
|
39
|
+
variants: [{ id: "gid://shopify/ProductVariant/456" }],
|
|
40
|
+
};
|
|
41
|
+
});
|
|
42
|
+
afterEach(() => {
|
|
43
|
+
consoleErrorSpy.mockRestore();
|
|
44
|
+
});
|
|
45
|
+
describe("validation", () => {
|
|
46
|
+
it("returns false when no wishlist integration is enabled", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
47
|
+
const result = yield addItemToWishlist({
|
|
48
|
+
Tapcart,
|
|
49
|
+
integrations: [],
|
|
50
|
+
product,
|
|
51
|
+
});
|
|
52
|
+
expect(result).toBe(false);
|
|
53
|
+
expect(Tapcart.action).not.toHaveBeenCalled();
|
|
54
|
+
}));
|
|
55
|
+
it("logs and returns false when product is missing", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
56
|
+
const result = yield addItemToWishlist({
|
|
57
|
+
Tapcart,
|
|
58
|
+
integrations,
|
|
59
|
+
product: null,
|
|
60
|
+
});
|
|
61
|
+
expect(result).toBe(false);
|
|
62
|
+
expect(consoleErrorSpy).toHaveBeenCalledWith("Product is missing");
|
|
63
|
+
expect(Tapcart.action).not.toHaveBeenCalled();
|
|
64
|
+
}));
|
|
65
|
+
it("logs and returns false when Tapcart instance is missing", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
66
|
+
const result = yield addItemToWishlist({
|
|
67
|
+
Tapcart: null,
|
|
68
|
+
integrations,
|
|
69
|
+
product,
|
|
70
|
+
});
|
|
71
|
+
expect(result).toBe(false);
|
|
72
|
+
expect(consoleErrorSpy).toHaveBeenCalledWith("Tapcart instance is missing");
|
|
73
|
+
}));
|
|
74
|
+
});
|
|
75
|
+
describe("drawer behavior", () => {
|
|
76
|
+
it("opens the wishlist drawer when multiple wishlists are supported", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
77
|
+
const multiWishlistIntegrations = [
|
|
78
|
+
{
|
|
79
|
+
name: "tapcart-wishlist",
|
|
80
|
+
enabled: true,
|
|
81
|
+
multiwishlist: true,
|
|
82
|
+
},
|
|
83
|
+
];
|
|
84
|
+
const result = yield addItemToWishlist({
|
|
85
|
+
Tapcart,
|
|
86
|
+
integrations: multiWishlistIntegrations,
|
|
87
|
+
product,
|
|
88
|
+
});
|
|
89
|
+
expect(result).toBe(false);
|
|
90
|
+
expect(Tapcart.action).toHaveBeenCalledWith("screen/open", expect.objectContaining({
|
|
91
|
+
destination: {
|
|
92
|
+
type: "internal",
|
|
93
|
+
url: "wishlist-add-item?productId=123",
|
|
94
|
+
},
|
|
95
|
+
}));
|
|
96
|
+
}));
|
|
97
|
+
it("opens the wishlist drawer when the product exposes multiple variants", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
98
|
+
const result = yield addItemToWishlist({
|
|
99
|
+
Tapcart,
|
|
100
|
+
integrations,
|
|
101
|
+
product: {
|
|
102
|
+
id: product.id,
|
|
103
|
+
variants: [
|
|
104
|
+
{ id: "gid://shopify/ProductVariant/111" },
|
|
105
|
+
{ id: "gid://shopify/ProductVariant/222" },
|
|
106
|
+
],
|
|
107
|
+
},
|
|
108
|
+
});
|
|
109
|
+
expect(result).toBe(false);
|
|
110
|
+
expect(Tapcart.action).toHaveBeenCalledWith("screen/open", expect.objectContaining({
|
|
111
|
+
destination: {
|
|
112
|
+
type: "internal",
|
|
113
|
+
url: "wishlist-add-item?productId=123",
|
|
114
|
+
},
|
|
115
|
+
}));
|
|
116
|
+
}));
|
|
117
|
+
it("opens the wishlist drawer when the customer is not authenticated", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
118
|
+
Tapcart.variables.customer = null;
|
|
119
|
+
const result = yield addItemToWishlist({
|
|
120
|
+
Tapcart,
|
|
121
|
+
integrations,
|
|
122
|
+
product,
|
|
123
|
+
});
|
|
124
|
+
expect(result).toBe(false);
|
|
125
|
+
expect(Tapcart.action).toHaveBeenCalledWith("screen/open", expect.objectContaining({
|
|
126
|
+
presentation: expect.objectContaining({
|
|
127
|
+
snapPoints: [0.3, 0.5, 0.75],
|
|
128
|
+
}),
|
|
129
|
+
}));
|
|
130
|
+
}));
|
|
131
|
+
});
|
|
132
|
+
describe("direct add", () => {
|
|
133
|
+
it("adds the item using the provided variant id", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
134
|
+
const result = yield addItemToWishlist({
|
|
135
|
+
Tapcart,
|
|
136
|
+
integrations,
|
|
137
|
+
product: { id: product.id, variants: [] },
|
|
138
|
+
selectedVariantId: "gid://shopify/ProductVariant/789",
|
|
139
|
+
});
|
|
140
|
+
expect(result).toBe(true);
|
|
141
|
+
expect(Tapcart.action).toHaveBeenCalledTimes(1);
|
|
142
|
+
expect(Tapcart.action).toHaveBeenCalledWith("wishlist/item/add", {
|
|
143
|
+
productId: "123",
|
|
144
|
+
variantId: "789",
|
|
145
|
+
wishlistId: "gid://shopify/Wishlist/primary",
|
|
146
|
+
});
|
|
147
|
+
}));
|
|
148
|
+
it("uses the first product variant when none is selected", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
149
|
+
const result = yield addItemToWishlist({
|
|
150
|
+
Tapcart,
|
|
151
|
+
integrations,
|
|
152
|
+
product,
|
|
153
|
+
});
|
|
154
|
+
expect(result).toBe(true);
|
|
155
|
+
expect(Tapcart.action).toHaveBeenCalledWith("wishlist/item/add", {
|
|
156
|
+
productId: "123",
|
|
157
|
+
variantId: "456",
|
|
158
|
+
wishlistId: "gid://shopify/Wishlist/primary",
|
|
159
|
+
});
|
|
160
|
+
}));
|
|
161
|
+
it("falls back to the default wishlist id when none are present", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
162
|
+
Tapcart.variables.wishlists = [];
|
|
163
|
+
const result = yield addItemToWishlist({
|
|
164
|
+
Tapcart,
|
|
165
|
+
integrations,
|
|
166
|
+
product: { id: product.id, variants: [] },
|
|
167
|
+
selectedVariantId: "gid://shopify/ProductVariant/456",
|
|
168
|
+
});
|
|
169
|
+
expect(result).toBe(true);
|
|
170
|
+
expect(Tapcart.action).toHaveBeenCalledWith("wishlist/item/add", {
|
|
171
|
+
productId: "123",
|
|
172
|
+
variantId: "456",
|
|
173
|
+
wishlistId: "Default Wishlist",
|
|
174
|
+
});
|
|
175
|
+
}));
|
|
176
|
+
it("logs and returns false when no variant id can be resolved", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
177
|
+
const result = yield addItemToWishlist({
|
|
178
|
+
Tapcart,
|
|
179
|
+
integrations,
|
|
180
|
+
product: { id: product.id, variants: [] },
|
|
181
|
+
});
|
|
182
|
+
expect(result).toBe(false);
|
|
183
|
+
expect(consoleErrorSpy).toHaveBeenCalledWith("Missing variant id for wishlist add");
|
|
184
|
+
expect(Tapcart.action).not.toHaveBeenCalled();
|
|
185
|
+
}));
|
|
186
|
+
it("logs and returns false when Tapcart action rejects", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
187
|
+
Tapcart.action = jest.fn().mockRejectedValue(new Error("boom"));
|
|
188
|
+
const result = yield addItemToWishlist({
|
|
189
|
+
Tapcart,
|
|
190
|
+
integrations,
|
|
191
|
+
product: { id: product.id, variants: [] },
|
|
192
|
+
selectedVariantId: "gid://shopify/ProductVariant/999",
|
|
193
|
+
});
|
|
194
|
+
expect(result).toBe(false);
|
|
195
|
+
expect(consoleErrorSpy).toHaveBeenCalledWith("Failed to add to wishlist", expect.any(Error));
|
|
196
|
+
}));
|
|
197
|
+
});
|
|
198
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"removeItemFromWishlists.test.d.ts","sourceRoot":"","sources":["../../../tests/removeItemFromWishlists/removeItemFromWishlists.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { removeItemFromWishlists } from "../../lib/utils";
|
|
11
|
+
describe("removeItemFromWishlists", () => {
|
|
12
|
+
let mockTapcart;
|
|
13
|
+
let consoleErrorSpy;
|
|
14
|
+
beforeEach(() => {
|
|
15
|
+
jest.clearAllMocks();
|
|
16
|
+
consoleErrorSpy = jest.spyOn(console, "error").mockImplementation();
|
|
17
|
+
mockTapcart = {
|
|
18
|
+
action: jest.fn().mockResolvedValue(true),
|
|
19
|
+
variables: {
|
|
20
|
+
wishlists: [
|
|
21
|
+
{
|
|
22
|
+
id: "gid://shopify/Wishlist/1",
|
|
23
|
+
items: [
|
|
24
|
+
{
|
|
25
|
+
productId: "gid://shopify/Product/123",
|
|
26
|
+
variantId: "gid://shopify/ProductVariant/456",
|
|
27
|
+
},
|
|
28
|
+
],
|
|
29
|
+
},
|
|
30
|
+
],
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
});
|
|
34
|
+
afterEach(() => {
|
|
35
|
+
consoleErrorSpy.mockRestore();
|
|
36
|
+
});
|
|
37
|
+
it("returns an empty array and logs when Tapcart instance is missing", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
38
|
+
const result = yield removeItemFromWishlists({
|
|
39
|
+
Tapcart: null,
|
|
40
|
+
productId: "gid://shopify/Product/123",
|
|
41
|
+
});
|
|
42
|
+
expect(result).toEqual([]);
|
|
43
|
+
expect(consoleErrorSpy).toHaveBeenCalledWith("Tapcart instance is missing");
|
|
44
|
+
}));
|
|
45
|
+
it("logs and returns an empty array when removal throws", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
46
|
+
mockTapcart.action = jest.fn().mockImplementation(() => {
|
|
47
|
+
throw new Error("boom");
|
|
48
|
+
});
|
|
49
|
+
const result = yield removeItemFromWishlists({
|
|
50
|
+
Tapcart: mockTapcart,
|
|
51
|
+
productId: "gid://shopify/Product/123",
|
|
52
|
+
});
|
|
53
|
+
expect(result).toEqual([]);
|
|
54
|
+
expect(consoleErrorSpy).toHaveBeenCalledWith("Failed to remove from wishlist", expect.any(Error));
|
|
55
|
+
}));
|
|
56
|
+
it("removes every wishlist entry that matches the productId", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
57
|
+
mockTapcart.variables.wishlists.push({
|
|
58
|
+
_id: "wishlist-2",
|
|
59
|
+
items: [
|
|
60
|
+
{
|
|
61
|
+
productId: "gid://shopify/Product/123",
|
|
62
|
+
variantId: "gid://shopify/ProductVariant/789",
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
productId: "gid://shopify/Product/999",
|
|
66
|
+
variantId: "gid://shopify/ProductVariant/000",
|
|
67
|
+
},
|
|
68
|
+
],
|
|
69
|
+
});
|
|
70
|
+
const result = yield removeItemFromWishlists({
|
|
71
|
+
Tapcart: mockTapcart,
|
|
72
|
+
productId: "gid://shopify/Product/123",
|
|
73
|
+
});
|
|
74
|
+
expect(mockTapcart.action).toHaveBeenCalledTimes(2);
|
|
75
|
+
expect(mockTapcart.action).toHaveBeenNthCalledWith(1, "wishlist/item/remove", {
|
|
76
|
+
productId: "gid://shopify/Product/123",
|
|
77
|
+
variantId: "456",
|
|
78
|
+
wishlistId: "1",
|
|
79
|
+
});
|
|
80
|
+
expect(mockTapcart.action).toHaveBeenNthCalledWith(2, "wishlist/item/remove", {
|
|
81
|
+
productId: "gid://shopify/Product/123",
|
|
82
|
+
variantId: "789",
|
|
83
|
+
wishlistId: "wishlist-2",
|
|
84
|
+
});
|
|
85
|
+
expect(result).toEqual([
|
|
86
|
+
{ id: "1", productId: "gid://shopify/Product/123", variantId: "456" },
|
|
87
|
+
{
|
|
88
|
+
id: "wishlist-2",
|
|
89
|
+
productId: "gid://shopify/Product/123",
|
|
90
|
+
variantId: "789",
|
|
91
|
+
},
|
|
92
|
+
]);
|
|
93
|
+
}));
|
|
94
|
+
it("returns an empty array when no wishlist entries match", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
95
|
+
const result = yield removeItemFromWishlists({
|
|
96
|
+
Tapcart: mockTapcart,
|
|
97
|
+
productId: "gid://shopify/Product/000",
|
|
98
|
+
});
|
|
99
|
+
expect(result).toEqual([]);
|
|
100
|
+
expect(mockTapcart.action).not.toHaveBeenCalled();
|
|
101
|
+
expect(consoleErrorSpy).not.toHaveBeenCalled();
|
|
102
|
+
}));
|
|
103
|
+
it("returns an empty array and logs when a variant id is missing", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
104
|
+
mockTapcart.variables.wishlists[0].items[0].variantId = null;
|
|
105
|
+
const result = yield removeItemFromWishlists({
|
|
106
|
+
Tapcart: mockTapcart,
|
|
107
|
+
productId: "gid://shopify/Product/123",
|
|
108
|
+
});
|
|
109
|
+
expect(result).toEqual([]);
|
|
110
|
+
expect(consoleErrorSpy).toHaveBeenCalledWith("Missing variant id for wishlist removal");
|
|
111
|
+
expect(mockTapcart.action).not.toHaveBeenCalled();
|
|
112
|
+
}));
|
|
113
|
+
it("returns an empty array and logs when a wishlist id is missing", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
114
|
+
mockTapcart.variables.wishlists[0].id = null;
|
|
115
|
+
const result = yield removeItemFromWishlists({
|
|
116
|
+
Tapcart: mockTapcart,
|
|
117
|
+
productId: "gid://shopify/Product/123",
|
|
118
|
+
});
|
|
119
|
+
expect(result).toEqual([]);
|
|
120
|
+
expect(consoleErrorSpy).toHaveBeenCalledWith("Missing wishlist id for wishlist removal");
|
|
121
|
+
expect(mockTapcart.action).not.toHaveBeenCalled();
|
|
122
|
+
}));
|
|
123
|
+
});
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.wishlist.test.d.ts","sourceRoot":"","sources":["../../lib/utils.wishlist.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import { findWishlistEntry, getEnabledWishlistIntegration, supportsMultipleWishlists, } from "./utils";
|
|
2
|
-
describe("getEnabledWishlistIntegration", () => {
|
|
3
|
-
it("returns the first enabled wishlist integration", () => {
|
|
4
|
-
const integrations = [
|
|
5
|
-
{ name: "tapcart-search", enabled: true },
|
|
6
|
-
{ name: "tapcart-wishlist", enabled: true, multiwishlist: true },
|
|
7
|
-
{ name: "swym", enabled: true },
|
|
8
|
-
];
|
|
9
|
-
const result = getEnabledWishlistIntegration(integrations);
|
|
10
|
-
expect(result).toEqual({
|
|
11
|
-
name: "tapcart-wishlist",
|
|
12
|
-
enabled: true,
|
|
13
|
-
multiwishlist: true,
|
|
14
|
-
});
|
|
15
|
-
});
|
|
16
|
-
it("returns null when no wishlist integration is enabled", () => {
|
|
17
|
-
const integrations = [
|
|
18
|
-
{ name: "tapcart-search", enabled: true },
|
|
19
|
-
{ name: "tapcart-wishlist", enabled: false },
|
|
20
|
-
];
|
|
21
|
-
expect(getEnabledWishlistIntegration(integrations)).toBeNull();
|
|
22
|
-
});
|
|
23
|
-
it("returns null when integrations is not an array", () => {
|
|
24
|
-
expect(getEnabledWishlistIntegration(undefined)).toBeNull();
|
|
25
|
-
expect(getEnabledWishlistIntegration(null)).toBeNull();
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
describe("supportsMultipleWishlists", () => {
|
|
29
|
-
it("respects explicit multiwishlist flag", () => {
|
|
30
|
-
expect(supportsMultipleWishlists({
|
|
31
|
-
name: "tapcart-wishlist",
|
|
32
|
-
enabled: true,
|
|
33
|
-
multiwishlist: false,
|
|
34
|
-
})).toBe(false);
|
|
35
|
-
expect(supportsMultipleWishlists({
|
|
36
|
-
name: "tapcart-wishlist",
|
|
37
|
-
enabled: true,
|
|
38
|
-
multiwishlist: true,
|
|
39
|
-
})).toBe(true);
|
|
40
|
-
});
|
|
41
|
-
it("defaults to true for known integrations when flag is omitted", () => {
|
|
42
|
-
expect(supportsMultipleWishlists({
|
|
43
|
-
name: "tapcart-wishlist-v2",
|
|
44
|
-
enabled: true,
|
|
45
|
-
})).toBe(true);
|
|
46
|
-
});
|
|
47
|
-
it("returns false for unknown integrations", () => {
|
|
48
|
-
expect(supportsMultipleWishlists({
|
|
49
|
-
name: "not-a-wishlist",
|
|
50
|
-
enabled: true,
|
|
51
|
-
})).toBe(false);
|
|
52
|
-
});
|
|
53
|
-
});
|
|
54
|
-
describe("findWishlistEntry", () => {
|
|
55
|
-
const wishlists = [
|
|
56
|
-
{
|
|
57
|
-
id: "wl-1",
|
|
58
|
-
items: [
|
|
59
|
-
{
|
|
60
|
-
id: "item-1",
|
|
61
|
-
productId: "gid://shopify/Product/123",
|
|
62
|
-
variantId: "gid://shopify/ProductVariant/456",
|
|
63
|
-
},
|
|
64
|
-
],
|
|
65
|
-
},
|
|
66
|
-
{
|
|
67
|
-
_id: "wl-2",
|
|
68
|
-
items: [
|
|
69
|
-
{
|
|
70
|
-
id: "item-2",
|
|
71
|
-
productId: "789",
|
|
72
|
-
variantId: "654",
|
|
73
|
-
},
|
|
74
|
-
],
|
|
75
|
-
},
|
|
76
|
-
];
|
|
77
|
-
it("finds an entry when product and variant match across gid representations", () => {
|
|
78
|
-
const match = findWishlistEntry(wishlists, "123", "456");
|
|
79
|
-
expect(match).toEqual({
|
|
80
|
-
wishlistId: "wl-1",
|
|
81
|
-
item: {
|
|
82
|
-
id: "item-1",
|
|
83
|
-
productId: "gid://shopify/Product/123",
|
|
84
|
-
variantId: "gid://shopify/ProductVariant/456",
|
|
85
|
-
},
|
|
86
|
-
});
|
|
87
|
-
});
|
|
88
|
-
it("falls back to product-only lookup when variant is omitted", () => {
|
|
89
|
-
const match = findWishlistEntry(wishlists, "789");
|
|
90
|
-
expect(match).toEqual({
|
|
91
|
-
wishlistId: "wl-2",
|
|
92
|
-
item: {
|
|
93
|
-
id: "item-2",
|
|
94
|
-
productId: "789",
|
|
95
|
-
variantId: "654",
|
|
96
|
-
},
|
|
97
|
-
});
|
|
98
|
-
});
|
|
99
|
-
it("returns null when no matching entry is found", () => {
|
|
100
|
-
const match = findWishlistEntry(wishlists, "999", "888");
|
|
101
|
-
expect(match).toBeNull();
|
|
102
|
-
});
|
|
103
|
-
it("handles empty or invalid inputs gracefully", () => {
|
|
104
|
-
expect(findWishlistEntry(undefined, "123")).toBeNull();
|
|
105
|
-
expect(findWishlistEntry([], "123")).toBeNull();
|
|
106
|
-
expect(findWishlistEntry(wishlists, undefined)).toBeNull();
|
|
107
|
-
});
|
|
108
|
-
});
|