ng-easycommerce 0.0.571 → 0.0.573
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -0
- package/assets/ec-i18n/ct.json +2 -1
- package/assets/ec-i18n/en.json +2 -1
- package/assets/ec-i18n/es.json +2 -1
- package/assets/ec-i18n/fr.json +2 -1
- package/assets/ec-i18n/gl.json +2 -1
- package/assets/ec-i18n/pr.json +2 -1
- package/bundles/ng-easycommerce.umd.js +202 -8
- package/bundles/ng-easycommerce.umd.js.map +1 -1
- package/bundles/ng-easycommerce.umd.min.js +1 -1
- package/bundles/ng-easycommerce.umd.min.js.map +1 -1
- package/esm2015/lib/ec-component/build-your-ec/build-your-ec.component.js +2 -2
- package/esm2015/lib/ec-component/cart-ec/cart-ec.component.js +60 -3
- package/esm2015/lib/ec-component/header-ec/header-ec.component.js +7 -1
- package/esm2015/lib/services/cart.service.js +66 -2
- package/esm2015/lib/services/products/product-detail.service.js +29 -1
- package/esm5/lib/ec-component/build-your-ec/build-your-ec.component.js +2 -2
- package/esm5/lib/ec-component/cart-ec/cart-ec.component.js +94 -3
- package/esm5/lib/ec-component/header-ec/header-ec.component.js +8 -1
- package/esm5/lib/services/cart.service.js +70 -2
- package/esm5/lib/services/products/product-detail.service.js +29 -1
- package/fesm2015/ng-easycommerce.js +159 -4
- package/fesm2015/ng-easycommerce.js.map +1 -1
- package/fesm5/ng-easycommerce.js +202 -8
- package/fesm5/ng-easycommerce.js.map +1 -1
- package/lib/ec-component/cart-ec/cart-ec.component.d.ts +6 -3
- package/lib/ec-component/header-ec/header-ec.component.d.ts +3 -0
- package/lib/services/cart.service.d.ts +19 -0
- package/lib/services/products/product-detail.service.d.ts +9 -3
- package/ng-easycommerce.metadata.json +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
# version 0.0.573
|
|
2
|
+
- Se modifica y se agrega funcion para actualizar el stock y cambie al disponible en caso de que sea mayor. Tambien lo elimina en caso de que el stock sea 0.
|
|
3
|
+
# version 0.0.572
|
|
4
|
+
- Se implementó la lógica para gestionar un observable `balanceCustomerSubject` en `cart.service` que contiene los datos referentes al crédito del usuario.
|
|
5
|
+
- Se añadió la validaciónes en `cart.service` y `product-detail`, para verificar si el usuario tiene suficientes créditos antes de continuar con la compra.
|
|
6
|
+
- Se mostraron mensajes de retroalimentación para casos de créditos insuficientes.
|
|
7
|
+
- Se modifica `build-your-ec.component.html` para que permita retroceder en los pasos.
|
|
1
8
|
# version 0.0.571
|
|
2
9
|
- Update Bancard Version
|
|
3
10
|
# version 0.0.570
|
package/assets/ec-i18n/ct.json
CHANGED
|
@@ -273,5 +273,6 @@
|
|
|
273
273
|
"will_contact": "Un cop percebuda la transferència, ens posarem en contacte amb vostè per informar l'estat de la seva compra",
|
|
274
274
|
"date": "Data",
|
|
275
275
|
"repeat-order": "Repetir comanda",
|
|
276
|
-
"no-products-to-add": "No hi ha productes per afegir"
|
|
276
|
+
"no-products-to-add": "No hi ha productes per afegir",
|
|
277
|
+
"not-enough-credits": "No té prou crèdits per comprar aquest producte"
|
|
277
278
|
}
|
package/assets/ec-i18n/en.json
CHANGED
|
@@ -375,5 +375,6 @@
|
|
|
375
375
|
"instructions": "Instructions",
|
|
376
376
|
"error-convertibility": "Convertibility error. Try again later.",
|
|
377
377
|
"repeat-order": "Repeat order",
|
|
378
|
-
"no-products-to-add": "You have no products to add"
|
|
378
|
+
"no-products-to-add": "You have no products to add",
|
|
379
|
+
"not-enough-credits": "You do not have enough credits to make this purchase."
|
|
379
380
|
}
|
package/assets/ec-i18n/es.json
CHANGED
|
@@ -380,5 +380,6 @@
|
|
|
380
380
|
"success-review": "Su reseña fue enviada",
|
|
381
381
|
"error-convertibility": "Se produjo un error al realizar la conversión",
|
|
382
382
|
"repeat-order": "Repetir pedido",
|
|
383
|
-
"no-products-to-add": "No hay productos para agregar"
|
|
383
|
+
"no-products-to-add": "No hay productos para agregar",
|
|
384
|
+
"not-enough-credits": "No tiene suficientes créditos para comprar este producto"
|
|
384
385
|
}
|
package/assets/ec-i18n/fr.json
CHANGED
|
@@ -265,5 +265,6 @@
|
|
|
265
265
|
"will_contact": "Une fois le virement reçu, nous vous contacterons pour vous informer de l'état de votre achat",
|
|
266
266
|
"date": "Date",
|
|
267
267
|
"repeat-order": "Répéter la commande",
|
|
268
|
-
"no-products-to-add": "Aucun produit à ajouter"
|
|
268
|
+
"no-products-to-add": "Aucun produit à ajouter",
|
|
269
|
+
"not-enough-credits": "Vous n'avez pas assez de crédits pour acheter ce produit"
|
|
269
270
|
}
|
package/assets/ec-i18n/gl.json
CHANGED
|
@@ -273,5 +273,6 @@
|
|
|
273
273
|
"will_contact": "Unha vez recibida a transferencia, porémonos en contacto con vostede para informarche do estado da súa compra",
|
|
274
274
|
"date": "Data",
|
|
275
275
|
"repeat-order": "Repetir pedido",
|
|
276
|
-
"no-products-to-add": "Non hai produtos para engadir"
|
|
276
|
+
"no-products-to-add": "Non hai produtos para engadir",
|
|
277
|
+
"not-enough-credits": "Non ten suficientes créditos para realizar a compra"
|
|
277
278
|
}
|
package/assets/ec-i18n/pr.json
CHANGED
|
@@ -273,5 +273,6 @@
|
|
|
273
273
|
"will_contact": "Assim que a transferência for recebida, entraremos em contato para informá-lo sobre o status de sua compra",
|
|
274
274
|
"date": "Encontro",
|
|
275
275
|
"repeat-order": "Repetir pedido",
|
|
276
|
-
"no-products-to-add": "Não há produtos para adicionar"
|
|
276
|
+
"no-products-to-add": "Não há produtos para adicionar",
|
|
277
|
+
"not-enough-credits": "Você não tem créditos suficientes para fazer essa compra"
|
|
277
278
|
}
|
|
@@ -4524,6 +4524,14 @@
|
|
|
4524
4524
|
this.cartSubject = new rxjs.BehaviorSubject(null);
|
|
4525
4525
|
this.requestInProcess = new rxjs.BehaviorSubject(false);
|
|
4526
4526
|
this.promotionsSubject = new rxjs.BehaviorSubject([]);
|
|
4527
|
+
this.balanceCustomerSubject = new rxjs.BehaviorSubject({
|
|
4528
|
+
allowAnyPaymentMethod: false,
|
|
4529
|
+
allowExceedBalance: false,
|
|
4530
|
+
creditAmount: 0,
|
|
4531
|
+
showMax: false,
|
|
4532
|
+
showPrice: false,
|
|
4533
|
+
remainingCredits: 0,
|
|
4534
|
+
});
|
|
4527
4535
|
this.items = [];
|
|
4528
4536
|
this.count = 0;
|
|
4529
4537
|
this.locale = "";
|
|
@@ -4545,6 +4553,12 @@
|
|
|
4545
4553
|
this.cart = this.cartSubject.asObservable();
|
|
4546
4554
|
this.promotions = this.promotionsSubject.asObservable();
|
|
4547
4555
|
this.deleting = false;
|
|
4556
|
+
this.balanceCustomer$ = this.balanceCustomerSubject.asObservable();
|
|
4557
|
+
this.allowAnyPaymentMethod$ = this.balanceCustomer$.pipe(operators.map(function (data) { return data.allowAnyPaymentMethod; }));
|
|
4558
|
+
this.allowExceedBalance$ = this.balanceCustomer$.pipe(operators.map(function (data) { return data.allowExceedBalance; }));
|
|
4559
|
+
this.creditAmount$ = this.balanceCustomer$.pipe(operators.map(function (data) { return data.creditAmount; }));
|
|
4560
|
+
this.showMax$ = this.balanceCustomer$.pipe(operators.map(function (data) { return data.showMax; }));
|
|
4561
|
+
this.showPrice$ = this.balanceCustomer$.pipe(operators.map(function (data) { return data.showPrice; }));
|
|
4548
4562
|
this.getAddressBook = function () { return __awaiter$5(_this, void 0, void 0, function () { return __generator$5(this, function (_a) {
|
|
4549
4563
|
return [2 /*return*/, this.connection.get(this.addressBookApi()).pipe(operators.map(function (res) { var _a; return ((_a = res) === null || _a === void 0 ? void 0 : _a.length) && res.map(function (addres) { return addres && __assign$9(__assign$9({}, addres), { selected: addres.default }); }) || null; })).toPromise()];
|
|
4550
4564
|
}); }); };
|
|
@@ -4654,6 +4668,7 @@
|
|
|
4654
4668
|
this.resetCart = function (next) {
|
|
4655
4669
|
_this.items = [];
|
|
4656
4670
|
_this.cartSubject.next(null);
|
|
4671
|
+
_this.updateBalanceAttributes(null);
|
|
4657
4672
|
_this.cart_token = null;
|
|
4658
4673
|
_this.cartItemsSubject.next([]);
|
|
4659
4674
|
_this.count = 0;
|
|
@@ -4664,6 +4679,7 @@
|
|
|
4664
4679
|
this.updateCartObj = function (cart, emitEvent) {
|
|
4665
4680
|
if (emitEvent === void 0) { emitEvent = true; }
|
|
4666
4681
|
_this.cartSubject.next(cart);
|
|
4682
|
+
_this.updateBalanceAttributes(cart);
|
|
4667
4683
|
emitEvent && _this.analyticsService.callEvent('add_to_cart', cart);
|
|
4668
4684
|
_this.promotionsSubject.next(_this.orderUtils.getPromotions(cart, true));
|
|
4669
4685
|
cart.couponCode
|
|
@@ -4770,7 +4786,7 @@
|
|
|
4770
4786
|
return __spread$3(items, paramsMerge);
|
|
4771
4787
|
};
|
|
4772
4788
|
this.updateItemQuantity = function (item, quantity) {
|
|
4773
|
-
if (_this.validateQuantity(item, quantity)) {
|
|
4789
|
+
if (_this.validateQuantity(item, quantity) && (_this.validatePriceAndCredits(item, quantity))) {
|
|
4774
4790
|
_this.connection.put(_this.updateItemQuantityApi(_this.findItemByIdVariant(item.variant_id)), { 'quantity': Number(quantity) }).subscribe(function (res) { return _this.updateCartObj(res) && _this.updateCartItemQuantity(item.variant_id, Number(quantity)); }, function (err) { return _this.handleError(err); });
|
|
4775
4791
|
}
|
|
4776
4792
|
};
|
|
@@ -4785,6 +4801,38 @@
|
|
|
4785
4801
|
}
|
|
4786
4802
|
return true;
|
|
4787
4803
|
};
|
|
4804
|
+
this.validatePriceAndCredits = function (item, quantity) {
|
|
4805
|
+
if (_this.balanceCustomerSubject.value.creditAmount === null) {
|
|
4806
|
+
return true;
|
|
4807
|
+
}
|
|
4808
|
+
if (_this.balanceCustomerSubject.value.remainingCredits === undefined) {
|
|
4809
|
+
return false;
|
|
4810
|
+
}
|
|
4811
|
+
var unitPrice = item.total / item.quantity;
|
|
4812
|
+
var additionalQuantity = quantity - item.quantity;
|
|
4813
|
+
if (additionalQuantity <= 0) {
|
|
4814
|
+
return true;
|
|
4815
|
+
}
|
|
4816
|
+
var additionalCost = unitPrice * additionalQuantity;
|
|
4817
|
+
if (additionalCost > _this.balanceCustomerSubject.value.remainingCredits) {
|
|
4818
|
+
_this.toastrService.show('not-enough-credits');
|
|
4819
|
+
return false;
|
|
4820
|
+
}
|
|
4821
|
+
return true;
|
|
4822
|
+
};
|
|
4823
|
+
this.hasSufficientCreditsForCartTotal = function () {
|
|
4824
|
+
if (_this.balanceCustomerSubject.value.creditAmount === null) {
|
|
4825
|
+
return true;
|
|
4826
|
+
}
|
|
4827
|
+
if (_this.balanceCustomerSubject.value.remainingCredits === undefined) {
|
|
4828
|
+
return false;
|
|
4829
|
+
}
|
|
4830
|
+
if (_this.cartSubject.value.totals.total > _this.balanceCustomerSubject.value.creditAmount) {
|
|
4831
|
+
_this.toastrService.show('not-enough-credits');
|
|
4832
|
+
return false;
|
|
4833
|
+
}
|
|
4834
|
+
return true;
|
|
4835
|
+
};
|
|
4788
4836
|
this.calculateStockCounts = function (item, quantity) {
|
|
4789
4837
|
if (item.product.stock < item.quantity + quantity) {
|
|
4790
4838
|
// this.toastrService.show('out-of-stock');
|
|
@@ -4930,6 +4978,12 @@
|
|
|
4930
4978
|
// }, 100);
|
|
4931
4979
|
return item;
|
|
4932
4980
|
}); };
|
|
4981
|
+
this.getCreditAmount = function () {
|
|
4982
|
+
return _this.balanceCustomerSubject.pipe(operators.map(function (balanceCustomer) { var _a, _b; return _b = (_a = balanceCustomer) === null || _a === void 0 ? void 0 : _a.creditAmount, (_b !== null && _b !== void 0 ? _b : null); }));
|
|
4983
|
+
};
|
|
4984
|
+
this.getRemainingCredits = function () {
|
|
4985
|
+
return _this.balanceCustomerSubject.pipe(operators.map(function (balanceCustomer) { var _a; return (_a = balanceCustomer) === null || _a === void 0 ? void 0 : _a.remainingCredits; }));
|
|
4986
|
+
};
|
|
4933
4987
|
this.requestInProcess.next(true);
|
|
4934
4988
|
this.items = JSON.parse(localStorage.getItem('cart')) || [];
|
|
4935
4989
|
this.cart_token = localStorage.getItem('cart_token') || null;
|
|
@@ -5003,6 +5057,20 @@
|
|
|
5003
5057
|
return subtotal - total;
|
|
5004
5058
|
}));
|
|
5005
5059
|
};
|
|
5060
|
+
CartService$1.prototype.updateBalanceAttributes = function (cartData) {
|
|
5061
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
5062
|
+
var balanceData = {
|
|
5063
|
+
allowAnyPaymentMethod: (_b = (_a = cartData) === null || _a === void 0 ? void 0 : _a.allowAnyPaymentMethod, (_b !== null && _b !== void 0 ? _b : false)),
|
|
5064
|
+
allowExceedBalance: (_d = (_c = cartData) === null || _c === void 0 ? void 0 : _c.allowExceedBalance, (_d !== null && _d !== void 0 ? _d : false)),
|
|
5065
|
+
creditAmount: (_f = (_e = cartData) === null || _e === void 0 ? void 0 : _e.creditAmount, (_f !== null && _f !== void 0 ? _f : null)),
|
|
5066
|
+
showMax: (_h = (_g = cartData) === null || _g === void 0 ? void 0 : _g.showMax, (_h !== null && _h !== void 0 ? _h : false)),
|
|
5067
|
+
showPrice: (_k = (_j = cartData) === null || _j === void 0 ? void 0 : _j.showPrice, (_k !== null && _k !== void 0 ? _k : false)),
|
|
5068
|
+
remainingCredits: ((_l = cartData) === null || _l === void 0 ? void 0 : _l.creditAmount) && ((_m = cartData) === null || _m === void 0 ? void 0 : _m.creditAmount) >= ((_o = cartData) === null || _o === void 0 ? void 0 : _o.totals.total)
|
|
5069
|
+
? ((_p = cartData) === null || _p === void 0 ? void 0 : _p.creditAmount) - ((_q = cartData) === null || _q === void 0 ? void 0 : _q.totals.total)
|
|
5070
|
+
: 0,
|
|
5071
|
+
};
|
|
5072
|
+
this.balanceCustomerSubject.next(balanceData);
|
|
5073
|
+
};
|
|
5006
5074
|
CartService$1.ctorParameters = function () { return [
|
|
5007
5075
|
{ type: ConnectionService },
|
|
5008
5076
|
{ type: ToastService },
|
|
@@ -7179,6 +7247,17 @@
|
|
|
7179
7247
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
7180
7248
|
}
|
|
7181
7249
|
};
|
|
7250
|
+
var __values = (this && this.__values) || function(o) {
|
|
7251
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
7252
|
+
if (m) return m.call(o);
|
|
7253
|
+
if (o && typeof o.length === "number") return {
|
|
7254
|
+
next: function () {
|
|
7255
|
+
if (o && i >= o.length) o = void 0;
|
|
7256
|
+
return { value: o && o[i++], done: !o };
|
|
7257
|
+
}
|
|
7258
|
+
};
|
|
7259
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
7260
|
+
};
|
|
7182
7261
|
var CartEcComponent = /** @class */ (function (_super) {
|
|
7183
7262
|
__extends$g(CartEcComponent, _super);
|
|
7184
7263
|
function CartEcComponent(cartService, authService, consts, productsService, router, modalService, toastrService, addressingService) {
|
|
@@ -7197,6 +7276,8 @@
|
|
|
7197
7276
|
_this.promotions = [];
|
|
7198
7277
|
_this.cargando = false;
|
|
7199
7278
|
_this.channel = {};
|
|
7279
|
+
_this.updateStock = false;
|
|
7280
|
+
_this.exitUpdate = false;
|
|
7200
7281
|
_this.toDecimal = function (amount) { return _this.consts.toDecimal(amount); };
|
|
7201
7282
|
_this.actualizarCantidad = function (item, cantidad, stock, id) {
|
|
7202
7283
|
if (id) {
|
|
@@ -7208,7 +7289,14 @@
|
|
|
7208
7289
|
cantidad > 0 && cantidad <= stock ? _this.cartService.updateItemQuantity(item, cantidad) : _this.toastrService.show('out-of-stock-actually');
|
|
7209
7290
|
}
|
|
7210
7291
|
};
|
|
7211
|
-
_this.redirectCheckout = function () {
|
|
7292
|
+
_this.redirectCheckout = function () {
|
|
7293
|
+
if (_this.cartService.hasSufficientCreditsForCartTotal()) {
|
|
7294
|
+
_this.router.navigateByUrl("/checkout");
|
|
7295
|
+
}
|
|
7296
|
+
else {
|
|
7297
|
+
console.warn("No se puede redirigir al checkout debido a una validación fallida.");
|
|
7298
|
+
}
|
|
7299
|
+
};
|
|
7212
7300
|
_this.redirectRegister = function () { return _this.router.navigateByUrl("/auth/login"); };
|
|
7213
7301
|
_this.getVariants = function (product) {
|
|
7214
7302
|
var item = product.product;
|
|
@@ -7444,7 +7532,78 @@
|
|
|
7444
7532
|
$('#' + id).modal('hide');
|
|
7445
7533
|
};
|
|
7446
7534
|
CartEcComponent.prototype.checkStock = function (item) {
|
|
7447
|
-
|
|
7535
|
+
var e_1, _a;
|
|
7536
|
+
try {
|
|
7537
|
+
for (var _b = __values(item.product.variants), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
7538
|
+
var variant = _c.value;
|
|
7539
|
+
if (item.variant_id === variant.code) {
|
|
7540
|
+
if (variant.stock === 0) {
|
|
7541
|
+
this.updateStock = true;
|
|
7542
|
+
return '0';
|
|
7543
|
+
}
|
|
7544
|
+
else if (item.quantity > variant.stock) {
|
|
7545
|
+
this.updateStock = true;
|
|
7546
|
+
return variant.stock;
|
|
7547
|
+
}
|
|
7548
|
+
}
|
|
7549
|
+
}
|
|
7550
|
+
}
|
|
7551
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
7552
|
+
finally {
|
|
7553
|
+
try {
|
|
7554
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
7555
|
+
}
|
|
7556
|
+
finally { if (e_1) throw e_1.error; }
|
|
7557
|
+
}
|
|
7558
|
+
return false; // Solo se ejecuta si no se cumple la condición
|
|
7559
|
+
};
|
|
7560
|
+
CartEcComponent.prototype.updateAllStock = function () {
|
|
7561
|
+
var _this = this;
|
|
7562
|
+
var items = [];
|
|
7563
|
+
// Define la suscripción antes de usarla
|
|
7564
|
+
this.cartService.cartItems.subscribe(function (res) {
|
|
7565
|
+
res.forEach(function (item) {
|
|
7566
|
+
var e_2, _a;
|
|
7567
|
+
try {
|
|
7568
|
+
for (var _b = __values(item.product.variants), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
7569
|
+
var variant = _c.value;
|
|
7570
|
+
if (item.variant_id === variant.code && !_this.exitUpdate) {
|
|
7571
|
+
if (variant.stock === 0) {
|
|
7572
|
+
_this.cartService.deleteCartItem(item, false); // Borra el artículo
|
|
7573
|
+
}
|
|
7574
|
+
else if (item.quantity > variant.stock) {
|
|
7575
|
+
items.push({
|
|
7576
|
+
productCode: item.product.id,
|
|
7577
|
+
quantity: variant.stock,
|
|
7578
|
+
variantCode: variant.code,
|
|
7579
|
+
});
|
|
7580
|
+
}
|
|
7581
|
+
else {
|
|
7582
|
+
items.push({
|
|
7583
|
+
productCode: item.product.id,
|
|
7584
|
+
quantity: item.quantity,
|
|
7585
|
+
variantCode: variant.code,
|
|
7586
|
+
});
|
|
7587
|
+
}
|
|
7588
|
+
}
|
|
7589
|
+
}
|
|
7590
|
+
}
|
|
7591
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
7592
|
+
finally {
|
|
7593
|
+
try {
|
|
7594
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
7595
|
+
}
|
|
7596
|
+
finally { if (e_2) throw e_2.error; }
|
|
7597
|
+
}
|
|
7598
|
+
});
|
|
7599
|
+
if (items.length > 0 && !_this.exitUpdate) {
|
|
7600
|
+
// subscription.unsubscribe(); // Desuscríbete antes de actualizar
|
|
7601
|
+
_this.cartService.addAllToCart(items); // Actualiza el carrito
|
|
7602
|
+
_this.updateStock = false;
|
|
7603
|
+
_this.exitUpdate = true;
|
|
7604
|
+
// this.updateAllStock(); // Vuelve a verificar el stock
|
|
7605
|
+
}
|
|
7606
|
+
});
|
|
7448
7607
|
};
|
|
7449
7608
|
CartEcComponent.prototype.createDiscountMessage = function (saleprice, price) {
|
|
7450
7609
|
if (isNaN(saleprice) || isNaN(price) || saleprice >= price || saleprice <= 0 || price <= 0) {
|
|
@@ -8230,7 +8389,7 @@
|
|
|
8230
8389
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
8231
8390
|
}
|
|
8232
8391
|
};
|
|
8233
|
-
var __values = (this && this.__values) || function(o) {
|
|
8392
|
+
var __values$1 = (this && this.__values) || function(o) {
|
|
8234
8393
|
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
8235
8394
|
if (m) return m.call(o);
|
|
8236
8395
|
if (o && typeof o.length === "number") return {
|
|
@@ -8335,7 +8494,7 @@
|
|
|
8335
8494
|
var e_1, _a;
|
|
8336
8495
|
var parent = e.target.parentElement.children;
|
|
8337
8496
|
try {
|
|
8338
|
-
for (var parent_1 = __values(parent), parent_1_1 = parent_1.next(); !parent_1_1.done; parent_1_1 = parent_1.next()) {
|
|
8497
|
+
for (var parent_1 = __values$1(parent), parent_1_1 = parent_1.next(); !parent_1_1.done; parent_1_1 = parent_1.next()) {
|
|
8339
8498
|
var button = parent_1_1.value;
|
|
8340
8499
|
if (button.classList.contains('active')) {
|
|
8341
8500
|
button.classList.remove('active');
|
|
@@ -8404,7 +8563,7 @@
|
|
|
8404
8563
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
8405
8564
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
8406
8565
|
};
|
|
8407
|
-
var __values$
|
|
8566
|
+
var __values$2 = (this && this.__values) || function(o) {
|
|
8408
8567
|
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
8409
8568
|
if (m) return m.call(o);
|
|
8410
8569
|
if (o && typeof o.length === "number") return {
|
|
@@ -8493,7 +8652,7 @@
|
|
|
8493
8652
|
var e_1, _a;
|
|
8494
8653
|
var parent = e.target.parentElement.children;
|
|
8495
8654
|
try {
|
|
8496
|
-
for (var parent_1 = __values$
|
|
8655
|
+
for (var parent_1 = __values$2(parent), parent_1_1 = parent_1.next(); !parent_1_1.done; parent_1_1 = parent_1.next()) {
|
|
8497
8656
|
var button = parent_1_1.value;
|
|
8498
8657
|
if (button.classList.contains('active')) {
|
|
8499
8658
|
button.classList.remove('active');
|
|
@@ -9486,8 +9645,15 @@
|
|
|
9486
9645
|
this.paramsService.parameters.subscribe(function (res) { return _this.params = res; });
|
|
9487
9646
|
var mediaQuery = window.matchMedia('(max-width: 992px)');
|
|
9488
9647
|
this.mediaMenu = mediaQuery.matches;
|
|
9648
|
+
this.subscribeToBalance();
|
|
9489
9649
|
this.ecOnInit();
|
|
9490
9650
|
};
|
|
9651
|
+
HeaderEcComponent.prototype.subscribeToBalance = function () {
|
|
9652
|
+
var _this = this;
|
|
9653
|
+
this.balanceSubscription = this.cartService.balanceCustomer$.subscribe(function (balanceData) {
|
|
9654
|
+
_this.balanceAttributes = balanceData;
|
|
9655
|
+
});
|
|
9656
|
+
};
|
|
9491
9657
|
HeaderEcComponent.ctorParameters = function () { return [
|
|
9492
9658
|
{ type: router.Router },
|
|
9493
9659
|
{ type: Constants },
|
|
@@ -9976,6 +10142,7 @@
|
|
|
9976
10142
|
_this.optionsSubject.next(_this.getOptions());
|
|
9977
10143
|
variant_code ? _this.updateVariants(variant_code) : _this.updateVariants();
|
|
9978
10144
|
_this.variants.length && _this.generateAsociatedDataFromVariants();
|
|
10145
|
+
_this.fetchCartData();
|
|
9979
10146
|
//this.analyticsService.callEvent('view_item', { ...product, currency: this.constants.currency.code })
|
|
9980
10147
|
// variant_code && this.analyticsService.callEvent('view_item', { ...product, currency: this.constants.currency.code })
|
|
9981
10148
|
};
|
|
@@ -10188,6 +10355,31 @@
|
|
|
10188
10355
|
}
|
|
10189
10356
|
return true;
|
|
10190
10357
|
};
|
|
10358
|
+
this.validatePriceAndCredits = function (price) {
|
|
10359
|
+
if (_this.creditAmount === null) {
|
|
10360
|
+
console.log('No hay configuración de créditos para este usuario.');
|
|
10361
|
+
return true;
|
|
10362
|
+
}
|
|
10363
|
+
if (_this.remainingCredits === undefined) {
|
|
10364
|
+
return false;
|
|
10365
|
+
}
|
|
10366
|
+
if (price > _this.remainingCredits) {
|
|
10367
|
+
_this.toastrService.show('not-enough-credits');
|
|
10368
|
+
return false;
|
|
10369
|
+
}
|
|
10370
|
+
return true;
|
|
10371
|
+
};
|
|
10372
|
+
this.fetchCartData = function () {
|
|
10373
|
+
_this.cartService.getTotalAmount().subscribe(function (totalAmount) {
|
|
10374
|
+
_this.currentTotalAmount = totalAmount;
|
|
10375
|
+
});
|
|
10376
|
+
_this.cartService.getCreditAmount().subscribe(function (creditAmount) {
|
|
10377
|
+
_this.creditAmount = creditAmount;
|
|
10378
|
+
});
|
|
10379
|
+
_this.cartService.getRemainingCredits().subscribe(function (remainingCredits) {
|
|
10380
|
+
_this.remainingCredits = remainingCredits;
|
|
10381
|
+
});
|
|
10382
|
+
};
|
|
10191
10383
|
// Cuando haya modelos de respuesta, validamos que no se intente cargar un producto incompleto
|
|
10192
10384
|
this.isProductValid = function (product) { return true; };
|
|
10193
10385
|
/**
|
|
@@ -10242,6 +10434,8 @@
|
|
|
10242
10434
|
return;
|
|
10243
10435
|
if (!this.validateQuantity(quantity))
|
|
10244
10436
|
return;
|
|
10437
|
+
if (!this.validatePriceAndCredits(product_selected.price * quantity))
|
|
10438
|
+
return;
|
|
10245
10439
|
this.cartService.addToCart(this.makeAffordableProduct(product_selected), quantity, variant.code);
|
|
10246
10440
|
};
|
|
10247
10441
|
;
|
|
@@ -15948,7 +16142,7 @@
|
|
|
15948
16142
|
_this.prev = function (index) {
|
|
15949
16143
|
if (index === void 0) { index = -1; }
|
|
15950
16144
|
_this.values.pop();
|
|
15951
|
-
|
|
16145
|
+
// this.attributes.pop();
|
|
15952
16146
|
_this.total.pop();
|
|
15953
16147
|
_this.taxonCode = 0;
|
|
15954
16148
|
_this.noMoreCoincidences = false;
|