@ikas/storefront 0.0.165-alpha.2 → 0.0.165-alpha.3
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 +47 -131
- package/build/index.js +47 -131
- package/build/models/ui/product-detail/index.d.ts +1 -3
- package/build/utils/providers/page-data.d.ts +2 -3
- package/package.json +1 -1
package/build/index.es.js
CHANGED
|
@@ -27598,11 +27598,9 @@ var IkasNavigationLink = /** @class */ (function () {
|
|
|
27598
27598
|
}());
|
|
27599
27599
|
|
|
27600
27600
|
var IkasProductDetail = /** @class */ (function () {
|
|
27601
|
-
function IkasProductDetail(product, selectedVariantValues
|
|
27602
|
-
this.router = null;
|
|
27601
|
+
function IkasProductDetail(product, selectedVariantValues) {
|
|
27603
27602
|
this.product = new IkasProduct(product);
|
|
27604
27603
|
this.selectedVariantValues = selectedVariantValues.map(function (vv) { return new IkasVariantValue(vv); });
|
|
27605
|
-
this.router = router;
|
|
27606
27604
|
makeAutoObservable(this);
|
|
27607
27605
|
}
|
|
27608
27606
|
Object.defineProperty(IkasProductDetail.prototype, "mainVariantValue", {
|
|
@@ -27633,11 +27631,6 @@ var IkasProductDetail = /** @class */ (function () {
|
|
|
27633
27631
|
var metaData = this.product.metaData;
|
|
27634
27632
|
if (!(metaData === null || metaData === void 0 ? void 0 : metaData.slug))
|
|
27635
27633
|
return "";
|
|
27636
|
-
if (this.product.hasVariant) {
|
|
27637
|
-
return "/" + metaData.slug + "-" + this.selectedVariantValues
|
|
27638
|
-
.map(function (vv) { return vv.slug; })
|
|
27639
|
-
.join("-");
|
|
27640
|
-
}
|
|
27641
27634
|
return "/" + metaData.slug;
|
|
27642
27635
|
},
|
|
27643
27636
|
enumerable: false,
|
|
@@ -27685,24 +27678,12 @@ var IkasProductDetail = /** @class */ (function () {
|
|
|
27685
27678
|
configurable: true
|
|
27686
27679
|
});
|
|
27687
27680
|
IkasProductDetail.prototype.selectVariantValue = function (variantValue) {
|
|
27688
|
-
var _a;
|
|
27689
|
-
var metaData = this.product.metaData;
|
|
27690
27681
|
var selectedVariantValues = this.selectedVariantValues.map(function (vv) {
|
|
27691
27682
|
if (vv.variantTypeId === variantValue.variantTypeId)
|
|
27692
27683
|
return variantValue;
|
|
27693
27684
|
return vv;
|
|
27694
27685
|
});
|
|
27695
27686
|
this.selectedVariantValues = selectedVariantValues;
|
|
27696
|
-
var newUrl = "/" + metaData.slug + "-" + this.selectedVariantValues
|
|
27697
|
-
.map(function (vv) { return vv.slug; })
|
|
27698
|
-
.join("-");
|
|
27699
|
-
if (newUrl === window.location.pathname)
|
|
27700
|
-
return;
|
|
27701
|
-
var isShallow = process.env.NODE_ENV !== "production";
|
|
27702
|
-
(_a = this.router) === null || _a === void 0 ? void 0 : _a.replace(newUrl, undefined, {
|
|
27703
|
-
shallow: isShallow,
|
|
27704
|
-
scroll: false,
|
|
27705
|
-
});
|
|
27706
27687
|
};
|
|
27707
27688
|
return IkasProductDetail;
|
|
27708
27689
|
}());
|
|
@@ -33550,7 +33531,7 @@ var IkasPageDataProvider = /** @class */ (function () {
|
|
|
33550
33531
|
IkasPageDataProvider.prototype.getPageSpecificData = function () {
|
|
33551
33532
|
var _a, _b;
|
|
33552
33533
|
return __awaiter(this, void 0, void 0, function () {
|
|
33553
|
-
var slug, metaDataList, metaData, handleBrandPage, handleCategoryPage, handleBlogPage, handleBlogCategoryPage, _c;
|
|
33534
|
+
var slug, metaDataList, metaData, handleProductPage, handleBrandPage, handleCategoryPage, handleBlogPage, handleBlogCategoryPage, _c;
|
|
33554
33535
|
var _this = this;
|
|
33555
33536
|
return __generator(this, function (_d) {
|
|
33556
33537
|
switch (_d.label) {
|
|
@@ -33579,12 +33560,47 @@ var IkasPageDataProvider = /** @class */ (function () {
|
|
|
33579
33560
|
case 2: return [4 /*yield*/, IkasHTMLMetaDataAPI.listHTMLMetaData(slug)];
|
|
33580
33561
|
case 3:
|
|
33581
33562
|
metaDataList = _d.sent();
|
|
33582
|
-
if (!metaDataList || !metaDataList.length)
|
|
33583
|
-
return [2 /*return
|
|
33584
|
-
}
|
|
33563
|
+
if (!metaDataList || !metaDataList.length)
|
|
33564
|
+
return [2 /*return*/];
|
|
33585
33565
|
_d.label = 4;
|
|
33586
33566
|
case 4:
|
|
33587
33567
|
metaData = metaDataList[0];
|
|
33568
|
+
if (!metaData.targetId)
|
|
33569
|
+
return [2 /*return*/];
|
|
33570
|
+
handleProductPage = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
33571
|
+
var productsResponse, product, displayedVariantType, inStockVariant;
|
|
33572
|
+
return __generator(this, function (_a) {
|
|
33573
|
+
switch (_a.label) {
|
|
33574
|
+
case 0: return [4 /*yield*/, IkasProductSearchAPI.searchProducts({
|
|
33575
|
+
productIdList: [metaData.targetId],
|
|
33576
|
+
priceListId: IkasStorefrontConfig.priceListId,
|
|
33577
|
+
salesChannelId: IkasStorefrontConfig.salesChannelId,
|
|
33578
|
+
})];
|
|
33579
|
+
case 1:
|
|
33580
|
+
productsResponse = _a.sent();
|
|
33581
|
+
if (!(productsResponse === null || productsResponse === void 0 ? void 0 : productsResponse.data.length)) {
|
|
33582
|
+
return [2 /*return*/];
|
|
33583
|
+
}
|
|
33584
|
+
product = productsResponse.data[0];
|
|
33585
|
+
this.pageSpecificData = new IkasProductDetail(product, product.variants[0].variantValues);
|
|
33586
|
+
// Select the first displayed in stock variant
|
|
33587
|
+
if (this.pageSpecificData.displayedVariantTypes.length) {
|
|
33588
|
+
displayedVariantType = this
|
|
33589
|
+
.pageSpecificData.displayedVariantTypes[0];
|
|
33590
|
+
if (displayedVariantType.displayedVariantValues.length) {
|
|
33591
|
+
inStockVariant = displayedVariantType.displayedVariantValues.find(function (dvv) { return dvv.hasStock; });
|
|
33592
|
+
if (inStockVariant) {
|
|
33593
|
+
this.pageSpecificData.selectedVariantValues =
|
|
33594
|
+
inStockVariant.variant.variantValues;
|
|
33595
|
+
}
|
|
33596
|
+
}
|
|
33597
|
+
}
|
|
33598
|
+
this.pageType = IkasThemePageType.PRODUCT;
|
|
33599
|
+
this.setPageMetaData(metaData);
|
|
33600
|
+
return [2 /*return*/];
|
|
33601
|
+
}
|
|
33602
|
+
});
|
|
33603
|
+
}); };
|
|
33588
33604
|
handleBrandPage = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
33589
33605
|
var brandsResponse, brand;
|
|
33590
33606
|
return __generator(this, function (_a) {
|
|
@@ -33676,7 +33692,7 @@ var IkasPageDataProvider = /** @class */ (function () {
|
|
|
33676
33692
|
case 6: return [2 /*return*/, _d.sent()];
|
|
33677
33693
|
case 7: return [4 /*yield*/, handleCategoryPage()];
|
|
33678
33694
|
case 8: return [2 /*return*/, _d.sent()];
|
|
33679
|
-
case 9: return [4 /*yield*/,
|
|
33695
|
+
case 9: return [4 /*yield*/, handleProductPage()];
|
|
33680
33696
|
case 10: return [2 /*return*/, _d.sent()];
|
|
33681
33697
|
case 11: return [4 /*yield*/, handleBlogPage()];
|
|
33682
33698
|
case 12: return [2 /*return*/, _d.sent()];
|
|
@@ -33688,91 +33704,6 @@ var IkasPageDataProvider = /** @class */ (function () {
|
|
|
33688
33704
|
});
|
|
33689
33705
|
});
|
|
33690
33706
|
};
|
|
33691
|
-
IkasPageDataProvider.prototype.getPageSpecificProduct = function () {
|
|
33692
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
33693
|
-
var slug, getProductMetaData, metaDataResponse, productsResponse, product, isMainProductSlug, selectedVariantValues, variantSlugPart, _i, _a, variant, values, slugPart, displayedVariantType, inStockVariant;
|
|
33694
|
-
var _this = this;
|
|
33695
|
-
return __generator(this, function (_b) {
|
|
33696
|
-
switch (_b.label) {
|
|
33697
|
-
case 0:
|
|
33698
|
-
slug = this.pageParams.slug;
|
|
33699
|
-
if (!slug) {
|
|
33700
|
-
console.log("Slug not found for getPageSpecificProduct");
|
|
33701
|
-
}
|
|
33702
|
-
getProductMetaData = function (slug) { return __awaiter(_this, void 0, void 0, function () {
|
|
33703
|
-
var metaDataList, splitParts, newSlug;
|
|
33704
|
-
return __generator(this, function (_a) {
|
|
33705
|
-
switch (_a.label) {
|
|
33706
|
-
case 0:
|
|
33707
|
-
if (!slug)
|
|
33708
|
-
return [2 /*return*/];
|
|
33709
|
-
return [4 /*yield*/, IkasHTMLMetaDataAPI.listHTMLMetaData(slug)];
|
|
33710
|
-
case 1:
|
|
33711
|
-
metaDataList = _a.sent();
|
|
33712
|
-
if (!(!metaDataList || !metaDataList.length)) return [3 /*break*/, 3];
|
|
33713
|
-
splitParts = slug.split("-");
|
|
33714
|
-
newSlug = splitParts.slice(0, splitParts.length - 1).join("-");
|
|
33715
|
-
return [4 /*yield*/, getProductMetaData(newSlug)];
|
|
33716
|
-
case 2: return [2 /*return*/, _a.sent()];
|
|
33717
|
-
case 3: return [2 /*return*/, {
|
|
33718
|
-
metaData: metaDataList[0],
|
|
33719
|
-
slug: slug,
|
|
33720
|
-
}];
|
|
33721
|
-
}
|
|
33722
|
-
});
|
|
33723
|
-
}); };
|
|
33724
|
-
return [4 /*yield*/, getProductMetaData(slug)];
|
|
33725
|
-
case 1:
|
|
33726
|
-
metaDataResponse = _b.sent();
|
|
33727
|
-
if (!metaDataResponse)
|
|
33728
|
-
return [2 /*return*/];
|
|
33729
|
-
return [4 /*yield*/, IkasProductSearchAPI.searchProducts({
|
|
33730
|
-
productIdList: [metaDataResponse.metaData.targetId],
|
|
33731
|
-
priceListId: IkasStorefrontConfig.priceListId,
|
|
33732
|
-
salesChannelId: IkasStorefrontConfig.salesChannelId,
|
|
33733
|
-
})];
|
|
33734
|
-
case 2:
|
|
33735
|
-
productsResponse = _b.sent();
|
|
33736
|
-
if (!(productsResponse === null || productsResponse === void 0 ? void 0 : productsResponse.data.length))
|
|
33737
|
-
return [2 /*return*/];
|
|
33738
|
-
product = productsResponse.data[0];
|
|
33739
|
-
isMainProductSlug = slug.length === metaDataResponse.slug.length;
|
|
33740
|
-
selectedVariantValues = [];
|
|
33741
|
-
if (!isMainProductSlug) {
|
|
33742
|
-
variantSlugPart = slug.slice(metaDataResponse.slug.length + 1);
|
|
33743
|
-
for (_i = 0, _a = product.variants; _i < _a.length; _i++) {
|
|
33744
|
-
variant = _a[_i];
|
|
33745
|
-
values = variant.variantValues;
|
|
33746
|
-
slugPart = values.map(function (vv) { return vv.slug; }).join("-");
|
|
33747
|
-
if (slugPart === variantSlugPart) {
|
|
33748
|
-
selectedVariantValues = values;
|
|
33749
|
-
break;
|
|
33750
|
-
}
|
|
33751
|
-
}
|
|
33752
|
-
}
|
|
33753
|
-
this.pageSpecificData = new IkasProductDetail(product, selectedVariantValues.length
|
|
33754
|
-
? selectedVariantValues
|
|
33755
|
-
: product.variants[0].variantValues);
|
|
33756
|
-
// Select the first displayed in stock variant
|
|
33757
|
-
if (!selectedVariantValues.length &&
|
|
33758
|
-
this.pageSpecificData.displayedVariantTypes.length) {
|
|
33759
|
-
displayedVariantType = this.pageSpecificData
|
|
33760
|
-
.displayedVariantTypes[0];
|
|
33761
|
-
if (displayedVariantType.displayedVariantValues.length) {
|
|
33762
|
-
inStockVariant = displayedVariantType.displayedVariantValues.find(function (dvv) { return dvv.hasStock; });
|
|
33763
|
-
if (inStockVariant) {
|
|
33764
|
-
this.pageSpecificData.selectedVariantValues =
|
|
33765
|
-
inStockVariant.variant.variantValues;
|
|
33766
|
-
}
|
|
33767
|
-
}
|
|
33768
|
-
}
|
|
33769
|
-
this.pageType = IkasThemePageType.PRODUCT;
|
|
33770
|
-
this.setPageMetaData(metaDataResponse.metaData);
|
|
33771
|
-
return [2 /*return*/];
|
|
33772
|
-
}
|
|
33773
|
-
});
|
|
33774
|
-
});
|
|
33775
|
-
};
|
|
33776
33707
|
IkasPageDataProvider.prototype.getPageComponentPropValues = function (pageComponent) {
|
|
33777
33708
|
return __awaiter(this, void 0, void 0, function () {
|
|
33778
33709
|
var component, result, setPageComponentPropValue;
|
|
@@ -33964,7 +33895,7 @@ var IkasPageDataProvider = /** @class */ (function () {
|
|
|
33964
33895
|
IkasPageDataProvider.initProductListPropValue(prop, propValue, pageComponentPropValue, router);
|
|
33965
33896
|
break;
|
|
33966
33897
|
case IkasThemeComponentPropType.PRODUCT_DETAIL:
|
|
33967
|
-
IkasPageDataProvider.initProductDetailPropValue(prop, propValue, pageComponentPropValue,
|
|
33898
|
+
IkasPageDataProvider.initProductDetailPropValue(prop, propValue, pageComponentPropValue, isBrowser);
|
|
33968
33899
|
break;
|
|
33969
33900
|
case IkasThemeComponentPropType.PRODUCT_ATTRIBUTE:
|
|
33970
33901
|
IkasPageDataProvider.initAttributePropValue(prop, propValue, pageComponentPropValue);
|
|
@@ -34033,10 +33964,10 @@ var IkasPageDataProvider = /** @class */ (function () {
|
|
|
34033
33964
|
IkasPageDataProvider._initProductListPropValue = function (propValue, router) {
|
|
34034
33965
|
return new IkasProductList(propValue, router);
|
|
34035
33966
|
};
|
|
34036
|
-
IkasPageDataProvider.initProductDetailPropValue = function (prop, propValue, pageComponentPropValue,
|
|
34037
|
-
pageComponentPropValue.propValues[prop.name] = this._initProductDetailPropValue(propValue,
|
|
33967
|
+
IkasPageDataProvider.initProductDetailPropValue = function (prop, propValue, pageComponentPropValue, isBrowser) {
|
|
33968
|
+
pageComponentPropValue.propValues[prop.name] = this._initProductDetailPropValue(propValue, isBrowser);
|
|
34038
33969
|
};
|
|
34039
|
-
IkasPageDataProvider._initProductDetailPropValue = function (propValue,
|
|
33970
|
+
IkasPageDataProvider._initProductDetailPropValue = function (propValue, isBrowser) {
|
|
34040
33971
|
var _propValue = propValue;
|
|
34041
33972
|
var productDetail = new IkasProductDetail(_propValue.product, _propValue.selectedVariantValues);
|
|
34042
33973
|
if (isBrowser) {
|
|
@@ -34049,7 +33980,7 @@ var IkasPageDataProvider = /** @class */ (function () {
|
|
|
34049
33980
|
}
|
|
34050
33981
|
}
|
|
34051
33982
|
}
|
|
34052
|
-
return new IkasProductDetail(productDetail.product, productDetail.selectedVariantValues
|
|
33983
|
+
return new IkasProductDetail(productDetail.product, productDetail.selectedVariantValues);
|
|
34053
33984
|
};
|
|
34054
33985
|
IkasPageDataProvider.initAttributePropValue = function (prop, propValue, pageComponentPropValue) {
|
|
34055
33986
|
pageComponentPropValue.propValues[prop.name] = IkasPageDataProvider._initAttributePropValue(propValue);
|
|
@@ -34125,7 +34056,7 @@ var IkasPageDataProvider = /** @class */ (function () {
|
|
|
34125
34056
|
case IkasThemeComponentPropType.LINK:
|
|
34126
34057
|
return this._initLinkPropValue(propValue);
|
|
34127
34058
|
case IkasThemeComponentPropType.PRODUCT_DETAIL:
|
|
34128
|
-
return this._initProductDetailPropValue(propValue,
|
|
34059
|
+
return this._initProductDetailPropValue(propValue, isBrowser);
|
|
34129
34060
|
case IkasThemeComponentPropType.PRODUCT_LIST:
|
|
34130
34061
|
return this._initProductListPropValue(propValue, router);
|
|
34131
34062
|
case IkasThemeComponentPropType.PRODUCT_ATTRIBUTE:
|
|
@@ -62315,21 +62246,6 @@ var Page$1 = function (_a) {
|
|
|
62315
62246
|
var index$1 = observer(Page$1);
|
|
62316
62247
|
var getStaticPaths = function (context) { return __awaiter(void 0, void 0, void 0, function () {
|
|
62317
62248
|
return __generator(this, function (_a) {
|
|
62318
|
-
// const targetTypes = [
|
|
62319
|
-
// IkasHTMLMetaDataTargetType.BRAND,
|
|
62320
|
-
// IkasHTMLMetaDataTargetType.CATEGORY,
|
|
62321
|
-
// ];
|
|
62322
|
-
// const metaData = await IkasHTMLMetaDataAPI.listHTMLMetaData(
|
|
62323
|
-
// undefined,
|
|
62324
|
-
// undefined,
|
|
62325
|
-
// targetTypes
|
|
62326
|
-
// );
|
|
62327
|
-
// metaData.map((m) => ({
|
|
62328
|
-
// params: {
|
|
62329
|
-
// slug: m.slug,
|
|
62330
|
-
// originalSlug: m.slug,
|
|
62331
|
-
// },
|
|
62332
|
-
// }))
|
|
62333
62249
|
return [2 /*return*/, {
|
|
62334
62250
|
paths: [],
|
|
62335
62251
|
fallback: "blocking",
|
package/build/index.js
CHANGED
|
@@ -27581,11 +27581,9 @@ var IkasNavigationLink = /** @class */ (function () {
|
|
|
27581
27581
|
}());
|
|
27582
27582
|
|
|
27583
27583
|
var IkasProductDetail = /** @class */ (function () {
|
|
27584
|
-
function IkasProductDetail(product, selectedVariantValues
|
|
27585
|
-
this.router = null;
|
|
27584
|
+
function IkasProductDetail(product, selectedVariantValues) {
|
|
27586
27585
|
this.product = new IkasProduct(product);
|
|
27587
27586
|
this.selectedVariantValues = selectedVariantValues.map(function (vv) { return new IkasVariantValue(vv); });
|
|
27588
|
-
this.router = router;
|
|
27589
27587
|
mobx.makeAutoObservable(this);
|
|
27590
27588
|
}
|
|
27591
27589
|
Object.defineProperty(IkasProductDetail.prototype, "mainVariantValue", {
|
|
@@ -27616,11 +27614,6 @@ var IkasProductDetail = /** @class */ (function () {
|
|
|
27616
27614
|
var metaData = this.product.metaData;
|
|
27617
27615
|
if (!(metaData === null || metaData === void 0 ? void 0 : metaData.slug))
|
|
27618
27616
|
return "";
|
|
27619
|
-
if (this.product.hasVariant) {
|
|
27620
|
-
return "/" + metaData.slug + "-" + this.selectedVariantValues
|
|
27621
|
-
.map(function (vv) { return vv.slug; })
|
|
27622
|
-
.join("-");
|
|
27623
|
-
}
|
|
27624
27617
|
return "/" + metaData.slug;
|
|
27625
27618
|
},
|
|
27626
27619
|
enumerable: false,
|
|
@@ -27668,24 +27661,12 @@ var IkasProductDetail = /** @class */ (function () {
|
|
|
27668
27661
|
configurable: true
|
|
27669
27662
|
});
|
|
27670
27663
|
IkasProductDetail.prototype.selectVariantValue = function (variantValue) {
|
|
27671
|
-
var _a;
|
|
27672
|
-
var metaData = this.product.metaData;
|
|
27673
27664
|
var selectedVariantValues = this.selectedVariantValues.map(function (vv) {
|
|
27674
27665
|
if (vv.variantTypeId === variantValue.variantTypeId)
|
|
27675
27666
|
return variantValue;
|
|
27676
27667
|
return vv;
|
|
27677
27668
|
});
|
|
27678
27669
|
this.selectedVariantValues = selectedVariantValues;
|
|
27679
|
-
var newUrl = "/" + metaData.slug + "-" + this.selectedVariantValues
|
|
27680
|
-
.map(function (vv) { return vv.slug; })
|
|
27681
|
-
.join("-");
|
|
27682
|
-
if (newUrl === window.location.pathname)
|
|
27683
|
-
return;
|
|
27684
|
-
var isShallow = process.env.NODE_ENV !== "production";
|
|
27685
|
-
(_a = this.router) === null || _a === void 0 ? void 0 : _a.replace(newUrl, undefined, {
|
|
27686
|
-
shallow: isShallow,
|
|
27687
|
-
scroll: false,
|
|
27688
|
-
});
|
|
27689
27670
|
};
|
|
27690
27671
|
return IkasProductDetail;
|
|
27691
27672
|
}());
|
|
@@ -33530,7 +33511,7 @@ var IkasPageDataProvider = /** @class */ (function () {
|
|
|
33530
33511
|
IkasPageDataProvider.prototype.getPageSpecificData = function () {
|
|
33531
33512
|
var _a, _b;
|
|
33532
33513
|
return __awaiter(this, void 0, void 0, function () {
|
|
33533
|
-
var slug, metaDataList, metaData, handleBrandPage, handleCategoryPage, handleBlogPage, handleBlogCategoryPage, _c;
|
|
33514
|
+
var slug, metaDataList, metaData, handleProductPage, handleBrandPage, handleCategoryPage, handleBlogPage, handleBlogCategoryPage, _c;
|
|
33534
33515
|
var _this = this;
|
|
33535
33516
|
return __generator(this, function (_d) {
|
|
33536
33517
|
switch (_d.label) {
|
|
@@ -33559,12 +33540,47 @@ var IkasPageDataProvider = /** @class */ (function () {
|
|
|
33559
33540
|
case 2: return [4 /*yield*/, IkasHTMLMetaDataAPI.listHTMLMetaData(slug)];
|
|
33560
33541
|
case 3:
|
|
33561
33542
|
metaDataList = _d.sent();
|
|
33562
|
-
if (!metaDataList || !metaDataList.length)
|
|
33563
|
-
return [2 /*return
|
|
33564
|
-
}
|
|
33543
|
+
if (!metaDataList || !metaDataList.length)
|
|
33544
|
+
return [2 /*return*/];
|
|
33565
33545
|
_d.label = 4;
|
|
33566
33546
|
case 4:
|
|
33567
33547
|
metaData = metaDataList[0];
|
|
33548
|
+
if (!metaData.targetId)
|
|
33549
|
+
return [2 /*return*/];
|
|
33550
|
+
handleProductPage = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
33551
|
+
var productsResponse, product, displayedVariantType, inStockVariant;
|
|
33552
|
+
return __generator(this, function (_a) {
|
|
33553
|
+
switch (_a.label) {
|
|
33554
|
+
case 0: return [4 /*yield*/, IkasProductSearchAPI.searchProducts({
|
|
33555
|
+
productIdList: [metaData.targetId],
|
|
33556
|
+
priceListId: IkasStorefrontConfig.priceListId,
|
|
33557
|
+
salesChannelId: IkasStorefrontConfig.salesChannelId,
|
|
33558
|
+
})];
|
|
33559
|
+
case 1:
|
|
33560
|
+
productsResponse = _a.sent();
|
|
33561
|
+
if (!(productsResponse === null || productsResponse === void 0 ? void 0 : productsResponse.data.length)) {
|
|
33562
|
+
return [2 /*return*/];
|
|
33563
|
+
}
|
|
33564
|
+
product = productsResponse.data[0];
|
|
33565
|
+
this.pageSpecificData = new IkasProductDetail(product, product.variants[0].variantValues);
|
|
33566
|
+
// Select the first displayed in stock variant
|
|
33567
|
+
if (this.pageSpecificData.displayedVariantTypes.length) {
|
|
33568
|
+
displayedVariantType = this
|
|
33569
|
+
.pageSpecificData.displayedVariantTypes[0];
|
|
33570
|
+
if (displayedVariantType.displayedVariantValues.length) {
|
|
33571
|
+
inStockVariant = displayedVariantType.displayedVariantValues.find(function (dvv) { return dvv.hasStock; });
|
|
33572
|
+
if (inStockVariant) {
|
|
33573
|
+
this.pageSpecificData.selectedVariantValues =
|
|
33574
|
+
inStockVariant.variant.variantValues;
|
|
33575
|
+
}
|
|
33576
|
+
}
|
|
33577
|
+
}
|
|
33578
|
+
this.pageType = exports.IkasThemePageType.PRODUCT;
|
|
33579
|
+
this.setPageMetaData(metaData);
|
|
33580
|
+
return [2 /*return*/];
|
|
33581
|
+
}
|
|
33582
|
+
});
|
|
33583
|
+
}); };
|
|
33568
33584
|
handleBrandPage = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
33569
33585
|
var brandsResponse, brand;
|
|
33570
33586
|
return __generator(this, function (_a) {
|
|
@@ -33656,7 +33672,7 @@ var IkasPageDataProvider = /** @class */ (function () {
|
|
|
33656
33672
|
case 6: return [2 /*return*/, _d.sent()];
|
|
33657
33673
|
case 7: return [4 /*yield*/, handleCategoryPage()];
|
|
33658
33674
|
case 8: return [2 /*return*/, _d.sent()];
|
|
33659
|
-
case 9: return [4 /*yield*/,
|
|
33675
|
+
case 9: return [4 /*yield*/, handleProductPage()];
|
|
33660
33676
|
case 10: return [2 /*return*/, _d.sent()];
|
|
33661
33677
|
case 11: return [4 /*yield*/, handleBlogPage()];
|
|
33662
33678
|
case 12: return [2 /*return*/, _d.sent()];
|
|
@@ -33668,91 +33684,6 @@ var IkasPageDataProvider = /** @class */ (function () {
|
|
|
33668
33684
|
});
|
|
33669
33685
|
});
|
|
33670
33686
|
};
|
|
33671
|
-
IkasPageDataProvider.prototype.getPageSpecificProduct = function () {
|
|
33672
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
33673
|
-
var slug, getProductMetaData, metaDataResponse, productsResponse, product, isMainProductSlug, selectedVariantValues, variantSlugPart, _i, _a, variant, values, slugPart, displayedVariantType, inStockVariant;
|
|
33674
|
-
var _this = this;
|
|
33675
|
-
return __generator(this, function (_b) {
|
|
33676
|
-
switch (_b.label) {
|
|
33677
|
-
case 0:
|
|
33678
|
-
slug = this.pageParams.slug;
|
|
33679
|
-
if (!slug) {
|
|
33680
|
-
console.log("Slug not found for getPageSpecificProduct");
|
|
33681
|
-
}
|
|
33682
|
-
getProductMetaData = function (slug) { return __awaiter(_this, void 0, void 0, function () {
|
|
33683
|
-
var metaDataList, splitParts, newSlug;
|
|
33684
|
-
return __generator(this, function (_a) {
|
|
33685
|
-
switch (_a.label) {
|
|
33686
|
-
case 0:
|
|
33687
|
-
if (!slug)
|
|
33688
|
-
return [2 /*return*/];
|
|
33689
|
-
return [4 /*yield*/, IkasHTMLMetaDataAPI.listHTMLMetaData(slug)];
|
|
33690
|
-
case 1:
|
|
33691
|
-
metaDataList = _a.sent();
|
|
33692
|
-
if (!(!metaDataList || !metaDataList.length)) return [3 /*break*/, 3];
|
|
33693
|
-
splitParts = slug.split("-");
|
|
33694
|
-
newSlug = splitParts.slice(0, splitParts.length - 1).join("-");
|
|
33695
|
-
return [4 /*yield*/, getProductMetaData(newSlug)];
|
|
33696
|
-
case 2: return [2 /*return*/, _a.sent()];
|
|
33697
|
-
case 3: return [2 /*return*/, {
|
|
33698
|
-
metaData: metaDataList[0],
|
|
33699
|
-
slug: slug,
|
|
33700
|
-
}];
|
|
33701
|
-
}
|
|
33702
|
-
});
|
|
33703
|
-
}); };
|
|
33704
|
-
return [4 /*yield*/, getProductMetaData(slug)];
|
|
33705
|
-
case 1:
|
|
33706
|
-
metaDataResponse = _b.sent();
|
|
33707
|
-
if (!metaDataResponse)
|
|
33708
|
-
return [2 /*return*/];
|
|
33709
|
-
return [4 /*yield*/, IkasProductSearchAPI.searchProducts({
|
|
33710
|
-
productIdList: [metaDataResponse.metaData.targetId],
|
|
33711
|
-
priceListId: IkasStorefrontConfig.priceListId,
|
|
33712
|
-
salesChannelId: IkasStorefrontConfig.salesChannelId,
|
|
33713
|
-
})];
|
|
33714
|
-
case 2:
|
|
33715
|
-
productsResponse = _b.sent();
|
|
33716
|
-
if (!(productsResponse === null || productsResponse === void 0 ? void 0 : productsResponse.data.length))
|
|
33717
|
-
return [2 /*return*/];
|
|
33718
|
-
product = productsResponse.data[0];
|
|
33719
|
-
isMainProductSlug = slug.length === metaDataResponse.slug.length;
|
|
33720
|
-
selectedVariantValues = [];
|
|
33721
|
-
if (!isMainProductSlug) {
|
|
33722
|
-
variantSlugPart = slug.slice(metaDataResponse.slug.length + 1);
|
|
33723
|
-
for (_i = 0, _a = product.variants; _i < _a.length; _i++) {
|
|
33724
|
-
variant = _a[_i];
|
|
33725
|
-
values = variant.variantValues;
|
|
33726
|
-
slugPart = values.map(function (vv) { return vv.slug; }).join("-");
|
|
33727
|
-
if (slugPart === variantSlugPart) {
|
|
33728
|
-
selectedVariantValues = values;
|
|
33729
|
-
break;
|
|
33730
|
-
}
|
|
33731
|
-
}
|
|
33732
|
-
}
|
|
33733
|
-
this.pageSpecificData = new IkasProductDetail(product, selectedVariantValues.length
|
|
33734
|
-
? selectedVariantValues
|
|
33735
|
-
: product.variants[0].variantValues);
|
|
33736
|
-
// Select the first displayed in stock variant
|
|
33737
|
-
if (!selectedVariantValues.length &&
|
|
33738
|
-
this.pageSpecificData.displayedVariantTypes.length) {
|
|
33739
|
-
displayedVariantType = this.pageSpecificData
|
|
33740
|
-
.displayedVariantTypes[0];
|
|
33741
|
-
if (displayedVariantType.displayedVariantValues.length) {
|
|
33742
|
-
inStockVariant = displayedVariantType.displayedVariantValues.find(function (dvv) { return dvv.hasStock; });
|
|
33743
|
-
if (inStockVariant) {
|
|
33744
|
-
this.pageSpecificData.selectedVariantValues =
|
|
33745
|
-
inStockVariant.variant.variantValues;
|
|
33746
|
-
}
|
|
33747
|
-
}
|
|
33748
|
-
}
|
|
33749
|
-
this.pageType = exports.IkasThemePageType.PRODUCT;
|
|
33750
|
-
this.setPageMetaData(metaDataResponse.metaData);
|
|
33751
|
-
return [2 /*return*/];
|
|
33752
|
-
}
|
|
33753
|
-
});
|
|
33754
|
-
});
|
|
33755
|
-
};
|
|
33756
33687
|
IkasPageDataProvider.prototype.getPageComponentPropValues = function (pageComponent) {
|
|
33757
33688
|
return __awaiter(this, void 0, void 0, function () {
|
|
33758
33689
|
var component, result, setPageComponentPropValue;
|
|
@@ -33944,7 +33875,7 @@ var IkasPageDataProvider = /** @class */ (function () {
|
|
|
33944
33875
|
IkasPageDataProvider.initProductListPropValue(prop, propValue, pageComponentPropValue, router);
|
|
33945
33876
|
break;
|
|
33946
33877
|
case exports.IkasThemeComponentPropType.PRODUCT_DETAIL:
|
|
33947
|
-
IkasPageDataProvider.initProductDetailPropValue(prop, propValue, pageComponentPropValue,
|
|
33878
|
+
IkasPageDataProvider.initProductDetailPropValue(prop, propValue, pageComponentPropValue, isBrowser);
|
|
33948
33879
|
break;
|
|
33949
33880
|
case exports.IkasThemeComponentPropType.PRODUCT_ATTRIBUTE:
|
|
33950
33881
|
IkasPageDataProvider.initAttributePropValue(prop, propValue, pageComponentPropValue);
|
|
@@ -34013,10 +33944,10 @@ var IkasPageDataProvider = /** @class */ (function () {
|
|
|
34013
33944
|
IkasPageDataProvider._initProductListPropValue = function (propValue, router) {
|
|
34014
33945
|
return new IkasProductList(propValue, router);
|
|
34015
33946
|
};
|
|
34016
|
-
IkasPageDataProvider.initProductDetailPropValue = function (prop, propValue, pageComponentPropValue,
|
|
34017
|
-
pageComponentPropValue.propValues[prop.name] = this._initProductDetailPropValue(propValue,
|
|
33947
|
+
IkasPageDataProvider.initProductDetailPropValue = function (prop, propValue, pageComponentPropValue, isBrowser) {
|
|
33948
|
+
pageComponentPropValue.propValues[prop.name] = this._initProductDetailPropValue(propValue, isBrowser);
|
|
34018
33949
|
};
|
|
34019
|
-
IkasPageDataProvider._initProductDetailPropValue = function (propValue,
|
|
33950
|
+
IkasPageDataProvider._initProductDetailPropValue = function (propValue, isBrowser) {
|
|
34020
33951
|
var _propValue = propValue;
|
|
34021
33952
|
var productDetail = new IkasProductDetail(_propValue.product, _propValue.selectedVariantValues);
|
|
34022
33953
|
if (isBrowser) {
|
|
@@ -34029,7 +33960,7 @@ var IkasPageDataProvider = /** @class */ (function () {
|
|
|
34029
33960
|
}
|
|
34030
33961
|
}
|
|
34031
33962
|
}
|
|
34032
|
-
return new IkasProductDetail(productDetail.product, productDetail.selectedVariantValues
|
|
33963
|
+
return new IkasProductDetail(productDetail.product, productDetail.selectedVariantValues);
|
|
34033
33964
|
};
|
|
34034
33965
|
IkasPageDataProvider.initAttributePropValue = function (prop, propValue, pageComponentPropValue) {
|
|
34035
33966
|
pageComponentPropValue.propValues[prop.name] = IkasPageDataProvider._initAttributePropValue(propValue);
|
|
@@ -34105,7 +34036,7 @@ var IkasPageDataProvider = /** @class */ (function () {
|
|
|
34105
34036
|
case exports.IkasThemeComponentPropType.LINK:
|
|
34106
34037
|
return this._initLinkPropValue(propValue);
|
|
34107
34038
|
case exports.IkasThemeComponentPropType.PRODUCT_DETAIL:
|
|
34108
|
-
return this._initProductDetailPropValue(propValue,
|
|
34039
|
+
return this._initProductDetailPropValue(propValue, isBrowser);
|
|
34109
34040
|
case exports.IkasThemeComponentPropType.PRODUCT_LIST:
|
|
34110
34041
|
return this._initProductListPropValue(propValue, router);
|
|
34111
34042
|
case exports.IkasThemeComponentPropType.PRODUCT_ATTRIBUTE:
|
|
@@ -62294,21 +62225,6 @@ var Page$1 = function (_a) {
|
|
|
62294
62225
|
var index$1 = mobxReactLite.observer(Page$1);
|
|
62295
62226
|
var getStaticPaths = function (context) { return __awaiter(void 0, void 0, void 0, function () {
|
|
62296
62227
|
return __generator(this, function (_a) {
|
|
62297
|
-
// const targetTypes = [
|
|
62298
|
-
// IkasHTMLMetaDataTargetType.BRAND,
|
|
62299
|
-
// IkasHTMLMetaDataTargetType.CATEGORY,
|
|
62300
|
-
// ];
|
|
62301
|
-
// const metaData = await IkasHTMLMetaDataAPI.listHTMLMetaData(
|
|
62302
|
-
// undefined,
|
|
62303
|
-
// undefined,
|
|
62304
|
-
// targetTypes
|
|
62305
|
-
// );
|
|
62306
|
-
// metaData.map((m) => ({
|
|
62307
|
-
// params: {
|
|
62308
|
-
// slug: m.slug,
|
|
62309
|
-
// originalSlug: m.slug,
|
|
62310
|
-
// },
|
|
62311
|
-
// }))
|
|
62312
62228
|
return [2 /*return*/, {
|
|
62313
62229
|
paths: [],
|
|
62314
62230
|
fallback: "blocking",
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { IkasProduct, IkasVariantValue } from "../../index";
|
|
2
|
-
import { NextRouter } from "next/router";
|
|
3
2
|
import { IkasProductVariant, IkasVariantType } from "../../data/index";
|
|
4
3
|
export declare class IkasProductDetail {
|
|
5
4
|
product: IkasProduct;
|
|
6
5
|
selectedVariantValues: IkasVariantValue[];
|
|
7
|
-
|
|
8
|
-
constructor(product: IkasProduct, selectedVariantValues: IkasVariantValue[], router?: NextRouter);
|
|
6
|
+
constructor(product: IkasProduct, selectedVariantValues: IkasVariantValue[]);
|
|
9
7
|
get mainVariantValue(): IkasVariantValue | undefined;
|
|
10
8
|
get selectedVariant(): IkasProductVariant;
|
|
11
9
|
get href(): string;
|
|
@@ -46,7 +46,6 @@ export declare class IkasPageDataProvider {
|
|
|
46
46
|
getMerchantSettings(): Promise<void>;
|
|
47
47
|
getPageData(): Promise<void>;
|
|
48
48
|
getPageSpecificData(): Promise<void>;
|
|
49
|
-
getPageSpecificProduct(): Promise<void>;
|
|
50
49
|
getPageComponentPropValues(pageComponent: IkasThemePageComponent): Promise<IkasPageComponentPropValue>;
|
|
51
50
|
getPageComponentPropValue(pageComponent: IkasThemePageComponent, prop: IkasThemeComponentProp): Promise<any>;
|
|
52
51
|
private setPageMetaData;
|
|
@@ -62,8 +61,8 @@ export declare class IkasPageDataProvider {
|
|
|
62
61
|
static _initCategoryListPropValue(propValue: IkasCategoryListParams): IkasCategoryList;
|
|
63
62
|
static initProductListPropValue(prop: IkasThemeComponentProp, propValue: any, pageComponentPropValue: IkasPageComponentPropValue, router: NextRouter): void;
|
|
64
63
|
static _initProductListPropValue(propValue: IkasProductListParams, router: NextRouter): IkasProductList;
|
|
65
|
-
static initProductDetailPropValue(prop: IkasThemeComponentProp, propValue: any, pageComponentPropValue: IkasPageComponentPropValue,
|
|
66
|
-
static _initProductDetailPropValue(propValue: any,
|
|
64
|
+
static initProductDetailPropValue(prop: IkasThemeComponentProp, propValue: any, pageComponentPropValue: IkasPageComponentPropValue, isBrowser?: boolean): void;
|
|
65
|
+
static _initProductDetailPropValue(propValue: any, isBrowser?: boolean): IkasProductDetail;
|
|
67
66
|
static initAttributePropValue(prop: IkasThemeComponentProp, propValue: any, pageComponentPropValue: IkasPageComponentPropValue): void;
|
|
68
67
|
static _initAttributePropValue(propValue: IkasProductAttributeValue[]): IkasProductAttributeValue[];
|
|
69
68
|
static initAttributeListPropValue(prop: IkasThemeComponentProp, propValue: any, pageComponentPropValue: IkasPageComponentPropValue): void;
|