@ikas/storefront 0.0.158-alpha.9 → 0.0.158

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/build/index.es.js CHANGED
@@ -11061,8 +11061,6 @@ var IkasCategoryPath = /** @class */ (function () {
11061
11061
  }());
11062
11062
  var IkasFilterCategory = /** @class */ (function () {
11063
11063
  function IkasFilterCategory(data) {
11064
- // Extra
11065
- this._isSelected = false;
11066
11064
  this.id = data.id || "";
11067
11065
  this.name = data.name || "";
11068
11066
  this.slug = data.slug || "";
@@ -11070,16 +11068,8 @@ var IkasFilterCategory = /** @class */ (function () {
11070
11068
  data.resultCount !== undefined && data.resultCount !== null
11071
11069
  ? data.resultCount
11072
11070
  : null;
11073
- this._isSelected = data.isSelected || false;
11074
11071
  makeAutoObservable(this);
11075
11072
  }
11076
- Object.defineProperty(IkasFilterCategory.prototype, "isSelected", {
11077
- get: function () {
11078
- return this._isSelected;
11079
- },
11080
- enumerable: false,
11081
- configurable: true
11082
- });
11083
11073
  Object.defineProperty(IkasFilterCategory.prototype, "href", {
11084
11074
  get: function () {
11085
11075
  if (!this.slug)
@@ -11089,9 +11079,6 @@ var IkasFilterCategory = /** @class */ (function () {
11089
11079
  enumerable: false,
11090
11080
  configurable: true
11091
11081
  });
11092
- IkasFilterCategory.prototype.toJSON = function () {
11093
- return __assign(__assign({}, this), { isSelected: this._isSelected });
11094
- };
11095
11082
  return IkasFilterCategory;
11096
11083
  }());
11097
11084
 
@@ -11184,7 +11171,7 @@ var IkasOrderAddress = /** @class */ (function () {
11184
11171
  });
11185
11172
  Object.defineProperty(IkasOrderAddress.prototype, "validationResult", {
11186
11173
  get: function () {
11187
- var _a, _b, _c, _d;
11174
+ var _a, _b, _c, _d, _e;
11188
11175
  var isValidPhone = !!this.phone &&
11189
11176
  this.phone.length >= 10 &&
11190
11177
  validatePhoneNumber(this.phone);
@@ -11205,7 +11192,10 @@ var IkasOrderAddress = /** @class */ (function () {
11205
11192
  ? isValidPhone
11206
11193
  : true,
11207
11194
  identityNumber: ((_d = this.checkoutSettings) === null || _d === void 0 ? void 0 : _d.identityNumberRequirement) ===
11208
- IkasCheckoutRequirementEnum.MANDATORY
11195
+ IkasCheckoutRequirementEnum.MANDATORY ||
11196
+ (((_e = this.checkoutSettings) === null || _e === void 0 ? void 0 : _e.identityNumberRequirement) ===
11197
+ IkasCheckoutRequirementEnum.OPTIONAL &&
11198
+ this.phone)
11209
11199
  ? !!this.identityNumber
11210
11200
  : true,
11211
11201
  };
@@ -11336,13 +11326,6 @@ var IkasOrderLineItem = /** @class */ (function () {
11336
11326
  this.status = data.status || OrderLineItemStatusEnum.FULFILLED;
11337
11327
  makeAutoObservable(this);
11338
11328
  }
11339
- Object.defineProperty(IkasOrderLineItem.prototype, "priceWithQuantity", {
11340
- get: function () {
11341
- return this.price * this.quantity;
11342
- },
11343
- enumerable: false,
11344
- configurable: true
11345
- });
11346
11329
  Object.defineProperty(IkasOrderLineItem.prototype, "finalPriceWithQuantity", {
11347
11330
  get: function () {
11348
11331
  return this.finalPrice * this.quantity;
@@ -17485,8 +17468,6 @@ var LS_TOKEN_KEY = "customerToken";
17485
17468
  var LS_TOKEN_EXPIRY = "customerTokenExpiry";
17486
17469
  var LS_CUSTOMER_KEY = "customer";
17487
17470
  var LS_CUSTOMER_SUB_KEY = "customerEmailSubscription";
17488
- var LS_LAST_VIEWED_PRODUCTS_KEY = "lastViewedProducts";
17489
- var LS_CUSTOMER_CONSENT = "customerConsent";
17490
17471
  var IkasCustomerStore = /** @class */ (function () {
17491
17472
  function IkasCustomerStore(baseStore) {
17492
17473
  var _this = this;
@@ -17496,8 +17477,6 @@ var IkasCustomerStore = /** @class */ (function () {
17496
17477
  this.baseStore = null;
17497
17478
  this._initialized = false;
17498
17479
  this._visitorSubscribedEmail = false;
17499
- this._lastViewedProducts = [];
17500
- this._customerConsentGranted = false;
17501
17480
  this.login = function (email, password) { return __awaiter(_this, void 0, void 0, function () {
17502
17481
  var response, cart;
17503
17482
  var _a;
@@ -17517,9 +17496,7 @@ var IkasCustomerStore = /** @class */ (function () {
17517
17496
  case 2:
17518
17497
  _b.sent();
17519
17498
  _b.label = 3;
17520
- case 3:
17521
- this.saveLocalLastViewedProducts();
17522
- return [2 /*return*/, true];
17499
+ case 3: return [2 /*return*/, true];
17523
17500
  case 4: return [2 /*return*/, false];
17524
17501
  }
17525
17502
  });
@@ -17534,7 +17511,6 @@ var IkasCustomerStore = /** @class */ (function () {
17534
17511
  if (response) {
17535
17512
  this.setToken(response.token, response.tokenExpiry);
17536
17513
  this.setCustomer(response.customer);
17537
- this.saveLocalLastViewedProducts();
17538
17514
  return [2 /*return*/, true];
17539
17515
  }
17540
17516
  return [2 /*return*/, false];
@@ -17750,9 +17726,6 @@ var IkasCustomerStore = /** @class */ (function () {
17750
17726
  }
17751
17727
  });
17752
17728
  }); };
17753
- this.onCustomerConsentGrant = function () {
17754
- _this.saveCustomerConsent();
17755
- };
17756
17729
  this.baseStore = baseStore;
17757
17730
  this.init();
17758
17731
  makeAutoObservable(this);
@@ -17775,13 +17748,6 @@ var IkasCustomerStore = /** @class */ (function () {
17775
17748
  enumerable: false,
17776
17749
  configurable: true
17777
17750
  });
17778
- Object.defineProperty(IkasCustomerStore.prototype, "customerConsentGranted", {
17779
- get: function () {
17780
- return this._customerConsentGranted;
17781
- },
17782
- enumerable: false,
17783
- configurable: true
17784
- });
17785
17751
  IkasCustomerStore.prototype.init = function () {
17786
17752
  return __awaiter(this, void 0, void 0, function () {
17787
17753
  return __generator(this, function (_a) {
@@ -17789,8 +17755,6 @@ var IkasCustomerStore = /** @class */ (function () {
17789
17755
  case 0:
17790
17756
  this.loadToken();
17791
17757
  this.loadCustomer();
17792
- this.loadLastViewedProducts();
17793
- this.loadCustomerConsent();
17794
17758
  return [4 /*yield*/, this.refreshToken()];
17795
17759
  case 1:
17796
17760
  _a.sent();
@@ -17861,127 +17825,6 @@ var IkasCustomerStore = /** @class */ (function () {
17861
17825
  }
17862
17826
  catch (err) { }
17863
17827
  };
17864
- IkasCustomerStore.prototype.getLastViewedProducts = function () {
17865
- return __awaiter(this, void 0, void 0, function () {
17866
- var _a;
17867
- return __generator(this, function (_b) {
17868
- switch (_b.label) {
17869
- case 0:
17870
- if (!this.customer) return [3 /*break*/, 2];
17871
- _a = this;
17872
- return [4 /*yield*/, IkasCustomerAPI.getLastViewedProducts(this.customer.id)];
17873
- case 1:
17874
- _a._lastViewedProducts = _b.sent();
17875
- return [3 /*break*/, 3];
17876
- case 2:
17877
- this.loadLastViewedProducts();
17878
- _b.label = 3;
17879
- case 3: return [2 /*return*/, this._lastViewedProducts];
17880
- }
17881
- });
17882
- });
17883
- };
17884
- IkasCustomerStore.prototype.saveLastViewedProducts = function () {
17885
- if (isServer$3)
17886
- return;
17887
- window.localStorage.setItem(LS_LAST_VIEWED_PRODUCTS_KEY, JSON.stringify(this._lastViewedProducts));
17888
- };
17889
- IkasCustomerStore.prototype.loadLastViewedProducts = function () {
17890
- if (isServer$3)
17891
- return;
17892
- try {
17893
- var lvpStr = window.localStorage.getItem(LS_LAST_VIEWED_PRODUCTS_KEY);
17894
- if (lvpStr) {
17895
- this._lastViewedProducts = JSON.parse(lvpStr);
17896
- this._lastViewedProducts = this._lastViewedProducts.reverse();
17897
- }
17898
- }
17899
- catch (err) { }
17900
- };
17901
- IkasCustomerStore.prototype.removeLastViewedProducts = function () {
17902
- if (isServer$3)
17903
- return;
17904
- window.localStorage.removeItem(LS_LAST_VIEWED_PRODUCTS_KEY);
17905
- };
17906
- IkasCustomerStore.prototype.onProductView = function (productId, variantId) {
17907
- return __awaiter(this, void 0, void 0, function () {
17908
- var isSuccess;
17909
- return __generator(this, function (_a) {
17910
- switch (_a.label) {
17911
- case 0:
17912
- if (!this.customer) return [3 /*break*/, 2];
17913
- return [4 /*yield*/, IkasCustomerAPI.saveLastViewedProducts({
17914
- customerId: this.customer.id,
17915
- products: [
17916
- {
17917
- productId: productId,
17918
- variantId: variantId,
17919
- },
17920
- ],
17921
- })];
17922
- case 1:
17923
- isSuccess = _a.sent();
17924
- if (isSuccess)
17925
- this._lastViewedProducts.push({ productId: productId, variantId: variantId });
17926
- return [3 /*break*/, 3];
17927
- case 2:
17928
- this._lastViewedProducts.push({ productId: productId, variantId: variantId });
17929
- this._lastViewedProducts = this._lastViewedProducts.slice(0, 20);
17930
- this.saveLastViewedProducts();
17931
- _a.label = 3;
17932
- case 3: return [2 /*return*/];
17933
- }
17934
- });
17935
- });
17936
- };
17937
- IkasCustomerStore.prototype.saveLocalLastViewedProducts = function () {
17938
- return __awaiter(this, void 0, void 0, function () {
17939
- var isSuccess;
17940
- return __generator(this, function (_a) {
17941
- switch (_a.label) {
17942
- case 0:
17943
- if (isServer$3)
17944
- return [2 /*return*/];
17945
- _a.label = 1;
17946
- case 1:
17947
- _a.trys.push([1, 4, , 5]);
17948
- this.loadLastViewedProducts();
17949
- if (!this._lastViewedProducts.length) return [3 /*break*/, 3];
17950
- return [4 /*yield*/, IkasCustomerAPI.saveLastViewedProducts({
17951
- customerId: this.customer.id,
17952
- products: this._lastViewedProducts,
17953
- })];
17954
- case 2:
17955
- isSuccess = _a.sent();
17956
- if (isSuccess) {
17957
- this.removeLastViewedProducts();
17958
- }
17959
- _a.label = 3;
17960
- case 3: return [3 /*break*/, 5];
17961
- case 4:
17962
- _a.sent();
17963
- return [3 /*break*/, 5];
17964
- case 5: return [2 /*return*/];
17965
- }
17966
- });
17967
- });
17968
- };
17969
- IkasCustomerStore.prototype.saveCustomerConsent = function () {
17970
- if (isServer$3)
17971
- return;
17972
- this._customerConsentGranted = true;
17973
- window.localStorage.setItem(LS_CUSTOMER_CONSENT, "true");
17974
- };
17975
- IkasCustomerStore.prototype.loadCustomerConsent = function () {
17976
- if (isServer$3)
17977
- return;
17978
- this._customerConsentGranted = !!window.localStorage.getItem(LS_CUSTOMER_CONSENT);
17979
- };
17980
- IkasCustomerStore.prototype.removeCustomerConsent = function () {
17981
- if (isServer$3)
17982
- return;
17983
- window.localStorage.removeItem(LS_CUSTOMER_CONSENT);
17984
- };
17985
17828
  IkasCustomerStore.prototype.setToken = function (token, tokenExpiry) {
17986
17829
  if (isServer$3)
17987
17830
  return;
@@ -21093,15 +20936,6 @@ var CustomerAccountStatusesEnum;
21093
20936
  CustomerAccountStatusesEnum["DISABLED_ACCOUNT"] = "DISABLED_ACCOUNT";
21094
20937
  CustomerAccountStatusesEnum["INVITED_TO_CREATE_ACCOUNT"] = "INVITED_TO_CREATE_ACCOUNT";
21095
20938
  })(CustomerAccountStatusesEnum || (CustomerAccountStatusesEnum = {}));
21096
- /**
21097
- * Customer Email Subscription Statuses
21098
- */
21099
- var CustomerEmailSubscriptionStatusesEnum;
21100
- (function (CustomerEmailSubscriptionStatusesEnum) {
21101
- CustomerEmailSubscriptionStatusesEnum["NOT_SUBSCRIBED"] = "NOT_SUBSCRIBED";
21102
- CustomerEmailSubscriptionStatusesEnum["PENDING_CONFIRMATION"] = "PENDING_CONFIRMATION";
21103
- CustomerEmailSubscriptionStatusesEnum["SUBSCRIBED"] = "SUBSCRIBED";
21104
- })(CustomerEmailSubscriptionStatusesEnum || (CustomerEmailSubscriptionStatusesEnum = {}));
21105
20939
  /**
21106
20940
  * Url Slug Target Type Enum Codes
21107
20941
  */
@@ -21355,7 +21189,6 @@ var IkasProductList = /** @class */ (function () {
21355
21189
  var _this = this;
21356
21190
  this.filters = null;
21357
21191
  this._filterCategories = null;
21358
- this._infiniteScrollPage = null;
21359
21192
  this._initialized = false;
21360
21193
  this._minPage = null;
21361
21194
  this._filterBrandId = null;
@@ -21366,12 +21199,12 @@ var IkasProductList = /** @class */ (function () {
21366
21199
  this.router = null;
21367
21200
  this.applyFilters = function () { return __awaiter(_this, void 0, void 0, function () {
21368
21201
  var resultsSet;
21369
- var _a;
21370
- return __generator(this, function (_b) {
21371
- switch (_b.label) {
21202
+ var _a, _b;
21203
+ return __generator(this, function (_c) {
21204
+ switch (_c.label) {
21372
21205
  case 0: return [4 /*yield*/, this.getInitial()];
21373
21206
  case 1:
21374
- resultsSet = _b.sent();
21207
+ resultsSet = _c.sent();
21375
21208
  if (![
21376
21209
  IkasThemePageType.CATEGORY,
21377
21210
  IkasThemePageType.BRAND,
@@ -21380,30 +21213,38 @@ var IkasProductList = /** @class */ (function () {
21380
21213
  return [2 /*return*/];
21381
21214
  // Change url params
21382
21215
  if (resultsSet && this.isBrowser()) {
21383
- (_a = this.router) === null || _a === void 0 ? void 0 : _a.replace("" + location.pathname + (this.filterQueryParams ? "?" + this.filterQueryParams : ""), undefined, { shallow: true });
21216
+ if (this.isFiltered) {
21217
+ (_a = this.router) === null || _a === void 0 ? void 0 : _a.replace("" + location.pathname + (this.filterQueryParams ? "?" + this.filterQueryParams : ""), undefined, { shallow: true });
21218
+ }
21219
+ else {
21220
+ (_b = this.router) === null || _b === void 0 ? void 0 : _b.replace("" + location.pathname, undefined, {
21221
+ shallow: true,
21222
+ });
21223
+ }
21384
21224
  }
21385
21225
  return [2 /*return*/];
21386
21226
  }
21387
21227
  });
21388
21228
  }); };
21389
21229
  this.getInitial = function (queryParams, isInfiteScrollReturn) { return __awaiter(_this, void 0, void 0, function () {
21390
- var fetchRequestTime, page, limit, productIdList, lastViewedProducts, response_1, data, idList, err_1;
21391
- return __generator(this, function (_a) {
21392
- switch (_a.label) {
21230
+ var fetchRequestTime, page, limit, response_1, data, err_1;
21231
+ var _a;
21232
+ return __generator(this, function (_b) {
21233
+ switch (_b.label) {
21393
21234
  case 0:
21394
21235
  this._isLoading = true;
21395
21236
  fetchRequestTime = Date.now();
21396
21237
  this._fetchRequestTime = fetchRequestTime;
21397
- _a.label = 1;
21238
+ _b.label = 1;
21398
21239
  case 1:
21399
- _a.trys.push([1, 12, 13, 14]);
21240
+ _b.trys.push([1, 5, 6, 7]);
21400
21241
  page = isInfiteScrollReturn ? this._page : 1;
21401
21242
  limit = this._limit;
21402
21243
  if (!(this.isFilterable && !this.filters)) return [3 /*break*/, 3];
21403
21244
  return [4 /*yield*/, this.getFilters()];
21404
21245
  case 2:
21405
- _a.sent();
21406
- _a.label = 3;
21246
+ _b.sent();
21247
+ _b.label = 3;
21407
21248
  case 3:
21408
21249
  this.applyQueryParamFilters(queryParams);
21409
21250
  if (this.isSearch && !this.hasAppliedfilter) {
@@ -21414,48 +21255,27 @@ var IkasProductList = /** @class */ (function () {
21414
21255
  this._initialized = true;
21415
21256
  return [2 /*return*/, true];
21416
21257
  }
21417
- productIdList = void 0;
21418
- if (!this.isStatic) return [3 /*break*/, 4];
21419
- page = undefined;
21420
- limit = undefined;
21421
- return [3 /*break*/, 10];
21422
- case 4:
21423
- if (!this.isDiscounted) return [3 /*break*/, 5];
21424
- page = 1;
21425
- limit = 10;
21426
- return [3 /*break*/, 10];
21427
- case 5:
21428
- if (!this.isRecommended) return [3 /*break*/, 6];
21429
- page = 1;
21430
- limit = 10;
21431
- return [3 /*break*/, 10];
21432
- case 6:
21433
- if (!this.isLastViewed) return [3 /*break*/, 10];
21434
- if (!this.isBrowser()) return [3 /*break*/, 9];
21435
- return [4 /*yield*/, this.waitForCustomerStoreInit()];
21436
- case 7:
21437
- _a.sent();
21438
- return [4 /*yield*/, IkasStorefrontConfig.store.customerStore.getLastViewedProducts()];
21439
- case 8:
21440
- lastViewedProducts = _a.sent();
21441
- if (lastViewedProducts && lastViewedProducts.length) {
21442
- productIdList = lastViewedProducts.map(function (p) { return p.productId; });
21258
+ if (this.isStatic) {
21259
+ page = undefined;
21260
+ limit = undefined;
21443
21261
  }
21444
- return [3 /*break*/, 10];
21445
- case 9: return [2 /*return*/];
21446
- case 10: return [4 /*yield*/, this.searchProducts(page || 1, limit || 10, productIdList)];
21447
- case 11:
21448
- response_1 = _a.sent();
21262
+ else if (this.isDiscounted) {
21263
+ page = 1;
21264
+ limit = 10;
21265
+ }
21266
+ else if (this.isRecommended) {
21267
+ page = 1;
21268
+ limit = 10;
21269
+ }
21270
+ return [4 /*yield*/, this.searchProducts(page || 1, limit || 10)];
21271
+ case 4:
21272
+ response_1 = _b.sent();
21449
21273
  if (!response_1 || this._fetchRequestTime !== fetchRequestTime)
21450
21274
  return [2 /*return*/];
21451
21275
  data = [];
21452
- if (this.isStatic || this.isLastViewed) {
21453
- idList = this.isStatic
21454
- ? this._productListPropValue.productIds
21455
- : //@ts-ignore
21456
- IkasStorefrontConfig.store.customerStore._lastViewedProducts;
21276
+ if (this.isStatic) {
21457
21277
  data =
21458
- (idList === null || idList === void 0 ? void 0 : idList.map(function (pID) {
21278
+ ((_a = this._productListPropValue.productIds) === null || _a === void 0 ? void 0 : _a.map(function (pID) {
21459
21279
  var product = response_1.data.find(function (p) { return p.id === pID.productId; });
21460
21280
  var variant = product === null || product === void 0 ? void 0 : product.variants.find(function (v) { return v.id === pID.variantId; });
21461
21281
  if (product && variant)
@@ -21473,18 +21293,16 @@ var IkasProductList = /** @class */ (function () {
21473
21293
  this._initialized = true;
21474
21294
  this._page = page || 1;
21475
21295
  this._minPage = this.page;
21476
- if (!isInfiteScrollReturn)
21477
- this._infiniteScrollPage = null;
21478
21296
  return [2 /*return*/, true];
21479
- case 12:
21480
- err_1 = _a.sent();
21297
+ case 5:
21298
+ err_1 = _b.sent();
21481
21299
  console.log(err_1);
21482
- return [3 /*break*/, 14];
21483
- case 13:
21300
+ return [3 /*break*/, 7];
21301
+ case 6:
21484
21302
  if (fetchRequestTime === this._fetchRequestTime)
21485
21303
  this._isLoading = false;
21486
21304
  return [7 /*endfinally*/];
21487
- case 14: return [2 /*return*/];
21305
+ case 7: return [2 /*return*/];
21488
21306
  }
21489
21307
  });
21490
21308
  }); };
@@ -21496,7 +21314,6 @@ var IkasProductList = /** @class */ (function () {
21496
21314
  if (this.isStatic ||
21497
21315
  this.isDiscounted ||
21498
21316
  this.isRecommended ||
21499
- this.isLastViewed ||
21500
21317
  this._isLoading ||
21501
21318
  !this.hasPrev)
21502
21319
  return [2 /*return*/];
@@ -21536,7 +21353,6 @@ var IkasProductList = /** @class */ (function () {
21536
21353
  if (this.isStatic ||
21537
21354
  this.isDiscounted ||
21538
21355
  this.isRecommended ||
21539
- this.isLastViewed ||
21540
21356
  this._isLoading ||
21541
21357
  !this.hasNext)
21542
21358
  return [2 /*return*/];
@@ -21575,8 +21391,7 @@ var IkasProductList = /** @class */ (function () {
21575
21391
  if (this._isLoading ||
21576
21392
  this.isStatic ||
21577
21393
  this.isDiscounted ||
21578
- this.isRecommended ||
21579
- this.isLastViewed)
21394
+ this.isRecommended)
21580
21395
  return [2 /*return*/];
21581
21396
  this._isLoading = true;
21582
21397
  _a.label = 1;
@@ -21606,13 +21421,6 @@ var IkasProductList = /** @class */ (function () {
21606
21421
  }
21607
21422
  });
21608
21423
  }); };
21609
- this.setVisibleInfiniteScrollPage = function (page) {
21610
- var _a;
21611
- if (_this._infiniteScrollPage === page)
21612
- return;
21613
- _this._infiniteScrollPage = page;
21614
- (_a = _this.router) === null || _a === void 0 ? void 0 : _a.replace("" + location.pathname + (_this.filterQueryParams ? "?" + _this.filterQueryParams : ""), undefined, { shallow: true });
21615
- };
21616
21424
  this.searchDebouncer = debounce_1(function () {
21617
21425
  _this.applyFilters();
21618
21426
  }, 100);
@@ -21653,7 +21461,7 @@ var IkasProductList = /** @class */ (function () {
21653
21461
  this.router = router;
21654
21462
  makeAutoObservable(this);
21655
21463
  if (this.isBrowser()) {
21656
- this.restoreInfiniteScrollPage();
21464
+ this.checkRestoreInfiniteScroll();
21657
21465
  if (location.search &&
21658
21466
  (this.isFilterable || this._type === IkasProductListType.SEARCH)) {
21659
21467
  var queryParams = this.getQueryParams();
@@ -21662,9 +21470,6 @@ var IkasProductList = /** @class */ (function () {
21662
21470
  else if (this._page > 1) {
21663
21471
  this.getInitial(undefined, true);
21664
21472
  }
21665
- else if (this.isLastViewed) {
21666
- this.getInitial();
21667
- }
21668
21473
  }
21669
21474
  }
21670
21475
  Object.defineProperty(IkasProductList.prototype, "sort", {
@@ -21777,13 +21582,6 @@ var IkasProductList = /** @class */ (function () {
21777
21582
  enumerable: false,
21778
21583
  configurable: true
21779
21584
  });
21780
- Object.defineProperty(IkasProductList.prototype, "isLastViewed", {
21781
- get: function () {
21782
- return this._type === IkasProductListType.LAST_VIEWED;
21783
- },
21784
- enumerable: false,
21785
- configurable: true
21786
- });
21787
21585
  Object.defineProperty(IkasProductList.prototype, "isSearch", {
21788
21586
  get: function () {
21789
21587
  return this._type === IkasProductListType.SEARCH;
@@ -21825,13 +21623,10 @@ var IkasProductList = /** @class */ (function () {
21825
21623
  var _a, _b, _c;
21826
21624
  var queryParams = {};
21827
21625
  (_a = this.filters) === null || _a === void 0 ? void 0 : _a.forEach(function (f) {
21828
- if (f.keyList.length)
21829
- queryParams[f.key] = f.keyList;
21626
+ queryParams[f.key] = f.keyList;
21830
21627
  });
21831
21628
  if (this._searchKeyword)
21832
21629
  queryParams.s = this._searchKeyword;
21833
- if (this._infiniteScrollPage)
21834
- queryParams.page = this._infiniteScrollPage;
21835
21630
  if (this._pageType !== IkasThemePageType.CATEGORY &&
21836
21631
  this._filterCategoryId) {
21837
21632
  var slug = (_c = (_b = this.filterCategories) === null || _b === void 0 ? void 0 : _b.find(function (fc) { return fc.id === _this._filterCategoryId; })) === null || _c === void 0 ? void 0 : _c.slug;
@@ -21901,7 +21696,7 @@ var IkasProductList = /** @class */ (function () {
21901
21696
  type: type,
21902
21697
  };
21903
21698
  };
21904
- IkasProductList.prototype.searchProducts = function (page, limit, productIdList) {
21699
+ IkasProductList.prototype.searchProducts = function (page, limit) {
21905
21700
  var _a, _b;
21906
21701
  return __awaiter(this, void 0, void 0, function () {
21907
21702
  var filterList;
@@ -21929,7 +21724,7 @@ var IkasProductList = /** @class */ (function () {
21929
21724
  page: page,
21930
21725
  perPage: limit,
21931
21726
  productIdList: this.isStatic
21932
- ? (_b = this._productListPropValue.productIds) === null || _b === void 0 ? void 0 : _b.map(function (p) { return p.productId; }) : productIdList,
21727
+ ? (_b = this._productListPropValue.productIds) === null || _b === void 0 ? void 0 : _b.map(function (p) { return p.productId; }) : undefined,
21933
21728
  filterList: filterList,
21934
21729
  brandId: this._pageType === IkasThemePageType.BRAND &&
21935
21730
  this._type !== IkasProductListType.SEARCH
@@ -22055,34 +21850,32 @@ var IkasProductList = /** @class */ (function () {
22055
21850
  });
22056
21851
  };
22057
21852
  IkasProductList.prototype.onFilterCategoryClick = function (filterCategory, disableRoute) {
22058
- var _a, _b;
21853
+ var _a;
22059
21854
  if (disableRoute === void 0) { disableRoute = false; }
22060
21855
  return __awaiter(this, void 0, void 0, function () {
22061
- return __generator(this, function (_c) {
22062
- switch (_c.label) {
21856
+ return __generator(this, function (_b) {
21857
+ switch (_b.label) {
22063
21858
  case 0:
22064
21859
  if (!disableRoute) return [3 /*break*/, 2];
22065
- if (this._filterCategoryId === filterCategory.id)
22066
- this._filterCategoryId = undefined;
22067
- else
22068
- this._filterCategoryId = filterCategory.id;
22069
- (_a = this._filterCategories) === null || _a === void 0 ? void 0 : _a.forEach(function (fc) {
22070
- //@ts-ignore
22071
- fc._isSelected = fc.id === filterCategory.id;
22072
- });
21860
+ this._filterCategoryId = filterCategory.id;
22073
21861
  return [4 /*yield*/, this.applyFilters()];
22074
21862
  case 1:
22075
- _c.sent();
21863
+ _b.sent();
22076
21864
  return [3 /*break*/, 3];
22077
21865
  case 2:
22078
- (_b = this.router) === null || _b === void 0 ? void 0 : _b.push(filterCategory.href +
21866
+ (_a = this.router) === null || _a === void 0 ? void 0 : _a.push(filterCategory.href +
22079
21867
  (this.filterQueryParams ? "?" + this.filterQueryParams : ""));
22080
- _c.label = 3;
21868
+ _b.label = 3;
22081
21869
  case 3: return [2 /*return*/];
22082
21870
  }
22083
21871
  });
22084
21872
  });
22085
21873
  };
21874
+ IkasProductList.prototype.setVisibleInfiniteScrollPage = function (page) {
21875
+ //@ts-ignore
21876
+ var infiniteScrollPages = IkasStorefrontConfig.store.infiniteScrollPages;
21877
+ infiniteScrollPages[this._productListPropValue.id] = page;
21878
+ };
22086
21879
  IkasProductList.prototype.toJSON = function () {
22087
21880
  return {
22088
21881
  data: this.data,
@@ -22103,17 +21896,22 @@ var IkasProductList = /** @class */ (function () {
22103
21896
  productListPropValue: this._productListPropValue,
22104
21897
  };
22105
21898
  };
22106
- IkasProductList.prototype.restoreInfiniteScrollPage = function () {
22107
- var queryParams = this.getQueryParams();
22108
- var pageStr = queryParams === null || queryParams === void 0 ? void 0 : queryParams.get("page");
22109
- if (pageStr) {
22110
- var page = parseInt(pageStr);
22111
- if (!isNaN(page)) {
21899
+ IkasProductList.prototype.checkRestoreInfiniteScroll = function () {
21900
+ //@ts-ignore
21901
+ var infiniteScrollPages = IkasStorefrontConfig.store.infiniteScrollPages;
21902
+ var page = infiniteScrollPages[this._productListPropValue.id];
21903
+ if (page) {
21904
+ if (this.hasForwardRoute()) {
22112
21905
  this._page = page;
22113
- this._infiniteScrollPage = page;
21906
+ }
21907
+ else {
21908
+ delete infiniteScrollPages[this._productListPropValue.id];
22114
21909
  }
22115
21910
  }
22116
21911
  };
21912
+ IkasProductList.prototype.hasForwardRoute = function () {
21913
+ return this.isBrowser() && !!window.history.forward;
21914
+ };
22117
21915
  IkasProductList.prototype.getQueryParams = function () {
22118
21916
  if (!this.isBrowser())
22119
21917
  return;
@@ -22122,16 +21920,6 @@ var IkasProductList = /** @class */ (function () {
22122
21920
  IkasProductList.prototype.isBrowser = function () {
22123
21921
  return typeof window !== "undefined";
22124
21922
  };
22125
- IkasProductList.prototype.waitForCustomerStoreInit = function () {
22126
- return new Promise(function (resolve) {
22127
- var interval = setInterval(function () {
22128
- if (IkasStorefrontConfig.store.customerStore.initialized) {
22129
- clearInterval(interval);
22130
- resolve(null);
22131
- }
22132
- }, 1000);
22133
- });
22134
- };
22135
21923
  return IkasProductList;
22136
21924
  }());
22137
21925
  var IkasProductListType;
@@ -22142,7 +21930,6 @@ var IkasProductListType;
22142
21930
  IkasProductListType["RECOMMENDED"] = "RECOMMENDED";
22143
21931
  IkasProductListType["CATEGORY"] = "CATEGORY";
22144
21932
  IkasProductListType["SEARCH"] = "SEARCH";
22145
- IkasProductListType["LAST_VIEWED"] = "LAST_VIEWED";
22146
21933
  })(IkasProductListType || (IkasProductListType = {}));
22147
21934
  var IkasProductListSortType;
22148
21935
  (function (IkasProductListSortType) {
@@ -27899,73 +27686,9 @@ var IkasCustomerAPI = /** @class */ (function () {
27899
27686
  });
27900
27687
  });
27901
27688
  };
27902
- IkasCustomerAPI.getLastViewedProducts = function (customerId) {
27903
- return __awaiter(this, void 0, void 0, function () {
27904
- var QUERY, _a, data, errors, error_2;
27905
- return __generator(this, function (_b) {
27906
- switch (_b.label) {
27907
- case 0:
27908
- QUERY = src(templateObject_13 || (templateObject_13 = __makeTemplateObject(["\n query getLastViewedProducts($customerId: String) {\n getLastViewedProducts(customerId: $customerId) {\n products {\n productId\n variantId\n }\n }\n }\n "], ["\n query getLastViewedProducts($customerId: String) {\n getLastViewedProducts(customerId: $customerId) {\n products {\n productId\n variantId\n }\n }\n }\n "])));
27909
- _b.label = 1;
27910
- case 1:
27911
- _b.trys.push([1, 3, , 4]);
27912
- return [4 /*yield*/, apollo
27913
- .getClient()
27914
- .query({
27915
- query: QUERY,
27916
- variables: {
27917
- customerId: customerId,
27918
- },
27919
- })];
27920
- case 2:
27921
- _a = _b.sent(), data = _a.data, errors = _a.errors;
27922
- if (errors && errors.length)
27923
- return [2 /*return*/, []];
27924
- return [2 /*return*/, data.getLastViewedProducts.products];
27925
- case 3:
27926
- error_2 = _b.sent();
27927
- console.log(error_2);
27928
- return [2 /*return*/, []];
27929
- case 4: return [2 /*return*/];
27930
- }
27931
- });
27932
- });
27933
- };
27934
- IkasCustomerAPI.saveLastViewedProducts = function (input) {
27935
- return __awaiter(this, void 0, void 0, function () {
27936
- var MUTATION, errors, err_12;
27937
- return __generator(this, function (_a) {
27938
- switch (_a.label) {
27939
- case 0:
27940
- MUTATION = src(templateObject_14 || (templateObject_14 = __makeTemplateObject(["\n mutation saveLastViewedProducts($input: ProductLastViewedInput!) {\n saveLastViewedProducts(input: $input) {\n id\n }\n }\n "], ["\n mutation saveLastViewedProducts($input: ProductLastViewedInput!) {\n saveLastViewedProducts(input: $input) {\n id\n }\n }\n "])));
27941
- _a.label = 1;
27942
- case 1:
27943
- _a.trys.push([1, 3, , 4]);
27944
- return [4 /*yield*/, apollo
27945
- .getClient()
27946
- .mutate({
27947
- mutation: MUTATION,
27948
- variables: {
27949
- input: input,
27950
- },
27951
- })];
27952
- case 2:
27953
- errors = (_a.sent()).errors;
27954
- if (errors && errors.length)
27955
- return [2 /*return*/, false];
27956
- return [3 /*break*/, 4];
27957
- case 3:
27958
- err_12 = _a.sent();
27959
- console.log(err_12);
27960
- return [2 /*return*/, false];
27961
- case 4: return [2 /*return*/, true];
27962
- }
27963
- });
27964
- });
27965
- };
27966
27689
  return IkasCustomerAPI;
27967
27690
  }());
27968
- var templateObject_1$7, templateObject_2$5, templateObject_3$3, templateObject_4$2, templateObject_5$1, templateObject_6$1, templateObject_7$1, templateObject_8$1, templateObject_9, templateObject_10, templateObject_11, templateObject_12, templateObject_13, templateObject_14;
27691
+ var templateObject_1$7, templateObject_2$5, templateObject_3$3, templateObject_4$2, templateObject_5$1, templateObject_6$1, templateObject_7$1, templateObject_8$1, templateObject_9, templateObject_10, templateObject_11, templateObject_12;
27969
27692
 
27970
27693
  var IkasDistrictAPI = /** @class */ (function () {
27971
27694
  function IkasDistrictAPI() {
@@ -30280,7 +30003,7 @@ var style = {
30280
30003
  backgroundColor: "rgba(255, 0, 0, 0.5)",
30281
30004
  };
30282
30005
 
30283
- var PACKAGE_VERSION = "0.0.158";
30006
+ var PACKAGE_VERSION = "0.0.139";
30284
30007
  var PageViewModel = /** @class */ (function () {
30285
30008
  function PageViewModel(router) {
30286
30009
  var _this = this;
@@ -31171,20 +30894,6 @@ var Page$1 = function (_a) {
31171
30894
  useEffect(function () {
31172
30895
  setPropValues(IkasPageDataProvider.initPropValues(propValuesStr, router, settingsStr, isBrowser));
31173
30896
  }, [isBrowser, propValuesStr]);
31174
- // If the user clicks a link for the same page, we need this logic to re-render the page
31175
- useEffect(function () {
31176
- router.events.on("routeChangeComplete", handleRouteChange);
31177
- return function () {
31178
- router.events.off("routeChangeComplete", handleRouteChange);
31179
- };
31180
- }, []);
31181
- var handleRouteChange = function (url, options) {
31182
- var shallow = options.shallow;
31183
- if (!shallow &&
31184
- [IkasThemePageType.CATEGORY, IkasThemePageType.BRAND].includes(page.type)) {
31185
- setPropValues(IkasPageDataProvider.initPropValues(propValuesStr, router, settingsStr, isBrowser));
31186
- }
31187
- };
31188
30897
  return (createElement(IkasPage, { page: page, propValues: propValues, pageSpecificDataStr: pageSpecificDataStr, settingsStr: settingsStr, merchantSettings: merchantSettings, addOgpMetas: true }));
31189
30898
  };
31190
30899
  var index$1 = observer(Page$1);
@@ -31232,8 +30941,6 @@ function handleAnalytics(page, pageSpecificDataStr) {
31232
30941
  var productDetailParsed = JSON.parse(pageSpecificDataStr);
31233
30942
  var productDetail = new IkasProductDetail(productDetailParsed.product, productDetailParsed.selectedVariantValues);
31234
30943
  Analytics.productView(productDetail);
31235
- // @ts-ignore
31236
- IkasStorefrontConfig.store.customerStore.onProductView(productDetail.product.id, productDetail.selectedVariant.id);
31237
30944
  }
31238
30945
  if (page.type === IkasThemePageType.CATEGORY) {
31239
30946
  var category = JSON.parse(pageSpecificDataStr);
@@ -31835,6 +31542,7 @@ var IkasBaseStore = /** @class */ (function () {
31835
31542
  this.showLocaleOptions = false;
31836
31543
  this.localeChecked = false;
31837
31544
  this.settingsSet = false;
31545
+ this.infiniteScrollPages = {}; // key is productListPropValueId
31838
31546
  this.customerStore = new IkasCustomerStore(this);
31839
31547
  this.cartStore = new IkasCartStore(this);
31840
31548
  makeObservable(this, {