vanilli-shop-client
Advanced tools
Comparing version 1.6.0 to 1.6.1
@@ -8,4 +8,5 @@ import RootApi from "./root-api"; | ||
searchProducts(request: IProductSearchDto, queryParams?: IQueryParams): Promise<AxiosResponse>; | ||
getProductGroups(): Promise<AxiosResponse>; | ||
getProductByRef(ref: string, refType: string): Promise<AxiosResponse>; | ||
getParameters(productId: number): Promise<AxiosResponse>; | ||
} |
@@ -73,2 +73,9 @@ "use strict"; | ||
}; | ||
ProductApi.prototype.getProductGroups = function () { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, axios_1.default.get(this.endpoint + "/groups")]; | ||
}); | ||
}); | ||
}; | ||
ProductApi.prototype.getProductByRef = function (ref, refType) { | ||
@@ -75,0 +82,0 @@ return __awaiter(this, void 0, void 0, function () { |
@@ -17,2 +17,10 @@ import { IBaseDto, IPropertyDto } from "./base"; | ||
} | ||
export interface IProductGroupDto { | ||
categoryName: string; | ||
products: IProductGroupProductDto[]; | ||
} | ||
export interface IProductGroupProductDto extends IBaseDto { | ||
code: string; | ||
name: string; | ||
} | ||
export declare enum ProductRefTypeEnum { | ||
@@ -19,0 +27,0 @@ Code = "code", |
import BaseStore from "./base-store"; | ||
import { IProductDetails, IProductDto, IProductSearchDto } from "../models/product"; | ||
import { IProductDetails, IProductDto, IProductGroupDto, IProductSearchDto } from "../models/product"; | ||
import { IListDto, IPropertyDto, IQueryParams, SortByEnum } from "../models/base"; | ||
export default class ProductStore extends BaseStore { | ||
loadingProductGroups: boolean; | ||
loadingMoreProducts: boolean; | ||
@@ -11,4 +12,6 @@ showProductList: boolean; | ||
productList: IListDto<IProductDto>; | ||
productGroups: IProductGroupDto[]; | ||
product: IProductDetails | undefined; | ||
searchProducts(request: IProductSearchDto, queryParams?: IQueryParams): Promise<void>; | ||
getProductGroups(): Promise<void>; | ||
sortProducts(sortBy: SortByEnum, sortDesc?: boolean): Promise<void>; | ||
@@ -23,4 +26,7 @@ loadMoreProducts(): Promise<void>; | ||
private setProducts; | ||
private setProductGroups; | ||
private toggleProductList; | ||
private setProduct; | ||
private startLoadingProductGroups; | ||
private finishLoadingProductGroups; | ||
private startLoadingMoreProducts; | ||
@@ -27,0 +33,0 @@ private finishLoadingMoreProducts; |
@@ -69,2 +69,3 @@ "use strict"; | ||
var _this = _super !== null && _super.apply(this, arguments) || this; | ||
_this.loadingProductGroups = false; | ||
_this.loadingMoreProducts = false; | ||
@@ -81,2 +82,3 @@ _this.showProductList = false; | ||
}; | ||
_this.productGroups = []; | ||
return _this; | ||
@@ -122,5 +124,30 @@ } | ||
}; | ||
ProductStore.prototype.getProductGroups = function () { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var result, e_2; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
_a.trys.push([0, 2, 3, 4]); | ||
this.startLoadingProductGroups(); | ||
return [4 /*yield*/, this.rootStore.productApi.getProductGroups()]; | ||
case 1: | ||
result = _a.sent(); | ||
this.setProductGroups(result.data); | ||
return [3 /*break*/, 4]; | ||
case 2: | ||
e_2 = _a.sent(); | ||
this.notificationStore.notifyError(e_2); | ||
return [3 /*break*/, 4]; | ||
case 3: | ||
this.finishLoadingProductGroups(); | ||
return [7 /*endfinally*/]; | ||
case 4: return [2 /*return*/]; | ||
} | ||
}); | ||
}); | ||
}; | ||
ProductStore.prototype.sortProducts = function (sortBy, sortDesc) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var notificationStore, queryParams, result, data, e_2; | ||
var notificationStore, queryParams, result, data, e_3; | ||
return __generator(this, function (_a) { | ||
@@ -151,4 +178,4 @@ switch (_a.label) { | ||
case 3: | ||
e_2 = _a.sent(); | ||
notificationStore.notifyError(e_2); | ||
e_3 = _a.sent(); | ||
notificationStore.notifyError(e_3); | ||
return [3 /*break*/, 5]; | ||
@@ -165,3 +192,3 @@ case 4: | ||
return __awaiter(this, void 0, void 0, function () { | ||
var notificationStore, result, data, e_3; | ||
var notificationStore, result, data, e_4; | ||
return __generator(this, function (_a) { | ||
@@ -190,4 +217,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]; | ||
@@ -204,3 +231,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) { | ||
@@ -226,4 +253,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]; | ||
@@ -281,2 +308,5 @@ case 4: | ||
}; | ||
ProductStore.prototype.setProductGroups = function (groups) { | ||
this.productGroups = groups; | ||
}; | ||
ProductStore.prototype.toggleProductList = function () { | ||
@@ -303,2 +333,8 @@ this.showProductList = true; | ||
}; | ||
ProductStore.prototype.startLoadingProductGroups = function () { | ||
this.loadingProductGroups = true; | ||
}; | ||
ProductStore.prototype.finishLoadingProductGroups = function () { | ||
this.loadingProductGroups = false; | ||
}; | ||
ProductStore.prototype.startLoadingMoreProducts = function () { | ||
@@ -345,2 +381,5 @@ this.loadingMoreProducts = true; | ||
mobx_1.observable | ||
], ProductStore.prototype, "loadingProductGroups", void 0); | ||
__decorate([ | ||
mobx_1.observable | ||
], ProductStore.prototype, "loadingMoreProducts", void 0); | ||
@@ -364,2 +403,5 @@ __decorate([ | ||
mobx_1.observable | ||
], ProductStore.prototype, "productGroups", void 0); | ||
__decorate([ | ||
mobx_1.observable | ||
], ProductStore.prototype, "product", void 0); | ||
@@ -383,2 +425,5 @@ __decorate([ | ||
mobx_1.action | ||
], ProductStore.prototype, "setProductGroups", null); | ||
__decorate([ | ||
mobx_1.action | ||
], ProductStore.prototype, "toggleProductList", null); | ||
@@ -390,2 +435,8 @@ __decorate([ | ||
mobx_1.action | ||
], ProductStore.prototype, "startLoadingProductGroups", null); | ||
__decorate([ | ||
mobx_1.action | ||
], ProductStore.prototype, "finishLoadingProductGroups", null); | ||
__decorate([ | ||
mobx_1.action | ||
], ProductStore.prototype, "startLoadingMoreProducts", null); | ||
@@ -392,0 +443,0 @@ __decorate([ |
{ | ||
"name": "vanilli-shop-client", | ||
"version": "1.6.0", | ||
"version": "1.6.1", | ||
"description": "Client for Vanilli Shop API", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -13,2 +13,6 @@ import RootApi from "./root-api"; | ||
async getProductGroups(): Promise<AxiosResponse> { | ||
return Axios.get(`${this.endpoint}/groups`); | ||
} | ||
async getProductByRef(ref: string, refType: string): Promise<AxiosResponse> { | ||
@@ -15,0 +19,0 @@ return Axios.get(`${this.endpoint}/${ref}?refType=${refType}&active=true`); |
@@ -20,2 +20,12 @@ import {IBaseDto, IPropertyDto} from "./base"; | ||
export interface IProductGroupDto { | ||
categoryName: string, | ||
products: IProductGroupProductDto[] | ||
} | ||
export interface IProductGroupProductDto extends IBaseDto { | ||
code: string, | ||
name: string | ||
} | ||
export enum ProductRefTypeEnum { | ||
@@ -22,0 +32,0 @@ Code = "code", |
import BaseStore from "./base-store"; | ||
import {action, observable} from "mobx"; | ||
import {IProductDetails, IProductDetailsDto, IProductDto, IProductSearchDto} from "../models/product"; | ||
import {IProductDetails, IProductDetailsDto, IProductDto, IProductGroupDto, IProductSearchDto} from "../models/product"; | ||
import {IListDto, IPropertyDto, IQueryParams, SortByEnum} from "../models/base"; | ||
@@ -8,2 +8,5 @@ | ||
@observable | ||
loadingProductGroups: boolean = false; | ||
@observable | ||
loadingMoreProducts: boolean = false | ||
@@ -33,2 +36,5 @@ | ||
@observable | ||
productGroups: IProductGroupDto[] = []; | ||
@observable | ||
product: IProductDetails | undefined; | ||
@@ -60,2 +66,14 @@ | ||
async getProductGroups() { | ||
try { | ||
this.startLoadingProductGroups(); | ||
const result = await this.rootStore.productApi.getProductGroups(); | ||
this.setProductGroups(result.data); | ||
} catch (e) { | ||
this.notificationStore.notifyError(e); | ||
} finally { | ||
this.finishLoadingProductGroups(); | ||
} | ||
} | ||
async sortProducts(sortBy: SortByEnum, sortDesc?: boolean) { | ||
@@ -188,2 +206,7 @@ const notificationStore = this.notificationStore; | ||
@action | ||
private setProductGroups(groups: IProductGroupDto[]) { | ||
this.productGroups = groups; | ||
} | ||
@action | ||
private toggleProductList() { | ||
@@ -214,2 +237,12 @@ this.showProductList = true; | ||
@action | ||
private startLoadingProductGroups() { | ||
this.loadingProductGroups = true; | ||
} | ||
@action | ||
private finishLoadingProductGroups() { | ||
this.loadingProductGroups = false; | ||
} | ||
@action | ||
private startLoadingMoreProducts() { | ||
@@ -216,0 +249,0 @@ this.loadingMoreProducts = 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
269895
5998