Socket
Socket
Sign inDemoInstall

vanilli-shop-client

Package Overview
Dependencies
Maintainers
1
Versions
115
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vanilli-shop-client - npm Package Compare versions

Comparing version 1.2.9 to 1.3.0

1

dist/models/product.d.ts

@@ -14,2 +14,3 @@ import { IBaseDto, IPropertyDto } from "./base";

export interface IProductDto extends IProductBaseDto {
hasParameters: boolean;
img?: string;

@@ -16,0 +17,0 @@ }

@@ -27,3 +27,4 @@ import BaseStore from "./base-store";

private loadCart;
private validateQuickAddingToCart;
private validateAddingToCart;
}

51

dist/stores/cart-store.js

@@ -98,24 +98,19 @@ "use strict";

CartStore.prototype.quickAddToCart = function (product) {
var notificationStore = this.notificationStore;
var translationStore = this.translationStore;
var stock = product.stock;
var productName = product.name;
if (stock && 1 > stock) {
this.notificationStore.notifyError(translationStore.t("product.out-of-stock", "Toodet {0} on saadaval ainult {1}", [productName, stock.toString()]));
return;
var valid = this.validateQuickAddingToCart(product);
if (valid) {
var item = {
id: uuid_1.v4(),
productId: product.id,
productCode: product.code,
productName: product.name,
categoryId: product.categoryId,
price: product.price,
discountPrice: product.discountPrice,
qty: 1,
img: product.img
};
this.cartItems.push(item);
this.updateCart();
this.notificationStore.notifySuccess(this.translationStore.t("cart.added", "{0} lisati {1}tk ostukorvi", [item.productName || "", item.qty.toString()]));
}
var item = {
id: uuid_1.v4(),
productId: product.id,
productCode: product.code,
productName: productName,
categoryId: product.categoryId,
price: product.price,
discountPrice: product.discountPrice,
qty: 1,
img: product.img
};
this.cartItems.push(item);
this.updateCart();
notificationStore.notifySuccess(translationStore.t("cart.added", "{0} lisati {1}tk ostukorvi", [item.productName || "", item.qty.toString()]));
};

@@ -215,2 +210,16 @@ CartStore.prototype.addToCart = function (product, qty) {

};
CartStore.prototype.validateQuickAddingToCart = function (product) {
var notificationStore = this.notificationStore;
var translationStore = this.translationStore;
if (product.hasParameters) {
notificationStore.notifyError(translationStore.t("product.has-parameters", "Toote täpsemate valikute tegemiseks palume minna detailvaatesse"));
return false;
}
var stock = product.stock;
if (stock && 1 > stock) {
notificationStore.notifyError(translationStore.t("product.out-of-stock", "Toodet {0} on saadaval ainult {1}", [product.name, stock.toString()]));
return false;
}
return true;
};
CartStore.prototype.validateAddingToCart = function (product, qty) {

@@ -217,0 +226,0 @@ var notificationStore = this.notificationStore;

import BaseStore from "./base-store";
import { IProductDetailsDto, IProductDto, IProductSearchDto } from "../models/product";
import { IListDto, IPropertyDto } from "../models/base";
import { IListDto, IPropertyDto, IQueryParams } from "../models/base";
export default class ProductStore extends BaseStore {

@@ -11,3 +11,3 @@ loadingMoreProducts: boolean;

product: IProductDetailsDto | undefined;
searchProducts(request: IProductSearchDto): Promise<void>;
searchProducts(request: IProductSearchDto, queryParams?: IQueryParams): Promise<void>;
loadMoreProducts(request: IProductSearchDto): Promise<void>;

@@ -14,0 +14,0 @@ getProductByRef(ref: string, refType: string): Promise<void>;

@@ -80,3 +80,3 @@ "use strict";

}
ProductStore.prototype.searchProducts = function (request) {
ProductStore.prototype.searchProducts = function (request, queryParams) {
return __awaiter(this, void 0, void 0, function () {

@@ -94,3 +94,3 @@ var notificationStore, result, data, e_1;

this.startLoading();
return [4 /*yield*/, this.rootStore.productApi.searchProducts(request)];
return [4 /*yield*/, this.rootStore.productApi.searchProducts(request, queryParams)];
case 2:

@@ -97,0 +97,0 @@ result = _a.sent();

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

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

@@ -16,2 +16,3 @@ import {IBaseDto, IPropertyDto} from "./base";

export interface IProductDto extends IProductBaseDto {
hasParameters: boolean,
img?: string

@@ -18,0 +19,0 @@ }

@@ -97,27 +97,21 @@ import BaseStore from "./base-store";

quickAddToCart(product: IProductDto) {
const notificationStore = this.notificationStore;
const translationStore = this.translationStore;
const stock = product.stock;
const productName = product.name;
const valid = this.validateQuickAddingToCart(product);
if (stock && 1 > stock) {
this.notificationStore.notifyError(translationStore.t("product.out-of-stock", "Toodet {0} on saadaval ainult {1}", [productName, stock.toString()]));
return;
}
if (valid) {
const item = {
id: v4(),
productId: product.id,
productCode: product.code,
productName: product.name,
categoryId: product.categoryId,
price: product.price,
discountPrice: product.discountPrice,
qty: 1,
img: product.img
}
const item = {
id: v4(),
productId: product.id,
productCode: product.code,
productName: productName,
categoryId: product.categoryId,
price: product.price,
discountPrice: product.discountPrice,
qty: 1,
img: product.img
this.cartItems.push(item);
this.updateCart();
this.notificationStore.notifySuccess(this.translationStore.t("cart.added", "{0} lisati {1}tk ostukorvi", [item.productName || "", item.qty.toString()]));
}
this.cartItems.push(item);
this.updateCart();
notificationStore.notifySuccess(translationStore.t("cart.added", "{0} lisati {1}tk ostukorvi", [item.productName || "", item.qty.toString()]));
}

@@ -241,2 +235,21 @@

private validateQuickAddingToCart(product: IProductDto): boolean {
const notificationStore = this.notificationStore;
const translationStore = this.translationStore;
if (product.hasParameters) {
notificationStore.notifyError(translationStore.t("product.has-parameters", "Toote täpsemate valikute tegemiseks palume minna detailvaatesse"));
return false;
}
const stock = product.stock;
if (stock && 1 > stock) {
notificationStore.notifyError(translationStore.t("product.out-of-stock", "Toodet {0} on saadaval ainult {1}", [product.name, stock.toString()]));
return false;
}
return true;
}
private validateAddingToCart(product: IProductDetailsDto, qty: number): boolean {

@@ -243,0 +256,0 @@ const notificationStore = this.notificationStore;

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

@@ -29,3 +29,3 @@ export default class ProductStore extends BaseStore {

async searchProducts(request: IProductSearchDto) {
async searchProducts(request: IProductSearchDto, queryParams?: IQueryParams) {
request.additionalProps = this.searchProps;

@@ -37,3 +37,3 @@ const notificationStore = this.notificationStore;

this.startLoading();
const result = await this.rootStore.productApi.searchProducts(request);
const result = await this.rootStore.productApi.searchProducts(request, queryParams);
const data = result.data;

@@ -40,0 +40,0 @@

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc