contentoh-components-library 21.3.15 → 21.3.16

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.
@@ -759,14 +759,18 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
759
759
 
760
760
  var saveDescriptions = /*#__PURE__*/function () {
761
761
  var _ref6 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5() {
762
- var _product$article9, productTemp, articleId, dataObject, res, _JSON$parse2, newStatus, newArticleStatus;
762
+ var dataClean, _product$article9, productTemp, articleId, dataObject, res, _JSON$parse2, newStatus, newArticleStatus;
763
763
 
764
764
  return _regenerator.default.wrap(function _callee5$(_context5) {
765
765
  while (1) {
766
766
  switch (_context5.prev = _context5.next) {
767
767
  case 0:
768
- if (!updatedDescriptions) {
769
- _context5.next = 24;
768
+ dataClean = updatedDescriptions.filter(function (f) {
769
+ return f.value !== '';
770
+ });
771
+
772
+ if (!(dataClean.length > 0)) {
773
+ _context5.next = 25;
770
774
  break;
771
775
  }
772
776
 
@@ -775,22 +779,22 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
775
779
  articleId = product === null || product === void 0 ? void 0 : (_product$article9 = product.article) === null || _product$article9 === void 0 ? void 0 : _product$article9.id_article;
776
780
  dataObject = {
777
781
  articleId: articleId,
778
- articleData: updatedDescriptions
782
+ articleData: dataClean
779
783
  };
780
784
  if (product !== null && product !== void 0 && product.orderId) dataObject["orderId"] = product === null || product === void 0 ? void 0 : product.orderId;
781
- _context5.prev = 6;
782
- _context5.next = 9;
785
+ _context5.prev = 7;
786
+ _context5.next = 10;
783
787
  return _axios.default.put("".concat(process.env.REACT_APP_ARTICLE_DATA_ENDPOINT, "?description=true&version=").concat(version), dataObject, {
784
788
  headers: {
785
789
  Authorization: token
786
790
  }
787
791
  });
788
792
 
789
- case 9:
793
+ case 10:
790
794
  res = _context5.sent;
791
795
 
792
796
  if (!(res.data.statusCode === 200)) {
793
- _context5.next = 19;
797
+ _context5.next = 20;
794
798
  break;
795
799
  }
796
800
 
@@ -800,24 +804,24 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
800
804
  setProduct(productTemp);
801
805
  sessionStorage.setItem("productSelected", JSON.stringify(productTemp));
802
806
  setMessage("Descripciones guardadas con éxito");
803
- _context5.next = 19;
807
+ _context5.next = 20;
804
808
  return loadData();
805
809
 
806
- case 19:
807
- _context5.next = 24;
810
+ case 20:
811
+ _context5.next = 25;
808
812
  break;
809
813
 
810
- case 21:
811
- _context5.prev = 21;
812
- _context5.t0 = _context5["catch"](6);
814
+ case 22:
815
+ _context5.prev = 22;
816
+ _context5.t0 = _context5["catch"](7);
813
817
  console.log(_context5.t0);
814
818
 
815
- case 24:
819
+ case 25:
816
820
  case "end":
817
821
  return _context5.stop();
818
822
  }
819
823
  }
820
- }, _callee5, null, [[6, 21]]);
824
+ }, _callee5, null, [[7, 22]]);
821
825
  }));
822
826
 
823
827
  return function saveDescriptions() {
@@ -827,14 +831,18 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
827
831
 
828
832
  var saveDatasheets = /*#__PURE__*/function () {
829
833
  var _ref7 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6() {
830
- var _product$article10, productTemp, articleId, dataObject, res, _JSON$parse3, newStatus, newArticleStatus;
834
+ var dataClean, _product$article10, productTemp, articleId, dataObject, res, _JSON$parse3, newStatus, newArticleStatus;
831
835
 
832
836
  return _regenerator.default.wrap(function _callee6$(_context6) {
833
837
  while (1) {
834
838
  switch (_context6.prev = _context6.next) {
835
839
  case 0:
836
- if (!(updatedDatasheets.length > 0)) {
837
- _context6.next = 24;
840
+ dataClean = updatedDatasheets.filter(function (f) {
841
+ return f.value !== '';
842
+ });
843
+
844
+ if (!(dataClean.length > 0)) {
845
+ _context6.next = 25;
838
846
  break;
839
847
  }
840
848
 
@@ -843,22 +851,22 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
843
851
  articleId = product === null || product === void 0 ? void 0 : (_product$article10 = product.article) === null || _product$article10 === void 0 ? void 0 : _product$article10.id_article;
844
852
  dataObject = {
845
853
  articleId: articleId,
846
- articleData: updatedDatasheets
854
+ articleData: dataClean
847
855
  };
848
856
  if (product !== null && product !== void 0 && product.orderId) dataObject["orderId"] = product === null || product === void 0 ? void 0 : product.orderId;
849
- _context6.prev = 6;
850
- _context6.next = 9;
857
+ _context6.prev = 7;
858
+ _context6.next = 10;
851
859
  return _axios.default.put("".concat(process.env.REACT_APP_ARTICLE_DATA_ENDPOINT, "?datasheet=true&version=").concat(version), dataObject, {
852
860
  headers: {
853
861
  Authorization: token
854
862
  }
855
863
  });
856
864
 
857
- case 9:
865
+ case 10:
858
866
  res = _context6.sent;
859
867
 
860
868
  if (!(res.data.statusCode === 200)) {
861
- _context6.next = 19;
869
+ _context6.next = 20;
862
870
  break;
863
871
  }
864
872
 
@@ -868,24 +876,24 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
868
876
  setProduct(productTemp);
869
877
  sessionStorage.setItem("productSelected", JSON.stringify(productTemp));
870
878
  setMessage("Fichas técnicas guardadas");
871
- _context6.next = 19;
879
+ _context6.next = 20;
872
880
  return loadData();
873
881
 
874
- case 19:
875
- _context6.next = 24;
882
+ case 20:
883
+ _context6.next = 25;
876
884
  break;
877
885
 
878
- case 21:
879
- _context6.prev = 21;
880
- _context6.t0 = _context6["catch"](6);
886
+ case 22:
887
+ _context6.prev = 22;
888
+ _context6.t0 = _context6["catch"](7);
881
889
  console.log(_context6.t0);
882
890
 
883
- case 24:
891
+ case 25:
884
892
  case "end":
885
893
  return _context6.stop();
886
894
  }
887
895
  }
888
- }, _callee6, null, [[6, 21]]);
896
+ }, _callee6, null, [[7, 22]]);
889
897
  }));
890
898
 
891
899
  return function saveDatasheets() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "contentoh-components-library",
3
- "version": "21.3.15",
3
+ "version": "21.3.16",
4
4
  "dependencies": {
5
5
  "@aws-amplify/auth": "^4.5.3",
6
6
  "@aws-amplify/datastore": "^3.11.0",
@@ -435,13 +435,14 @@ export const RetailerProductEdition = ({
435
435
  };
436
436
 
437
437
  const saveDescriptions = async () => {
438
- if (updatedDescriptions) {
438
+ const dataClean = updatedDescriptions.filter((f) => f.value !== '');
439
+ if (dataClean.length > 0) {
439
440
  setLoading(true);
440
441
  const productTemp = product;
441
442
  const articleId = product?.article?.id_article;
442
443
  const dataObject = {
443
444
  articleId,
444
- articleData: updatedDescriptions,
445
+ articleData: dataClean,
445
446
  };
446
447
  if (product?.orderId) dataObject["orderId"] = product?.orderId;
447
448
  try {
@@ -475,13 +476,14 @@ export const RetailerProductEdition = ({
475
476
  };
476
477
 
477
478
  const saveDatasheets = async () => {
478
- if (updatedDatasheets.length > 0) {
479
+ const dataClean = updatedDatasheets.filter((f) => f.value !== '');
480
+ if (dataClean.length > 0) {
479
481
  setLoading(true);
480
482
  const productTemp = product;
481
483
  const articleId = product?.article?.id_article;
482
484
  const dataObject = {
483
485
  articleId,
484
- articleData: updatedDatasheets,
486
+ articleData: dataClean,
485
487
  };
486
488
  if (product?.orderId) dataObject["orderId"] = product?.orderId;
487
489
  try {