@sentecacommerce-theme/lib 0.14.5 → 0.14.8

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.
@@ -249,14 +249,15 @@ var WishlistApiFactory = function() {
249
249
  });
250
250
  },
251
251
  useIsExisting: function(productId, identifier) {
252
+ var useVariant = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : true;
252
253
  return (0, _reactQuery).useQuery([
253
254
  cacheKeys.useIsExisting,
254
255
  productId,
255
256
  identifier
256
257
  ], function() {
257
- var ref, ref1;
258
+ var ref, ref1, ref2;
258
259
  var parsedData = (0, _utils).readFromLocalStorage(WISHLIST_STORAGE_KEY);
259
- return !!(parsedData === null || parsedData === void 0 ? void 0 : (ref = parsedData.items) === null || ref === void 0 ? void 0 : (ref1 = ref[productId]) === null || ref1 === void 0 ? void 0 : ref1[identifier]);
260
+ return useVariant ? !!(parsedData === null || parsedData === void 0 ? void 0 : (ref = parsedData.items) === null || ref === void 0 ? void 0 : (ref1 = ref[productId]) === null || ref1 === void 0 ? void 0 : ref1[identifier]) : !!(parsedData === null || parsedData === void 0 ? void 0 : (ref2 = parsedData.items) === null || ref2 === void 0 ? void 0 : ref2[productId]);
260
261
  });
261
262
  }
262
263
  });
@@ -50,10 +50,10 @@ function _unsupportedIterableToArray(o, minLen) {
50
50
  if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
51
51
  }
52
52
  var useWishlist = function(param) {
53
- var productId = param.productId, variantId = param.variantId, collapseKey = param.collapseKey, onAddCallback = param.onAddCallback, onRemoveCallback = param.onRemoveCallback;
53
+ var productId = param.productId, variantId = param.variantId, collapseKey = param.collapseKey, onAddCallback = param.onAddCallback, onRemoveCallback = param.onRemoveCallback, _useVariant = param.useVariant, useVariant = _useVariant === void 0 ? true : _useVariant;
54
54
  var ref = _slicedToArray(_wishlistApi.wishlistApi.useAdd(onAddCallback), 1), add = ref[0];
55
55
  var ref1 = _slicedToArray(_wishlistApi.wishlistApi.useRemove(onRemoveCallback), 1), remove = ref1[0];
56
- var ref2 = _wishlistApi.wishlistApi.useIsExisting(productId, collapseKey !== null && collapseKey !== void 0 ? collapseKey : variantId), isExisting = ref2.data;
56
+ var ref2 = _wishlistApi.wishlistApi.useIsExisting(productId, collapseKey !== null && collapseKey !== void 0 ? collapseKey : variantId, useVariant), isExisting = ref2.data;
57
57
  return {
58
58
  addToWishlist: function() {
59
59
  return add({
@@ -106,7 +106,7 @@ var buildCategoryQuery = function(param) {
106
106
  };
107
107
  var _obj;
108
108
  var query = (_obj = {}, _defineProperty(_obj, type, aggValue), _defineProperty(_obj, "filter", getFilters()), _obj);
109
- if (pageType === _index.ListingTypesEnum.Collection) {
109
+ if (pageType === _index.ListingTypesEnum.Collection && (config === null || config === void 0 ? void 0 : config.collapseMode)) {
110
110
  var collapseMode = config === null || config === void 0 ? void 0 : config.collapseMode;
111
111
  query = _objectSpread({}, query, {
112
112
  collapseMode: collapseMode
@@ -2,17 +2,19 @@ Object.defineProperty(exports, "__esModule", {
2
2
  value: true
3
3
  });
4
4
  exports.getUniCreditProductOffersKey = exports.getBnpProductOffersKey = void 0;
5
- var getBnpProductOffersKey = function(sku) {
5
+ var getBnpProductOffersKey = function(sku, downPaymentCentAmount) {
6
6
  return [
7
7
  'product-bnp-offers',
8
- sku
8
+ sku,
9
+ downPaymentCentAmount
9
10
  ];
10
11
  };
11
12
  exports.getBnpProductOffersKey = getBnpProductOffersKey;
12
- var getUniCreditProductOffersKey = function(sku) {
13
+ var getUniCreditProductOffersKey = function(sku, downPaymentCentAmount) {
13
14
  return [
14
15
  'product-unicredit-offers',
15
- sku
16
+ sku,
17
+ downPaymentCentAmount
16
18
  ];
17
19
  };
18
20
  exports.getUniCreditProductOffersKey = getUniCreditProductOffersKey;
@@ -43,7 +43,7 @@ function _interopRequireDefault(obj) {
43
43
  }
44
44
  var useBnpOffersQuery = function(param) {
45
45
  var sku = param.sku, _preferredInstallmentCentAmount = param.preferredInstallmentCentAmount, preferredInstallmentCentAmount = _preferredInstallmentCentAmount === void 0 ? 0 : _preferredInstallmentCentAmount, _downPaymentCentAmount = param.downPaymentCentAmount, downPaymentCentAmount = _downPaymentCentAmount === void 0 ? 0 : _downPaymentCentAmount;
46
- return (0, _reactQuery).useQuery((0, _keys).getBnpProductOffersKey(sku), _asyncToGenerator(_regeneratorRuntime.default.mark(function _callee() {
46
+ return (0, _reactQuery).useQuery((0, _keys).getBnpProductOffersKey(sku, downPaymentCentAmount), _asyncToGenerator(_regeneratorRuntime.default.mark(function _callee() {
47
47
  return _regeneratorRuntime.default.wrap(function _callee$(_ctx) {
48
48
  while(1)switch(_ctx.prev = _ctx.next){
49
49
  case 0:
@@ -43,7 +43,7 @@ function _interopRequireDefault(obj) {
43
43
  }
44
44
  var useUniCreditOffersQuery = function(param) {
45
45
  var sku = param.sku, _downPaymentCentAmount = param.downPaymentCentAmount, downPaymentCentAmount = _downPaymentCentAmount === void 0 ? 0 : _downPaymentCentAmount;
46
- return (0, _reactQuery).useQuery((0, _keys).getUniCreditProductOffersKey(sku), _asyncToGenerator(_regeneratorRuntime.default.mark(function _callee() {
46
+ return (0, _reactQuery).useQuery((0, _keys).getUniCreditProductOffersKey(sku, downPaymentCentAmount), _asyncToGenerator(_regeneratorRuntime.default.mark(function _callee() {
47
47
  return _regeneratorRuntime.default.wrap(function _callee$(_ctx) {
48
48
  while(1)switch(_ctx.prev = _ctx.next){
49
49
  case 0:
@@ -237,14 +237,15 @@ export var WishlistApiFactory = function() {
237
237
  });
238
238
  },
239
239
  useIsExisting: function(productId, identifier) {
240
+ var useVariant = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : true;
240
241
  return useQuery([
241
242
  cacheKeys.useIsExisting,
242
243
  productId,
243
244
  identifier
244
245
  ], function() {
245
- var ref, ref1;
246
+ var ref, ref1, ref2;
246
247
  var parsedData = readFromLocalStorage(WISHLIST_STORAGE_KEY);
247
- return !!(parsedData === null || parsedData === void 0 ? void 0 : (ref = parsedData.items) === null || ref === void 0 ? void 0 : (ref1 = ref[productId]) === null || ref1 === void 0 ? void 0 : ref1[identifier]);
248
+ return useVariant ? !!(parsedData === null || parsedData === void 0 ? void 0 : (ref = parsedData.items) === null || ref === void 0 ? void 0 : (ref1 = ref[productId]) === null || ref1 === void 0 ? void 0 : ref1[identifier]) : !!(parsedData === null || parsedData === void 0 ? void 0 : (ref2 = parsedData.items) === null || ref2 === void 0 ? void 0 : ref2[productId]);
248
249
  });
249
250
  }
250
251
  });
@@ -1,4 +1,4 @@
1
- import { wishlistApi } from "../../../api/wishlistApi";
1
+ import { wishlistApi } from '../../../api/wishlistApi';
2
2
  function _arrayLikeToArray(arr, len) {
3
3
  if (len == null || len > arr.length) len = arr.length;
4
4
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
@@ -46,10 +46,10 @@ function _unsupportedIterableToArray(o, minLen) {
46
46
  if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
47
47
  }
48
48
  export var useWishlist = function(param) {
49
- var productId = param.productId, variantId = param.variantId, collapseKey = param.collapseKey, onAddCallback = param.onAddCallback, onRemoveCallback = param.onRemoveCallback;
49
+ var productId = param.productId, variantId = param.variantId, collapseKey = param.collapseKey, onAddCallback = param.onAddCallback, onRemoveCallback = param.onRemoveCallback, _useVariant = param.useVariant, useVariant = _useVariant === void 0 ? true : _useVariant;
50
50
  var ref = _slicedToArray(wishlistApi.useAdd(onAddCallback), 1), add = ref[0];
51
51
  var ref1 = _slicedToArray(wishlistApi.useRemove(onRemoveCallback), 1), remove = ref1[0];
52
- var ref2 = wishlistApi.useIsExisting(productId, collapseKey !== null && collapseKey !== void 0 ? collapseKey : variantId), isExisting = ref2.data;
52
+ var ref2 = wishlistApi.useIsExisting(productId, collapseKey !== null && collapseKey !== void 0 ? collapseKey : variantId, useVariant), isExisting = ref2.data;
53
53
  return {
54
54
  addToWishlist: function() {
55
55
  return add({
@@ -102,7 +102,7 @@ export var buildCategoryQuery = function(param) {
102
102
  };
103
103
  var _obj;
104
104
  var query = (_obj = {}, _defineProperty(_obj, type, aggValue), _defineProperty(_obj, "filter", getFilters()), _obj);
105
- if (pageType === ListingTypesEnum.Collection) {
105
+ if (pageType === ListingTypesEnum.Collection && (config === null || config === void 0 ? void 0 : config.collapseMode)) {
106
106
  var collapseMode = config === null || config === void 0 ? void 0 : config.collapseMode;
107
107
  query = _objectSpread({}, query, {
108
108
  collapseMode: collapseMode
@@ -1,12 +1,14 @@
1
- export var getBnpProductOffersKey = function(sku) {
1
+ export var getBnpProductOffersKey = function(sku, downPaymentCentAmount) {
2
2
  return [
3
3
  'product-bnp-offers',
4
- sku
4
+ sku,
5
+ downPaymentCentAmount
5
6
  ];
6
7
  };
7
- export var getUniCreditProductOffersKey = function(sku) {
8
+ export var getUniCreditProductOffersKey = function(sku, downPaymentCentAmount) {
8
9
  return [
9
10
  'product-unicredit-offers',
10
- sku
11
+ sku,
12
+ downPaymentCentAmount
11
13
  ];
12
14
  };
@@ -34,7 +34,7 @@ function _asyncToGenerator(fn) {
34
34
  }
35
35
  export var useBnpOffersQuery = function(param) {
36
36
  var sku = param.sku, _preferredInstallmentCentAmount = param.preferredInstallmentCentAmount, preferredInstallmentCentAmount = _preferredInstallmentCentAmount === void 0 ? 0 : _preferredInstallmentCentAmount, _downPaymentCentAmount = param.downPaymentCentAmount, downPaymentCentAmount = _downPaymentCentAmount === void 0 ? 0 : _downPaymentCentAmount;
37
- return useQuery(getBnpProductOffersKey(sku), _asyncToGenerator(regeneratorRuntime.mark(function _callee() {
37
+ return useQuery(getBnpProductOffersKey(sku, downPaymentCentAmount), _asyncToGenerator(regeneratorRuntime.mark(function _callee() {
38
38
  return regeneratorRuntime.wrap(function _callee$(_ctx) {
39
39
  while(1)switch(_ctx.prev = _ctx.next){
40
40
  case 0:
@@ -34,7 +34,7 @@ function _asyncToGenerator(fn) {
34
34
  }
35
35
  export var useUniCreditOffersQuery = function(param) {
36
36
  var sku = param.sku, _downPaymentCentAmount = param.downPaymentCentAmount, downPaymentCentAmount = _downPaymentCentAmount === void 0 ? 0 : _downPaymentCentAmount;
37
- return useQuery(getUniCreditProductOffersKey(sku), _asyncToGenerator(regeneratorRuntime.mark(function _callee() {
37
+ return useQuery(getUniCreditProductOffersKey(sku, downPaymentCentAmount), _asyncToGenerator(regeneratorRuntime.mark(function _callee() {
38
38
  return regeneratorRuntime.wrap(function _callee$(_ctx) {
39
39
  while(1)switch(_ctx.prev = _ctx.next){
40
40
  case 0:
@@ -12,7 +12,7 @@ declare type WishlistApiType = {
12
12
  offset: number;
13
13
  }) => InfiniteQueryResult<WishListDTO, unknown>;
14
14
  readonly useGetCompact: () => QueryResult<CompactWishlist, unknown>;
15
- readonly useIsExisting: (productId: string, variantId: string) => QueryResult<boolean, unknown>;
15
+ readonly useIsExisting: (productId: string, variantId: string, useVariant?: boolean) => QueryResult<boolean, unknown>;
16
16
  readonly useAdd: (onSuccess?: () => void) => MutationResultPair<WishListDTO, unknown, WishListItemDraftDTO, unknown>;
17
17
  readonly useSync: (onSuccess?: () => void) => MutationResultPair<WishListDTO, unknown, {
18
18
  query?: {
@@ -1,9 +1,10 @@
1
- export declare const useWishlist: ({ productId, variantId, collapseKey, onAddCallback, onRemoveCallback, }: {
1
+ export declare const useWishlist: ({ productId, variantId, collapseKey, onAddCallback, onRemoveCallback, useVariant, }: {
2
2
  productId: string;
3
3
  variantId?: string | undefined;
4
4
  collapseKey?: string | undefined;
5
5
  onAddCallback?: (() => void) | undefined;
6
6
  onRemoveCallback?: (() => void) | undefined;
7
+ useVariant?: boolean | undefined;
7
8
  }) => {
8
9
  addToWishlist: () => Promise<import("@sentecacommerce/sdk").WishListDTO | undefined>;
9
10
  removeFromWishlist: () => void;
@@ -1,2 +1,2 @@
1
- export declare const getBnpProductOffersKey: (sku: string) => string[];
2
- export declare const getUniCreditProductOffersKey: (sku: string) => string[];
1
+ export declare const getBnpProductOffersKey: (sku: string, downPaymentCentAmount?: number | undefined) => (string | number | undefined)[];
2
+ export declare const getUniCreditProductOffersKey: (sku: string, downPaymentCentAmount?: number | undefined) => (string | number | undefined)[];
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sentecacommerce-theme/lib",
3
3
  "sideEffects": false,
4
- "version": "0.14.5",
4
+ "version": "0.14.8",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
7
7
  "types": "dist/types/index.d.ts",
@@ -31,13 +31,13 @@
31
31
  "watch:cjs": "swc src --out-dir dist/cjs -w",
32
32
  "watch:esm": "swc src --out-dir dist/esm --no-swcrc -w"
33
33
  },
34
- "gitHead": "b59d78afea36337aef60d948e2a3a9b7f52749bd",
34
+ "gitHead": "556a26ab90b2169a12b698de7a8117efa6069664",
35
35
  "peerDependencies": {
36
36
  "react-query": "^2.26.2"
37
37
  },
38
38
  "dependencies": {
39
- "@sentecacommerce-theme/base": "^0.14.5",
40
- "@sentecacommerce-theme/cms": "^0.14.5",
39
+ "@sentecacommerce-theme/base": "^0.14.8",
40
+ "@sentecacommerce-theme/cms": "^0.14.8",
41
41
  "@sentecacommerce/sdk": "2.0.175",
42
42
  "body-scroll-lock": "^3.1.5",
43
43
  "copy-to-clipboard": "^3.3.1",