@ikas/storefront 0.0.158-alpha.8 → 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/__generated__/global-types.d.ts +0 -24
- package/build/api/customer/__generated__/customerLogin.d.ts +1 -2
- package/build/api/customer/index.d.ts +1 -13
- package/build/index.es.js +72 -354
- package/build/index.js +72 -354
- package/build/models/data/order/line-item/index.d.ts +0 -1
- package/build/models/ui/product-list/index.d.ts +4 -8
- package/build/store/base.d.ts +1 -0
- package/build/store/customer.d.ts +6 -19
- package/package.json +1 -1
- package/build/api/customer/__generated__/getLastViewedProducts.d.ts +0 -15
- package/build/api/customer/__generated__/saveLastViewedProducts.d.ts +0 -11
package/build/index.es.js
CHANGED
|
@@ -11171,7 +11171,7 @@ var IkasOrderAddress = /** @class */ (function () {
|
|
|
11171
11171
|
});
|
|
11172
11172
|
Object.defineProperty(IkasOrderAddress.prototype, "validationResult", {
|
|
11173
11173
|
get: function () {
|
|
11174
|
-
var _a, _b, _c, _d;
|
|
11174
|
+
var _a, _b, _c, _d, _e;
|
|
11175
11175
|
var isValidPhone = !!this.phone &&
|
|
11176
11176
|
this.phone.length >= 10 &&
|
|
11177
11177
|
validatePhoneNumber(this.phone);
|
|
@@ -11192,7 +11192,10 @@ var IkasOrderAddress = /** @class */ (function () {
|
|
|
11192
11192
|
? isValidPhone
|
|
11193
11193
|
: true,
|
|
11194
11194
|
identityNumber: ((_d = this.checkoutSettings) === null || _d === void 0 ? void 0 : _d.identityNumberRequirement) ===
|
|
11195
|
-
IkasCheckoutRequirementEnum.MANDATORY
|
|
11195
|
+
IkasCheckoutRequirementEnum.MANDATORY ||
|
|
11196
|
+
(((_e = this.checkoutSettings) === null || _e === void 0 ? void 0 : _e.identityNumberRequirement) ===
|
|
11197
|
+
IkasCheckoutRequirementEnum.OPTIONAL &&
|
|
11198
|
+
this.phone)
|
|
11196
11199
|
? !!this.identityNumber
|
|
11197
11200
|
: true,
|
|
11198
11201
|
};
|
|
@@ -11323,13 +11326,6 @@ var IkasOrderLineItem = /** @class */ (function () {
|
|
|
11323
11326
|
this.status = data.status || OrderLineItemStatusEnum.FULFILLED;
|
|
11324
11327
|
makeAutoObservable(this);
|
|
11325
11328
|
}
|
|
11326
|
-
Object.defineProperty(IkasOrderLineItem.prototype, "priceWithQuantity", {
|
|
11327
|
-
get: function () {
|
|
11328
|
-
return this.price * this.quantity;
|
|
11329
|
-
},
|
|
11330
|
-
enumerable: false,
|
|
11331
|
-
configurable: true
|
|
11332
|
-
});
|
|
11333
11329
|
Object.defineProperty(IkasOrderLineItem.prototype, "finalPriceWithQuantity", {
|
|
11334
11330
|
get: function () {
|
|
11335
11331
|
return this.finalPrice * this.quantity;
|
|
@@ -17472,8 +17468,6 @@ var LS_TOKEN_KEY = "customerToken";
|
|
|
17472
17468
|
var LS_TOKEN_EXPIRY = "customerTokenExpiry";
|
|
17473
17469
|
var LS_CUSTOMER_KEY = "customer";
|
|
17474
17470
|
var LS_CUSTOMER_SUB_KEY = "customerEmailSubscription";
|
|
17475
|
-
var LS_LAST_VIEWED_PRODUCTS_KEY = "lastViewedProducts";
|
|
17476
|
-
var LS_CUSTOMER_CONSENT = "customerConsent";
|
|
17477
17471
|
var IkasCustomerStore = /** @class */ (function () {
|
|
17478
17472
|
function IkasCustomerStore(baseStore) {
|
|
17479
17473
|
var _this = this;
|
|
@@ -17483,8 +17477,6 @@ var IkasCustomerStore = /** @class */ (function () {
|
|
|
17483
17477
|
this.baseStore = null;
|
|
17484
17478
|
this._initialized = false;
|
|
17485
17479
|
this._visitorSubscribedEmail = false;
|
|
17486
|
-
this._lastViewedProducts = [];
|
|
17487
|
-
this._customerConsentGranted = false;
|
|
17488
17480
|
this.login = function (email, password) { return __awaiter(_this, void 0, void 0, function () {
|
|
17489
17481
|
var response, cart;
|
|
17490
17482
|
var _a;
|
|
@@ -17504,9 +17496,7 @@ var IkasCustomerStore = /** @class */ (function () {
|
|
|
17504
17496
|
case 2:
|
|
17505
17497
|
_b.sent();
|
|
17506
17498
|
_b.label = 3;
|
|
17507
|
-
case 3:
|
|
17508
|
-
this.saveLocalLastViewedProducts();
|
|
17509
|
-
return [2 /*return*/, true];
|
|
17499
|
+
case 3: return [2 /*return*/, true];
|
|
17510
17500
|
case 4: return [2 /*return*/, false];
|
|
17511
17501
|
}
|
|
17512
17502
|
});
|
|
@@ -17521,7 +17511,6 @@ var IkasCustomerStore = /** @class */ (function () {
|
|
|
17521
17511
|
if (response) {
|
|
17522
17512
|
this.setToken(response.token, response.tokenExpiry);
|
|
17523
17513
|
this.setCustomer(response.customer);
|
|
17524
|
-
this.saveLocalLastViewedProducts();
|
|
17525
17514
|
return [2 /*return*/, true];
|
|
17526
17515
|
}
|
|
17527
17516
|
return [2 /*return*/, false];
|
|
@@ -17737,9 +17726,6 @@ var IkasCustomerStore = /** @class */ (function () {
|
|
|
17737
17726
|
}
|
|
17738
17727
|
});
|
|
17739
17728
|
}); };
|
|
17740
|
-
this.onCustomerConsentGrant = function () {
|
|
17741
|
-
_this.saveCustomerConsent();
|
|
17742
|
-
};
|
|
17743
17729
|
this.baseStore = baseStore;
|
|
17744
17730
|
this.init();
|
|
17745
17731
|
makeAutoObservable(this);
|
|
@@ -17762,13 +17748,6 @@ var IkasCustomerStore = /** @class */ (function () {
|
|
|
17762
17748
|
enumerable: false,
|
|
17763
17749
|
configurable: true
|
|
17764
17750
|
});
|
|
17765
|
-
Object.defineProperty(IkasCustomerStore.prototype, "customerConsentGranted", {
|
|
17766
|
-
get: function () {
|
|
17767
|
-
return this._customerConsentGranted;
|
|
17768
|
-
},
|
|
17769
|
-
enumerable: false,
|
|
17770
|
-
configurable: true
|
|
17771
|
-
});
|
|
17772
17751
|
IkasCustomerStore.prototype.init = function () {
|
|
17773
17752
|
return __awaiter(this, void 0, void 0, function () {
|
|
17774
17753
|
return __generator(this, function (_a) {
|
|
@@ -17776,8 +17755,6 @@ var IkasCustomerStore = /** @class */ (function () {
|
|
|
17776
17755
|
case 0:
|
|
17777
17756
|
this.loadToken();
|
|
17778
17757
|
this.loadCustomer();
|
|
17779
|
-
this.loadLastViewedProducts();
|
|
17780
|
-
this.loadCustomerConsent();
|
|
17781
17758
|
return [4 /*yield*/, this.refreshToken()];
|
|
17782
17759
|
case 1:
|
|
17783
17760
|
_a.sent();
|
|
@@ -17848,125 +17825,6 @@ var IkasCustomerStore = /** @class */ (function () {
|
|
|
17848
17825
|
}
|
|
17849
17826
|
catch (err) { }
|
|
17850
17827
|
};
|
|
17851
|
-
IkasCustomerStore.prototype.getLastViewedProducts = function () {
|
|
17852
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
17853
|
-
var _a;
|
|
17854
|
-
return __generator(this, function (_b) {
|
|
17855
|
-
switch (_b.label) {
|
|
17856
|
-
case 0:
|
|
17857
|
-
if (!this.customer) return [3 /*break*/, 2];
|
|
17858
|
-
_a = this;
|
|
17859
|
-
return [4 /*yield*/, IkasCustomerAPI.getLastViewedProducts(this.customer.id)];
|
|
17860
|
-
case 1:
|
|
17861
|
-
_a._lastViewedProducts = _b.sent();
|
|
17862
|
-
return [3 /*break*/, 3];
|
|
17863
|
-
case 2:
|
|
17864
|
-
this.loadLastViewedProducts();
|
|
17865
|
-
_b.label = 3;
|
|
17866
|
-
case 3: return [2 /*return*/, this._lastViewedProducts];
|
|
17867
|
-
}
|
|
17868
|
-
});
|
|
17869
|
-
});
|
|
17870
|
-
};
|
|
17871
|
-
IkasCustomerStore.prototype.saveLastViewedProducts = function () {
|
|
17872
|
-
if (isServer$3)
|
|
17873
|
-
return;
|
|
17874
|
-
window.localStorage.setItem(LS_LAST_VIEWED_PRODUCTS_KEY, JSON.stringify(this._lastViewedProducts));
|
|
17875
|
-
};
|
|
17876
|
-
IkasCustomerStore.prototype.loadLastViewedProducts = function () {
|
|
17877
|
-
if (isServer$3)
|
|
17878
|
-
return;
|
|
17879
|
-
try {
|
|
17880
|
-
var lvpStr = window.localStorage.getItem(LS_LAST_VIEWED_PRODUCTS_KEY);
|
|
17881
|
-
if (lvpStr)
|
|
17882
|
-
this._lastViewedProducts = JSON.parse(lvpStr);
|
|
17883
|
-
}
|
|
17884
|
-
catch (err) { }
|
|
17885
|
-
};
|
|
17886
|
-
IkasCustomerStore.prototype.removeLastViewedProducts = function () {
|
|
17887
|
-
if (isServer$3)
|
|
17888
|
-
return;
|
|
17889
|
-
window.localStorage.removeItem(LS_LAST_VIEWED_PRODUCTS_KEY);
|
|
17890
|
-
};
|
|
17891
|
-
IkasCustomerStore.prototype.onProductView = function (productId, variantId) {
|
|
17892
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
17893
|
-
var isSuccess;
|
|
17894
|
-
return __generator(this, function (_a) {
|
|
17895
|
-
switch (_a.label) {
|
|
17896
|
-
case 0:
|
|
17897
|
-
if (!this.customer) return [3 /*break*/, 2];
|
|
17898
|
-
return [4 /*yield*/, IkasCustomerAPI.saveLastViewedProducts({
|
|
17899
|
-
customerId: this.customer.id,
|
|
17900
|
-
products: [
|
|
17901
|
-
{
|
|
17902
|
-
productId: productId,
|
|
17903
|
-
variantId: variantId,
|
|
17904
|
-
},
|
|
17905
|
-
],
|
|
17906
|
-
})];
|
|
17907
|
-
case 1:
|
|
17908
|
-
isSuccess = _a.sent();
|
|
17909
|
-
if (isSuccess)
|
|
17910
|
-
this._lastViewedProducts.push({ productId: productId, variantId: variantId });
|
|
17911
|
-
return [3 /*break*/, 3];
|
|
17912
|
-
case 2:
|
|
17913
|
-
this._lastViewedProducts.push({ productId: productId, variantId: variantId });
|
|
17914
|
-
this._lastViewedProducts = this._lastViewedProducts.slice(0, 20);
|
|
17915
|
-
this.saveLastViewedProducts();
|
|
17916
|
-
_a.label = 3;
|
|
17917
|
-
case 3: return [2 /*return*/];
|
|
17918
|
-
}
|
|
17919
|
-
});
|
|
17920
|
-
});
|
|
17921
|
-
};
|
|
17922
|
-
IkasCustomerStore.prototype.saveLocalLastViewedProducts = function () {
|
|
17923
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
17924
|
-
var isSuccess;
|
|
17925
|
-
return __generator(this, function (_a) {
|
|
17926
|
-
switch (_a.label) {
|
|
17927
|
-
case 0:
|
|
17928
|
-
if (isServer$3)
|
|
17929
|
-
return [2 /*return*/];
|
|
17930
|
-
_a.label = 1;
|
|
17931
|
-
case 1:
|
|
17932
|
-
_a.trys.push([1, 4, , 5]);
|
|
17933
|
-
this.loadLastViewedProducts();
|
|
17934
|
-
if (!this._lastViewedProducts.length) return [3 /*break*/, 3];
|
|
17935
|
-
return [4 /*yield*/, IkasCustomerAPI.saveLastViewedProducts({
|
|
17936
|
-
customerId: this.customer.id,
|
|
17937
|
-
products: this._lastViewedProducts,
|
|
17938
|
-
})];
|
|
17939
|
-
case 2:
|
|
17940
|
-
isSuccess = _a.sent();
|
|
17941
|
-
if (isSuccess) {
|
|
17942
|
-
this.removeLastViewedProducts();
|
|
17943
|
-
}
|
|
17944
|
-
_a.label = 3;
|
|
17945
|
-
case 3: return [3 /*break*/, 5];
|
|
17946
|
-
case 4:
|
|
17947
|
-
_a.sent();
|
|
17948
|
-
return [3 /*break*/, 5];
|
|
17949
|
-
case 5: return [2 /*return*/];
|
|
17950
|
-
}
|
|
17951
|
-
});
|
|
17952
|
-
});
|
|
17953
|
-
};
|
|
17954
|
-
IkasCustomerStore.prototype.saveCustomerConsent = function () {
|
|
17955
|
-
if (isServer$3)
|
|
17956
|
-
return;
|
|
17957
|
-
this._customerConsentGranted = true;
|
|
17958
|
-
window.localStorage.setItem(LS_CUSTOMER_CONSENT, "true");
|
|
17959
|
-
};
|
|
17960
|
-
IkasCustomerStore.prototype.loadCustomerConsent = function () {
|
|
17961
|
-
if (isServer$3)
|
|
17962
|
-
return;
|
|
17963
|
-
this._customerConsentGranted = !!window.localStorage.getItem(LS_CUSTOMER_CONSENT);
|
|
17964
|
-
};
|
|
17965
|
-
IkasCustomerStore.prototype.removeCustomerConsent = function () {
|
|
17966
|
-
if (isServer$3)
|
|
17967
|
-
return;
|
|
17968
|
-
window.localStorage.removeItem(LS_CUSTOMER_CONSENT);
|
|
17969
|
-
};
|
|
17970
17828
|
IkasCustomerStore.prototype.setToken = function (token, tokenExpiry) {
|
|
17971
17829
|
if (isServer$3)
|
|
17972
17830
|
return;
|
|
@@ -21078,15 +20936,6 @@ var CustomerAccountStatusesEnum;
|
|
|
21078
20936
|
CustomerAccountStatusesEnum["DISABLED_ACCOUNT"] = "DISABLED_ACCOUNT";
|
|
21079
20937
|
CustomerAccountStatusesEnum["INVITED_TO_CREATE_ACCOUNT"] = "INVITED_TO_CREATE_ACCOUNT";
|
|
21080
20938
|
})(CustomerAccountStatusesEnum || (CustomerAccountStatusesEnum = {}));
|
|
21081
|
-
/**
|
|
21082
|
-
* Customer Email Subscription Statuses
|
|
21083
|
-
*/
|
|
21084
|
-
var CustomerEmailSubscriptionStatusesEnum;
|
|
21085
|
-
(function (CustomerEmailSubscriptionStatusesEnum) {
|
|
21086
|
-
CustomerEmailSubscriptionStatusesEnum["NOT_SUBSCRIBED"] = "NOT_SUBSCRIBED";
|
|
21087
|
-
CustomerEmailSubscriptionStatusesEnum["PENDING_CONFIRMATION"] = "PENDING_CONFIRMATION";
|
|
21088
|
-
CustomerEmailSubscriptionStatusesEnum["SUBSCRIBED"] = "SUBSCRIBED";
|
|
21089
|
-
})(CustomerEmailSubscriptionStatusesEnum || (CustomerEmailSubscriptionStatusesEnum = {}));
|
|
21090
20939
|
/**
|
|
21091
20940
|
* Url Slug Target Type Enum Codes
|
|
21092
20941
|
*/
|
|
@@ -21340,7 +21189,6 @@ var IkasProductList = /** @class */ (function () {
|
|
|
21340
21189
|
var _this = this;
|
|
21341
21190
|
this.filters = null;
|
|
21342
21191
|
this._filterCategories = null;
|
|
21343
|
-
this._infiniteScrollPage = null;
|
|
21344
21192
|
this._initialized = false;
|
|
21345
21193
|
this._minPage = null;
|
|
21346
21194
|
this._filterBrandId = null;
|
|
@@ -21351,12 +21199,12 @@ var IkasProductList = /** @class */ (function () {
|
|
|
21351
21199
|
this.router = null;
|
|
21352
21200
|
this.applyFilters = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
21353
21201
|
var resultsSet;
|
|
21354
|
-
var _a;
|
|
21355
|
-
return __generator(this, function (
|
|
21356
|
-
switch (
|
|
21202
|
+
var _a, _b;
|
|
21203
|
+
return __generator(this, function (_c) {
|
|
21204
|
+
switch (_c.label) {
|
|
21357
21205
|
case 0: return [4 /*yield*/, this.getInitial()];
|
|
21358
21206
|
case 1:
|
|
21359
|
-
resultsSet =
|
|
21207
|
+
resultsSet = _c.sent();
|
|
21360
21208
|
if (![
|
|
21361
21209
|
IkasThemePageType.CATEGORY,
|
|
21362
21210
|
IkasThemePageType.BRAND,
|
|
@@ -21365,30 +21213,38 @@ var IkasProductList = /** @class */ (function () {
|
|
|
21365
21213
|
return [2 /*return*/];
|
|
21366
21214
|
// Change url params
|
|
21367
21215
|
if (resultsSet && this.isBrowser()) {
|
|
21368
|
-
|
|
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
|
+
}
|
|
21369
21224
|
}
|
|
21370
21225
|
return [2 /*return*/];
|
|
21371
21226
|
}
|
|
21372
21227
|
});
|
|
21373
21228
|
}); };
|
|
21374
21229
|
this.getInitial = function (queryParams, isInfiteScrollReturn) { return __awaiter(_this, void 0, void 0, function () {
|
|
21375
|
-
var fetchRequestTime, page, limit,
|
|
21376
|
-
|
|
21377
|
-
|
|
21230
|
+
var fetchRequestTime, page, limit, response_1, data, err_1;
|
|
21231
|
+
var _a;
|
|
21232
|
+
return __generator(this, function (_b) {
|
|
21233
|
+
switch (_b.label) {
|
|
21378
21234
|
case 0:
|
|
21379
21235
|
this._isLoading = true;
|
|
21380
21236
|
fetchRequestTime = Date.now();
|
|
21381
21237
|
this._fetchRequestTime = fetchRequestTime;
|
|
21382
|
-
|
|
21238
|
+
_b.label = 1;
|
|
21383
21239
|
case 1:
|
|
21384
|
-
|
|
21240
|
+
_b.trys.push([1, 5, 6, 7]);
|
|
21385
21241
|
page = isInfiteScrollReturn ? this._page : 1;
|
|
21386
21242
|
limit = this._limit;
|
|
21387
21243
|
if (!(this.isFilterable && !this.filters)) return [3 /*break*/, 3];
|
|
21388
21244
|
return [4 /*yield*/, this.getFilters()];
|
|
21389
21245
|
case 2:
|
|
21390
|
-
|
|
21391
|
-
|
|
21246
|
+
_b.sent();
|
|
21247
|
+
_b.label = 3;
|
|
21392
21248
|
case 3:
|
|
21393
21249
|
this.applyQueryParamFilters(queryParams);
|
|
21394
21250
|
if (this.isSearch && !this.hasAppliedfilter) {
|
|
@@ -21399,48 +21255,27 @@ var IkasProductList = /** @class */ (function () {
|
|
|
21399
21255
|
this._initialized = true;
|
|
21400
21256
|
return [2 /*return*/, true];
|
|
21401
21257
|
}
|
|
21402
|
-
|
|
21403
|
-
|
|
21404
|
-
|
|
21405
|
-
limit = undefined;
|
|
21406
|
-
return [3 /*break*/, 10];
|
|
21407
|
-
case 4:
|
|
21408
|
-
if (!this.isDiscounted) return [3 /*break*/, 5];
|
|
21409
|
-
page = 1;
|
|
21410
|
-
limit = 10;
|
|
21411
|
-
return [3 /*break*/, 10];
|
|
21412
|
-
case 5:
|
|
21413
|
-
if (!this.isRecommended) return [3 /*break*/, 6];
|
|
21414
|
-
page = 1;
|
|
21415
|
-
limit = 10;
|
|
21416
|
-
return [3 /*break*/, 10];
|
|
21417
|
-
case 6:
|
|
21418
|
-
if (!this.isLastViewed) return [3 /*break*/, 10];
|
|
21419
|
-
if (!this.isBrowser()) return [3 /*break*/, 9];
|
|
21420
|
-
return [4 /*yield*/, this.waitForCustomerStoreInit()];
|
|
21421
|
-
case 7:
|
|
21422
|
-
_a.sent();
|
|
21423
|
-
return [4 /*yield*/, IkasStorefrontConfig.store.customerStore.getLastViewedProducts()];
|
|
21424
|
-
case 8:
|
|
21425
|
-
lastViewedProducts = _a.sent();
|
|
21426
|
-
if (lastViewedProducts && lastViewedProducts.length) {
|
|
21427
|
-
productIdList = lastViewedProducts.map(function (p) { return p.productId; });
|
|
21258
|
+
if (this.isStatic) {
|
|
21259
|
+
page = undefined;
|
|
21260
|
+
limit = undefined;
|
|
21428
21261
|
}
|
|
21429
|
-
|
|
21430
|
-
|
|
21431
|
-
|
|
21432
|
-
|
|
21433
|
-
|
|
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();
|
|
21434
21273
|
if (!response_1 || this._fetchRequestTime !== fetchRequestTime)
|
|
21435
21274
|
return [2 /*return*/];
|
|
21436
21275
|
data = [];
|
|
21437
|
-
if (this.isStatic
|
|
21438
|
-
idList = this.isStatic
|
|
21439
|
-
? this._productListPropValue.productIds
|
|
21440
|
-
: //@ts-ignore
|
|
21441
|
-
IkasStorefrontConfig.store.customerStore._lastViewedProducts;
|
|
21276
|
+
if (this.isStatic) {
|
|
21442
21277
|
data =
|
|
21443
|
-
(
|
|
21278
|
+
((_a = this._productListPropValue.productIds) === null || _a === void 0 ? void 0 : _a.map(function (pID) {
|
|
21444
21279
|
var product = response_1.data.find(function (p) { return p.id === pID.productId; });
|
|
21445
21280
|
var variant = product === null || product === void 0 ? void 0 : product.variants.find(function (v) { return v.id === pID.variantId; });
|
|
21446
21281
|
if (product && variant)
|
|
@@ -21458,18 +21293,16 @@ var IkasProductList = /** @class */ (function () {
|
|
|
21458
21293
|
this._initialized = true;
|
|
21459
21294
|
this._page = page || 1;
|
|
21460
21295
|
this._minPage = this.page;
|
|
21461
|
-
if (!isInfiteScrollReturn)
|
|
21462
|
-
this._infiniteScrollPage = null;
|
|
21463
21296
|
return [2 /*return*/, true];
|
|
21464
|
-
case
|
|
21465
|
-
err_1 =
|
|
21297
|
+
case 5:
|
|
21298
|
+
err_1 = _b.sent();
|
|
21466
21299
|
console.log(err_1);
|
|
21467
|
-
return [3 /*break*/,
|
|
21468
|
-
case
|
|
21300
|
+
return [3 /*break*/, 7];
|
|
21301
|
+
case 6:
|
|
21469
21302
|
if (fetchRequestTime === this._fetchRequestTime)
|
|
21470
21303
|
this._isLoading = false;
|
|
21471
21304
|
return [7 /*endfinally*/];
|
|
21472
|
-
case
|
|
21305
|
+
case 7: return [2 /*return*/];
|
|
21473
21306
|
}
|
|
21474
21307
|
});
|
|
21475
21308
|
}); };
|
|
@@ -21481,7 +21314,6 @@ var IkasProductList = /** @class */ (function () {
|
|
|
21481
21314
|
if (this.isStatic ||
|
|
21482
21315
|
this.isDiscounted ||
|
|
21483
21316
|
this.isRecommended ||
|
|
21484
|
-
this.isLastViewed ||
|
|
21485
21317
|
this._isLoading ||
|
|
21486
21318
|
!this.hasPrev)
|
|
21487
21319
|
return [2 /*return*/];
|
|
@@ -21521,7 +21353,6 @@ var IkasProductList = /** @class */ (function () {
|
|
|
21521
21353
|
if (this.isStatic ||
|
|
21522
21354
|
this.isDiscounted ||
|
|
21523
21355
|
this.isRecommended ||
|
|
21524
|
-
this.isLastViewed ||
|
|
21525
21356
|
this._isLoading ||
|
|
21526
21357
|
!this.hasNext)
|
|
21527
21358
|
return [2 /*return*/];
|
|
@@ -21560,8 +21391,7 @@ var IkasProductList = /** @class */ (function () {
|
|
|
21560
21391
|
if (this._isLoading ||
|
|
21561
21392
|
this.isStatic ||
|
|
21562
21393
|
this.isDiscounted ||
|
|
21563
|
-
this.isRecommended
|
|
21564
|
-
this.isLastViewed)
|
|
21394
|
+
this.isRecommended)
|
|
21565
21395
|
return [2 /*return*/];
|
|
21566
21396
|
this._isLoading = true;
|
|
21567
21397
|
_a.label = 1;
|
|
@@ -21591,13 +21421,6 @@ var IkasProductList = /** @class */ (function () {
|
|
|
21591
21421
|
}
|
|
21592
21422
|
});
|
|
21593
21423
|
}); };
|
|
21594
|
-
this.setVisibleInfiniteScrollPage = function (page) {
|
|
21595
|
-
var _a;
|
|
21596
|
-
if (_this._infiniteScrollPage === page)
|
|
21597
|
-
return;
|
|
21598
|
-
_this._infiniteScrollPage = page;
|
|
21599
|
-
(_a = _this.router) === null || _a === void 0 ? void 0 : _a.replace("" + location.pathname + (_this.filterQueryParams ? "?" + _this.filterQueryParams : ""), undefined, { shallow: true });
|
|
21600
|
-
};
|
|
21601
21424
|
this.searchDebouncer = debounce_1(function () {
|
|
21602
21425
|
_this.applyFilters();
|
|
21603
21426
|
}, 100);
|
|
@@ -21638,7 +21461,7 @@ var IkasProductList = /** @class */ (function () {
|
|
|
21638
21461
|
this.router = router;
|
|
21639
21462
|
makeAutoObservable(this);
|
|
21640
21463
|
if (this.isBrowser()) {
|
|
21641
|
-
this.
|
|
21464
|
+
this.checkRestoreInfiniteScroll();
|
|
21642
21465
|
if (location.search &&
|
|
21643
21466
|
(this.isFilterable || this._type === IkasProductListType.SEARCH)) {
|
|
21644
21467
|
var queryParams = this.getQueryParams();
|
|
@@ -21647,23 +21470,8 @@ var IkasProductList = /** @class */ (function () {
|
|
|
21647
21470
|
else if (this._page > 1) {
|
|
21648
21471
|
this.getInitial(undefined, true);
|
|
21649
21472
|
}
|
|
21650
|
-
else if (this.isLastViewed) {
|
|
21651
|
-
this.getInitial();
|
|
21652
|
-
}
|
|
21653
21473
|
}
|
|
21654
21474
|
}
|
|
21655
|
-
Object.defineProperty(IkasProductList.prototype, "id", {
|
|
21656
|
-
get: function () {
|
|
21657
|
-
var id = this._productListPropValue.id;
|
|
21658
|
-
if (this._filterCategoryId)
|
|
21659
|
-
id += this._filterCategoryId;
|
|
21660
|
-
if (this._filterBrandId)
|
|
21661
|
-
id += this._filterBrandId;
|
|
21662
|
-
return id;
|
|
21663
|
-
},
|
|
21664
|
-
enumerable: false,
|
|
21665
|
-
configurable: true
|
|
21666
|
-
});
|
|
21667
21475
|
Object.defineProperty(IkasProductList.prototype, "sort", {
|
|
21668
21476
|
get: function () {
|
|
21669
21477
|
return this._sort;
|
|
@@ -21774,13 +21582,6 @@ var IkasProductList = /** @class */ (function () {
|
|
|
21774
21582
|
enumerable: false,
|
|
21775
21583
|
configurable: true
|
|
21776
21584
|
});
|
|
21777
|
-
Object.defineProperty(IkasProductList.prototype, "isLastViewed", {
|
|
21778
|
-
get: function () {
|
|
21779
|
-
return this._type === IkasProductListType.LAST_VIEWED;
|
|
21780
|
-
},
|
|
21781
|
-
enumerable: false,
|
|
21782
|
-
configurable: true
|
|
21783
|
-
});
|
|
21784
21585
|
Object.defineProperty(IkasProductList.prototype, "isSearch", {
|
|
21785
21586
|
get: function () {
|
|
21786
21587
|
return this._type === IkasProductListType.SEARCH;
|
|
@@ -21822,13 +21623,10 @@ var IkasProductList = /** @class */ (function () {
|
|
|
21822
21623
|
var _a, _b, _c;
|
|
21823
21624
|
var queryParams = {};
|
|
21824
21625
|
(_a = this.filters) === null || _a === void 0 ? void 0 : _a.forEach(function (f) {
|
|
21825
|
-
|
|
21826
|
-
queryParams[f.key] = f.keyList;
|
|
21626
|
+
queryParams[f.key] = f.keyList;
|
|
21827
21627
|
});
|
|
21828
21628
|
if (this._searchKeyword)
|
|
21829
21629
|
queryParams.s = this._searchKeyword;
|
|
21830
|
-
if (this._infiniteScrollPage)
|
|
21831
|
-
queryParams.page = this._infiniteScrollPage;
|
|
21832
21630
|
if (this._pageType !== IkasThemePageType.CATEGORY &&
|
|
21833
21631
|
this._filterCategoryId) {
|
|
21834
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;
|
|
@@ -21898,7 +21696,7 @@ var IkasProductList = /** @class */ (function () {
|
|
|
21898
21696
|
type: type,
|
|
21899
21697
|
};
|
|
21900
21698
|
};
|
|
21901
|
-
IkasProductList.prototype.searchProducts = function (page, limit
|
|
21699
|
+
IkasProductList.prototype.searchProducts = function (page, limit) {
|
|
21902
21700
|
var _a, _b;
|
|
21903
21701
|
return __awaiter(this, void 0, void 0, function () {
|
|
21904
21702
|
var filterList;
|
|
@@ -21926,7 +21724,7 @@ var IkasProductList = /** @class */ (function () {
|
|
|
21926
21724
|
page: page,
|
|
21927
21725
|
perPage: limit,
|
|
21928
21726
|
productIdList: this.isStatic
|
|
21929
|
-
? (_b = this._productListPropValue.productIds) === null || _b === void 0 ? void 0 : _b.map(function (p) { return p.productId; }) :
|
|
21727
|
+
? (_b = this._productListPropValue.productIds) === null || _b === void 0 ? void 0 : _b.map(function (p) { return p.productId; }) : undefined,
|
|
21930
21728
|
filterList: filterList,
|
|
21931
21729
|
brandId: this._pageType === IkasThemePageType.BRAND &&
|
|
21932
21730
|
this._type !== IkasProductListType.SEARCH
|
|
@@ -22073,6 +21871,11 @@ var IkasProductList = /** @class */ (function () {
|
|
|
22073
21871
|
});
|
|
22074
21872
|
});
|
|
22075
21873
|
};
|
|
21874
|
+
IkasProductList.prototype.setVisibleInfiniteScrollPage = function (page) {
|
|
21875
|
+
//@ts-ignore
|
|
21876
|
+
var infiniteScrollPages = IkasStorefrontConfig.store.infiniteScrollPages;
|
|
21877
|
+
infiniteScrollPages[this._productListPropValue.id] = page;
|
|
21878
|
+
};
|
|
22076
21879
|
IkasProductList.prototype.toJSON = function () {
|
|
22077
21880
|
return {
|
|
22078
21881
|
data: this.data,
|
|
@@ -22093,17 +21896,22 @@ var IkasProductList = /** @class */ (function () {
|
|
|
22093
21896
|
productListPropValue: this._productListPropValue,
|
|
22094
21897
|
};
|
|
22095
21898
|
};
|
|
22096
|
-
IkasProductList.prototype.
|
|
22097
|
-
|
|
22098
|
-
var
|
|
22099
|
-
|
|
22100
|
-
|
|
22101
|
-
if (
|
|
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()) {
|
|
22102
21905
|
this._page = page;
|
|
22103
|
-
|
|
21906
|
+
}
|
|
21907
|
+
else {
|
|
21908
|
+
delete infiniteScrollPages[this._productListPropValue.id];
|
|
22104
21909
|
}
|
|
22105
21910
|
}
|
|
22106
21911
|
};
|
|
21912
|
+
IkasProductList.prototype.hasForwardRoute = function () {
|
|
21913
|
+
return this.isBrowser() && !!window.history.forward;
|
|
21914
|
+
};
|
|
22107
21915
|
IkasProductList.prototype.getQueryParams = function () {
|
|
22108
21916
|
if (!this.isBrowser())
|
|
22109
21917
|
return;
|
|
@@ -22112,16 +21920,6 @@ var IkasProductList = /** @class */ (function () {
|
|
|
22112
21920
|
IkasProductList.prototype.isBrowser = function () {
|
|
22113
21921
|
return typeof window !== "undefined";
|
|
22114
21922
|
};
|
|
22115
|
-
IkasProductList.prototype.waitForCustomerStoreInit = function () {
|
|
22116
|
-
return new Promise(function (resolve) {
|
|
22117
|
-
var interval = setInterval(function () {
|
|
22118
|
-
if (IkasStorefrontConfig.store.customerStore.initialized) {
|
|
22119
|
-
clearInterval(interval);
|
|
22120
|
-
resolve(null);
|
|
22121
|
-
}
|
|
22122
|
-
}, 1000);
|
|
22123
|
-
});
|
|
22124
|
-
};
|
|
22125
21923
|
return IkasProductList;
|
|
22126
21924
|
}());
|
|
22127
21925
|
var IkasProductListType;
|
|
@@ -22132,7 +21930,6 @@ var IkasProductListType;
|
|
|
22132
21930
|
IkasProductListType["RECOMMENDED"] = "RECOMMENDED";
|
|
22133
21931
|
IkasProductListType["CATEGORY"] = "CATEGORY";
|
|
22134
21932
|
IkasProductListType["SEARCH"] = "SEARCH";
|
|
22135
|
-
IkasProductListType["LAST_VIEWED"] = "LAST_VIEWED";
|
|
22136
21933
|
})(IkasProductListType || (IkasProductListType = {}));
|
|
22137
21934
|
var IkasProductListSortType;
|
|
22138
21935
|
(function (IkasProductListSortType) {
|
|
@@ -27889,73 +27686,9 @@ var IkasCustomerAPI = /** @class */ (function () {
|
|
|
27889
27686
|
});
|
|
27890
27687
|
});
|
|
27891
27688
|
};
|
|
27892
|
-
IkasCustomerAPI.getLastViewedProducts = function (customerId) {
|
|
27893
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
27894
|
-
var QUERY, _a, data, errors, error_2;
|
|
27895
|
-
return __generator(this, function (_b) {
|
|
27896
|
-
switch (_b.label) {
|
|
27897
|
-
case 0:
|
|
27898
|
-
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 "])));
|
|
27899
|
-
_b.label = 1;
|
|
27900
|
-
case 1:
|
|
27901
|
-
_b.trys.push([1, 3, , 4]);
|
|
27902
|
-
return [4 /*yield*/, apollo
|
|
27903
|
-
.getClient()
|
|
27904
|
-
.query({
|
|
27905
|
-
query: QUERY,
|
|
27906
|
-
variables: {
|
|
27907
|
-
customerId: customerId,
|
|
27908
|
-
},
|
|
27909
|
-
})];
|
|
27910
|
-
case 2:
|
|
27911
|
-
_a = _b.sent(), data = _a.data, errors = _a.errors;
|
|
27912
|
-
if (errors && errors.length)
|
|
27913
|
-
return [2 /*return*/, []];
|
|
27914
|
-
return [2 /*return*/, data.getLastViewedProducts.products];
|
|
27915
|
-
case 3:
|
|
27916
|
-
error_2 = _b.sent();
|
|
27917
|
-
console.log(error_2);
|
|
27918
|
-
return [2 /*return*/, []];
|
|
27919
|
-
case 4: return [2 /*return*/];
|
|
27920
|
-
}
|
|
27921
|
-
});
|
|
27922
|
-
});
|
|
27923
|
-
};
|
|
27924
|
-
IkasCustomerAPI.saveLastViewedProducts = function (input) {
|
|
27925
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
27926
|
-
var MUTATION, errors, err_12;
|
|
27927
|
-
return __generator(this, function (_a) {
|
|
27928
|
-
switch (_a.label) {
|
|
27929
|
-
case 0:
|
|
27930
|
-
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 "])));
|
|
27931
|
-
_a.label = 1;
|
|
27932
|
-
case 1:
|
|
27933
|
-
_a.trys.push([1, 3, , 4]);
|
|
27934
|
-
return [4 /*yield*/, apollo
|
|
27935
|
-
.getClient()
|
|
27936
|
-
.mutate({
|
|
27937
|
-
mutation: MUTATION,
|
|
27938
|
-
variables: {
|
|
27939
|
-
input: input,
|
|
27940
|
-
},
|
|
27941
|
-
})];
|
|
27942
|
-
case 2:
|
|
27943
|
-
errors = (_a.sent()).errors;
|
|
27944
|
-
if (errors && errors.length)
|
|
27945
|
-
return [2 /*return*/, false];
|
|
27946
|
-
return [3 /*break*/, 4];
|
|
27947
|
-
case 3:
|
|
27948
|
-
err_12 = _a.sent();
|
|
27949
|
-
console.log(err_12);
|
|
27950
|
-
return [2 /*return*/, false];
|
|
27951
|
-
case 4: return [2 /*return*/, true];
|
|
27952
|
-
}
|
|
27953
|
-
});
|
|
27954
|
-
});
|
|
27955
|
-
};
|
|
27956
27689
|
return IkasCustomerAPI;
|
|
27957
27690
|
}());
|
|
27958
|
-
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
|
|
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;
|
|
27959
27692
|
|
|
27960
27693
|
var IkasDistrictAPI = /** @class */ (function () {
|
|
27961
27694
|
function IkasDistrictAPI() {
|
|
@@ -30270,7 +30003,7 @@ var style = {
|
|
|
30270
30003
|
backgroundColor: "rgba(255, 0, 0, 0.5)",
|
|
30271
30004
|
};
|
|
30272
30005
|
|
|
30273
|
-
var PACKAGE_VERSION = "0.0.
|
|
30006
|
+
var PACKAGE_VERSION = "0.0.139";
|
|
30274
30007
|
var PageViewModel = /** @class */ (function () {
|
|
30275
30008
|
function PageViewModel(router) {
|
|
30276
30009
|
var _this = this;
|
|
@@ -31161,20 +30894,6 @@ var Page$1 = function (_a) {
|
|
|
31161
30894
|
useEffect(function () {
|
|
31162
30895
|
setPropValues(IkasPageDataProvider.initPropValues(propValuesStr, router, settingsStr, isBrowser));
|
|
31163
30896
|
}, [isBrowser, propValuesStr]);
|
|
31164
|
-
// If the user clicks a link for the same page, we need this logic to re-render the page
|
|
31165
|
-
useEffect(function () {
|
|
31166
|
-
router.events.on("routeChangeComplete", handleRouteChange);
|
|
31167
|
-
return function () {
|
|
31168
|
-
router.events.off("routeChangeComplete", handleRouteChange);
|
|
31169
|
-
};
|
|
31170
|
-
}, []);
|
|
31171
|
-
var handleRouteChange = function (url, options) {
|
|
31172
|
-
var shallow = options.shallow;
|
|
31173
|
-
if (!shallow &&
|
|
31174
|
-
[IkasThemePageType.CATEGORY, IkasThemePageType.BRAND].includes(page.type)) {
|
|
31175
|
-
setPropValues(IkasPageDataProvider.initPropValues(propValuesStr, router, settingsStr, isBrowser));
|
|
31176
|
-
}
|
|
31177
|
-
};
|
|
31178
30897
|
return (createElement(IkasPage, { page: page, propValues: propValues, pageSpecificDataStr: pageSpecificDataStr, settingsStr: settingsStr, merchantSettings: merchantSettings, addOgpMetas: true }));
|
|
31179
30898
|
};
|
|
31180
30899
|
var index$1 = observer(Page$1);
|
|
@@ -31222,8 +30941,6 @@ function handleAnalytics(page, pageSpecificDataStr) {
|
|
|
31222
30941
|
var productDetailParsed = JSON.parse(pageSpecificDataStr);
|
|
31223
30942
|
var productDetail = new IkasProductDetail(productDetailParsed.product, productDetailParsed.selectedVariantValues);
|
|
31224
30943
|
Analytics.productView(productDetail);
|
|
31225
|
-
// @ts-ignore
|
|
31226
|
-
IkasStorefrontConfig.store.customerStore.onProductView(productDetail.product.id, productDetail.selectedVariant.id);
|
|
31227
30944
|
}
|
|
31228
30945
|
if (page.type === IkasThemePageType.CATEGORY) {
|
|
31229
30946
|
var category = JSON.parse(pageSpecificDataStr);
|
|
@@ -31825,6 +31542,7 @@ var IkasBaseStore = /** @class */ (function () {
|
|
|
31825
31542
|
this.showLocaleOptions = false;
|
|
31826
31543
|
this.localeChecked = false;
|
|
31827
31544
|
this.settingsSet = false;
|
|
31545
|
+
this.infiniteScrollPages = {}; // key is productListPropValueId
|
|
31828
31546
|
this.customerStore = new IkasCustomerStore(this);
|
|
31829
31547
|
this.cartStore = new IkasCartStore(this);
|
|
31830
31548
|
makeObservable(this, {
|