ng-easycommerce 0.0.631 → 0.0.633

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 (31) hide show
  1. package/README.md +5 -0
  2. package/assets/ec-i18n/ct.json +3 -1
  3. package/assets/ec-i18n/en.json +3 -1
  4. package/assets/ec-i18n/es.json +6 -4
  5. package/assets/ec-i18n/fr.json +3 -1
  6. package/assets/ec-i18n/gl.json +3 -1
  7. package/assets/ec-i18n/pr.json +3 -1
  8. package/bundles/ng-easycommerce.umd.js +73 -37
  9. package/bundles/ng-easycommerce.umd.js.map +1 -1
  10. package/bundles/ng-easycommerce.umd.min.js +1 -1
  11. package/bundles/ng-easycommerce.umd.min.js.map +1 -1
  12. package/esm2015/lib/ec-component/auth-ec/register-form-ec/register-form-ec.component.js +3 -3
  13. package/esm2015/lib/ec-component/auth-ec/register-wholesaler-form-ec/register-wholesaler-form-ec.component.js +3 -3
  14. package/esm2015/lib/ec-component/checkout-ec/success-ec/success-ec.component.js +15 -3
  15. package/esm2015/lib/ec-component/product-detail-ec/product-detail-ec.component.js +4 -3
  16. package/esm2015/lib/services/options.service.js +13 -20
  17. package/esm2015/lib/services/products/product-detail.service.js +12 -5
  18. package/esm5/lib/ec-component/auth-ec/register-form-ec/register-form-ec.component.js +3 -3
  19. package/esm5/lib/ec-component/auth-ec/register-wholesaler-form-ec/register-wholesaler-form-ec.component.js +3 -3
  20. package/esm5/lib/ec-component/checkout-ec/success-ec/success-ec.component.js +15 -3
  21. package/esm5/lib/ec-component/product-detail-ec/product-detail-ec.component.js +4 -3
  22. package/esm5/lib/services/options.service.js +35 -19
  23. package/esm5/lib/services/products/product-detail.service.js +12 -5
  24. package/fesm2015/ng-easycommerce.js +44 -31
  25. package/fesm2015/ng-easycommerce.js.map +1 -1
  26. package/fesm5/ng-easycommerce.js +73 -37
  27. package/fesm5/ng-easycommerce.js.map +1 -1
  28. package/lib/ec-component/checkout-ec/success-ec/success-ec.component.d.ts +3 -0
  29. package/lib/services/options.service.d.ts +1 -1
  30. package/ng-easycommerce.metadata.json +1 -1
  31. package/package.json +1 -1
@@ -1003,6 +1003,17 @@ var __spread = (this && this.__spread) || function () {
1003
1003
  for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));
1004
1004
  return ar;
1005
1005
  };
1006
+ var __values = (this && this.__values) || function(o) {
1007
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
1008
+ if (m) return m.call(o);
1009
+ if (o && typeof o.length === "number") return {
1010
+ next: function () {
1011
+ if (o && i >= o.length) o = void 0;
1012
+ return { value: o && o[i++], done: !o };
1013
+ }
1014
+ };
1015
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
1016
+ };
1006
1017
  var OptionsService = /** @class */ (function () {
1007
1018
  function OptionsService(connection, constants) {
1008
1019
  var _this = this;
@@ -1136,26 +1147,31 @@ var OptionsService = /** @class */ (function () {
1136
1147
  });
1137
1148
  return final_result;
1138
1149
  };
1139
- this.generateBreadcrumb = function (code, elements, result) {
1140
- var element = elements.find(function (elem) { return elem.code == code; });
1141
- if (element) {
1142
- result.push(element);
1143
- }
1144
- else {
1145
- elements.some(function (elem) {
1146
- if (elem.children && elem.children.length) {
1147
- var length_1 = result.length;
1148
- var new_result = _this.generateBreadcrumb(code, elem.children, result);
1149
- if (new_result.length > length_1) {
1150
- result = new_result;
1151
- result.push(elem);
1152
- return true;
1153
- }
1150
+ this.generateBreadcrumb = function (code, elements, path) {
1151
+ var e_1, _a;
1152
+ if (path === void 0) { path = []; }
1153
+ var _b;
1154
+ try {
1155
+ for (var elements_1 = __values(elements), elements_1_1 = elements_1.next(); !elements_1_1.done; elements_1_1 = elements_1.next()) {
1156
+ var elem = elements_1_1.value;
1157
+ if (elem.code === code) {
1158
+ return __spread(path, [elem]);
1154
1159
  }
1155
- return false;
1156
- });
1160
+ if ((_b = elem.children) === null || _b === void 0 ? void 0 : _b.length) {
1161
+ var childPath = _this.generateBreadcrumb(code, elem.children, __spread(path, [elem]));
1162
+ if (childPath.length)
1163
+ return childPath;
1164
+ }
1165
+ }
1157
1166
  }
1158
- return result;
1167
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
1168
+ finally {
1169
+ try {
1170
+ if (elements_1_1 && !elements_1_1.done && (_a = elements_1.return)) _a.call(elements_1);
1171
+ }
1172
+ finally { if (e_1) throw e_1.error; }
1173
+ }
1174
+ return [];
1159
1175
  };
1160
1176
  this.getAllData();
1161
1177
  // this.authService.loggedIn.subscribe(res => res && this.getAllData());
@@ -7420,7 +7436,7 @@ var __generator$8 = (this && this.__generator) || function (thisArg, body) {
7420
7436
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
7421
7437
  }
7422
7438
  };
7423
- var __values = (this && this.__values) || function(o) {
7439
+ var __values$1 = (this && this.__values) || function(o) {
7424
7440
  var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
7425
7441
  if (m) return m.call(o);
7426
7442
  if (o && typeof o.length === "number") return {
@@ -7760,7 +7776,7 @@ var CartEcComponent = /** @class */ (function (_super) {
7760
7776
  CartEcComponent.prototype.checkStock = function (item) {
7761
7777
  var e_1, _a;
7762
7778
  try {
7763
- for (var _b = __values(item.product.variants), _c = _b.next(); !_c.done; _c = _b.next()) {
7779
+ for (var _b = __values$1(item.product.variants), _c = _b.next(); !_c.done; _c = _b.next()) {
7764
7780
  var variant = _c.value;
7765
7781
  if (item.variant_id === variant.code) {
7766
7782
  if (variant.stock === 0) {
@@ -7791,7 +7807,7 @@ var CartEcComponent = /** @class */ (function (_super) {
7791
7807
  res.forEach(function (item) {
7792
7808
  var e_2, _a;
7793
7809
  try {
7794
- for (var _b = __values(item.product.variants), _c = _b.next(); !_c.done; _c = _b.next()) {
7810
+ for (var _b = __values$1(item.product.variants), _c = _b.next(); !_c.done; _c = _b.next()) {
7795
7811
  var variant = _c.value;
7796
7812
  if (item.variant_id === variant.code && !_this.exitUpdate) {
7797
7813
  if (variant.stock === 0) {
@@ -8696,7 +8712,7 @@ var __generator$b = (this && this.__generator) || function (thisArg, body) {
8696
8712
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
8697
8713
  }
8698
8714
  };
8699
- var __values$1 = (this && this.__values) || function(o) {
8715
+ var __values$2 = (this && this.__values) || function(o) {
8700
8716
  var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
8701
8717
  if (m) return m.call(o);
8702
8718
  if (o && typeof o.length === "number") return {
@@ -8841,7 +8857,7 @@ var PaymentEcComponent = /** @class */ (function (_super) {
8841
8857
  var e_1, _a;
8842
8858
  var parent = e.target.parentElement.children;
8843
8859
  try {
8844
- for (var parent_1 = __values$1(parent), parent_1_1 = parent_1.next(); !parent_1_1.done; parent_1_1 = parent_1.next()) {
8860
+ for (var parent_1 = __values$2(parent), parent_1_1 = parent_1.next(); !parent_1_1.done; parent_1_1 = parent_1.next()) {
8845
8861
  var button = parent_1_1.value;
8846
8862
  if (button.classList.contains('active')) {
8847
8863
  button.classList.remove('active');
@@ -8911,7 +8927,7 @@ var __decorate$T = (this && this.__decorate) || function (decorators, target, ke
8911
8927
  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;
8912
8928
  return c > 3 && r && Object.defineProperty(target, key, r), r;
8913
8929
  };
8914
- var __values$2 = (this && this.__values) || function(o) {
8930
+ var __values$3 = (this && this.__values) || function(o) {
8915
8931
  var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
8916
8932
  if (m) return m.call(o);
8917
8933
  if (o && typeof o.length === "number") return {
@@ -9000,7 +9016,7 @@ var ShipmentEcComponent = /** @class */ (function (_super) {
9000
9016
  var e_1, _a;
9001
9017
  var parent = e.target.parentElement.children;
9002
9018
  try {
9003
- for (var parent_1 = __values$2(parent), parent_1_1 = parent_1.next(); !parent_1_1.done; parent_1_1 = parent_1.next()) {
9019
+ for (var parent_1 = __values$3(parent), parent_1_1 = parent_1.next(); !parent_1_1.done; parent_1_1 = parent_1.next()) {
9004
9020
  var button = parent_1_1.value;
9005
9021
  if (button.classList.contains('active')) {
9006
9022
  button.classList.remove('active');
@@ -9068,6 +9084,8 @@ var SuccessEcComponent = /** @class */ (function (_super) {
9068
9084
  _this.orderDetails = {};
9069
9085
  _this.params = {};
9070
9086
  _this.from_mp = true;
9087
+ _this.totalAmount = null;
9088
+ _this.paymentDate = null;
9071
9089
  /**
9072
9090
  * @description Chequea si existe un bloque recibido por parametro.
9073
9091
  * @param codeBlock codigo del bloque.
@@ -9075,19 +9093,29 @@ var SuccessEcComponent = /** @class */ (function (_super) {
9075
9093
  */
9076
9094
  _this.containsBlock = function (codeBlock) { return _this.blocks.find(function (block) { return block.code == codeBlock; }); };
9077
9095
  _this.isBalanceInAccount = function (code) { return code && code.toLocaleLowerCase().includes('balance_in_account'); };
9096
+ _this.isPlaceToPay = function (code) { return code && code.toLocaleLowerCase().includes('place_to_pay'); };
9078
9097
  _this.ecOnConstruct();
9079
9098
  return _this;
9080
9099
  }
9081
9100
  SuccessEcComponent.prototype.ngOnInit = function () {
9082
9101
  var _this = this;
9083
9102
  this.checkoutService.order$.subscribe(function (res) {
9084
- var _a, _b;
9103
+ var _a, _b, _c, _d, _e, _f, _g, _h;
9085
9104
  //console.log('LO QUE LLEGA EN ORDEN', res);
9086
9105
  ((_a = res) === null || _a === void 0 ? void 0 : _a.number) ? _this.params = {
9087
9106
  external_reference: res.number,
9088
9107
  } : null;
9089
9108
  //this.payments = [{method:{code:'bank_transsfer'}}]
9090
9109
  _this.payments = ((_b = res) === null || _b === void 0 ? void 0 : _b.payments) ? res.payments : null;
9110
+ 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)) {
9111
+ _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));
9112
+ var now = new Date();
9113
+ _this.paymentDate = now.toLocaleDateString('es-AR', {
9114
+ day: '2-digit',
9115
+ month: '2-digit',
9116
+ year: 'numeric',
9117
+ });
9118
+ }
9091
9119
  });
9092
9120
  this.blocksService.getBlocks('info_metodo_pago');
9093
9121
  this.blocksService.blocks.subscribe(function (res) { return _this.blocks = res; });
@@ -9104,7 +9132,7 @@ var SuccessEcComponent = /** @class */ (function (_super) {
9104
9132
  SuccessEcComponent = __decorate$U([
9105
9133
  Component({
9106
9134
  selector: 'app-order-success-ec',
9107
- template: "<div id=\"container\" class=\"flex-center generalContainer container-xl\">\n <div class=\"Main card my-2\" *ngIf=\"this.payments && this.payments[0].method.code; else loading\">\n <ng-container *ngIf=\"this.blocks && this.blocks.length > 0; else notInfoToMethod\">\n <ng-container *ngIf=\"containsBlock(this.payments[0].method.code) as bloque; else notInfoToMethod\">\n <div class=\"wrap my-4 card-body\" [id]=\"bloque.code\">\n <div class=\"row\">\n <div class=\"col-md-12 col-12\">\n <h5 [class]=\"bloque.code+'-title'\">{{ (bloque?.translations[consts.getLocale()]?.name ?\n bloque.translations[consts.getLocale()].name :\n 'thanks-for-buying') | translate\n | uppercase }}</h5>\n </div>\n </div>\n <div class=\"row\">\n <div class=\"col-md-12 col-12 text-start\">\n <app-blocks-ec [section]=\"'info_metodo_pago'\" [blockFilters]=\"this.payments[0].method.code\">\n </app-blocks-ec>\n <div class=\"d-flex flex-column details\">\n <p class=\"card-text\">{{ ('number' | translate) + ': ' + params.external_reference }}</p>\n <p class=\"card-text\">\n {{ isBalanceInAccount(payments[0].method.code) ?\n ('balance-in-account-message' | translate) :\n ((params.payment_status || 'pending') | translate) }}\n </p>\n </div>\n </div>\n </div>\n </div>\n </ng-container>\n </ng-container>\n <ng-template #notInfoToMethod>\n <ng-template #defaultMessage>\n <div class=\"wrap my-4 card-body\">\n <div class=\"row\">\n <div class=\"col-md-12 col-12\">\n <h5 class=\"card-title titpage center-block text-center\">\n {{ 'thanks-for-buying' | translate | uppercase }}\n </h5>\n </div>\n </div>\n <div class=\"row\">\n <div class=\"col-md-12 col-12 text-center py-3\">\n <h4 class=\"thanks-details\">{{ 'thanks-details' | translate }}</h4>\n <h5 class=\"number\">{{ ('number' | translate) + ': ' + params.external_reference }}</h5>\n <h5 class=\"pending\">\n {{ isBalanceInAccount(payments[0].method.code) ?\n ('balance-in-account-message' | translate) :\n ((params.payment_status || 'pending') | translate) }}\n </h5>\n <!-- <h5 *ngIf=\"!from_mp\">{{ ('will_contact' | translate) }}</h5> -->\n\n <!-- <a routerLink=\"/collection\"><button class=\"comprar\">{{ 'continue-shopping' | translate }}</button></a> -->\n </div>\n </div>\n </div>\n </ng-template>\n <ng-container [ngTemplateOutlet]=\"notInfoToMethodTemplate ? notInfoToMethodTemplate : defaultMessage\"\n [ngTemplateOutletContext]=\"{params:params}\">\n </ng-container>\n </ng-template>\n </div>\n</div>\n\n<ng-template #loading>\n <app-loading-full-ec></app-loading-full-ec>\n</ng-template>",
9135
+ template: "<div id=\"container\" class=\"flex-center generalContainer container-xl\">\n <div class=\"Main card my-2\" *ngIf=\"this.payments && this.payments[0].method.code; else loading\">\n <ng-container *ngIf=\"this.blocks && this.blocks.length > 0; else notInfoToMethod\">\n <ng-container *ngIf=\"containsBlock(this.payments[0].method.code) as bloque; else notInfoToMethod\">\n <div class=\"wrap my-4 card-body\" [id]=\"bloque.code\">\n <div class=\"row\">\n <div class=\"col-md-12 col-12\">\n <h5 [class]=\"bloque.code+'-title'\">{{ (bloque?.translations[consts.getLocale()]?.name ?\n bloque.translations[consts.getLocale()].name :\n 'thanks-for-buying') | translate\n | uppercase }}</h5>\n </div>\n </div>\n <div class=\"row\">\n <div class=\"col-md-12 col-12 text-start\">\n <app-blocks-ec [section]=\"'info_metodo_pago'\" [blockFilters]=\"this.payments[0].method.code\">\n </app-blocks-ec>\n <div class=\"d-flex flex-column details\">\n <p class=\"card-text\">{{ ('number' | translate) + ': ' + params.external_reference }}</p>\n <p class=\"card-text\">\n {{ isBalanceInAccount(payments[0].method.code) ?\n ('balance-in-account-message' | translate) :\n ((params.payment_status || 'pending') | translate) }}\n </p>\n </div>\n </div>\n </div>\n </div>\n </ng-container>\n </ng-container>\n <ng-template #notInfoToMethod>\n <ng-template #defaultMessage>\n <div class=\"wrap my-4 card-body\">\n <div class=\"row\">\n <div class=\"col-md-12 col-12\">\n <h5 class=\"card-title titpage center-block text-center\">\n {{ 'thanks-for-buying' | translate | uppercase }}\n </h5>\n </div>\n </div>\n <div class=\"row\">\n <div class=\"col-md-12 col-12 text-center py-3\">\n <h4 class=\"thanks-details\">{{ 'thanks-details' | translate }}</h4>\n <h5 class=\"number order-info-line\" [ngClass]=\"{ 'compact': paymentDate && totalAmount }\">{{ ('number' | translate) + ': ' + params.external_reference }}</h5>\n <h5 class=\"order-info-line\" *ngIf=\"paymentDate && totalAmount\">\n {{'payment-date' | translate }}: {{ paymentDate }}\n </h5>\n <h5 class=\"order-info-line\" *ngIf=\"paymentDate && totalAmount\">\n {{'total-paid' | translate }}: {{ totalAmount | ecCurrencySymbol }}\n </h5>\n <h5 class=\"pending\">\n {{ isBalanceInAccount(payments[0].method.code) ?\n ('balance-in-account-message' | translate) :\n ((params.payment_status || 'pending') | translate) }}\n </h5>\n <!-- <h5 *ngIf=\"!from_mp\">{{ ('will_contact' | translate) }}</h5> -->\n\n <!-- <a routerLink=\"/collection\"><button class=\"comprar\">{{ 'continue-shopping' | translate }}</button></a> -->\n </div>\n </div>\n </div>\n </ng-template>\n <ng-container [ngTemplateOutlet]=\"notInfoToMethodTemplate ? notInfoToMethodTemplate : defaultMessage\"\n [ngTemplateOutletContext]=\"{params:params}\">\n </ng-container>\n </ng-template>\n </div>\n</div>\n\n<ng-template #loading>\n <app-loading-full-ec></app-loading-full-ec>\n</ng-template>",
9108
9136
  styles: [""]
9109
9137
  })
9110
9138
  ], SuccessEcComponent);
@@ -10844,11 +10872,18 @@ var ProductDetailService = /** @class */ (function () {
10844
10872
  return min_price == max_price ? max_price.toString() : min_price + ' - ' + max_price;
10845
10873
  };
10846
10874
  this.inRange = function (quantity, min, max) { return ((quantity - min) * (quantity - max) <= 0); };
10847
- this.validateQuantity = function (quantity) {
10848
- var actualQuantity = _this.cartService.getCountFromItemInCart(_this.variants[0].code);
10875
+ this.validateQuantity = function (quantity, variantCode) {
10876
+ var _a, _b;
10877
+ var codeToCheck = variantCode || _this.variants[0].code;
10878
+ var actualQuantity = _this.cartService.getCountFromItemInCart(codeToCheck);
10849
10879
  var asociatedData = _this.asociatedDataSubject.value;
10850
10880
  var totalQuantity = actualQuantity + quantity;
10851
- console.log('La cantidad que llegó: ', quantity, ' y la cantidad actual: ', actualQuantity);
10881
+ var variant = _this.variants.find(function (v) { return v.code === codeToCheck; });
10882
+ var stock = (_b = (_a = variant) === null || _a === void 0 ? void 0 : _a.stock, (_b !== null && _b !== void 0 ? _b : 0));
10883
+ if (totalQuantity > stock) {
10884
+ _this.toastrService.show('out-of-stock-actually');
10885
+ return false;
10886
+ }
10852
10887
  if (asociatedData.maximumItemsQuantity && totalQuantity > asociatedData.maximumItemsQuantity) {
10853
10888
  _this.toastrService.show('maximum-items-quantity', { quantity: asociatedData.maximumItemsQuantity });
10854
10889
  return false;
@@ -10941,7 +10976,7 @@ var ProductDetailService = /** @class */ (function () {
10941
10976
  }
10942
10977
  if (!variant)
10943
10978
  return;
10944
- if (!this.validateQuantity(quantity))
10979
+ if (!this.validateQuantity(quantity, variant.code))
10945
10980
  return;
10946
10981
  var priceToValidate = product_selected.saleprice ? product_selected.saleprice * quantity : product_selected.price * quantity;
10947
10982
  if (!this.validatePriceAndCredits(priceToValidate))
@@ -11100,9 +11135,10 @@ var ProductDetailEcComponent = /** @class */ (function (_super) {
11100
11135
  _this.plus = function (stock, changeAmount, forceMultiple) {
11101
11136
  if (changeAmount === void 0) { changeAmount = 1; }
11102
11137
  if (forceMultiple === void 0) { forceMultiple = false; }
11103
- var newQuantity = _this.quantity + changeAmount;
11138
+ var currentQuantity = Number(_this.quantity);
11139
+ var newQuantity = currentQuantity + changeAmount;
11104
11140
  if (forceMultiple && changeAmount > 0) {
11105
- if (_this.quantity < changeAmount) {
11141
+ if (currentQuantity < changeAmount) {
11106
11142
  newQuantity = changeAmount;
11107
11143
  }
11108
11144
  else {
@@ -13776,8 +13812,8 @@ var RegisterFormEcComponent = /** @class */ (function (_super) {
13776
13812
  RegisterFormEcComponent.prototype.ngOnInit = function () {
13777
13813
  var _this = this;
13778
13814
  this.registerForm = this.formBuilder.group({
13779
- firstName: ['', Validators.required],
13780
- lastName: ['', Validators.required],
13815
+ firstName: ['', [Validators.required, Validators.pattern(/^[A-Za-zÁÉÍÓÚáéíóúÑñ\s]+$/)]],
13816
+ lastName: ['', [Validators.required, Validators.pattern(/^[A-Za-zÁÉÍÓÚáéíóúÑñ\s]+$/)]],
13781
13817
  email: ['', Validators.required],
13782
13818
  plainPassword: ['', Validators.required],
13783
13819
  plainPassword2: ['', Validators.required],
@@ -14373,8 +14409,8 @@ var RegisterWholesalerFormEcComponent = /** @class */ (function (_super) {
14373
14409
  var _this = this;
14374
14410
  this.paramsService.parameters.subscribe(function (res) { return _this.params = res; });
14375
14411
  this.registerForm = this.formBuilder.group({
14376
- firstName: ['', [Validators.required]],
14377
- lastName: ['', [Validators.required]],
14412
+ firstName: ['', [Validators.required, Validators.pattern(/^[A-Za-zÁÉÍÓÚáéíóúÑñ\s]+$/)]],
14413
+ lastName: ['', [Validators.required, Validators.pattern(/^[A-Za-zÁÉÍÓÚáéíóúÑñ\s]+$/)]],
14378
14414
  documentType: [null, [Validators.required]],
14379
14415
  documentNumber: ['', [Validators.required]],
14380
14416
  email: ['', [Validators.required, Validators.email]],