ng-easycommerce 0.0.588 → 0.0.589

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 CHANGED
@@ -1,3 +1,7 @@
1
+ # version 0.0.589
2
+ - En `cart.service.ts`, dentro del método `addRepeatOrderToCart`, se agregaron validaciones para manejar la respuesta del backend al repetir un pedido.
3
+ - Se implementó la verificación de crédito y pedidos pendientes para usuarios con cuenta corriente.
4
+ - En `filters-ec.component.ts` se agregaron los metodos de filtro por rango de precio `roundToNearest` y `updateFilterPrices`
1
5
  # version 0.0.588
2
6
  - Se agrega `ip-address.service.ts` y se modifica para mandar datos en endpoint haspurchase del checkout.
3
7
  # version 0.0.587
@@ -277,5 +277,7 @@
277
277
  "repeat-order": "Repetir comanda",
278
278
  "no-products-to-add": "No hi ha productes per afegir",
279
279
  "not-enough-credits": "No té prou crèdits per comprar aquest producte",
280
- "max-orders-reached": "Has assolit el nombre màxim de comandes"
280
+ "max-orders-reached": "Has assolit el nombre màxim de comandes",
281
+ "order_limit_reached": "Límit de comandes assolit",
282
+ "insufficient_credit": "Crèdit insuficient"
281
283
  }
@@ -382,4 +382,6 @@
382
382
  "thanks-send-review": "Thank you for leaving a review.",
383
383
  "authenticated-for-comment": "Please log in to leave a review.",
384
384
  "max-orders-reached": "You have reached the maximum number of orders allowed.",
385
+ "order_limit_reached": "Order limit reached",
386
+ "insufficient_credit": "Insufficient credit"
385
387
  }
@@ -386,5 +386,7 @@
386
386
  "not-enough-credits": "No tiene suficientes créditos para comprar este producto",
387
387
  "thanks-send-review": "Gracias por dejar una reseña.",
388
388
  "authenticated-for-comment": "Inicia sesión para dejar una reseña.",
389
- "max-orders-reached": "Has alcanzado el número máximo de pedidos"
389
+ "max-orders-reached": "Has alcanzado el número máximo de pedidos",
390
+ "order_limit_reached": "Límite de pedidos alcanzado",
391
+ "insufficient_credit": "Crédito insuficiente"
390
392
  }
@@ -269,5 +269,7 @@
269
269
  "repeat-order": "Répéter la commande",
270
270
  "no-products-to-add": "Aucun produit à ajouter",
271
271
  "not-enough-credits": "Vous n'avez pas assez de crédits pour acheter ce produit",
272
- "max-orders-reached": "Vous avez atteint le nombre maximum de commandes."
272
+ "max-orders-reached": "Vous avez atteint le nombre maximum de commandes.",
273
+ "order_limit_reached": "Limite de commandes atteinte",
274
+ "insufficient_credit": "Crédit insuffisant"
273
275
  }
@@ -277,5 +277,7 @@
277
277
  "repeat-order": "Repetir pedido",
278
278
  "no-products-to-add": "Non hai produtos para engadir",
279
279
  "not-enough-credits": "Non ten suficientes créditos para realizar a compra",
280
- "max-orders-reached": "Acadaches o número máximo de pedidos"
280
+ "max-orders-reached": "Acadaches o número máximo de pedidos",
281
+ "order_limit_reached": "Límite de pedidos acadado",
282
+ "insufficient_credit": "Crédito insuficiente"
281
283
  }
@@ -277,5 +277,7 @@
277
277
  "repeat-order": "Repetir pedido",
278
278
  "no-products-to-add": "Não há produtos para adicionar",
279
279
  "not-enough-credits": "Você não tem créditos suficientes para fazer essa compra",
280
- "max-orders-reached": "Você atingiu o número máximo de pedidos"
280
+ "max-orders-reached": "Você atingiu o número máximo de pedidos",
281
+ "order_limit_reached": "Limite de pedidos atingido",
282
+ "insufficient_credit": "Crédito insuficiente"
281
283
  }
@@ -5072,16 +5072,26 @@
5072
5072
  };
5073
5073
  this.requestInProcess.next(true);
5074
5074
  this.connection.post(this.addAllItemsApi(), params)
5075
- .toPromise().then(function (res) {
5076
- _this.updateCartObj(res.cart);
5077
- _this.updateCartItems(_this.transformItems(res.cart.items));
5075
+ .toPromise()
5076
+ .then(function (res) {
5077
+ var _a, _b;
5078
+ if (res.status === 'failure') {
5079
+ var errorMessage = ((_a = res.error) === null || _a === void 0 ? void 0 : _a.toLowerCase().replace(/\s+/g, '_')) || 'unknown_error';
5080
+ _this.toastrService.show(errorMessage);
5081
+ return;
5082
+ }
5083
+ if ((_b = res) === null || _b === void 0 ? void 0 : _b.cart) {
5084
+ _this.updateCartObj(res.cart);
5085
+ _this.updateCartItems(_this.transformItems(res.cart.items));
5086
+ }
5078
5087
  if (res.cart_response.status === 'success') {
5079
5088
  _this.toastrService.show('products-added');
5080
5089
  _this.router.navigate(['/cart']);
5081
5090
  }
5082
5091
  }, function (err) {
5083
5092
  _this.handleError(err);
5084
- }).catch(function (err) {
5093
+ })
5094
+ .catch(function (err) {
5085
5095
  _this.handleError(err);
5086
5096
  });
5087
5097
  };
@@ -9254,6 +9264,10 @@
9254
9264
  // : this.document.getElementById(accordion_id).classList.remove('show');
9255
9265
  return true;
9256
9266
  };
9267
+ _this.scrollUp = function () {
9268
+ window.scroll(0, 0);
9269
+ return true;
9270
+ };
9257
9271
  _this.ecOnConstruct();
9258
9272
  return _this;
9259
9273
  }
@@ -9295,6 +9309,59 @@
9295
9309
  });
9296
9310
  });
9297
9311
  };
9312
+ /**
9313
+ * Redondea al múltiplo de 'step' respetando el redondeo entero:
9314
+ * - Mínimo: redondea hacia abajo.
9315
+ * - Máximo: redondea hacia arriba.
9316
+ */
9317
+ FiltersEcComponent.prototype.roundToNearest = function (value, step, type, filter) {
9318
+ var rounded = Math.round(value / step) * step;
9319
+ if (type === 'max' && rounded < filter.maxPrice) {
9320
+ rounded = Math.ceil(value / step) * step;
9321
+ }
9322
+ if (type === 'min' && rounded > filter.minPrice) {
9323
+ rounded = Math.floor(value / step) * step;
9324
+ }
9325
+ return rounded;
9326
+ };
9327
+ /**
9328
+ * Actualiza los valores del filtro permitiendo que un input empuje al otro.
9329
+ */
9330
+ FiltersEcComponent.prototype.updateFilterPrices = function (type, value, filter, priceGap) {
9331
+ var _a, _b, _c;
9332
+ var globalMin = (_a = filter.minPrice, (_a !== null && _a !== void 0 ? _a : 0));
9333
+ var globalMax = filter.maxPrice;
9334
+ var currentMin = (_b = filter.currentMinPrice, (_b !== null && _b !== void 0 ? _b : globalMin));
9335
+ var currentMax = (_c = filter.currentMaxPrice, (_c !== null && _c !== void 0 ? _c : globalMax));
9336
+ if (type === 'min') {
9337
+ var newMin = Math.min(Math.max(value, globalMin), globalMax);
9338
+ if (newMin + priceGap > currentMax) {
9339
+ var newMaxCandidate = newMin + priceGap;
9340
+ if (newMaxCandidate <= globalMax) {
9341
+ currentMax = newMaxCandidate;
9342
+ }
9343
+ else {
9344
+ newMin = globalMax - priceGap;
9345
+ }
9346
+ }
9347
+ filter.currentMinPrice = newMin;
9348
+ filter.currentMaxPrice = currentMax;
9349
+ }
9350
+ else if (type === 'max') {
9351
+ var newMax = Math.max(Math.min(value, globalMax), globalMin);
9352
+ if (newMax - priceGap < currentMin) {
9353
+ var newMinCandidate = newMax - priceGap;
9354
+ if (newMinCandidate >= globalMin) {
9355
+ currentMin = newMinCandidate;
9356
+ }
9357
+ else {
9358
+ newMax = globalMin + priceGap;
9359
+ }
9360
+ }
9361
+ filter.currentMaxPrice = newMax;
9362
+ filter.currentMinPrice = currentMin;
9363
+ }
9364
+ };
9298
9365
  FiltersEcComponent.ctorParameters = function () { return [
9299
9366
  { type: Constants },
9300
9367
  { type: Document, decorators: [{ type: core.Inject, args: [common.DOCUMENT,] }] },
@@ -10521,7 +10588,8 @@
10521
10588
  return;
10522
10589
  if (!this.validateQuantity(quantity))
10523
10590
  return;
10524
- if (!this.validatePriceAndCredits(product_selected.price * quantity))
10591
+ var priceToValidate = product_selected.saleprice ? product_selected.saleprice * quantity : product_selected.price * quantity;
10592
+ if (!this.validatePriceAndCredits(priceToValidate))
10525
10593
  return;
10526
10594
  this.cartService.addToCart(this.makeAffordableProduct(product_selected), quantity, variant.code);
10527
10595
  };