vanilli-shop-client
Advanced tools
Comparing version 1.7.2 to 1.7.3
@@ -5,2 +5,3 @@ import BaseStore from "./base-store"; | ||
export default class ProductStore extends BaseStore { | ||
loadingFeaturedProducts: boolean; | ||
loadingProductGroups: boolean; | ||
@@ -13,5 +14,7 @@ loadingMoreProducts: boolean; | ||
productList: IListDto<IProductDto>; | ||
featuredProducts: IProductDto[]; | ||
productGroups: IProductGroupDto[]; | ||
product: IProductDetails | undefined; | ||
searchProducts(request: IProductSearchDto, queryParams?: IQueryParams): Promise<void>; | ||
getFeaturedProducts(): Promise<void>; | ||
getProductGroups(): Promise<void>; | ||
@@ -29,4 +32,7 @@ sortProducts(sortBy: SortByEnum, sortDesc?: boolean): Promise<void>; | ||
private setProducts; | ||
private setFeaturedProducts; | ||
private setProductGroups; | ||
private setProduct; | ||
private startLoadingFeaturedProducts; | ||
private finishLoadingFeaturedProducts; | ||
private startLoadingProductGroups; | ||
@@ -33,0 +39,0 @@ private finishLoadingProductGroups; |
@@ -69,2 +69,3 @@ "use strict"; | ||
var _this = _super !== null && _super.apply(this, arguments) || this; | ||
_this.loadingFeaturedProducts = false; | ||
_this.loadingProductGroups = false; | ||
@@ -82,2 +83,3 @@ _this.loadingMoreProducts = false; | ||
}; | ||
_this.featuredProducts = []; | ||
_this.productGroups = []; | ||
@@ -123,5 +125,43 @@ return _this; | ||
}; | ||
ProductStore.prototype.getFeaturedProducts = function () { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var notificationStore, request, result, data, e_2; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
notificationStore = this.notificationStore; | ||
request = { | ||
active: true, | ||
source: "Vanilli" | ||
}; | ||
_a.label = 1; | ||
case 1: | ||
_a.trys.push([1, 3, 4, 5]); | ||
this.startLoadingFeaturedProducts(); | ||
return [4 /*yield*/, this.rootStore.productApi.searchProducts(request)]; | ||
case 2: | ||
result = _a.sent(); | ||
data = result.data; | ||
if (data.valid) { | ||
this.setFeaturedProducts(data.result); | ||
} | ||
else { | ||
notificationStore.notifyErrors(data.errors); | ||
} | ||
return [3 /*break*/, 5]; | ||
case 3: | ||
e_2 = _a.sent(); | ||
notificationStore.notifyError(e_2); | ||
return [3 /*break*/, 5]; | ||
case 4: | ||
this.finishLoadingFeaturedProducts(); | ||
return [7 /*endfinally*/]; | ||
case 5: return [2 /*return*/]; | ||
} | ||
}); | ||
}); | ||
}; | ||
ProductStore.prototype.getProductGroups = function () { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var result, e_2; | ||
var result, e_3; | ||
return __generator(this, function (_a) { | ||
@@ -138,4 +178,4 @@ switch (_a.label) { | ||
case 2: | ||
e_2 = _a.sent(); | ||
this.notificationStore.notifyError(e_2); | ||
e_3 = _a.sent(); | ||
this.notificationStore.notifyError(e_3); | ||
return [3 /*break*/, 4]; | ||
@@ -152,3 +192,3 @@ case 3: | ||
return __awaiter(this, void 0, void 0, function () { | ||
var notificationStore, queryParams, result, data, e_3; | ||
var notificationStore, queryParams, result, data, e_4; | ||
return __generator(this, function (_a) { | ||
@@ -179,4 +219,4 @@ switch (_a.label) { | ||
case 3: | ||
e_3 = _a.sent(); | ||
notificationStore.notifyError(e_3); | ||
e_4 = _a.sent(); | ||
notificationStore.notifyError(e_4); | ||
return [3 /*break*/, 5]; | ||
@@ -193,3 +233,3 @@ case 4: | ||
return __awaiter(this, void 0, void 0, function () { | ||
var notificationStore, result, data, e_4; | ||
var notificationStore, result, data, e_5; | ||
return __generator(this, function (_a) { | ||
@@ -218,4 +258,4 @@ switch (_a.label) { | ||
case 3: | ||
e_4 = _a.sent(); | ||
notificationStore.notifyError(e_4); | ||
e_5 = _a.sent(); | ||
notificationStore.notifyError(e_5); | ||
return [3 /*break*/, 5]; | ||
@@ -232,3 +272,3 @@ case 4: | ||
return __awaiter(this, void 0, void 0, function () { | ||
var notificationStore, result, data, e_5; | ||
var notificationStore, result, data, e_6; | ||
return __generator(this, function (_a) { | ||
@@ -254,4 +294,4 @@ switch (_a.label) { | ||
case 3: | ||
e_5 = _a.sent(); | ||
notificationStore.notifyError(e_5); | ||
e_6 = _a.sent(); | ||
notificationStore.notifyError(e_6); | ||
return [3 /*break*/, 5]; | ||
@@ -318,2 +358,5 @@ case 4: | ||
}; | ||
ProductStore.prototype.setFeaturedProducts = function (products) { | ||
this.featuredProducts = products; | ||
}; | ||
ProductStore.prototype.setProductGroups = function (groups) { | ||
@@ -340,2 +383,8 @@ this.productGroups = groups; | ||
}; | ||
ProductStore.prototype.startLoadingFeaturedProducts = function () { | ||
this.loadingFeaturedProducts = true; | ||
}; | ||
ProductStore.prototype.finishLoadingFeaturedProducts = function () { | ||
this.loadingFeaturedProducts = false; | ||
}; | ||
ProductStore.prototype.startLoadingProductGroups = function () { | ||
@@ -388,2 +437,5 @@ this.loadingProductGroups = true; | ||
mobx_1.observable | ||
], ProductStore.prototype, "loadingFeaturedProducts", void 0); | ||
__decorate([ | ||
mobx_1.observable | ||
], ProductStore.prototype, "loadingProductGroups", void 0); | ||
@@ -410,2 +462,5 @@ __decorate([ | ||
mobx_1.observable | ||
], ProductStore.prototype, "featuredProducts", void 0); | ||
__decorate([ | ||
mobx_1.observable | ||
], ProductStore.prototype, "productGroups", void 0); | ||
@@ -441,2 +496,5 @@ __decorate([ | ||
mobx_1.action | ||
], ProductStore.prototype, "setFeaturedProducts", null); | ||
__decorate([ | ||
mobx_1.action | ||
], ProductStore.prototype, "setProductGroups", null); | ||
@@ -448,2 +506,8 @@ __decorate([ | ||
mobx_1.action | ||
], ProductStore.prototype, "startLoadingFeaturedProducts", null); | ||
__decorate([ | ||
mobx_1.action | ||
], ProductStore.prototype, "finishLoadingFeaturedProducts", null); | ||
__decorate([ | ||
mobx_1.action | ||
], ProductStore.prototype, "startLoadingProductGroups", null); | ||
@@ -450,0 +514,0 @@ __decorate([ |
{ | ||
"name": "vanilli-shop-client", | ||
"version": "1.7.2", | ||
"version": "1.7.3", | ||
"description": "Client for Vanilli Shop API", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -8,2 +8,5 @@ import BaseStore from "./base-store"; | ||
@observable | ||
loadingFeaturedProducts = false; | ||
@observable | ||
loadingProductGroups: boolean = false; | ||
@@ -36,2 +39,5 @@ | ||
@observable | ||
featuredProducts: IProductDto[] = []; | ||
@observable | ||
productGroups: IProductGroupDto[] = []; | ||
@@ -65,2 +71,27 @@ | ||
async getFeaturedProducts() { | ||
const notificationStore = this.notificationStore; | ||
const request = { | ||
active: true, | ||
source: "Vanilli" | ||
}; | ||
try { | ||
this.startLoadingFeaturedProducts(); | ||
const result = await this.rootStore.productApi.searchProducts(request); | ||
const data = result.data; | ||
if (data.valid) { | ||
this.setFeaturedProducts(data.result); | ||
} else { | ||
notificationStore.notifyErrors(data.errors); | ||
} | ||
} catch (e) { | ||
notificationStore.notifyError(e); | ||
} finally { | ||
this.finishLoadingFeaturedProducts(); | ||
} | ||
} | ||
async getProductGroups() { | ||
@@ -220,2 +251,7 @@ try { | ||
@action | ||
private setFeaturedProducts(products: IProductDto[]) { | ||
this.featuredProducts = products; | ||
} | ||
@action | ||
private setProductGroups(groups: IProductGroupDto[]) { | ||
@@ -246,2 +282,12 @@ this.productGroups = groups; | ||
@action | ||
private startLoadingFeaturedProducts() { | ||
this.loadingFeaturedProducts = true; | ||
} | ||
@action | ||
private finishLoadingFeaturedProducts() { | ||
this.loadingFeaturedProducts = false; | ||
} | ||
@action | ||
private startLoadingProductGroups() { | ||
@@ -248,0 +294,0 @@ this.loadingProductGroups = true; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
276742
6188