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
@@ -981,26 +981,19 @@ let OptionsService = class OptionsService {
981
981
  });
982
982
  return final_result;
983
983
  };
984
- this.generateBreadcrumb = (code, elements, result) => {
985
- let element = elements.find(elem => elem.code == code);
986
- if (element) {
987
- result.push(element);
988
- }
989
- else {
990
- elements.some(elem => {
991
- if (elem.children && elem.children.length) {
992
- const length = result.length;
993
- let new_result = this.generateBreadcrumb(code, elem.children, result);
994
- if (new_result.length > length) {
995
- result = new_result;
996
- result.push(elem);
997
- return true;
998
- }
999
- }
1000
- return false;
1001
- });
984
+ this.generateBreadcrumb = (code, elements, path = []) => {
985
+ var _a;
986
+ for (const elem of elements) {
987
+ if (elem.code === code) {
988
+ return [...path, elem];
989
+ }
990
+ if ((_a = elem.children) === null || _a === void 0 ? void 0 : _a.length) {
991
+ const childPath = this.generateBreadcrumb(code, elem.children, [...path, elem]);
992
+ if (childPath.length)
993
+ return childPath;
994
+ }
1002
995
  }
1003
- return result;
996
+ return [];
1004
997
  };
1005
998
  this.getAllData();
1006
999
  // this.authService.loggedIn.subscribe(res => res && this.getAllData());
@@ -7525,6 +7518,8 @@ let SuccessEcComponent = class SuccessEcComponent extends ComponentHelper {
7525
7518
  this.orderDetails = {};
7526
7519
  this.params = {};
7527
7520
  this.from_mp = true;
7521
+ this.totalAmount = null;
7522
+ this.paymentDate = null;
7528
7523
  /**
7529
7524
  * @description Chequea si existe un bloque recibido por parametro.
7530
7525
  * @param codeBlock codigo del bloque.
@@ -7532,17 +7527,27 @@ let SuccessEcComponent = class SuccessEcComponent extends ComponentHelper {
7532
7527
  */
7533
7528
  this.containsBlock = (codeBlock) => this.blocks.find(block => block.code == codeBlock);
7534
7529
  this.isBalanceInAccount = (code) => code && code.toLocaleLowerCase().includes('balance_in_account');
7530
+ this.isPlaceToPay = (code) => code && code.toLocaleLowerCase().includes('place_to_pay');
7535
7531
  this.ecOnConstruct();
7536
7532
  }
7537
7533
  ngOnInit() {
7538
7534
  this.checkoutService.order$.subscribe(res => {
7539
- var _a, _b;
7535
+ var _a, _b, _c, _d, _e, _f, _g, _h;
7540
7536
  //console.log('LO QUE LLEGA EN ORDEN', res);
7541
7537
  ((_a = res) === null || _a === void 0 ? void 0 : _a.number) ? this.params = {
7542
7538
  external_reference: res.number,
7543
7539
  } : null;
7544
7540
  //this.payments = [{method:{code:'bank_transsfer'}}]
7545
7541
  this.payments = ((_b = res) === null || _b === void 0 ? void 0 : _b.payments) ? res.payments : null;
7542
+ 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)) {
7543
+ 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));
7544
+ const now = new Date();
7545
+ this.paymentDate = now.toLocaleDateString('es-AR', {
7546
+ day: '2-digit',
7547
+ month: '2-digit',
7548
+ year: 'numeric',
7549
+ });
7550
+ }
7546
7551
  });
7547
7552
  this.blocksService.getBlocks('info_metodo_pago');
7548
7553
  this.blocksService.blocks.subscribe(res => this.blocks = res);
@@ -7560,7 +7565,7 @@ SuccessEcComponent.ctorParameters = () => [
7560
7565
  SuccessEcComponent = __decorate$U([
7561
7566
  Component({
7562
7567
  selector: 'app-order-success-ec',
7563
- 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>",
7568
+ 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>",
7564
7569
  styles: [""]
7565
7570
  })
7566
7571
  ], SuccessEcComponent);
@@ -8962,11 +8967,18 @@ let ProductDetailService = class ProductDetailService {
8962
8967
  return min_price == max_price ? max_price.toString() : min_price + ' - ' + max_price;
8963
8968
  };
8964
8969
  this.inRange = (quantity, min, max) => ((quantity - min) * (quantity - max) <= 0);
8965
- this.validateQuantity = (quantity) => {
8966
- const actualQuantity = this.cartService.getCountFromItemInCart(this.variants[0].code);
8970
+ this.validateQuantity = (quantity, variantCode) => {
8971
+ var _a, _b;
8972
+ const codeToCheck = variantCode || this.variants[0].code;
8973
+ const actualQuantity = this.cartService.getCountFromItemInCart(codeToCheck);
8967
8974
  const asociatedData = this.asociatedDataSubject.value;
8968
8975
  const totalQuantity = actualQuantity + quantity;
8969
- console.log('La cantidad que llegó: ', quantity, ' y la cantidad actual: ', actualQuantity);
8976
+ const variant = this.variants.find(v => v.code === codeToCheck);
8977
+ const stock = (_b = (_a = variant) === null || _a === void 0 ? void 0 : _a.stock, (_b !== null && _b !== void 0 ? _b : 0));
8978
+ if (totalQuantity > stock) {
8979
+ this.toastrService.show('out-of-stock-actually');
8980
+ return false;
8981
+ }
8970
8982
  if (asociatedData.maximumItemsQuantity && totalQuantity > asociatedData.maximumItemsQuantity) {
8971
8983
  this.toastrService.show('maximum-items-quantity', { quantity: asociatedData.maximumItemsQuantity });
8972
8984
  return false;
@@ -9059,7 +9071,7 @@ let ProductDetailService = class ProductDetailService {
9059
9071
  }
9060
9072
  if (!variant)
9061
9073
  return;
9062
- if (!this.validateQuantity(quantity))
9074
+ if (!this.validateQuantity(quantity, variant.code))
9063
9075
  return;
9064
9076
  const priceToValidate = product_selected.saleprice ? product_selected.saleprice * quantity : product_selected.price * quantity;
9065
9077
  if (!this.validatePriceAndCredits(priceToValidate))
@@ -9186,9 +9198,10 @@ let ProductDetailEcComponent = class ProductDetailEcComponent extends ComponentH
9186
9198
  * @param forceMultiple si es true, obliga a que el resultado sea múltiplo de changeAmount.
9187
9199
  */
9188
9200
  this.plus = (stock, changeAmount = 1, forceMultiple = false) => {
9189
- let newQuantity = this.quantity + changeAmount;
9201
+ let currentQuantity = Number(this.quantity);
9202
+ let newQuantity = currentQuantity + changeAmount;
9190
9203
  if (forceMultiple && changeAmount > 0) {
9191
- if (this.quantity < changeAmount) {
9204
+ if (currentQuantity < changeAmount) {
9192
9205
  newQuantity = changeAmount;
9193
9206
  }
9194
9207
  else {
@@ -11468,8 +11481,8 @@ let RegisterFormEcComponent = class RegisterFormEcComponent extends ComponentHel
11468
11481
  }
11469
11482
  ngOnInit() {
11470
11483
  this.registerForm = this.formBuilder.group({
11471
- firstName: ['', Validators.required],
11472
- lastName: ['', Validators.required],
11484
+ firstName: ['', [Validators.required, Validators.pattern(/^[A-Za-zÁÉÍÓÚáéíóúÑñ\s]+$/)]],
11485
+ lastName: ['', [Validators.required, Validators.pattern(/^[A-Za-zÁÉÍÓÚáéíóúÑñ\s]+$/)]],
11473
11486
  email: ['', Validators.required],
11474
11487
  plainPassword: ['', Validators.required],
11475
11488
  plainPassword2: ['', Validators.required],
@@ -11968,8 +11981,8 @@ let RegisterWholesalerFormEcComponent = class RegisterWholesalerFormEcComponent
11968
11981
  ngOnInit() {
11969
11982
  this.paramsService.parameters.subscribe(res => this.params = res);
11970
11983
  this.registerForm = this.formBuilder.group({
11971
- firstName: ['', [Validators.required]],
11972
- lastName: ['', [Validators.required]],
11984
+ firstName: ['', [Validators.required, Validators.pattern(/^[A-Za-zÁÉÍÓÚáéíóúÑñ\s]+$/)]],
11985
+ lastName: ['', [Validators.required, Validators.pattern(/^[A-Za-zÁÉÍÓÚáéíóúÑñ\s]+$/)]],
11973
11986
  documentType: [null, [Validators.required]],
11974
11987
  documentNumber: ['', [Validators.required]],
11975
11988
  email: ['', [Validators.required, Validators.email]],