@ikas/storefront 0.0.56 → 0.0.58
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/api/product-search/__generated__/getProductFilterData.d.ts +23 -8
- package/build/api/product-search/index.d.ts +5 -1
- package/build/index.es.js +88 -23
- package/build/index.js +88 -23
- package/build/models/data/category/index.d.ts +8 -0
- package/build/models/ui/product-list/index.d.ts +7 -1
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ProductFilterDisplayTypeEnum, ProductFilterTypeEnum, ProductFilterSortTypeEnum } from "../../../__generated__/global-types";
|
|
2
|
-
export interface
|
|
2
|
+
export interface getProductFilterData_getProductFilterData_filters_values {
|
|
3
3
|
__typename: "ApplicableProductFilterValue";
|
|
4
4
|
colorCode: string | null;
|
|
5
5
|
id: string;
|
|
@@ -7,15 +7,15 @@ export interface getProductFilterData_getProductFilterData_values {
|
|
|
7
7
|
name: string;
|
|
8
8
|
thumbnailImageId: string | null;
|
|
9
9
|
}
|
|
10
|
-
export interface
|
|
10
|
+
export interface getProductFilterData_getProductFilterData_filters_settings {
|
|
11
11
|
__typename: "ProductFilterSettings";
|
|
12
12
|
showCollapsedOnDesktop: boolean;
|
|
13
13
|
showCollapsedOnMobile: boolean;
|
|
14
14
|
sortType: ProductFilterSortTypeEnum;
|
|
15
15
|
useAndFilter: boolean | null;
|
|
16
16
|
}
|
|
17
|
-
export interface
|
|
18
|
-
__typename: "
|
|
17
|
+
export interface getProductFilterData_getProductFilterData_filters {
|
|
18
|
+
__typename: "ProductFilterDataFilter";
|
|
19
19
|
customValues: string[] | null;
|
|
20
20
|
displayType: ProductFilterDisplayTypeEnum;
|
|
21
21
|
id: string;
|
|
@@ -24,12 +24,27 @@ export interface getProductFilterData_getProductFilterData {
|
|
|
24
24
|
name: string;
|
|
25
25
|
order: number;
|
|
26
26
|
type: ProductFilterTypeEnum;
|
|
27
|
-
values:
|
|
28
|
-
settings:
|
|
27
|
+
values: getProductFilterData_getProductFilterData_filters_values[] | null;
|
|
28
|
+
settings: getProductFilterData_getProductFilterData_filters_settings | null;
|
|
29
|
+
}
|
|
30
|
+
export interface getProductFilterData_getProductFilterData_categories_metaData {
|
|
31
|
+
__typename: "HTMLMetaData";
|
|
32
|
+
slug: string;
|
|
33
|
+
}
|
|
34
|
+
export interface getProductFilterData_getProductFilterData_categories {
|
|
35
|
+
__typename: "Category";
|
|
36
|
+
id: string;
|
|
37
|
+
name: string;
|
|
38
|
+
metaData: getProductFilterData_getProductFilterData_categories_metaData | null;
|
|
39
|
+
}
|
|
40
|
+
export interface getProductFilterData_getProductFilterData {
|
|
41
|
+
__typename: "ProductFilterData";
|
|
42
|
+
filters: getProductFilterData_getProductFilterData_filters[];
|
|
43
|
+
categories: getProductFilterData_getProductFilterData_categories[] | null;
|
|
29
44
|
}
|
|
30
45
|
export interface getProductFilterData {
|
|
31
|
-
getProductFilterData: getProductFilterData_getProductFilterData
|
|
46
|
+
getProductFilterData: getProductFilterData_getProductFilterData;
|
|
32
47
|
}
|
|
33
48
|
export interface getProductFilterDataVariables {
|
|
34
|
-
|
|
49
|
+
categoryId?: string | null;
|
|
35
50
|
}
|
|
@@ -2,6 +2,7 @@ import { SearchInput } from "../../__generated__/global-types";
|
|
|
2
2
|
import { IkasProduct } from "../../models/index";
|
|
3
3
|
import * as SearchProductTypes from "./__generated__/searchProducts";
|
|
4
4
|
import { IkasProductFilter } from "../../models/data/product-filter/index";
|
|
5
|
+
import { IkasFilterCategory } from "../../models/data/category/index";
|
|
5
6
|
export declare class IkasProductSearchAPI {
|
|
6
7
|
static searchProducts(input: SearchInput): Promise<{
|
|
7
8
|
data: IkasProduct[];
|
|
@@ -12,5 +13,8 @@ export declare class IkasProductSearchAPI {
|
|
|
12
13
|
page: number;
|
|
13
14
|
totalCount: number;
|
|
14
15
|
} | undefined>;
|
|
15
|
-
static getProductFilterData(
|
|
16
|
+
static getProductFilterData(categoryId?: string): Promise<{
|
|
17
|
+
filters: IkasProductFilter[];
|
|
18
|
+
categories: IkasFilterCategory[] | null;
|
|
19
|
+
} | undefined>;
|
|
16
20
|
}
|
package/build/index.es.js
CHANGED
|
@@ -12467,6 +12467,28 @@ var IkasCategoryPath = /** @class */ (function () {
|
|
|
12467
12467
|
configurable: true
|
|
12468
12468
|
});
|
|
12469
12469
|
return IkasCategoryPath;
|
|
12470
|
+
}());
|
|
12471
|
+
var IkasFilterCategory = /** @class */ (function () {
|
|
12472
|
+
function IkasFilterCategory(data) {
|
|
12473
|
+
this.id = data.id || "";
|
|
12474
|
+
this.name = data.name || "";
|
|
12475
|
+
this.slug = data.slug || "";
|
|
12476
|
+
this.resultCount =
|
|
12477
|
+
data.resultCount !== undefined && data.resultCount !== null
|
|
12478
|
+
? data.resultCount
|
|
12479
|
+
: null;
|
|
12480
|
+
makeAutoObservable(this);
|
|
12481
|
+
}
|
|
12482
|
+
Object.defineProperty(IkasFilterCategory.prototype, "href", {
|
|
12483
|
+
get: function () {
|
|
12484
|
+
if (!this.slug)
|
|
12485
|
+
return "";
|
|
12486
|
+
return "/" + this.slug;
|
|
12487
|
+
},
|
|
12488
|
+
enumerable: false,
|
|
12489
|
+
configurable: true
|
|
12490
|
+
});
|
|
12491
|
+
return IkasFilterCategory;
|
|
12470
12492
|
}());
|
|
12471
12493
|
|
|
12472
12494
|
var IkasOrderAddress = /** @class */ (function () {
|
|
@@ -18512,6 +18534,7 @@ var IkasProductList = /** @class */ (function () {
|
|
|
18512
18534
|
function IkasProductList(data, router) {
|
|
18513
18535
|
var _this = this;
|
|
18514
18536
|
this.filters = null;
|
|
18537
|
+
this._filterCategories = null;
|
|
18515
18538
|
this._initialized = false;
|
|
18516
18539
|
this._minPage = null;
|
|
18517
18540
|
this._filterBrandId = null;
|
|
@@ -18748,6 +18771,9 @@ var IkasProductList = /** @class */ (function () {
|
|
|
18748
18771
|
this.filters = data.filters
|
|
18749
18772
|
? data.filters.map(function (f) { return new IkasProductFilter(f); })
|
|
18750
18773
|
: null;
|
|
18774
|
+
this._filterCategories = data.filterCategories
|
|
18775
|
+
? data.filterCategories.map(function (c) { return new IkasFilterCategory(c); })
|
|
18776
|
+
: null;
|
|
18751
18777
|
this.router = router;
|
|
18752
18778
|
makeAutoObservable(this);
|
|
18753
18779
|
if (this.isBrowser() && location.search) {
|
|
@@ -18877,6 +18903,14 @@ var IkasProductList = /** @class */ (function () {
|
|
|
18877
18903
|
enumerable: false,
|
|
18878
18904
|
configurable: true
|
|
18879
18905
|
});
|
|
18906
|
+
Object.defineProperty(IkasProductList.prototype, "filterCategories", {
|
|
18907
|
+
get: function () {
|
|
18908
|
+
var _a;
|
|
18909
|
+
return (_a = this._filterCategories) === null || _a === void 0 ? void 0 : _a.filter(function (fc) { return fc.resultCount !== 0; });
|
|
18910
|
+
},
|
|
18911
|
+
enumerable: false,
|
|
18912
|
+
configurable: true
|
|
18913
|
+
});
|
|
18880
18914
|
IkasProductList.prototype.searchProducts = function (page, limit) {
|
|
18881
18915
|
var _a, _b;
|
|
18882
18916
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -18917,21 +18951,16 @@ var IkasProductList = /** @class */ (function () {
|
|
|
18917
18951
|
});
|
|
18918
18952
|
});
|
|
18919
18953
|
};
|
|
18920
|
-
IkasProductList.prototype.clear = function () {
|
|
18921
|
-
var _a;
|
|
18922
|
-
(_a = this.filters) === null || _a === void 0 ? void 0 : _a.forEach(function (filter) { return filter.clear(); });
|
|
18923
|
-
this._searchKeyword = "";
|
|
18924
|
-
};
|
|
18925
18954
|
IkasProductList.prototype.getFilters = function () {
|
|
18926
18955
|
return __awaiter(this, void 0, void 0, function () {
|
|
18927
|
-
var
|
|
18928
|
-
return __generator(this, function (
|
|
18929
|
-
switch (
|
|
18930
|
-
case 0:
|
|
18931
|
-
_a = this;
|
|
18932
|
-
return [4 /*yield*/, IkasProductSearchAPI.getProductFilterData()];
|
|
18956
|
+
var getFiltersResponse;
|
|
18957
|
+
return __generator(this, function (_a) {
|
|
18958
|
+
switch (_a.label) {
|
|
18959
|
+
case 0: return [4 /*yield*/, IkasProductSearchAPI.getProductFilterData(this._filterCategoryId ? this._filterCategoryId : undefined)];
|
|
18933
18960
|
case 1:
|
|
18934
|
-
|
|
18961
|
+
getFiltersResponse = _a.sent();
|
|
18962
|
+
this.filters = getFiltersResponse === null || getFiltersResponse === void 0 ? void 0 : getFiltersResponse.filters;
|
|
18963
|
+
this._filterCategories = getFiltersResponse === null || getFiltersResponse === void 0 ? void 0 : getFiltersResponse.categories;
|
|
18935
18964
|
if (this.filters)
|
|
18936
18965
|
this.filters.sort(function (f1, f2) { return (f1.order > f2.order ? 1 : -1); });
|
|
18937
18966
|
return [2 /*return*/];
|
|
@@ -18959,7 +18988,8 @@ var IkasProductList = /** @class */ (function () {
|
|
|
18959
18988
|
}
|
|
18960
18989
|
else {
|
|
18961
18990
|
(_c = filter.values) === null || _c === void 0 ? void 0 : _c.forEach(function (filterValue) {
|
|
18962
|
-
if (valueKeys.includes(filterValue.key)
|
|
18991
|
+
if (valueKeys.includes(filterValue.key) &&
|
|
18992
|
+
filterValue.resultCount !== 0)
|
|
18963
18993
|
filterValue.isSelected = true;
|
|
18964
18994
|
});
|
|
18965
18995
|
}
|
|
@@ -18971,7 +19001,7 @@ var IkasProductList = /** @class */ (function () {
|
|
|
18971
19001
|
}
|
|
18972
19002
|
};
|
|
18973
19003
|
IkasProductList.prototype.applyFacets = function (facets) {
|
|
18974
|
-
var _a;
|
|
19004
|
+
var _a, _b;
|
|
18975
19005
|
(_a = this.filters) === null || _a === void 0 ? void 0 : _a.forEach(function (filter) {
|
|
18976
19006
|
var _a, _b, _c;
|
|
18977
19007
|
var facet = facets === null || facets === void 0 ? void 0 : facets.find(function (f) { return f.id === filter.id; });
|
|
@@ -18993,6 +19023,28 @@ var IkasProductList = /** @class */ (function () {
|
|
|
18993
19023
|
(_c = filter.values) === null || _c === void 0 ? void 0 : _c.forEach(function (v) { return (v.resultCount = 0); });
|
|
18994
19024
|
}
|
|
18995
19025
|
});
|
|
19026
|
+
// Category facets
|
|
19027
|
+
var categoryFacet = facets === null || facets === void 0 ? void 0 : facets.find(function (f) { return f.id === "category"; });
|
|
19028
|
+
if (categoryFacet) {
|
|
19029
|
+
(_b = this._filterCategories) === null || _b === void 0 ? void 0 : _b.forEach(function (filterCategory) {
|
|
19030
|
+
var facetValue = categoryFacet.values.find(function (fv) { return fv.id === filterCategory.id; });
|
|
19031
|
+
if (facetValue) {
|
|
19032
|
+
filterCategory.resultCount = facetValue.count;
|
|
19033
|
+
}
|
|
19034
|
+
else {
|
|
19035
|
+
filterCategory.resultCount = 0;
|
|
19036
|
+
}
|
|
19037
|
+
});
|
|
19038
|
+
}
|
|
19039
|
+
};
|
|
19040
|
+
IkasProductList.prototype.clearFilters = function () {
|
|
19041
|
+
var _a;
|
|
19042
|
+
(_a = this.filters) === null || _a === void 0 ? void 0 : _a.forEach(function (filter) { return filter.clear(); });
|
|
19043
|
+
this._searchKeyword = "";
|
|
19044
|
+
};
|
|
19045
|
+
IkasProductList.prototype.onFilterCategoryClick = function (filterCategory) {
|
|
19046
|
+
var _a;
|
|
19047
|
+
(_a = this.router) === null || _a === void 0 ? void 0 : _a.push(filterCategory.href + window.location.search);
|
|
18996
19048
|
};
|
|
18997
19049
|
IkasProductList.prototype.toJSON = function () {
|
|
18998
19050
|
return {
|
|
@@ -19007,6 +19059,7 @@ var IkasProductList = /** @class */ (function () {
|
|
|
19007
19059
|
minPage: this._minPage,
|
|
19008
19060
|
filterBrandId: this._filterBrandId,
|
|
19009
19061
|
filterCategoryId: this._filterCategoryId,
|
|
19062
|
+
filterCategories: this._filterCategories,
|
|
19010
19063
|
filters: this.filters,
|
|
19011
19064
|
recommendFor: this._recommendFor,
|
|
19012
19065
|
productListPropValue: this._productListPropValue,
|
|
@@ -23192,20 +23245,20 @@ var IkasProductSearchAPI = /** @class */ (function () {
|
|
|
23192
23245
|
});
|
|
23193
23246
|
});
|
|
23194
23247
|
};
|
|
23195
|
-
IkasProductSearchAPI.getProductFilterData = function (
|
|
23248
|
+
IkasProductSearchAPI.getProductFilterData = function (categoryId) {
|
|
23196
23249
|
return __awaiter(this, void 0, void 0, function () {
|
|
23197
23250
|
var QUERY, _a, data, errors, err_2;
|
|
23198
23251
|
return __generator(this, function (_b) {
|
|
23199
23252
|
switch (_b.label) {
|
|
23200
23253
|
case 0:
|
|
23201
23254
|
_b.trys.push([0, 2, , 3]);
|
|
23202
|
-
QUERY = src(templateObject_2$4 || (templateObject_2$4 = __makeTemplateObject(["\n query getProductFilterData($
|
|
23255
|
+
QUERY = src(templateObject_2$4 || (templateObject_2$4 = __makeTemplateObject(["\n query getProductFilterData($categoryId: String) {\n getProductFilterData(categoryId: $categoryId) {\n filters {\n customValues\n displayType\n id\n isMultiSelect\n key\n name\n order\n type\n values {\n colorCode\n id\n key\n name\n thumbnailImageId\n }\n settings {\n showCollapsedOnDesktop\n showCollapsedOnMobile\n sortType\n useAndFilter\n }\n }\n categories {\n id\n name\n metaData {\n slug\n }\n }\n }\n }\n "], ["\n query getProductFilterData($categoryId: String) {\n getProductFilterData(categoryId: $categoryId) {\n filters {\n customValues\n displayType\n id\n isMultiSelect\n key\n name\n order\n type\n values {\n colorCode\n id\n key\n name\n thumbnailImageId\n }\n settings {\n showCollapsedOnDesktop\n showCollapsedOnMobile\n sortType\n useAndFilter\n }\n }\n categories {\n id\n name\n metaData {\n slug\n }\n }\n }\n }\n "])));
|
|
23203
23256
|
return [4 /*yield*/, apollo
|
|
23204
23257
|
.getClient()
|
|
23205
23258
|
.query({
|
|
23206
23259
|
query: QUERY,
|
|
23207
23260
|
variables: {
|
|
23208
|
-
|
|
23261
|
+
categoryId: categoryId || null,
|
|
23209
23262
|
},
|
|
23210
23263
|
})];
|
|
23211
23264
|
case 1:
|
|
@@ -23214,12 +23267,24 @@ var IkasProductSearchAPI = /** @class */ (function () {
|
|
|
23214
23267
|
console.log(errors);
|
|
23215
23268
|
return [2 /*return*/];
|
|
23216
23269
|
}
|
|
23217
|
-
return [2 /*return*/,
|
|
23218
|
-
|
|
23219
|
-
|
|
23220
|
-
|
|
23221
|
-
|
|
23222
|
-
|
|
23270
|
+
return [2 /*return*/, {
|
|
23271
|
+
filters: data.getProductFilterData.filters.map(function (d) {
|
|
23272
|
+
var _a;
|
|
23273
|
+
return new IkasProductFilter(__assign(__assign({}, d), { displayType: d.displayType, type: d.type, values: (_a = d.values) === null || _a === void 0 ? void 0 : _a.map(function (v) { return new IkasApplicableProductFilterValue(v); }), settings: d.settings
|
|
23274
|
+
? new IkasProductFilterSettings(__assign(__assign({}, d.settings), { sortType: d.settings.sortType }))
|
|
23275
|
+
: null }));
|
|
23276
|
+
}),
|
|
23277
|
+
categories: data.getProductFilterData.categories
|
|
23278
|
+
? data.getProductFilterData.categories.map(function (c) {
|
|
23279
|
+
var _a;
|
|
23280
|
+
return new IkasFilterCategory({
|
|
23281
|
+
id: c.id,
|
|
23282
|
+
name: c.name,
|
|
23283
|
+
slug: (_a = c.metaData) === null || _a === void 0 ? void 0 : _a.slug,
|
|
23284
|
+
});
|
|
23285
|
+
})
|
|
23286
|
+
: null,
|
|
23287
|
+
}];
|
|
23223
23288
|
case 2:
|
|
23224
23289
|
err_2 = _b.sent();
|
|
23225
23290
|
console.log(err_2);
|
package/build/index.js
CHANGED
|
@@ -12478,6 +12478,28 @@ var IkasCategoryPath = /** @class */ (function () {
|
|
|
12478
12478
|
configurable: true
|
|
12479
12479
|
});
|
|
12480
12480
|
return IkasCategoryPath;
|
|
12481
|
+
}());
|
|
12482
|
+
var IkasFilterCategory = /** @class */ (function () {
|
|
12483
|
+
function IkasFilterCategory(data) {
|
|
12484
|
+
this.id = data.id || "";
|
|
12485
|
+
this.name = data.name || "";
|
|
12486
|
+
this.slug = data.slug || "";
|
|
12487
|
+
this.resultCount =
|
|
12488
|
+
data.resultCount !== undefined && data.resultCount !== null
|
|
12489
|
+
? data.resultCount
|
|
12490
|
+
: null;
|
|
12491
|
+
mobx.makeAutoObservable(this);
|
|
12492
|
+
}
|
|
12493
|
+
Object.defineProperty(IkasFilterCategory.prototype, "href", {
|
|
12494
|
+
get: function () {
|
|
12495
|
+
if (!this.slug)
|
|
12496
|
+
return "";
|
|
12497
|
+
return "/" + this.slug;
|
|
12498
|
+
},
|
|
12499
|
+
enumerable: false,
|
|
12500
|
+
configurable: true
|
|
12501
|
+
});
|
|
12502
|
+
return IkasFilterCategory;
|
|
12481
12503
|
}());
|
|
12482
12504
|
|
|
12483
12505
|
var IkasOrderAddress = /** @class */ (function () {
|
|
@@ -18493,6 +18515,7 @@ var IkasProductList = /** @class */ (function () {
|
|
|
18493
18515
|
function IkasProductList(data, router) {
|
|
18494
18516
|
var _this = this;
|
|
18495
18517
|
this.filters = null;
|
|
18518
|
+
this._filterCategories = null;
|
|
18496
18519
|
this._initialized = false;
|
|
18497
18520
|
this._minPage = null;
|
|
18498
18521
|
this._filterBrandId = null;
|
|
@@ -18729,6 +18752,9 @@ var IkasProductList = /** @class */ (function () {
|
|
|
18729
18752
|
this.filters = data.filters
|
|
18730
18753
|
? data.filters.map(function (f) { return new IkasProductFilter(f); })
|
|
18731
18754
|
: null;
|
|
18755
|
+
this._filterCategories = data.filterCategories
|
|
18756
|
+
? data.filterCategories.map(function (c) { return new IkasFilterCategory(c); })
|
|
18757
|
+
: null;
|
|
18732
18758
|
this.router = router;
|
|
18733
18759
|
mobx.makeAutoObservable(this);
|
|
18734
18760
|
if (this.isBrowser() && location.search) {
|
|
@@ -18858,6 +18884,14 @@ var IkasProductList = /** @class */ (function () {
|
|
|
18858
18884
|
enumerable: false,
|
|
18859
18885
|
configurable: true
|
|
18860
18886
|
});
|
|
18887
|
+
Object.defineProperty(IkasProductList.prototype, "filterCategories", {
|
|
18888
|
+
get: function () {
|
|
18889
|
+
var _a;
|
|
18890
|
+
return (_a = this._filterCategories) === null || _a === void 0 ? void 0 : _a.filter(function (fc) { return fc.resultCount !== 0; });
|
|
18891
|
+
},
|
|
18892
|
+
enumerable: false,
|
|
18893
|
+
configurable: true
|
|
18894
|
+
});
|
|
18861
18895
|
IkasProductList.prototype.searchProducts = function (page, limit) {
|
|
18862
18896
|
var _a, _b;
|
|
18863
18897
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -18898,21 +18932,16 @@ var IkasProductList = /** @class */ (function () {
|
|
|
18898
18932
|
});
|
|
18899
18933
|
});
|
|
18900
18934
|
};
|
|
18901
|
-
IkasProductList.prototype.clear = function () {
|
|
18902
|
-
var _a;
|
|
18903
|
-
(_a = this.filters) === null || _a === void 0 ? void 0 : _a.forEach(function (filter) { return filter.clear(); });
|
|
18904
|
-
this._searchKeyword = "";
|
|
18905
|
-
};
|
|
18906
18935
|
IkasProductList.prototype.getFilters = function () {
|
|
18907
18936
|
return __awaiter(this, void 0, void 0, function () {
|
|
18908
|
-
var
|
|
18909
|
-
return __generator(this, function (
|
|
18910
|
-
switch (
|
|
18911
|
-
case 0:
|
|
18912
|
-
_a = this;
|
|
18913
|
-
return [4 /*yield*/, IkasProductSearchAPI.getProductFilterData()];
|
|
18937
|
+
var getFiltersResponse;
|
|
18938
|
+
return __generator(this, function (_a) {
|
|
18939
|
+
switch (_a.label) {
|
|
18940
|
+
case 0: return [4 /*yield*/, IkasProductSearchAPI.getProductFilterData(this._filterCategoryId ? this._filterCategoryId : undefined)];
|
|
18914
18941
|
case 1:
|
|
18915
|
-
|
|
18942
|
+
getFiltersResponse = _a.sent();
|
|
18943
|
+
this.filters = getFiltersResponse === null || getFiltersResponse === void 0 ? void 0 : getFiltersResponse.filters;
|
|
18944
|
+
this._filterCategories = getFiltersResponse === null || getFiltersResponse === void 0 ? void 0 : getFiltersResponse.categories;
|
|
18916
18945
|
if (this.filters)
|
|
18917
18946
|
this.filters.sort(function (f1, f2) { return (f1.order > f2.order ? 1 : -1); });
|
|
18918
18947
|
return [2 /*return*/];
|
|
@@ -18940,7 +18969,8 @@ var IkasProductList = /** @class */ (function () {
|
|
|
18940
18969
|
}
|
|
18941
18970
|
else {
|
|
18942
18971
|
(_c = filter.values) === null || _c === void 0 ? void 0 : _c.forEach(function (filterValue) {
|
|
18943
|
-
if (valueKeys.includes(filterValue.key)
|
|
18972
|
+
if (valueKeys.includes(filterValue.key) &&
|
|
18973
|
+
filterValue.resultCount !== 0)
|
|
18944
18974
|
filterValue.isSelected = true;
|
|
18945
18975
|
});
|
|
18946
18976
|
}
|
|
@@ -18952,7 +18982,7 @@ var IkasProductList = /** @class */ (function () {
|
|
|
18952
18982
|
}
|
|
18953
18983
|
};
|
|
18954
18984
|
IkasProductList.prototype.applyFacets = function (facets) {
|
|
18955
|
-
var _a;
|
|
18985
|
+
var _a, _b;
|
|
18956
18986
|
(_a = this.filters) === null || _a === void 0 ? void 0 : _a.forEach(function (filter) {
|
|
18957
18987
|
var _a, _b, _c;
|
|
18958
18988
|
var facet = facets === null || facets === void 0 ? void 0 : facets.find(function (f) { return f.id === filter.id; });
|
|
@@ -18974,6 +19004,28 @@ var IkasProductList = /** @class */ (function () {
|
|
|
18974
19004
|
(_c = filter.values) === null || _c === void 0 ? void 0 : _c.forEach(function (v) { return (v.resultCount = 0); });
|
|
18975
19005
|
}
|
|
18976
19006
|
});
|
|
19007
|
+
// Category facets
|
|
19008
|
+
var categoryFacet = facets === null || facets === void 0 ? void 0 : facets.find(function (f) { return f.id === "category"; });
|
|
19009
|
+
if (categoryFacet) {
|
|
19010
|
+
(_b = this._filterCategories) === null || _b === void 0 ? void 0 : _b.forEach(function (filterCategory) {
|
|
19011
|
+
var facetValue = categoryFacet.values.find(function (fv) { return fv.id === filterCategory.id; });
|
|
19012
|
+
if (facetValue) {
|
|
19013
|
+
filterCategory.resultCount = facetValue.count;
|
|
19014
|
+
}
|
|
19015
|
+
else {
|
|
19016
|
+
filterCategory.resultCount = 0;
|
|
19017
|
+
}
|
|
19018
|
+
});
|
|
19019
|
+
}
|
|
19020
|
+
};
|
|
19021
|
+
IkasProductList.prototype.clearFilters = function () {
|
|
19022
|
+
var _a;
|
|
19023
|
+
(_a = this.filters) === null || _a === void 0 ? void 0 : _a.forEach(function (filter) { return filter.clear(); });
|
|
19024
|
+
this._searchKeyword = "";
|
|
19025
|
+
};
|
|
19026
|
+
IkasProductList.prototype.onFilterCategoryClick = function (filterCategory) {
|
|
19027
|
+
var _a;
|
|
19028
|
+
(_a = this.router) === null || _a === void 0 ? void 0 : _a.push(filterCategory.href + window.location.search);
|
|
18977
19029
|
};
|
|
18978
19030
|
IkasProductList.prototype.toJSON = function () {
|
|
18979
19031
|
return {
|
|
@@ -18988,6 +19040,7 @@ var IkasProductList = /** @class */ (function () {
|
|
|
18988
19040
|
minPage: this._minPage,
|
|
18989
19041
|
filterBrandId: this._filterBrandId,
|
|
18990
19042
|
filterCategoryId: this._filterCategoryId,
|
|
19043
|
+
filterCategories: this._filterCategories,
|
|
18991
19044
|
filters: this.filters,
|
|
18992
19045
|
recommendFor: this._recommendFor,
|
|
18993
19046
|
productListPropValue: this._productListPropValue,
|
|
@@ -23170,20 +23223,20 @@ var IkasProductSearchAPI = /** @class */ (function () {
|
|
|
23170
23223
|
});
|
|
23171
23224
|
});
|
|
23172
23225
|
};
|
|
23173
|
-
IkasProductSearchAPI.getProductFilterData = function (
|
|
23226
|
+
IkasProductSearchAPI.getProductFilterData = function (categoryId) {
|
|
23174
23227
|
return __awaiter(this, void 0, void 0, function () {
|
|
23175
23228
|
var QUERY, _a, data, errors, err_2;
|
|
23176
23229
|
return __generator(this, function (_b) {
|
|
23177
23230
|
switch (_b.label) {
|
|
23178
23231
|
case 0:
|
|
23179
23232
|
_b.trys.push([0, 2, , 3]);
|
|
23180
|
-
QUERY = src(templateObject_2$4 || (templateObject_2$4 = __makeTemplateObject(["\n query getProductFilterData($
|
|
23233
|
+
QUERY = src(templateObject_2$4 || (templateObject_2$4 = __makeTemplateObject(["\n query getProductFilterData($categoryId: String) {\n getProductFilterData(categoryId: $categoryId) {\n filters {\n customValues\n displayType\n id\n isMultiSelect\n key\n name\n order\n type\n values {\n colorCode\n id\n key\n name\n thumbnailImageId\n }\n settings {\n showCollapsedOnDesktop\n showCollapsedOnMobile\n sortType\n useAndFilter\n }\n }\n categories {\n id\n name\n metaData {\n slug\n }\n }\n }\n }\n "], ["\n query getProductFilterData($categoryId: String) {\n getProductFilterData(categoryId: $categoryId) {\n filters {\n customValues\n displayType\n id\n isMultiSelect\n key\n name\n order\n type\n values {\n colorCode\n id\n key\n name\n thumbnailImageId\n }\n settings {\n showCollapsedOnDesktop\n showCollapsedOnMobile\n sortType\n useAndFilter\n }\n }\n categories {\n id\n name\n metaData {\n slug\n }\n }\n }\n }\n "])));
|
|
23181
23234
|
return [4 /*yield*/, apollo
|
|
23182
23235
|
.getClient()
|
|
23183
23236
|
.query({
|
|
23184
23237
|
query: QUERY,
|
|
23185
23238
|
variables: {
|
|
23186
|
-
|
|
23239
|
+
categoryId: categoryId || null,
|
|
23187
23240
|
},
|
|
23188
23241
|
})];
|
|
23189
23242
|
case 1:
|
|
@@ -23192,12 +23245,24 @@ var IkasProductSearchAPI = /** @class */ (function () {
|
|
|
23192
23245
|
console.log(errors);
|
|
23193
23246
|
return [2 /*return*/];
|
|
23194
23247
|
}
|
|
23195
|
-
return [2 /*return*/,
|
|
23196
|
-
|
|
23197
|
-
|
|
23198
|
-
|
|
23199
|
-
|
|
23200
|
-
|
|
23248
|
+
return [2 /*return*/, {
|
|
23249
|
+
filters: data.getProductFilterData.filters.map(function (d) {
|
|
23250
|
+
var _a;
|
|
23251
|
+
return new IkasProductFilter(__assign(__assign({}, d), { displayType: d.displayType, type: d.type, values: (_a = d.values) === null || _a === void 0 ? void 0 : _a.map(function (v) { return new IkasApplicableProductFilterValue(v); }), settings: d.settings
|
|
23252
|
+
? new IkasProductFilterSettings(__assign(__assign({}, d.settings), { sortType: d.settings.sortType }))
|
|
23253
|
+
: null }));
|
|
23254
|
+
}),
|
|
23255
|
+
categories: data.getProductFilterData.categories
|
|
23256
|
+
? data.getProductFilterData.categories.map(function (c) {
|
|
23257
|
+
var _a;
|
|
23258
|
+
return new IkasFilterCategory({
|
|
23259
|
+
id: c.id,
|
|
23260
|
+
name: c.name,
|
|
23261
|
+
slug: (_a = c.metaData) === null || _a === void 0 ? void 0 : _a.slug,
|
|
23262
|
+
});
|
|
23263
|
+
})
|
|
23264
|
+
: null,
|
|
23265
|
+
}];
|
|
23201
23266
|
case 2:
|
|
23202
23267
|
err_2 = _b.sent();
|
|
23203
23268
|
console.log(err_2);
|
|
@@ -17,3 +17,11 @@ export declare class IkasCategoryPath {
|
|
|
17
17
|
constructor(data: Partial<IkasCategoryPath>);
|
|
18
18
|
get href(): string;
|
|
19
19
|
}
|
|
20
|
+
export declare class IkasFilterCategory {
|
|
21
|
+
id: string;
|
|
22
|
+
name: string;
|
|
23
|
+
slug?: string | null;
|
|
24
|
+
resultCount?: number | null;
|
|
25
|
+
constructor(data: Partial<IkasFilterCategory>);
|
|
26
|
+
get href(): string;
|
|
27
|
+
}
|
|
@@ -2,9 +2,11 @@ import { IkasProductListPropValue } from "../../theme/index";
|
|
|
2
2
|
import { IkasProductDetail } from "../product-detail/index";
|
|
3
3
|
import { IkasProductFilter } from "../../data/product-filter/index";
|
|
4
4
|
import { NextRouter } from "next/router";
|
|
5
|
+
import { IkasFilterCategory } from "../../data/category/index";
|
|
5
6
|
export declare class IkasProductList {
|
|
6
7
|
data: IkasProductDetail[];
|
|
7
8
|
filters?: IkasProductFilter[] | null;
|
|
9
|
+
private _filterCategories?;
|
|
8
10
|
private _type;
|
|
9
11
|
private _sort;
|
|
10
12
|
private _limit;
|
|
@@ -37,16 +39,18 @@ export declare class IkasProductList {
|
|
|
37
39
|
get hasNext(): boolean;
|
|
38
40
|
get isLoading(): boolean;
|
|
39
41
|
get filterQueryParams(): string;
|
|
42
|
+
get filterCategories(): IkasFilterCategory[] | undefined;
|
|
40
43
|
private searchProducts;
|
|
41
|
-
clear(): void;
|
|
42
44
|
private getFilters;
|
|
43
45
|
private applyQueryParamFilters;
|
|
44
46
|
private applyFacets;
|
|
47
|
+
clearFilters(): void;
|
|
45
48
|
applyFilters: () => Promise<void>;
|
|
46
49
|
getInitial: (queryParams?: URLSearchParams | undefined) => Promise<void>;
|
|
47
50
|
getPrev: () => Promise<void>;
|
|
48
51
|
getNext: () => Promise<void>;
|
|
49
52
|
getPage: (page: number) => Promise<void>;
|
|
53
|
+
onFilterCategoryClick(filterCategory: IkasFilterCategory): void;
|
|
50
54
|
toJSON(): {
|
|
51
55
|
data: IkasProductDetail[];
|
|
52
56
|
type: IkasProductListType;
|
|
@@ -59,6 +63,7 @@ export declare class IkasProductList {
|
|
|
59
63
|
minPage: number | null | undefined;
|
|
60
64
|
filterBrandId: string | null | undefined;
|
|
61
65
|
filterCategoryId: string | null | undefined;
|
|
66
|
+
filterCategories: IkasFilterCategory[] | null | undefined;
|
|
62
67
|
filters: IkasProductFilter[] | null | undefined;
|
|
63
68
|
recommendFor: string | null | undefined;
|
|
64
69
|
productListPropValue: IkasProductListPropValue;
|
|
@@ -79,6 +84,7 @@ export declare type IkasProductListParams = {
|
|
|
79
84
|
filterBrandId?: string;
|
|
80
85
|
filterCategoryId?: string;
|
|
81
86
|
filters?: IkasProductFilter[];
|
|
87
|
+
filterCategories?: IkasFilterCategory[];
|
|
82
88
|
recommendFor?: string;
|
|
83
89
|
productListPropValue: IkasProductListPropValue;
|
|
84
90
|
};
|