ng-easycommerce 0.0.624 → 0.0.626

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.
@@ -4907,6 +4907,12 @@ var CartService = /** @class */ (function () {
4907
4907
  _this.toastrService.show('minimum-items-quantity', { quantity: item.product.variants[0].minimumItemsQuantity });
4908
4908
  return false;
4909
4909
  }
4910
+ if (item.product.variants[0].multipleQuantity && item.product.variants[0].multipleQuantity > 0) {
4911
+ if ((_this.getCountFromItemInCart(item.productCode) + quantity) % item.product.variants[0].multipleQuantity !== 0) {
4912
+ _this.toastrService.show('must-be-multiple', { quantity: item.product.variants[0].multipleQuantity });
4913
+ return false;
4914
+ }
4915
+ }
4910
4916
  return true;
4911
4917
  };
4912
4918
  this.validatePriceAndCredits = function (item, quantity) {
@@ -7445,28 +7451,6 @@ var CartEcComponent = /** @class */ (function (_super) {
7445
7451
  _this.creditAccountShowPrices = null;
7446
7452
  _this.showTaxLegend = false;
7447
7453
  _this.toDecimal = function (amount) { return _this.consts.toDecimal(amount); };
7448
- _this.actualizarCantidad = function (item, cantidad, stock, id) {
7449
- if (id) {
7450
- _this.isDisabled = true; // Actualiza la propiedad vinculada a `[disabled]`
7451
- if (cantidad > 0 && cantidad <= stock) {
7452
- _this.cartService.updateItemQuantity(item, cantidad);
7453
- }
7454
- else {
7455
- _this.toastrService.show('out-of-stock-actually');
7456
- }
7457
- setTimeout(function () {
7458
- _this.isDisabled = false;
7459
- }, 1000);
7460
- }
7461
- else {
7462
- if (cantidad > 0 && cantidad <= stock) {
7463
- _this.cartService.updateItemQuantity(item, cantidad);
7464
- }
7465
- else {
7466
- _this.toastrService.show('out-of-stock-actually');
7467
- }
7468
- }
7469
- };
7470
7454
  _this.redirectRegister = function () { return _this.router.navigateByUrl("/auth/login"); };
7471
7455
  _this.getVariants = function (product) {
7472
7456
  var item = product.product;
@@ -7543,6 +7527,47 @@ var CartEcComponent = /** @class */ (function (_super) {
7543
7527
  });
7544
7528
  this.ecOnInit();
7545
7529
  };
7530
+ CartEcComponent.prototype.actualizarCantidad = function (item, cantidad, stock, id) {
7531
+ var _this = this;
7532
+ var _a;
7533
+ var multipleQuantity = ((_a = item.product) === null || _a === void 0 ? void 0 : _a.variants) && item.product.variants.length > 0 ? item.product.variants[0].multipleQuantity : 0;
7534
+ var step = multipleQuantity && multipleQuantity > 0 ? multipleQuantity : 1;
7535
+ var newQuantity;
7536
+ if (typeof cantidad === 'string') {
7537
+ newQuantity = parseInt(cantidad, 10);
7538
+ if (newQuantity % step !== 0) {
7539
+ this.toastrService.show('must-be-multiple', { quantity: step });
7540
+ newQuantity = Math.round(newQuantity / step) * step;
7541
+ }
7542
+ }
7543
+ else {
7544
+ newQuantity = cantidad;
7545
+ if (newQuantity % step !== 0) {
7546
+ newQuantity = Math.round(newQuantity / step) * step;
7547
+ }
7548
+ }
7549
+ if (id) {
7550
+ this.isDisabled = true; // Actualiza la propiedad vinculada a `[disabled]`
7551
+ if (newQuantity > 0 && newQuantity <= stock) {
7552
+ this.cartService.updateItemQuantity(item, newQuantity);
7553
+ }
7554
+ else {
7555
+ this.toastrService.show('out-of-stock-actually');
7556
+ }
7557
+ setTimeout(function () {
7558
+ _this.isDisabled = false;
7559
+ }, 1000);
7560
+ }
7561
+ else {
7562
+ if (newQuantity > 0 && newQuantity <= stock) {
7563
+ this.cartService.updateItemQuantity(item, newQuantity);
7564
+ }
7565
+ else {
7566
+ this.toastrService.show('out-of-stock-actually');
7567
+ }
7568
+ }
7569
+ };
7570
+ ;
7546
7571
  CartEcComponent.prototype.redirectCheckout = function () {
7547
7572
  if (this.cartService.hasSufficientCreditsForCartTotal()) {
7548
7573
  this.router.navigateByUrl("/checkout");
@@ -13539,6 +13564,17 @@ var __extends$O = (this && this.__extends) || (function () {
13539
13564
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13540
13565
  };
13541
13566
  })();
13567
+ var __assign$r = (this && this.__assign) || function () {
13568
+ __assign$r = Object.assign || function(t) {
13569
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
13570
+ s = arguments[i];
13571
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
13572
+ t[p] = s[p];
13573
+ }
13574
+ return t;
13575
+ };
13576
+ return __assign$r.apply(this, arguments);
13577
+ };
13542
13578
  var __decorate$1n = (this && this.__decorate) || function (decorators, target, key, desc) {
13543
13579
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
13544
13580
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -13547,7 +13583,7 @@ var __decorate$1n = (this && this.__decorate) || function (decorators, target, k
13547
13583
  };
13548
13584
  var RegisterFormEcComponent = /** @class */ (function (_super) {
13549
13585
  __extends$O(RegisterFormEcComponent, _super);
13550
- function RegisterFormEcComponent(authService, toastr, router, analyticsService, formBuilder, channelConfigService) {
13586
+ function RegisterFormEcComponent(authService, toastr, router, analyticsService, formBuilder, channelConfigService, consts) {
13551
13587
  var _this = _super.call(this) || this;
13552
13588
  _this.authService = authService;
13553
13589
  _this.toastr = toastr;
@@ -13555,6 +13591,13 @@ var RegisterFormEcComponent = /** @class */ (function (_super) {
13555
13591
  _this.analyticsService = analyticsService;
13556
13592
  _this.formBuilder = formBuilder;
13557
13593
  _this.channelConfigService = channelConfigService;
13594
+ _this.consts = consts;
13595
+ _this.provincesSubject = new BehaviorSubject([]);
13596
+ _this.countriesSubject = new BehaviorSubject([]);
13597
+ _this.documentTypesSubject = new BehaviorSubject([]);
13598
+ _this.provinces$ = _this.provincesSubject.asObservable();
13599
+ _this.countries$ = _this.countriesSubject.asObservable();
13600
+ _this.documentTypes$ = _this.documentTypesSubject.asObservable();
13558
13601
  _this.isLogged = true;
13559
13602
  _this.darkMode = false;
13560
13603
  _this.redirect = true;
@@ -13596,7 +13639,8 @@ var RegisterFormEcComponent = /** @class */ (function (_super) {
13596
13639
  return;
13597
13640
  }
13598
13641
  if (_this.registerForm.valid) {
13599
- _this.authService.signUp(_this.registerForm.value).toPromise().then(function (res) {
13642
+ var normalizedData = _this.normalizeRegisterData(_this.registerForm.value);
13643
+ _this.authService.signUp(normalizedData).toPromise().then(function (res) {
13600
13644
  _this.register_loading = false;
13601
13645
  var messageKey;
13602
13646
  switch (true) {
@@ -13638,6 +13682,18 @@ var RegisterFormEcComponent = /** @class */ (function (_super) {
13638
13682
  _this.register_loading = false;
13639
13683
  }
13640
13684
  };
13685
+ _this.onCountrySelected = function (value) {
13686
+ $('#selectOpPais').attr('disabled', true);
13687
+ _this.registerForm.controls['countryCode'].setValue(value);
13688
+ _this.registerForm.controls['provinceCode'].setValue('');
13689
+ value != '' && _this.provincesSubject.next(_this.countriesSubject.value.find(function (country) { return country.code == value; }).provinces);
13690
+ };
13691
+ _this.onGenderSelected = function (value) {
13692
+ $('#selectOpSexo').attr('disabled', true);
13693
+ };
13694
+ _this.onProvincesSelected = function (value) {
13695
+ $('#selectOpProvincia').attr('disabled', true);
13696
+ };
13641
13697
  _this.ecOnConstruct();
13642
13698
  return _this;
13643
13699
  }
@@ -13651,7 +13707,40 @@ var RegisterFormEcComponent = /** @class */ (function (_super) {
13651
13707
  plainPassword2: ['', Validators.required],
13652
13708
  newsletter: [false],
13653
13709
  terms: ['', Validators.required],
13654
- birthday: [''],
13710
+ birthday: [null, [this.optionalMaxLengthValidator(11)]],
13711
+ // Dirección (opcional, pero si se envía, se recomienda enviar todos los campos internos)
13712
+ countryCode: [''],
13713
+ provinceCode: [null],
13714
+ street: [null],
13715
+ city: [''],
13716
+ postcode: [''],
13717
+ // Datos empresa (opcionales)
13718
+ companyName: [''],
13719
+ legalDenomination: [''],
13720
+ // Datos personales adicionales (opcionales)
13721
+ gender: [null],
13722
+ phoneNumber: ['', [Validators.pattern('[0-9]+')]],
13723
+ subscribedToNewsletter: [false],
13724
+ documentType: [null],
13725
+ documentNumber: [''],
13726
+ // Comentarios y contacto (opcionales)
13727
+ comments: ['', []],
13728
+ contactFirstName: ['', []],
13729
+ contactLastName: ['', []],
13730
+ contactCompanyPosition: ['', []],
13731
+ contactEmail: ['', []],
13732
+ contactDocumentType: ['', []],
13733
+ contactDocumentNumber: ['', []],
13734
+ }, {
13735
+ validators: [this.direccionCompletaValidator()]
13736
+ });
13737
+ this.authService.getCountriesData().then(function (res) {
13738
+ _this.countriesSubject.next(res);
13739
+ var documentTypes = [];
13740
+ res.map(function (paises) {
13741
+ _this.consts.getLocale().toLocaleLowerCase().includes(paises.code.toLocaleLowerCase()) && (documentTypes = paises.documentTypes || []);
13742
+ });
13743
+ _this.documentTypesSubject.next(documentTypes);
13655
13744
  });
13656
13745
  this.channelConfigService.channelConfig$.subscribe(function (config) {
13657
13746
  if (config && config.isAccountVerificationRequired !== undefined) {
@@ -13669,8 +13758,42 @@ var RegisterFormEcComponent = /** @class */ (function (_super) {
13669
13758
  });
13670
13759
  this.ecOnInit();
13671
13760
  };
13672
- RegisterFormEcComponent.prototype.prueba = function () {
13673
- this.toastr.showPersistent('hola');
13761
+ RegisterFormEcComponent.prototype.direccionCompletaValidator = function () {
13762
+ return function (control) {
13763
+ var _a, _b, _c, _d, _e;
13764
+ var street = (_a = control.get('street')) === null || _a === void 0 ? void 0 : _a.value;
13765
+ var city = (_b = control.get('city')) === null || _b === void 0 ? void 0 : _b.value;
13766
+ var provinceCode = (_c = control.get('provinceCode')) === null || _c === void 0 ? void 0 : _c.value;
13767
+ var countryCode = (_d = control.get('countryCode')) === null || _d === void 0 ? void 0 : _d.value;
13768
+ var postcode = (_e = control.get('postcode')) === null || _e === void 0 ? void 0 : _e.value;
13769
+ var hasValue = function (val) { return val !== null && val !== undefined && val.toString().trim() !== ''; };
13770
+ var anyFieldSet = [street, city, provinceCode, countryCode, postcode].some(hasValue);
13771
+ var allFieldsSet = [street, city, provinceCode, countryCode, postcode].every(hasValue);
13772
+ // Si al menos un campo de dirección está establecido, todos deben estarlo
13773
+ // Si no hay ningún campo de dirección establecido, no se aplica la validación
13774
+ if (anyFieldSet && !allFieldsSet) {
13775
+ return { direccionIncompleta: true };
13776
+ }
13777
+ return null;
13778
+ };
13779
+ };
13780
+ RegisterFormEcComponent.prototype.optionalMaxLengthValidator = function (max) {
13781
+ return function (control) {
13782
+ if (!control.value)
13783
+ return null;
13784
+ return control.value.length > max ? { maxLength: true } : null;
13785
+ };
13786
+ };
13787
+ RegisterFormEcComponent.prototype.normalizeRegisterData = function (data) {
13788
+ var normalizeString = function (val) {
13789
+ return val === undefined || val === null || val.toString().trim() === '' ? null : val.toString().trim();
13790
+ };
13791
+ var normalizeBool = function (val) {
13792
+ return typeof val === 'boolean' ? val : val === 'true' ? true : val === 'false' ? false : null;
13793
+ };
13794
+ return __assign$r(__assign$r({}, data), { birthday: normalizeString(data.birthday) || '', companyName: normalizeString(data.companyName), legalDenomination: normalizeString(data.legalDenomination), gender: normalizeString(data.gender), phoneNumber: normalizeString(data.phoneNumber), subscribedToNewsletter: normalizeBool(data.subscribedToNewsletter), documentType: normalizeString(data.documentType), documentNumber: normalizeString(data.documentNumber), comments: normalizeString(data.comments), contactFirstName: normalizeString(data.contactFirstName), contactLastName: normalizeString(data.contactLastName), contactCompanyPosition: normalizeString(data.contactCompanyPosition), contactEmail: normalizeString(data.contactEmail), contactDocumentType: normalizeString(data.contactDocumentType), contactDocumentNumber: normalizeString(data.contactDocumentNumber),
13795
+ // Dirección
13796
+ countryCode: normalizeString(data.countryCode), provinceCode: normalizeString(data.provinceCode), street: normalizeString(data.street), city: normalizeString(data.city), postcode: normalizeString(data.postcode) });
13674
13797
  };
13675
13798
  RegisterFormEcComponent.ctorParameters = function () { return [
13676
13799
  { type: AuthService },
@@ -13678,7 +13801,8 @@ var RegisterFormEcComponent = /** @class */ (function (_super) {
13678
13801
  { type: Router },
13679
13802
  { type: AnalyticsService },
13680
13803
  { type: FormBuilder },
13681
- { type: ChannelConfigService }
13804
+ { type: ChannelConfigService },
13805
+ { type: Constants }
13682
13806
  ]; };
13683
13807
  __decorate$1n([
13684
13808
  Input()
@@ -14069,8 +14193,8 @@ var __extends$T = (this && this.__extends) || (function () {
14069
14193
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14070
14194
  };
14071
14195
  })();
14072
- var __assign$r = (this && this.__assign) || function () {
14073
- __assign$r = Object.assign || function(t) {
14196
+ var __assign$s = (this && this.__assign) || function () {
14197
+ __assign$s = Object.assign || function(t) {
14074
14198
  for (var s, i = 1, n = arguments.length; i < n; i++) {
14075
14199
  s = arguments[i];
14076
14200
  for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
@@ -14078,7 +14202,7 @@ var __assign$r = (this && this.__assign) || function () {
14078
14202
  }
14079
14203
  return t;
14080
14204
  };
14081
- return __assign$r.apply(this, arguments);
14205
+ return __assign$s.apply(this, arguments);
14082
14206
  };
14083
14207
  var __decorate$1s = (this && this.__decorate) || function (decorators, target, key, desc) {
14084
14208
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@@ -14142,7 +14266,7 @@ var RegisterWholesalerFormEcComponent = /** @class */ (function (_super) {
14142
14266
  _this.register_loading = true;
14143
14267
  if (_this.registerForm.valid) {
14144
14268
  // Convertir postcode a string antes de enviar
14145
- var formValue = __assign$r(__assign$r({}, _this.registerForm.value), { postcode: String(_this.registerForm.value.postcode) });
14269
+ var formValue = __assign$s(__assign$s({}, _this.registerForm.value), { postcode: String(_this.registerForm.value.postcode) });
14146
14270
  _this.authService.signUpWholesaler(formValue).toPromise().then(function (res) {
14147
14271
  _this.register_loading = false;
14148
14272
  _this.toastr.show('register-ok');
@@ -15626,8 +15750,8 @@ var __extends$11 = (this && this.__extends) || (function () {
15626
15750
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15627
15751
  };
15628
15752
  })();
15629
- var __assign$s = (this && this.__assign) || function () {
15630
- __assign$s = Object.assign || function(t) {
15753
+ var __assign$t = (this && this.__assign) || function () {
15754
+ __assign$t = Object.assign || function(t) {
15631
15755
  for (var s, i = 1, n = arguments.length; i < n; i++) {
15632
15756
  s = arguments[i];
15633
15757
  for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
@@ -15635,7 +15759,7 @@ var __assign$s = (this && this.__assign) || function () {
15635
15759
  }
15636
15760
  return t;
15637
15761
  };
15638
- return __assign$s.apply(this, arguments);
15762
+ return __assign$t.apply(this, arguments);
15639
15763
  };
15640
15764
  var __decorate$1C = (this && this.__decorate) || function (decorators, target, key, desc) {
15641
15765
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@@ -15682,7 +15806,7 @@ var SelectChannelEcComponent = /** @class */ (function (_super) {
15682
15806
  var _this = this;
15683
15807
  this.subs = this.authService.channelsUser.pipe(filter(function (res) { return res != null && res.length > 0; })).subscribe(function (res) {
15684
15808
  _this.channels = res.map(function (item) {
15685
- return __assign$s(__assign$s({}, item), { selected: false });
15809
+ return __assign$t(__assign$t({}, item), { selected: false });
15686
15810
  });
15687
15811
  _this.initializeTemplate();
15688
15812
  });
@@ -16901,8 +17025,8 @@ var __extends$16 = (this && this.__extends) || (function () {
16901
17025
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
16902
17026
  };
16903
17027
  })();
16904
- var __assign$t = (this && this.__assign) || function () {
16905
- __assign$t = Object.assign || function(t) {
17028
+ var __assign$u = (this && this.__assign) || function () {
17029
+ __assign$u = Object.assign || function(t) {
16906
17030
  for (var s, i = 1, n = arguments.length; i < n; i++) {
16907
17031
  s = arguments[i];
16908
17032
  for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
@@ -16910,7 +17034,7 @@ var __assign$t = (this && this.__assign) || function () {
16910
17034
  }
16911
17035
  return t;
16912
17036
  };
16913
- return __assign$t.apply(this, arguments);
17037
+ return __assign$u.apply(this, arguments);
16914
17038
  };
16915
17039
  var __decorate$1L = (this && this.__decorate) || function (decorators, target, key, desc) {
16916
17040
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@@ -16954,7 +17078,7 @@ var ProductFoundEcComponent = /** @class */ (function (_super) {
16954
17078
  window.scroll(0, 0);
16955
17079
  });
16956
17080
  _this.productService.product$.pipe(filter(function (data) { return data && data.id && data.id != 0; })).subscribe(function (productParam) {
16957
- _this.analyticsService.callEvent('view_item', __assign$t(__assign$t({}, productParam), { currency: _this.consts.currency.code }));
17081
+ _this.analyticsService.callEvent('view_item', __assign$u(__assign$u({}, productParam), { currency: _this.consts.currency.code }));
16958
17082
  });
16959
17083
  _this.ecOnConstruct();
16960
17084
  return _this;
@@ -18137,8 +18261,8 @@ var BancardCatastroEcComponent = /** @class */ (function (_super) {
18137
18261
  return BancardCatastroEcComponent;
18138
18262
  }(ComponentHelper));
18139
18263
 
18140
- var __assign$u = (this && this.__assign) || function () {
18141
- __assign$u = Object.assign || function(t) {
18264
+ var __assign$v = (this && this.__assign) || function () {
18265
+ __assign$v = Object.assign || function(t) {
18142
18266
  for (var s, i = 1, n = arguments.length; i < n; i++) {
18143
18267
  s = arguments[i];
18144
18268
  for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
@@ -18146,7 +18270,7 @@ var __assign$u = (this && this.__assign) || function () {
18146
18270
  }
18147
18271
  return t;
18148
18272
  };
18149
- return __assign$u.apply(this, arguments);
18273
+ return __assign$v.apply(this, arguments);
18150
18274
  };
18151
18275
  var __decorate$1U = (this && this.__decorate) || function (decorators, target, key, desc) {
18152
18276
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@@ -18213,7 +18337,7 @@ var CookiesService = /** @class */ (function () {
18213
18337
  * @description realiza un merge con los valores por defecto para rellenar el objeto de cookies
18214
18338
  */
18215
18339
  this.setDefaultParameters = function () {
18216
- _this.cookies = __assign$u(__assign$u({}, _this.defaultValues), _this.cookies);
18340
+ _this.cookies = __assign$v(__assign$v({}, _this.defaultValues), _this.cookies);
18217
18341
  };
18218
18342
  /**
18219
18343
  * @description procesa el parametro ingresado, para transformarlo en un atributo del objeto de cookies.
@@ -18234,7 +18358,7 @@ var CookiesService = /** @class */ (function () {
18234
18358
  break;
18235
18359
  case 'others':
18236
18360
  !_this.cookies[attrName] ? _this.cookies[attrName] = {} : null;
18237
- _this.cookies[attrName] = __assign$u(__assign$u({}, _this.cookies[attrName]), _this.othersAttrProcessing(element));
18361
+ _this.cookies[attrName] = __assign$v(__assign$v({}, _this.cookies[attrName]), _this.othersAttrProcessing(element));
18238
18362
  break;
18239
18363
  case 'message':
18240
18364
  _this.cookies[attrName] = _this.messageAttrProcessing(element);
@@ -18286,7 +18410,7 @@ var CookiesService = /** @class */ (function () {
18286
18410
  break;
18287
18411
  default:
18288
18412
  //console.log(value)
18289
- objReturn = __assign$u(__assign$u({}, objReturn), _this.getObjByFormatType(objReturn.type, value));
18413
+ objReturn = __assign$v(__assign$v({}, objReturn), _this.getObjByFormatType(objReturn.type, value));
18290
18414
  break;
18291
18415
  }
18292
18416
  }
@@ -18844,21 +18968,6 @@ var SidebarEcComponent = /** @class */ (function () {
18844
18968
  this.hideTaxes = false;
18845
18969
  this.creditAccountShowPrices = null;
18846
18970
  this.showTaxLegend = false;
18847
- this.actualizarCantidad = function (item, cantidad, stock, id) {
18848
- if (id) {
18849
- var elem_1 = document.getElementById(id);
18850
- elem_1.disabled = true;
18851
- cantidad > 0 && cantidad <= stock
18852
- ? _this.cartService.updateItemQuantity(item, cantidad)
18853
- : _this.toastrService.show('out-of-stock-actually');
18854
- setTimeout(function () {
18855
- elem_1.disabled = false;
18856
- }, 1000);
18857
- }
18858
- else {
18859
- cantidad > 0 && cantidad <= stock && _this.cartService.updateItemQuantity(item, cantidad);
18860
- }
18861
- };
18862
18971
  this.getVariants = function (product) {
18863
18972
  var item = product.product;
18864
18973
  if (item.variants && item.variants.length && item.variants[0].options && item.variants[0].options.length) {
@@ -18917,6 +19026,47 @@ var SidebarEcComponent = /** @class */ (function () {
18917
19026
  _this.creditAccountShowPrices = showPrice;
18918
19027
  });
18919
19028
  };
19029
+ SidebarEcComponent.prototype.actualizarCantidad = function (item, cantidad, stock, id) {
19030
+ var _a;
19031
+ var multipleQuantity = ((_a = item.product) === null || _a === void 0 ? void 0 : _a.variants) && item.product.variants.length > 0 ? item.product.variants[0].multipleQuantity : 0;
19032
+ var step = multipleQuantity && multipleQuantity > 0 ? multipleQuantity : 1;
19033
+ var newQuantity;
19034
+ if (typeof cantidad === 'string') {
19035
+ newQuantity = parseInt(cantidad, 10);
19036
+ if (newQuantity % step !== 0) {
19037
+ this.toastrService.show('must-be-multiple', { quantity: step });
19038
+ newQuantity = Math.round(newQuantity / step) * step;
19039
+ }
19040
+ }
19041
+ else {
19042
+ newQuantity = cantidad;
19043
+ if (newQuantity % step !== 0) {
19044
+ newQuantity = Math.round(newQuantity / step) * step;
19045
+ }
19046
+ }
19047
+ if (id) {
19048
+ var elem_1 = document.getElementById(id);
19049
+ if (elem_1) {
19050
+ elem_1.disabled = true;
19051
+ }
19052
+ if (newQuantity > 0 && newQuantity <= stock) {
19053
+ this.cartService.updateItemQuantity(item, newQuantity);
19054
+ }
19055
+ else {
19056
+ this.toastrService.show('out-of-stock-actually');
19057
+ }
19058
+ if (elem_1) {
19059
+ setTimeout(function () {
19060
+ elem_1.disabled = false;
19061
+ }, 1000);
19062
+ }
19063
+ }
19064
+ else {
19065
+ if (newQuantity > 0 && newQuantity <= stock) {
19066
+ this.cartService.updateItemQuantity(item, newQuantity);
19067
+ }
19068
+ }
19069
+ };
18920
19070
  SidebarEcComponent.prototype.redirectDetailProduct = function (product) {
18921
19071
  var variant = product.variants[0];
18922
19072
  var path = '/product/';