Socket
Socket
Sign inDemoInstall

vanilli-shop-client

Package Overview
Dependencies
45
Maintainers
1
Versions
115
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.3.6 to 1.3.7

9

dist/stores/product-store.d.ts
import BaseStore from "./base-store";
import { IProductDetails, IProductDto, IProductSearchDto } from "../models/product";
import { IListDto, IPropertyDto, IQueryParams } from "../models/base";
import { IListDto, IPropertyDto, IQueryParams, SortByEnum } from "../models/base";
export default class ProductStore extends BaseStore {
loadingMoreProducts: boolean;
showProductList: boolean;
lastSearchRequest: IProductSearchDto;
searchProps: IPropertyDto[];
lastSearchProps: IPropertyDto[];
lastQueryParams: IQueryParams | undefined;

@@ -13,3 +13,4 @@ productList: IListDto<IProductDto>;

searchProducts(request: IProductSearchDto, queryParams?: IQueryParams): Promise<void>;
loadMoreProducts(request: IProductSearchDto): Promise<void>;
sortProducts(sortBy: SortByEnum, sortDesc?: boolean): Promise<void>;
loadMoreProducts(): Promise<void>;
getProductByRef(ref: string, refType: string): Promise<void>;

@@ -25,4 +26,4 @@ setSearchProp(value: string, key: string): void;

private finishLoadingMoreProducts;
private setLastSearchProps;
private setLastSearchRequest;
private setLastQueryParams;
}

@@ -71,4 +71,6 @@ "use strict";

_this.showProductList = false;
_this.lastSearchRequest = {
active: true
};
_this.searchProps = [];
_this.lastSearchProps = [];
_this.productList = {

@@ -100,3 +102,3 @@ entities: [],

this.setProducts(data.result);
this.setLastSearchProps();
this.setLastSearchRequest(request);
this.setLastQueryParams(queryParams);

@@ -120,3 +122,3 @@ }

};
ProductStore.prototype.loadMoreProducts = function (request) {
ProductStore.prototype.sortProducts = function (sortBy, sortDesc) {
return __awaiter(this, void 0, void 0, function () {

@@ -127,13 +129,12 @@ var notificationStore, queryParams, result, data, e_2;

case 0:
request.additionalProps = this.lastSearchProps;
notificationStore = this.notificationStore;
queryParams = this.lastQueryParams;
if (queryParams) {
queryParams.limit = this.productList.limit * 2;
}
queryParams = {
sortBy: sortBy,
sortDesc: sortDesc
};
_a.label = 1;
case 1:
_a.trys.push([1, 3, 4, 5]);
this.startLoadingMoreProducts();
return [4 /*yield*/, this.rootStore.productApi.searchProducts(request, queryParams)];
this.startLoading();
return [4 /*yield*/, this.rootStore.productApi.searchProducts(this.lastSearchRequest, queryParams)];
case 2:

@@ -144,2 +145,3 @@ result = _a.sent();

this.setProducts(data.result);
this.setLastQueryParams(queryParams);
}

@@ -155,2 +157,39 @@ else {

case 4:
this.finishLoading();
return [7 /*endfinally*/];
case 5: return [2 /*return*/];
}
});
});
};
ProductStore.prototype.loadMoreProducts = function () {
return __awaiter(this, void 0, void 0, function () {
var notificationStore, result, data, e_3;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
notificationStore = this.notificationStore;
if (this.lastQueryParams) {
this.lastQueryParams.limit = this.productList.limit * 2;
}
_a.label = 1;
case 1:
_a.trys.push([1, 3, 4, 5]);
this.startLoadingMoreProducts();
return [4 /*yield*/, this.rootStore.productApi.searchProducts(this.lastSearchRequest, this.lastQueryParams)];
case 2:
result = _a.sent();
data = result.data;
if (data.valid) {
this.setProducts(data.result);
}
else {
notificationStore.notifyErrors(data.errors);
}
return [3 /*break*/, 5];
case 3:
e_3 = _a.sent();
notificationStore.notifyError(e_3);
return [3 /*break*/, 5];
case 4:
this.finishLoadingMoreProducts();

@@ -165,3 +204,3 @@ return [7 /*endfinally*/];

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) {

@@ -187,4 +226,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];

@@ -266,12 +305,4 @@ case 4:

};
ProductStore.prototype.setLastSearchProps = function () {
this.lastSearchProps = [];
for (var _i = 0, _a = this.searchProps; _i < _a.length; _i++) {
var searchProp = _a[_i];
var lastSearchProp = {
key: searchProp.key,
value: searchProp.value
};
this.lastSearchProps.push(lastSearchProp);
}
ProductStore.prototype.setLastSearchRequest = function (request) {
this.lastSearchRequest = request;
};

@@ -289,6 +320,6 @@ ProductStore.prototype.setLastQueryParams = function (queryParams) {

mobx_1.observable
], ProductStore.prototype, "searchProps", void 0);
], ProductStore.prototype, "lastSearchRequest", void 0);
__decorate([
mobx_1.observable
], ProductStore.prototype, "lastSearchProps", void 0);
], ProductStore.prototype, "searchProps", void 0);
__decorate([

@@ -329,3 +360,3 @@ mobx_1.observable

mobx_1.action
], ProductStore.prototype, "setLastSearchProps", null);
], ProductStore.prototype, "setLastSearchRequest", null);
__decorate([

@@ -332,0 +363,0 @@ mobx_1.action

{
"name": "vanilli-shop-client",
"version": "1.3.6",
"version": "1.3.7",
"description": "Client for Vanilli Shop API",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

import BaseStore from "./base-store";
import {action, observable} from "mobx";
import {IProductDetails, IProductDetailsDto, IProductDto, IProductSearchDto} from "../models/product";
import {IListDto, IPropertyDto, IQueryParams} from "../models/base";
import {IListDto, IPropertyDto, IQueryParams, SortByEnum} from "../models/base";

@@ -14,6 +14,8 @@ export default class ProductStore extends BaseStore {

@observable
searchProps: IPropertyDto[] = [];
lastSearchRequest: IProductSearchDto = {
active: true
};
@observable
lastSearchProps: IPropertyDto[] = [];
searchProps: IPropertyDto[] = [];

@@ -45,3 +47,3 @@ @observable

this.setProducts(data.result);
this.setLastSearchProps();
this.setLastSearchRequest(request);
this.setLastQueryParams(queryParams);

@@ -58,14 +60,38 @@ } else {

async loadMoreProducts(request: IProductSearchDto) {
request.additionalProps = this.lastSearchProps;
async sortProducts(sortBy: SortByEnum, sortDesc?: boolean) {
const notificationStore = this.notificationStore;
const queryParams = this.lastQueryParams;
if (queryParams) {
queryParams.limit = this.productList.limit * 2;
const queryParams = {
sortBy: sortBy,
sortDesc: sortDesc
};
try {
this.startLoading();
const result = await this.rootStore.productApi.searchProducts(this.lastSearchRequest, queryParams);
const data = result.data;
if (data.valid) {
this.setProducts(data.result);
this.setLastQueryParams(queryParams);
} else {
notificationStore.notifyErrors(data.errors);
}
} catch (e) {
notificationStore.notifyError(e);
} finally {
this.finishLoading();
}
}
async loadMoreProducts() {
const notificationStore = this.notificationStore;
if (this.lastQueryParams) {
this.lastQueryParams.limit = this.productList.limit * 2;
}
try {
this.startLoadingMoreProducts();
const result = await this.rootStore.productApi.searchProducts(request, queryParams);
const result = await this.rootStore.productApi.searchProducts(this.lastSearchRequest, this.lastQueryParams);
const data = result.data;

@@ -192,13 +218,4 @@

@action
private setLastSearchProps() {
this.lastSearchProps = [];
for (const searchProp of this.searchProps) {
const lastSearchProp = {
key: searchProp.key,
value: searchProp.value
};
this.lastSearchProps.push(lastSearchProp);
}
private setLastSearchRequest(request: IProductSearchDto) {
this.lastSearchRequest = request;
}

@@ -205,0 +222,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc