ng-easycommerce 0.0.639 → 0.0.641

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.
Files changed (25) hide show
  1. package/README.md +5 -0
  2. package/bundles/ng-easycommerce.umd.js +71 -26
  3. package/bundles/ng-easycommerce.umd.js.map +1 -1
  4. package/bundles/ng-easycommerce.umd.min.js +1 -1
  5. package/bundles/ng-easycommerce.umd.min.js.map +1 -1
  6. package/esm2015/lib/ec-component/cart-ec/cart-ec.component.js +8 -1
  7. package/esm2015/lib/ec-component/checkout-ec/success-ec/success-ec.component.js +7 -3
  8. package/esm2015/lib/ec-component/widgets-ec/place-to-pay-ec/place-to-pay-ec.component.js +23 -3
  9. package/esm2015/lib/ec-component/widgets-ec/redsys-catch-ec/redsys-catch-ec.component.js +10 -1
  10. package/esm2015/lib/services/cart.service.js +6 -2
  11. package/esm2015/lib/services/products/product-detail.service.js +23 -22
  12. package/esm5/lib/ec-component/cart-ec/cart-ec.component.js +8 -1
  13. package/esm5/lib/ec-component/checkout-ec/success-ec/success-ec.component.js +7 -3
  14. package/esm5/lib/ec-component/widgets-ec/place-to-pay-ec/place-to-pay-ec.component.js +23 -3
  15. package/esm5/lib/ec-component/widgets-ec/redsys-catch-ec/redsys-catch-ec.component.js +10 -1
  16. package/esm5/lib/services/cart.service.js +6 -2
  17. package/esm5/lib/services/products/product-detail.service.js +23 -22
  18. package/fesm2015/ng-easycommerce.js +71 -26
  19. package/fesm2015/ng-easycommerce.js.map +1 -1
  20. package/fesm5/ng-easycommerce.js +71 -26
  21. package/fesm5/ng-easycommerce.js.map +1 -1
  22. package/lib/ec-component/cart-ec/cart-ec.component.d.ts +1 -0
  23. package/lib/ec-component/widgets-ec/place-to-pay-ec/place-to-pay-ec.component.d.ts +4 -0
  24. package/ng-easycommerce.metadata.json +1 -1
  25. package/package.json +1 -1
@@ -4941,7 +4941,11 @@ var CartService = /** @class */ (function () {
4941
4941
  };
4942
4942
  this.updateItemQuantity = function (item, quantity) {
4943
4943
  if (_this.validateQuantity(item, quantity) && (_this.validatePriceAndCredits(item, quantity))) {
4944
- _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); });
4944
+ _this.requestInProcess.next(true);
4945
+ _this.connection
4946
+ .put(_this.updateItemQuantityApi(_this.findItemByIdVariant(item.variant_id)), { 'quantity': Number(quantity) })
4947
+ .pipe(finalize(function () { return _this.requestInProcess.next(false); }))
4948
+ .subscribe(function (res) { return _this.updateCartObj(res) && _this.updateCartItemQuantity(item.variant_id, Number(quantity)); }, function (err) { return _this.handleError(err); });
4945
4949
  }
4946
4950
  };
4947
4951
  this.validateQuantity = function (item, quantity) {
@@ -7497,6 +7501,7 @@ var CartEcComponent = /** @class */ (function (_super) {
7497
7501
  _this.hideTaxes = false;
7498
7502
  _this.creditAccountShowPrices = null;
7499
7503
  _this.showTaxLegend = false;
7504
+ _this.cartLoading = false;
7500
7505
  _this.toDecimal = function (amount) { return _this.consts.toDecimal(amount); };
7501
7506
  _this.redirectRegister = function () { return _this.router.navigateByUrl("/auth/login"); };
7502
7507
  _this.getVariants = function (product) {
@@ -7572,11 +7577,17 @@ var CartEcComponent = /** @class */ (function (_super) {
7572
7577
  this.cartService.showPrice$.subscribe(function (showPrice) {
7573
7578
  _this.creditAccountShowPrices = showPrice;
7574
7579
  });
7580
+ this.cartService.loading.subscribe(function (isLoading) {
7581
+ _this.cartLoading = isLoading;
7582
+ });
7575
7583
  this.ecOnInit();
7576
7584
  };
7577
7585
  CartEcComponent.prototype.actualizarCantidad = function (item, cantidad, stock, id) {
7578
7586
  var _this = this;
7579
7587
  var _a;
7588
+ if (this.cartLoading) {
7589
+ return;
7590
+ }
7580
7591
  var multipleQuantity = ((_a = item.product) === null || _a === void 0 ? void 0 : _a.variants) && item.product.variants.length > 0 ? item.product.variants[0].multipleQuantity : 0;
7581
7592
  var step = multipleQuantity && multipleQuantity > 0 ? multipleQuantity : 1;
7582
7593
  var newQuantity;
@@ -9128,7 +9139,7 @@ var SuccessEcComponent = /** @class */ (function (_super) {
9128
9139
  SuccessEcComponent.prototype.ngOnInit = function () {
9129
9140
  var _this = this;
9130
9141
  this.checkoutService.order$.subscribe(function (res) {
9131
- var _a, _b, _c, _d, _e, _f, _g, _h;
9142
+ var _a, _b, _c, _d, _e;
9132
9143
  //console.log('LO QUE LLEGA EN ORDEN', res);
9133
9144
  ((_a = res) === null || _a === void 0 ? void 0 : _a.number) ? _this.params = {
9134
9145
  external_reference: res.number,
@@ -9136,7 +9147,11 @@ var SuccessEcComponent = /** @class */ (function (_super) {
9136
9147
  //this.payments = [{method:{code:'bank_transsfer'}}]
9137
9148
  _this.payments = ((_b = res) === null || _b === void 0 ? void 0 : _b.payments) ? res.payments : null;
9138
9149
  if (((_e = (_d = (_c = _this.payments) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d.method) === null || _e === void 0 ? void 0 : _e.code) && _this.isPlaceToPay(_this.payments[0].method.code)) {
9139
- _this.totalAmount = (_h = (_g = (_f = res) === null || _f === void 0 ? void 0 : _f.totals) === null || _g === void 0 ? void 0 : _g.total, (_h !== null && _h !== void 0 ? _h : null));
9150
+ var stored = localStorage.getItem('total_amount');
9151
+ if (stored !== null) {
9152
+ _this.totalAmount = parseFloat(stored);
9153
+ localStorage.removeItem('total_amount');
9154
+ }
9140
9155
  var now = new Date();
9141
9156
  _this.paymentDate = now.toLocaleDateString('es-AR', {
9142
9157
  day: '2-digit',
@@ -10806,18 +10821,19 @@ var ProductDetailService = /** @class */ (function () {
10806
10821
  options && options.forEach(function (option) { return Object.keys(option).forEach(function (key) { return _this.setOption(key, option[key]); }); });
10807
10822
  };
10808
10823
  this.generateAsociatedDataFromVariants = function () {
10809
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4;
10824
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6;
10810
10825
  var asociated = {};
10811
10826
  if (_this.isReady()) {
10812
10827
  asociated.stock = _this.variants[0].stock;
10813
10828
  // Precio: si viene taxLegendInfo usamos su price, si no el v.price
10814
10829
  var rawPrice = (_b = (_a = _this.variants[0].taxLegendInfo) === null || _a === void 0 ? void 0 : _a.price, (_b !== null && _b !== void 0 ? _b : _this.variants[0].price));
10815
10830
  asociated.price = rawPrice.toString();
10816
- asociated.saleprice = _this.variants[0].saleprice && _this.variants[0].saleprice.toString() || undefined;
10817
- asociated.discount = ((_c = _this.variants[0]) === null || _c === void 0 ? void 0 : _c.discount) || undefined;
10831
+ var rawSalePrice = (_d = (_c = _this.variants[0].taxLegendInfo) === null || _c === void 0 ? void 0 : _c.saleprice, (_d !== null && _d !== void 0 ? _d : _this.variants[0].saleprice));
10832
+ asociated.saleprice = rawSalePrice ? rawSalePrice.toString() : undefined;
10833
+ asociated.discount = ((_e = _this.variants[0]) === null || _e === void 0 ? void 0 : _e.discount) || undefined;
10818
10834
  asociated.properties = _this.variants[0].properties ? _this.beautifyProperties(_this.variants[0].properties) : undefined;
10819
- asociated.uniqueExternalCode = ((_d = _this.variants[0]) === null || _d === void 0 ? void 0 : _d.uniqueExternalCode) || undefined;
10820
- asociated.multipleQuantity = ((_e = _this.variants[0]) === null || _e === void 0 ? void 0 : _e.multipleQuantity) || undefined;
10835
+ asociated.uniqueExternalCode = ((_f = _this.variants[0]) === null || _f === void 0 ? void 0 : _f.uniqueExternalCode) || undefined;
10836
+ asociated.multipleQuantity = ((_g = _this.variants[0]) === null || _g === void 0 ? void 0 : _g.multipleQuantity) || undefined;
10821
10837
  }
10822
10838
  else {
10823
10839
  asociated.price = _this.cratePrice();
@@ -10828,31 +10844,31 @@ var ProductDetailService = /** @class */ (function () {
10828
10844
  ('images' in _this.variants[0] && _this.variants[0].images.length > 0)
10829
10845
  ? asociated.picture = _this.variants[0].images[0]
10830
10846
  : asociated.picture = (_this.asociatedDataSubject.value.picture || _this.productSubject.value.picturesdefault[0]);
10831
- asociated.maximumAmount = ((_f = _this.variants[0]) === null || _f === void 0 ? void 0 : _f.maximumAmount) || 0;
10832
- asociated.minimumAmount = ((_g = _this.variants[0]) === null || _g === void 0 ? void 0 : _g.minimumAmount) || 0;
10833
- asociated.maximumItemsQuantity = ((_h = _this.variants[0]) === null || _h === void 0 ? void 0 : _h.stock) > 0 && 'maximumItemsQuantity' in _this.variants[0] ? (_j = _this.variants[0]) === null || _j === void 0 ? void 0 : _j.maximumItemsQuantity : (_k = _this.variants[0]) === null || _k === void 0 ? void 0 : _k.stock;
10834
- asociated.minimumItemsQuantity = ((_l = _this.variants[0]) === null || _l === void 0 ? void 0 : _l.stock) > 0 && 'minimumItemsQuantity' in _this.variants[0]
10835
- && ((_m = _this.variants[0]) === null || _m === void 0 ? void 0 : _m.minimumItemsQuantity) > 0 ? (_o = _this.variants[0]) === null || _o === void 0 ? void 0 : _o.minimumItemsQuantity : (((_p = _this.variants[0]) === null || _p === void 0 ? void 0 : _p.multipleQuantity) ? (_q = _this.variants[0]) === null || _q === void 0 ? void 0 : _q.multipleQuantity : 1);
10847
+ asociated.maximumAmount = ((_h = _this.variants[0]) === null || _h === void 0 ? void 0 : _h.maximumAmount) || 0;
10848
+ asociated.minimumAmount = ((_j = _this.variants[0]) === null || _j === void 0 ? void 0 : _j.minimumAmount) || 0;
10849
+ asociated.maximumItemsQuantity = ((_k = _this.variants[0]) === null || _k === void 0 ? void 0 : _k.stock) > 0 && 'maximumItemsQuantity' in _this.variants[0] ? (_l = _this.variants[0]) === null || _l === void 0 ? void 0 : _l.maximumItemsQuantity : (_m = _this.variants[0]) === null || _m === void 0 ? void 0 : _m.stock;
10850
+ asociated.minimumItemsQuantity = ((_o = _this.variants[0]) === null || _o === void 0 ? void 0 : _o.stock) > 0 && 'minimumItemsQuantity' in _this.variants[0]
10851
+ && ((_p = _this.variants[0]) === null || _p === void 0 ? void 0 : _p.minimumItemsQuantity) > 0 ? (_q = _this.variants[0]) === null || _q === void 0 ? void 0 : _q.minimumItemsQuantity : (((_r = _this.variants[0]) === null || _r === void 0 ? void 0 : _r.multipleQuantity) ? (_s = _this.variants[0]) === null || _s === void 0 ? void 0 : _s.multipleQuantity : 1);
10836
10852
  asociated.finalConsumer = {
10837
- finalConsumerPrice: (_r = _this.variants[0]) === null || _r === void 0 ? void 0 : _r.final_consumer_price,
10838
- originalFinalConsumerPrice: (_s = _this.variants[0]) === null || _s === void 0 ? void 0 : _s.original_final_consumer_price,
10853
+ finalConsumerPrice: (_t = _this.variants[0]) === null || _t === void 0 ? void 0 : _t.final_consumer_price,
10854
+ originalFinalConsumerPrice: (_u = _this.variants[0]) === null || _u === void 0 ? void 0 : _u.original_final_consumer_price,
10839
10855
  };
10840
10856
  asociated.taxes = {
10841
- taxIncluded: (_t = _this.variants[0]) === null || _t === void 0 ? void 0 : _t.taxIncluded,
10842
- taxCategory: (_u = _this.variants[0]) === null || _u === void 0 ? void 0 : _u.taxCategory,
10857
+ taxIncluded: (_v = _this.variants[0]) === null || _v === void 0 ? void 0 : _v.taxIncluded,
10858
+ taxCategory: (_w = _this.variants[0]) === null || _w === void 0 ? void 0 : _w.taxCategory,
10843
10859
  };
10844
10860
  // Segun version del backend
10845
- if ((_v = _this.variants[0]) === null || _v === void 0 ? void 0 : _v.taxLegendInfo) {
10861
+ if ((_x = _this.variants[0]) === null || _x === void 0 ? void 0 : _x.taxLegendInfo) {
10846
10862
  // Nuevo backend
10847
- asociated.priceWithoutTaxes = (_w = _this.variants[0]) === null || _w === void 0 ? void 0 : _w.taxLegendInfo.priceWithoutTaxes;
10848
- asociated.taxeAmount = (_x = _this.variants[0]) === null || _x === void 0 ? void 0 : _x.taxLegendInfo.taxes;
10849
- asociated.taxRate = (_y = _this.variants[0]) === null || _y === void 0 ? void 0 : _y.taxLegendInfo.taxRate;
10863
+ asociated.priceWithoutTaxes = (_y = _this.variants[0]) === null || _y === void 0 ? void 0 : _y.taxLegendInfo.priceWithoutTaxes;
10864
+ asociated.taxeAmount = (_z = _this.variants[0]) === null || _z === void 0 ? void 0 : _z.taxLegendInfo.taxes;
10865
+ asociated.taxRate = (_0 = _this.variants[0]) === null || _0 === void 0 ? void 0 : _0.taxLegendInfo.taxRate;
10850
10866
  }
10851
10867
  else {
10852
10868
  // Backend antiguo
10853
- asociated.priceWithoutTaxes = (_0 = (_z = _this.variants[0]) === null || _z === void 0 ? void 0 : _z.priceWithoutTaxes, (_0 !== null && _0 !== void 0 ? _0 : undefined));
10854
- asociated.taxeAmount = (_2 = (_1 = _this.variants[0]) === null || _1 === void 0 ? void 0 : _1.taxes, (_2 !== null && _2 !== void 0 ? _2 : undefined));
10855
- asociated.taxRate = (_4 = (_3 = _this.variants[0]) === null || _3 === void 0 ? void 0 : _3.taxRate, (_4 !== null && _4 !== void 0 ? _4 : undefined));
10869
+ asociated.priceWithoutTaxes = (_2 = (_1 = _this.variants[0]) === null || _1 === void 0 ? void 0 : _1.priceWithoutTaxes, (_2 !== null && _2 !== void 0 ? _2 : undefined));
10870
+ asociated.taxeAmount = (_4 = (_3 = _this.variants[0]) === null || _3 === void 0 ? void 0 : _3.taxes, (_4 !== null && _4 !== void 0 ? _4 : undefined));
10871
+ asociated.taxRate = (_6 = (_5 = _this.variants[0]) === null || _5 === void 0 ? void 0 : _5.taxRate, (_6 !== null && _6 !== void 0 ? _6 : undefined));
10856
10872
  }
10857
10873
  _this.asociatedDataSubject.next(asociated);
10858
10874
  };
@@ -12757,15 +12773,24 @@ var RedsysCatchEcComponent = /** @class */ (function (_super) {
12757
12773
  case '200':
12758
12774
  state = 'success';
12759
12775
  _this.setStateInLocal('Su pago fue procesado con éxito.', state);
12776
+ if (queryParams.total_amount) {
12777
+ localStorage.setItem('total_amount', queryParams.total_amount);
12778
+ }
12760
12779
  break;
12761
12780
  case 'success':
12762
12781
  _this.setStateInLocal('Su pago fue procesado con éxito.', state);
12782
+ if (queryParams.total_amount) {
12783
+ localStorage.setItem('total_amount', queryParams.total_amount);
12784
+ }
12763
12785
  break;
12764
12786
  case 'pending':
12765
12787
  _this.setStateInLocal('Su pago fue procesado con éxito.', state);
12766
12788
  break;
12767
12789
  case 'failure':
12768
12790
  _this.setStateInLocal('Se ha cancelado el proceso de pago.', state);
12791
+ if (queryParams.total_amount) {
12792
+ localStorage.setItem('total_amount', queryParams.total_amount);
12793
+ }
12769
12794
  break;
12770
12795
  case 'cancel':
12771
12796
  _this.setStateInLocal('Se ha cancelado el proceso de pago.', state);
@@ -19292,6 +19317,10 @@ var PlaceToPayEcComponent = /** @class */ (function (_super) {
19292
19317
  _this.ready = new EventEmitter();
19293
19318
  _this.loading = false;
19294
19319
  _this.closeModal = '';
19320
+ _this.hasPreviousFailure = false;
19321
+ _this.previousFailureAmount = null;
19322
+ _this.previousFailureDate = null;
19323
+ _this.buttonText = 'Pagar';
19295
19324
  _this.dataRedirect = function () {
19296
19325
  return _this.consts.getUrlBase() + 'shop-api/' + _this.consts.getChannel() + '/place-to-pay/' + _this.cartService.cart_token + '/process-payment';
19297
19326
  };
@@ -19314,17 +19343,33 @@ var PlaceToPayEcComponent = /** @class */ (function (_super) {
19314
19343
  var _a, _b, _c, _d;
19315
19344
  var state = _this.closeModal !== '' ? _this.closeModal : localStorage.getItem('state');
19316
19345
  !state && ((_a = _this.ventana) === null || _a === void 0 ? void 0 : _a.closed) && (state = 'cancel');
19346
+ _this.hasPreviousFailure = false;
19317
19347
  _this.loading = true;
19318
19348
  if (state) {
19319
- _this.loading = false;
19320
19349
  localStorage.removeItem('state');
19321
19350
  if (state === 'success' || state === 'pending') {
19322
19351
  (_b = _this.ventana) === null || _b === void 0 ? void 0 : _b.close();
19323
19352
  _this.ready.emit(true);
19324
19353
  return;
19325
19354
  }
19355
+ _this.loading = false;
19326
19356
  if (state === 'failure' || state === 'cancel') {
19327
19357
  (_c = _this.ventana) === null || _c === void 0 ? void 0 : _c.close();
19358
+ if (state === 'failure') {
19359
+ var amt = localStorage.getItem('total_amount');
19360
+ if (amt) {
19361
+ _this.hasPreviousFailure = true;
19362
+ _this.previousFailureAmount = parseFloat(amt);
19363
+ _this.previousFailureDate = new Date().toLocaleDateString('es-AR', {
19364
+ day: '2-digit',
19365
+ month: '2-digit',
19366
+ year: 'numeric',
19367
+ });
19368
+ _this.buttonText = 'Reintentar pago';
19369
+ localStorage.removeItem('total_amount');
19370
+ localStorage.removeItem('payment_date');
19371
+ }
19372
+ }
19328
19373
  _this.getPreference();
19329
19374
  _this.processError(state === 'cancel' ? 'Se canceló el pago con Place to Pay' : '');
19330
19375
  return;
@@ -19387,7 +19432,7 @@ var PlaceToPayEcComponent = /** @class */ (function (_super) {
19387
19432
  PlaceToPayEcComponent = __decorate$20([
19388
19433
  Component({
19389
19434
  selector: 'app-place-to-pay-ec',
19390
- template: "<div class=\"text-center\">\n <ng-container *ngIf=\"url; else loadingUrl\">\n <ng-container *ngIf=\"!loading; else loadingTemp\">\n <button (click)=\"iniciar()\" class=\"btn btn-outline-secondary rounded-0 comprar mt-3\">Pagar</button>\n </ng-container>\n </ng-container>\n</div>\n\n<ng-template #loadingUrl>\n <div class=\"d-flex flex-column justify-content-center align-items-center mt-2\">\n <app-loading-full-ec></app-loading-full-ec>\n </div>\n</ng-template>\n\n<ng-template #loadingTemp>\n <div class=\"d-flex flex-column justify-content-center align-items-center mt-2\">\n <h3>Procesando el pago por Place to Pay</h3>\n <h5>Recuerde hacer click en \"Volver al sitio\" desde Place to Pay para finalizar la compra.</h5>\n <app-loading-full-ec></app-loading-full-ec>\n </div>\n <div class=\"container-fluid\">\n <div class=\"row\">\n <div class=\"col-5\">\n <hr>\n </div>\n <div class=\"col-2 text-center\">\n <label>o</label>\n </div>\n <div class=\"col-5\">\n <hr>\n </div>\n </div>\n </div>\n <div class=\"d-flex flex-column justify-content-center align-items-center mt-2\">\n <button (click)=\"clickClose()\" class=\"btn btn-outline-secondary rounded-0 comprar\">Cancelar pago</button>\n </div>\n</ng-template>",
19435
+ template: "<div class=\"text-center\">\n <ng-container *ngIf=\"url; else loadingUrl\">\n <ng-container *ngIf=\"!loading; else loadingTemp\">\n <button (click)=\"iniciar()\" class=\"btn btn-outline-secondary rounded-0 comprar mt-3\">\n {{ buttonText }}\n </button>\n\n <!-- Mensaje de intento previo fallido -->\n <div *ngIf=\"hasPreviousFailure\" class=\"alert alert-danger mt-3\">\n El pago no se pudo realizar el {{ previousFailureDate }}\n por un monto de {{ previousFailureAmount | ecCurrencySymbol }}.\n </div>\n </ng-container>\n </ng-container>\n</div>\n\n<ng-template #loadingUrl>\n <div class=\"d-flex flex-column justify-content-center align-items-center mt-2\">\n <app-loading-full-ec></app-loading-full-ec>\n </div>\n</ng-template>\n\n<ng-template #loadingTemp>\n <div class=\"d-flex flex-column justify-content-center align-items-center mt-2\">\n <h3>Procesando el pago por Place to Pay</h3>\n <h5>Recuerde hacer click en \"Volver al sitio\" desde Place to Pay para finalizar la compra.</h5>\n <app-loading-full-ec></app-loading-full-ec>\n </div>\n <div class=\"container-fluid\">\n <div class=\"row\">\n <div class=\"col-5\">\n <hr>\n </div>\n <div class=\"col-2 text-center\">\n <label>o</label>\n </div>\n <div class=\"col-5\">\n <hr>\n </div>\n </div>\n </div>\n <div class=\"d-flex flex-column justify-content-center align-items-center mt-2\">\n <button (click)=\"clickClose()\" class=\"btn btn-outline-secondary rounded-0 comprar\">Cancelar pago</button>\n </div>\n</ng-template>",
19391
19436
  styles: [""]
19392
19437
  })
19393
19438
  ], PlaceToPayEcComponent);