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 0.9.12 to 0.9.13

dist/api/shipping-api.d.ts

6

dist/models/shipping.d.ts

@@ -15,6 +15,10 @@ export interface IShippingMethodDto {

}
export interface IShippingPickupPointSearchDto {
countryCode: string | undefined;
provider: string | undefined;
}
export declare enum ShippingProviderEnum {
Dpd = "DPD",
Dpd = "Dpd",
Itella = "Itella",
Omniva = "Omniva"
}

2

dist/models/shipping.js

@@ -6,5 +6,5 @@ "use strict";

(function (ShippingProviderEnum) {
ShippingProviderEnum["Dpd"] = "DPD";
ShippingProviderEnum["Dpd"] = "Dpd";
ShippingProviderEnum["Itella"] = "Itella";
ShippingProviderEnum["Omniva"] = "Omniva";
})(ShippingProviderEnum = exports.ShippingProviderEnum || (exports.ShippingProviderEnum = {}));

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

countries: ICountryDto[];
selectedCountryId: number | undefined;
selectedCountry: ICountryDto | undefined;
getCountries(): Promise<void>;

@@ -15,2 +15,3 @@ searchMethods(request: IShippingSearchDto): Promise<void>;

private unsetCountry;
private initMethodSearch;
}

@@ -125,24 +125,20 @@ "use strict";

return __awaiter(this, void 0, void 0, function () {
var rootStore, shippingSearchRequest, categoryIds;
var country, shippingSearchRequest;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
rootStore = this.rootStore;
if (!id) return [3 /*break*/, 2];
this.setCountry(id);
shippingSearchRequest = {
countryId: this.selectedCountryId
};
categoryIds = rootStore.cartStore.cartItems.filter(function (x) { return x.categoryId; }).map(function (item) {
return item.categoryId || 0;
});
shippingSearchRequest.categoryIds = categoryIds;
if (!id) return [3 /*break*/, 3];
country = this.countries.find(function (x) { return x.id === id; });
if (!country) return [3 /*break*/, 2];
this.setCountry(country);
shippingSearchRequest = this.initMethodSearch();
return [4 /*yield*/, this.searchMethods(shippingSearchRequest)];
case 1:
_a.sent();
return [3 /*break*/, 3];
case 2:
_a.label = 2;
case 2: return [3 /*break*/, 4];
case 3:
this.unsetCountry();
_a.label = 3;
case 3: return [2 /*return*/];
_a.label = 4;
case 4: return [2 /*return*/];
}

@@ -159,9 +155,19 @@ });

};
CountryStore.prototype.setCountry = function (countryId) {
this.selectedCountryId = countryId;
CountryStore.prototype.setCountry = function (country) {
this.selectedCountry = country;
};
CountryStore.prototype.unsetCountry = function () {
this.selectedCountryId = undefined;
this.selectedCountry = undefined;
this.rootStore.shippingStore.unsetMethods();
};
CountryStore.prototype.initMethodSearch = function () {
var _a;
var shippingSearchRequest = {
countryId: (_a = this.selectedCountry) === null || _a === void 0 ? void 0 : _a.id
};
shippingSearchRequest.categoryIds = this.rootStore.cartStore.cartItems.filter(function (x) { return x.categoryId; }).map(function (item) {
return item.categoryId || 0;
});
return shippingSearchRequest;
};
__decorate([

@@ -172,3 +178,3 @@ mobx_1.observable

mobx_1.observable
], CountryStore.prototype, "selectedCountryId", void 0);
], CountryStore.prototype, "selectedCountry", void 0);
__decorate([

@@ -175,0 +181,0 @@ mobx_1.action

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

translationStore = this.translationStore;
if (!rootStore.countryStore.selectedCountryId) {
if (!rootStore.countryStore.selectedCountry) {
notificationStore.notifyError(translationStore.t("order.choose-country", "Palun valige riik"));

@@ -120,7 +120,7 @@ return [2 /*return*/, undefined];

OrderStore.prototype.initOrder = function (order) {
var _a, _b;
var _a, _b, _c;
var rootStore = this.rootStore;
order.paymentMethod = (_a = rootStore.companyStore.selectedPaymentProvider) === null || _a === void 0 ? void 0 : _a.name;
order.shipping.countryId = rootStore.countryStore.selectedCountryId;
order.shipping.methodId = (_b = rootStore.shippingStore.selectedMethod) === null || _b === void 0 ? void 0 : _b.methodId;
order.shipping.countryId = (_b = rootStore.countryStore.selectedCountry) === null || _b === void 0 ? void 0 : _b.id;
order.shipping.methodId = (_c = rootStore.shippingStore.selectedMethod) === null || _c === void 0 ? void 0 : _c.methodId;
order.items = rootStore.cartStore.cartItems.map(function (item) {

@@ -127,0 +127,0 @@ return {

@@ -13,2 +13,3 @@ import NotificationStore from "./notification-store";

import TranslationStore from "./translation-store";
import ShippingApi from "../api/shipping-api";
interface IRootStore {

@@ -37,4 +38,5 @@ cartStore: CartStore;

productApi: ProductApi;
shippingApi: ShippingApi;
constructor();
}
export {};

@@ -38,2 +38,3 @@ "use strict";

var translation_store_1 = __importDefault(require("./translation-store"));
var shipping_api_1 = __importDefault(require("../api/shipping-api"));
var RootStore = /** @class */ (function () {

@@ -56,2 +57,3 @@ function RootStore() {

this.productApi = new product_api_1.default();
this.shippingApi = new shipping_api_1.default();
}

@@ -58,0 +60,0 @@ return RootStore;

@@ -5,6 +5,12 @@ import BaseStore from "./base-store";

methods: IShippingMethodDto[];
pickupPoints: string[];
selectedMethod: IShippingMethodDto | undefined;
selectMethod(id: number): void;
selectedPickupPoint: string | undefined;
searchPickupPoints(): Promise<void>;
selectMethod(id: number): Promise<void>;
setMethods(methods: IShippingMethodDto[]): void;
unsetMethods(): void;
private unsetMethod;
private setPickupPoints;
private unsetPickupPoints;
}

@@ -23,2 +23,38 @@ "use strict";

};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -35,9 +71,68 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

_this.methods = [];
_this.pickupPoints = [];
return _this;
}
ShippingStore.prototype.searchPickupPoints = function () {
var _a, _b;
return __awaiter(this, void 0, void 0, function () {
var rootStore, notificationStore, request, result, data, e_1;
return __generator(this, function (_c) {
switch (_c.label) {
case 0:
rootStore = this.rootStore;
notificationStore = this.notificationStore;
request = {
countryCode: (_a = rootStore.countryStore.selectedCountry) === null || _a === void 0 ? void 0 : _a.code,
provider: (_b = this.selectedMethod) === null || _b === void 0 ? void 0 : _b.provider
};
_c.label = 1;
case 1:
_c.trys.push([1, 3, 4, 5]);
this.startLoading();
return [4 /*yield*/, rootStore.shippingApi.searchPickupPoints(request)];
case 2:
result = _c.sent();
data = result.data;
if (data.valid) {
this.setPickupPoints(data.result);
}
else {
notificationStore.notifyErrors(data.errors);
}
return [3 /*break*/, 5];
case 3:
e_1 = _c.sent();
notificationStore.notifyError(e_1);
return [3 /*break*/, 5];
case 4:
this.finishLoading();
return [7 /*endfinally*/];
case 5: return [2 /*return*/];
}
});
});
};
ShippingStore.prototype.selectMethod = function (id) {
var matchingMethod = this.methods.find(function (x) { return x.methodId === id; });
if (matchingMethod) {
this.selectedMethod = matchingMethod;
}
return __awaiter(this, void 0, void 0, function () {
var matchingMethod;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
if (!id) return [3 /*break*/, 3];
matchingMethod = this.methods.find(function (x) { return x.methodId === id; });
if (!matchingMethod) return [3 /*break*/, 2];
this.selectedMethod = matchingMethod;
if (!this.selectedMethod.provider) return [3 /*break*/, 2];
return [4 /*yield*/, this.searchPickupPoints()];
case 1:
_a.sent();
_a.label = 2;
case 2: return [3 /*break*/, 4];
case 3:
this.unsetMethod();
_a.label = 4;
case 4: return [2 /*return*/];
}
});
});
};

@@ -50,3 +145,15 @@ ShippingStore.prototype.setMethods = function (methods) {

this.selectedMethod = undefined;
this.unsetPickupPoints();
};
ShippingStore.prototype.unsetMethod = function () {
this.selectedMethod = undefined;
this.unsetPickupPoints();
};
ShippingStore.prototype.setPickupPoints = function (pickupPoints) {
this.pickupPoints = pickupPoints;
};
ShippingStore.prototype.unsetPickupPoints = function () {
this.pickupPoints = [];
this.selectedPickupPoint = undefined;
};
__decorate([

@@ -57,4 +164,10 @@ mobx_1.observable

mobx_1.observable
], ShippingStore.prototype, "pickupPoints", void 0);
__decorate([
mobx_1.observable
], ShippingStore.prototype, "selectedMethod", void 0);
__decorate([
mobx_1.observable
], ShippingStore.prototype, "selectedPickupPoint", void 0);
__decorate([
mobx_1.action

@@ -68,4 +181,13 @@ ], ShippingStore.prototype, "selectMethod", null);

], ShippingStore.prototype, "unsetMethods", null);
__decorate([
mobx_1.action
], ShippingStore.prototype, "unsetMethod", null);
__decorate([
mobx_1.action
], ShippingStore.prototype, "setPickupPoints", null);
__decorate([
mobx_1.action
], ShippingStore.prototype, "unsetPickupPoints", null);
return ShippingStore;
}(base_store_1.default));
exports.default = ShippingStore;
{
"name": "vanilli-shop-client",
"version": "0.9.12",
"version": "0.9.13",
"description": "Client for Vanilli Shop API",

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

@@ -17,6 +17,11 @@ export interface IShippingMethodDto {

export interface IShippingPickupPointSearchDto {
countryCode: string | undefined,
provider: string | undefined
}
export enum ShippingProviderEnum {
Dpd = "DPD",
Dpd = "Dpd",
Itella = "Itella",
Omniva = "Omniva"
}

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

@observable
selectedCountryId: number | undefined;
selectedCountry: ICountryDto | undefined;

@@ -40,17 +40,10 @@ async getCountries() {

async selectCountry(id: number) {
const rootStore = this.rootStore;
if (id) {
this.setCountry(id);
const country = this.countries.find(x => x.id === id);
const shippingSearchRequest: IShippingSearchDto = {
countryId: this.selectedCountryId
if (country) {
this.setCountry(country);
const shippingSearchRequest = this.initMethodSearch();
await this.searchMethods(shippingSearchRequest);
}
const categoryIds = rootStore.cartStore.cartItems.filter(x => x.categoryId).map((item) => {
return item.categoryId || 0;
});
shippingSearchRequest.categoryIds = categoryIds;
await this.searchMethods(shippingSearchRequest);
} else {

@@ -73,4 +66,4 @@ this.unsetCountry();

@action
private setCountry(countryId: number) {
this.selectedCountryId = countryId;
private setCountry(country: ICountryDto) {
this.selectedCountry = country;
}

@@ -80,5 +73,17 @@

private unsetCountry() {
this.selectedCountryId = undefined;
this.selectedCountry = undefined;
this.rootStore.shippingStore.unsetMethods();
}
private initMethodSearch(): IShippingSearchDto {
const shippingSearchRequest: IShippingSearchDto = {
countryId: this.selectedCountry?.id
}
shippingSearchRequest.categoryIds = this.rootStore.cartStore.cartItems.filter(x => x.categoryId).map((item) => {
return item.categoryId || 0;
});
return shippingSearchRequest;
}
}

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

if (!rootStore.countryStore.selectedCountryId) {
if (!rootStore.countryStore.selectedCountry) {
notificationStore.notifyError(translationStore.t("order.choose-country", "Palun valige riik"));

@@ -56,3 +56,3 @@ return undefined;

order.paymentMethod = rootStore.companyStore.selectedPaymentProvider?.name;
order.shipping.countryId = rootStore.countryStore.selectedCountryId;
order.shipping.countryId = rootStore.countryStore.selectedCountry?.id;
order.shipping.methodId = rootStore.shippingStore.selectedMethod?.methodId;

@@ -59,0 +59,0 @@

@@ -14,2 +14,3 @@ import * as mobx from "mobx";

import TranslationStore from "./translation-store";
import ShippingApi from "../api/shipping-api";

@@ -40,2 +41,3 @@ interface IRootStore {

productApi: ProductApi;
shippingApi: ShippingApi;

@@ -59,3 +61,4 @@ constructor() {

this.productApi = new ProductApi();
this.shippingApi = new ShippingApi();
}
}

@@ -10,10 +10,50 @@ import BaseStore from "./base-store";

@observable
pickupPoints: string[] = [];
@observable
selectedMethod: IShippingMethodDto | undefined;
@observable
selectedPickupPoint: string | undefined;
async searchPickupPoints() {
const rootStore = this.rootStore;
const notificationStore = this.notificationStore;
const request = {
countryCode: rootStore.countryStore.selectedCountry?.code,
provider: this.selectedMethod?.provider
};
try {
this.startLoading();
const result = await rootStore.shippingApi.searchPickupPoints(request);
const data = result.data;
if (data.valid) {
this.setPickupPoints(data.result);
} else {
notificationStore.notifyErrors(data.errors);
}
} catch (e) {
notificationStore.notifyError(e);
} finally {
this.finishLoading();
}
}
@action
selectMethod(id: number) {
const matchingMethod = this.methods.find(x => x.methodId === id);
async selectMethod(id: number) {
if (id) {
const matchingMethod = this.methods.find(x => x.methodId === id);
if (matchingMethod) {
this.selectedMethod = matchingMethod;
if (matchingMethod) {
this.selectedMethod = matchingMethod;
if (this.selectedMethod.provider) {
await this.searchPickupPoints();
}
}
} else {
this.unsetMethod()
}

@@ -31,3 +71,21 @@ }

this.selectedMethod = undefined;
this.unsetPickupPoints();
}
@action
private unsetMethod() {
this.selectedMethod = undefined;
this.unsetPickupPoints();
}
@action
private setPickupPoints(pickupPoints: string[]) {
this.pickupPoints = pickupPoints;
}
@action
private unsetPickupPoints() {
this.pickupPoints = [];
this.selectedPickupPoint = undefined;
}
}
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