contentoh-components-library 21.1.60 → 21.1.63

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 (22) hide show
  1. package/dist/components/atoms/ProductPercentCard/Percent.stories.js +1 -1
  2. package/dist/components/atoms/ProductPercentCard/styles.js +1 -1
  3. package/dist/components/molecules/AssignedWork/AssignedWork.stories.js +1 -1
  4. package/dist/components/molecules/AssignedWork/styles.js +1 -1
  5. package/dist/components/organisms/FullProductNameHeader/index.js +1 -1
  6. package/dist/components/pages/ProviderProductEdition/ProviderProductEdition.stories.js +93 -109
  7. package/dist/components/pages/ProviderProductEdition/index.js +430 -429
  8. package/dist/components/pages/RetailerProductEdition/RetailerProductEdition.stories.js +1 -1
  9. package/dist/components/pages/RetailerProductEdition/index.js +217 -200
  10. package/dist/global-files/data.js +8 -8
  11. package/package.json +1 -1
  12. package/src/components/atoms/ProductPercentCard/Percent.stories.js +11 -12
  13. package/src/components/atoms/ProductPercentCard/styles.js +9 -9
  14. package/src/components/molecules/AssignedWork/AssignedWork.stories.js +8 -8
  15. package/src/components/molecules/AssignedWork/styles.js +9 -10
  16. package/src/components/organisms/FullProductNameHeader/index.js +2 -2
  17. package/src/components/pages/ProviderProductEdition/ProviderProductEdition.stories.js +95 -114
  18. package/src/components/pages/ProviderProductEdition/index.js +232 -248
  19. package/src/components/pages/RetailerProductEdition/RetailerProductEdition.stories.js +1 -1
  20. package/src/components/pages/RetailerProductEdition/index.js +149 -173
  21. package/src/global-files/data.js +8 -8
  22. package/src/components/atoms/ProgressBar/styles.js +0 -69
@@ -9,8 +9,6 @@ exports.RetailerProductEdition = void 0;
9
9
 
10
10
  var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
11
11
 
12
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/defineProperty"));
13
-
14
12
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/asyncToGenerator"));
15
13
 
16
14
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/slicedToArray"));
@@ -39,7 +37,7 @@ var _GalleryElement = require("../../molecules/GalleryElement");
39
37
 
40
38
  var _fileSaver = require("file-saver");
41
39
 
42
- var _data2 = require("../../../global-files/data");
40
+ var _data = require("../../../global-files/data");
43
41
 
44
42
  var _GalleryHeader = require("../../molecules/GalleryHeader");
45
43
 
@@ -396,20 +394,20 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
396
394
  case 0:
397
395
  _context.prev = 0;
398
396
  _context.next = 3;
399
- return (0, _data2.getRetailerServices)(product === null || product === void 0 ? void 0 : (_product$article = product.article) === null || _product$article === void 0 ? void 0 : _product$article.id_article, product === null || product === void 0 ? void 0 : (_product$article2 = product.article) === null || _product$article2 === void 0 ? void 0 : _product$article2.category, parseInt(product === null || product === void 0 ? void 0 : (_product$article3 = product.article) === null || _product$article3 === void 0 ? void 0 : _product$article3.id_category), product === null || product === void 0 ? void 0 : product.version);
397
+ return (0, _data.getRetailerServices)(product === null || product === void 0 ? void 0 : (_product$article = product.article) === null || _product$article === void 0 ? void 0 : _product$article.id_article, product === null || product === void 0 ? void 0 : (_product$article2 = product.article) === null || _product$article2 === void 0 ? void 0 : _product$article2.category, parseInt(product === null || product === void 0 ? void 0 : (_product$article3 = product.article) === null || _product$article3 === void 0 ? void 0 : _product$article3.id_category), product === null || product === void 0 ? void 0 : product.version);
400
398
 
401
399
  case 3:
402
400
  _services = _context.sent;
403
401
  //Converts the data inside the datasheets object to array
404
402
  setServices(_services);
405
- getServices(); //setActiveRetailer(product?.retailers[0]);
403
+ getServices(); // setActiveRetailer(product?.retailers[0]);
406
404
 
407
405
  setImages({
408
406
  action: "init",
409
407
  init: _services[2]
410
408
  });
411
409
  if (((_services$ = _services[2]) === null || _services$ === void 0 ? void 0 : (_services$$values = _services$.values) === null || _services$$values === void 0 ? void 0 : _services$$values.length) > 0) setActiveImage(0);
412
- (0, _data2.getPercentage)({
410
+ (0, _data.getPercentage)({
413
411
  data: [product]
414
412
  }).then(function (res) {
415
413
  return setPercentages(res);
@@ -440,7 +438,7 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
440
438
  var _ref3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
441
439
  var _product$article4, _product$article5, _servicesResponse$dat;
442
440
 
443
- var servicesResponse, parsedResponse, retailers, active;
441
+ var servicesResponse, parsedResponse, retailers, retailerResponse, active;
444
442
  return _regenerator.default.wrap(function _callee2$(_context2) {
445
443
  while (1) {
446
444
  switch (_context2.prev = _context2.next) {
@@ -452,15 +450,16 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
452
450
  servicesResponse = _context2.sent;
453
451
  parsedResponse = JSON.parse(servicesResponse === null || servicesResponse === void 0 ? void 0 : (_servicesResponse$dat = servicesResponse.data) === null || _servicesResponse$dat === void 0 ? void 0 : _servicesResponse$dat.body).data;
454
452
  retailers = product.retailers || product.retailersAvailable;
455
- active = retailers === null || retailers === void 0 ? void 0 : retailers.filter(function (retailer) {
456
- return parsedResponse === null || parsedResponse === void 0 ? void 0 : parsedResponse.map(function (srv) {
457
- return srv.id_retailer;
458
- }).includes(retailer.id);
459
- })[0];
453
+ retailerResponse = parsedResponse === null || parsedResponse === void 0 ? void 0 : parsedResponse.map(function (srv) {
454
+ return srv.id_retailer;
455
+ });
456
+ active = retailers === null || retailers === void 0 ? void 0 : retailers.find(function (retailer) {
457
+ return retailerResponse.includes(retailer.id);
458
+ });
460
459
  !activeRetailer.id && setActiveRetailer(active ? active : retailers[0]);
461
460
  setServicesData(parsedResponse);
462
461
 
463
- case 8:
462
+ case 9:
464
463
  case "end":
465
464
  return _context2.stop();
466
465
  }
@@ -474,17 +473,12 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
474
473
  }();
475
474
 
476
475
  var translateConcept = function translateConcept(concept) {
477
- var translation = "";
478
-
479
- if (concept === "datasheet") {
480
- translation = "Ficha técnica";
481
- } else if (concept === "description") {
482
- translation = "Descripción";
483
- } else if (concept === "images") {
484
- translation = "Imágenes";
485
- }
486
-
487
- return translation;
476
+ var translation = {
477
+ datasheet: "Ficha técnica",
478
+ description: "Descripción",
479
+ images: "Imágenes"
480
+ };
481
+ return translation[concept];
488
482
  };
489
483
 
490
484
  var getComments = /*#__PURE__*/function () {
@@ -537,7 +531,7 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
537
531
  getComments();
538
532
  _context4.t0 = setUserGroups;
539
533
  _context4.next = 5;
540
- return (0, _data2.fetchUsers)(token);
534
+ return (0, _data.fetchUsers)(token);
541
535
 
542
536
  case 5:
543
537
  _context4.t1 = _context4.sent;
@@ -548,15 +542,15 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
548
542
  break;
549
543
 
550
544
  case 11:
551
- arr = ["IN_PROGRESS", "RF", "RA"];
545
+ arr = ["CA", "RC", "RA"];
552
546
  return _context4.abrupt("break", 19);
553
547
 
554
548
  case 13:
555
- arr = ["RF", "AF", "AA", "AP", "AC"];
549
+ arr = ["RC", "AC", "AA", "AP", "ACA"];
556
550
  return _context4.abrupt("break", 19);
557
551
 
558
552
  case 15:
559
- arr = ["RP", "RC", "AF", "RA"];
553
+ arr = ["RP", "RCA", "AC", "RA"];
560
554
  return _context4.abrupt("break", 19);
561
555
 
562
556
  case 17:
@@ -692,49 +686,60 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
692
686
  var _ref6 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5() {
693
687
  var _product$article9;
694
688
 
695
- var productTemp, dataObject;
689
+ var productTemp, articleId, dataObject, res, _JSON$parse2, newStatus, newArticleStatus;
690
+
696
691
  return _regenerator.default.wrap(function _callee5$(_context5) {
697
692
  while (1) {
698
693
  switch (_context5.prev = _context5.next) {
699
694
  case 0:
700
695
  setLoading(true);
701
696
  productTemp = product;
697
+ articleId = product === null || product === void 0 ? void 0 : (_product$article9 = product.article) === null || _product$article9 === void 0 ? void 0 : _product$article9.id_article;
702
698
  dataObject = {
703
- articleId: product === null || product === void 0 ? void 0 : (_product$article9 = product.article) === null || _product$article9 === void 0 ? void 0 : _product$article9.id_article,
699
+ articleId: articleId,
704
700
  articleData: updatedDescriptions
705
701
  };
706
702
  if (product !== null && product !== void 0 && product.orderId) dataObject["orderId"] = product === null || product === void 0 ? void 0 : product.orderId;
707
- _context5.prev = 4;
708
- _context5.next = 7;
703
+ _context5.prev = 5;
704
+ _context5.next = 8;
709
705
  return _axios.default.put("".concat(process.env.REACT_APP_ARTICLE_DATA_ENDPOINT, "?description=true&version=").concat(version), dataObject, {
710
706
  headers: {
711
707
  Authorization: token
712
708
  }
713
709
  });
714
710
 
715
- case 7:
716
- if (productTemp.status === "ASSIGNED") {
717
- productTemp.status = "IN_PROGRESS";
718
- setProduct(productTemp);
719
- sessionStorage.setItem("productSelected", JSON.stringify(productTemp));
711
+ case 8:
712
+ res = _context5.sent;
713
+
714
+ if (!(res.data.statusCode === 200)) {
715
+ _context5.next = 18;
716
+ break;
720
717
  }
721
718
 
719
+ _JSON$parse2 = JSON.parse(res.data.body), newStatus = _JSON$parse2.newStatus, newArticleStatus = _JSON$parse2.newArticleStatus;
720
+ if (newArticleStatus) productTemp.status = newArticleStatus[articleId];
721
+ if (newStatus) productTemp.description_status = newStatus;
722
+ setProduct(productTemp);
723
+ sessionStorage.setItem("productSelected", JSON.stringify(productTemp));
722
724
  setMessage("Descripciones guardadas con éxito");
723
- loadData();
724
- _context5.next = 15;
725
+ _context5.next = 18;
726
+ return loadData();
727
+
728
+ case 18:
729
+ _context5.next = 23;
725
730
  break;
726
731
 
727
- case 12:
728
- _context5.prev = 12;
729
- _context5.t0 = _context5["catch"](4);
732
+ case 20:
733
+ _context5.prev = 20;
734
+ _context5.t0 = _context5["catch"](5);
730
735
  console.log(_context5.t0);
731
736
 
732
- case 15:
737
+ case 23:
733
738
  case "end":
734
739
  return _context5.stop();
735
740
  }
736
741
  }
737
- }, _callee5, null, [[4, 12]]);
742
+ }, _callee5, null, [[5, 20]]);
738
743
  }));
739
744
 
740
745
  return function saveDescriptions() {
@@ -746,50 +751,60 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
746
751
  var _ref7 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6() {
747
752
  var _product$article10;
748
753
 
749
- var productTemp, dataObject;
754
+ var productTemp, articleId, dataObject, res, _JSON$parse3, newStatus, newArticleStatus;
755
+
750
756
  return _regenerator.default.wrap(function _callee6$(_context6) {
751
757
  while (1) {
752
758
  switch (_context6.prev = _context6.next) {
753
759
  case 0:
754
760
  setLoading(true);
755
761
  productTemp = product;
762
+ articleId = product === null || product === void 0 ? void 0 : (_product$article10 = product.article) === null || _product$article10 === void 0 ? void 0 : _product$article10.id_article;
756
763
  dataObject = {
757
- articleId: product === null || product === void 0 ? void 0 : (_product$article10 = product.article) === null || _product$article10 === void 0 ? void 0 : _product$article10.id_article,
764
+ articleId: articleId,
758
765
  articleData: updatedDatasheets
759
766
  };
760
767
  if (product !== null && product !== void 0 && product.orderId) dataObject["orderId"] = product === null || product === void 0 ? void 0 : product.orderId;
761
- _context6.prev = 4;
762
- _context6.next = 7;
768
+ _context6.prev = 5;
769
+ _context6.next = 8;
763
770
  return _axios.default.put("".concat(process.env.REACT_APP_ARTICLE_DATA_ENDPOINT, "?datasheet=true&version=").concat(version), dataObject, {
764
771
  headers: {
765
772
  Authorization: token
766
773
  }
767
774
  });
768
775
 
769
- case 7:
770
- setMessage("Fichas técnicas guardadas");
776
+ case 8:
777
+ res = _context6.sent;
771
778
 
772
- if (productTemp.status === "ASSIGNED") {
773
- productTemp.status = "IN_PROGRESS";
774
- setProduct(productTemp);
775
- sessionStorage.setItem("productSelected", JSON.stringify(productTemp));
779
+ if (!(res.data.statusCode === 200)) {
780
+ _context6.next = 18;
781
+ break;
776
782
  }
777
783
 
778
- loadData();
779
- _context6.next = 15;
784
+ _JSON$parse3 = JSON.parse(res.data.body), newStatus = _JSON$parse3.newStatus, newArticleStatus = _JSON$parse3.newArticleStatus;
785
+ if (newArticleStatus) productTemp.status = newArticleStatus[articleId];
786
+ if (newStatus) productTemp.datasheet_status = newStatus;
787
+ setProduct(productTemp);
788
+ sessionStorage.setItem("productSelected", JSON.stringify(productTemp));
789
+ setMessage("Fichas técnicas guardadas");
790
+ _context6.next = 18;
791
+ return loadData();
792
+
793
+ case 18:
794
+ _context6.next = 23;
780
795
  break;
781
796
 
782
- case 12:
783
- _context6.prev = 12;
784
- _context6.t0 = _context6["catch"](4);
797
+ case 20:
798
+ _context6.prev = 20;
799
+ _context6.t0 = _context6["catch"](5);
785
800
  console.log(_context6.t0);
786
801
 
787
- case 15:
802
+ case 23:
788
803
  case "end":
789
804
  return _context6.stop();
790
805
  }
791
806
  }
792
- }, _callee6, null, [[4, 12]]);
807
+ }, _callee6, null, [[5, 20]]);
793
808
  }));
794
809
 
795
810
  return function saveDatasheets() {
@@ -815,7 +830,7 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
815
830
  var updateImages = (0, _react.useCallback)( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7() {
816
831
  var _images$values2, _product$article11, _data$articleData, _data$articleData2, _data$updateImages;
817
832
 
818
- var imagesList, imagesListTemp, duplicated, attrForImgs, data, valid, _data$updateImages2, _data$articleData3, _data$articleData4, _data$articleData5, promiseArray, productTemp;
833
+ var imagesList, imagesListTemp, duplicated, attrForImgs, data, valid, _data$updateImages2, _data$articleData3, _data$articleData4, _data$articleData5, promiseArray;
819
834
 
820
835
  return _regenerator.default.wrap(function _callee7$(_context7) {
821
836
  while (1) {
@@ -867,7 +882,7 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
867
882
  }
868
883
 
869
884
  if (!(valid && (duplicated === null || duplicated === void 0 ? void 0 : duplicated.length) === 0)) {
870
- _context7.next = 32;
885
+ _context7.next = 30;
871
886
  break;
872
887
  }
873
888
 
@@ -907,44 +922,38 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
907
922
  setImagesUploaded(true);
908
923
 
909
924
  case 23:
910
- productTemp = product;
911
-
912
- if (productTemp.status === "ASSIGNED") {
913
- productTemp.status = "IN_PROGRESS";
914
- setProduct(productTemp);
915
- sessionStorage.setItem("productSelected", JSON.stringify(productTemp));
916
- }
917
-
918
- _context7.next = 30;
925
+ _context7.next = 28;
919
926
  break;
920
927
 
921
- case 27:
922
- _context7.prev = 27;
928
+ case 25:
929
+ _context7.prev = 25;
923
930
  _context7.t0 = _context7["catch"](10);
924
931
  console.log(_context7.t0); // setMainLoading(false);
925
932
 
926
- case 30:
927
- _context7.next = 33;
933
+ case 28:
934
+ _context7.next = 31;
928
935
  break;
929
936
 
930
- case 32:
937
+ case 30:
931
938
  // setMainLoading(false);
932
939
  setMessage("Completa los campos que solicita cada una de la imágenes o hay imágenes con el mismo tipo de toma.\nRecuerda hay campos obligatorios y no podras avanzar si no estan completos.");
933
940
 
934
- case 33:
941
+ case 31:
935
942
  case "end":
936
943
  return _context7.stop();
937
944
  }
938
945
  }
939
- }, _callee7, null, [[10, 27]]);
946
+ }, _callee7, null, [[10, 25]]);
940
947
  })), [images, imagesUploaded]);
941
948
  (0, _react.useEffect)( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee8() {
949
+ var res, productTemp, _JSON$parse4, newStatus, newArticleStatus;
950
+
942
951
  return _regenerator.default.wrap(function _callee8$(_context8) {
943
952
  while (1) {
944
953
  switch (_context8.prev = _context8.next) {
945
954
  case 0:
946
955
  if (!imagesUploaded) {
947
- _context8.next = 13;
956
+ _context8.next = 22;
948
957
  break;
949
958
  }
950
959
 
@@ -965,58 +974,72 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
965
974
  });
966
975
 
967
976
  case 5:
977
+ res = _context8.sent;
978
+
979
+ if (!(res.data.statusCode === 200)) {
980
+ _context8.next = 17;
981
+ break;
982
+ }
983
+
984
+ productTemp = product;
985
+ _JSON$parse4 = JSON.parse(res.data.body), newStatus = _JSON$parse4.newStatus, newArticleStatus = _JSON$parse4.newArticleStatus;
986
+ if (newArticleStatus) productTemp.status = newArticleStatus[articleId];
987
+ if (newStatus) productTemp.images_status = newStatus;
988
+ setProduct(productTemp);
989
+ sessionStorage.setItem("productSelected", JSON.stringify(productTemp));
968
990
  setMessage("Imágenes guardadas con éxito");
969
991
  sessionStorage.removeItem("imagesList");
970
- loadData();
971
- _context8.next = 13;
992
+ _context8.next = 17;
993
+ return loadData();
994
+
995
+ case 17:
996
+ _context8.next = 22;
972
997
  break;
973
998
 
974
- case 10:
975
- _context8.prev = 10;
999
+ case 19:
1000
+ _context8.prev = 19;
976
1001
  _context8.t0 = _context8["catch"](2);
977
1002
  console.log(_context8.t0);
978
1003
 
979
- case 13:
1004
+ case 22:
980
1005
  case "end":
981
1006
  return _context8.stop();
982
1007
  }
983
1008
  }
984
- }, _callee8, null, [[2, 10]]);
1009
+ }, _callee8, null, [[2, 19]]);
985
1010
  })), [dataImages, imagesUploaded]);
986
1011
 
987
1012
  var evaluationFinished = function evaluationFinished(userId, tab, statusArray) {
1013
+ var _srv$find, _srv$find$status, _product$;
1014
+
988
1015
  var srv = servicesData.filter(function (serv) {
989
1016
  return serv.service === getConcept(tab);
990
1017
  });
991
-
992
- var _srv$filter = srv.filter(function (serv) {
1018
+ var srvActive = (_srv$find = srv.find(function (serv) {
993
1019
  return serv.id_retailer === (activeRetailer === null || activeRetailer === void 0 ? void 0 : activeRetailer.id);
994
- }),
995
- _srv$filter2 = (0, _slicedToArray2.default)(_srv$filter, 1),
996
- srvActive = _srv$filter2[0];
997
-
998
- var unvalidated = product["".concat(getConcept(tab), "_status")] === "QF" || product["".concat(getConcept(tab), "_status")] === "IN_PROGRESS";
999
- var auditorUnvalidated = !["RA", "AA", "AC", "AP"].includes(product["".concat(getConcept(tab), "_status")]);
1020
+ })) === null || _srv$find === void 0 ? void 0 : (_srv$find$status = _srv$find.status) === null || _srv$find$status === void 0 ? void 0 : _srv$find$status.replace(/.*\//, "");
1021
+ var currStatus = (_product$ = product["".concat(getConcept(tab), "_status")]) === null || _product$ === void 0 ? void 0 : _product$.replace(/.*\//, "");
1022
+ var unvalidated = ["IE", "CA"].includes(currStatus);
1023
+ var auditorUnvalidated = !["RA", "AA", "ACA", "AP"].includes(currStatus);
1000
1024
 
1001
1025
  switch (userId) {
1002
1026
  case 7:
1003
1027
  case 8:
1004
- return ["RA", "RF"].includes(product === null || product === void 0 ? void 0 : product.status) && //"IN_PROGRESS", "RF", "RA"
1005
- statusArray.includes(srvActive === null || srvActive === void 0 ? void 0 : srvActive.status) || statusArray.includes(product.status) && srv.filter(function (serv) {
1028
+ return statusArray.includes(srvActive) && (["RA", "RC"].includes(product === null || product === void 0 ? void 0 : product.status) || srv.filter(function (serv) {
1006
1029
  return statusArray.includes(serv.status);
1007
- }).length === srv.length;
1030
+ }).length === srv.length);
1008
1031
 
1009
1032
  case 4:
1010
1033
  case 5:
1011
- return unvalidated && ["IN_PROGRESS", "QF"].includes(product.status) && //"RF", "AF", "AA", "AP", "AC
1034
+ return unvalidated && ["CA", "IE"].includes(product.status) && // "RC", "AC", "AA", "AP", "ACA"
1012
1035
  srv.filter(function (serv) {
1013
1036
  return statusArray.includes(serv.status);
1014
1037
  }).length === srv.length;
1015
1038
 
1016
1039
  case 6:
1017
- return statusArray.includes(product.status) && //RP, RC, AF, RA true
1040
+ return statusArray.includes(product.status) && // RP, RCA, AC, RA true
1018
1041
  srv.every(function (serv) {
1019
- return ["RA", "AA", "AP", "AC"].includes(serv.status);
1042
+ return ["RA", "AA", "AP", "ACA"].includes(serv.status);
1020
1043
  }) && auditorUnvalidated;
1021
1044
 
1022
1045
  default:
@@ -1038,16 +1061,16 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
1038
1061
  };
1039
1062
 
1040
1063
  var approveRejectButtons = function approveRejectButtons(action) {
1041
- var concept = getConcept(action || activeTab);
1064
+ var _servicesData$find, _servicesData$find$st;
1042
1065
 
1043
- var _servicesData$filter = servicesData.filter(function (srv) {
1066
+ var concept = getConcept(action || activeTab);
1067
+ var retailerStatus = (_servicesData$find = servicesData.find(function (srv) {
1044
1068
  return srv.id_retailer === (activeRetailer === null || activeRetailer === void 0 ? void 0 : activeRetailer.id) && srv.service === concept;
1045
- }),
1046
- _servicesData$filter2 = (0, _slicedToArray2.default)(_servicesData$filter, 1),
1047
- retailerStatus = _servicesData$filter2[0];
1069
+ })) === null || _servicesData$find === void 0 ? void 0 : (_servicesData$find$st = _servicesData$find.status) === null || _servicesData$find$st === void 0 ? void 0 : _servicesData$find$st.replace(/.*\//, ""); //sessionStorage product
1048
1070
 
1049
- return (retailerStatus === null || retailerStatus === void 0 ? void 0 : retailerStatus.status) === "QF" && (user.id_role === 1 || user.id_role === 4 || user.id_role === 5) || (retailerStatus === null || retailerStatus === void 0 ? void 0 : retailerStatus.status) === "AF" && ( //sessionStorage product
1050
- user.id_role === 1 || user.id_role === 6) || (retailerStatus === null || retailerStatus === void 0 ? void 0 : retailerStatus.status) === "RP" && (user.id_role === 1 || user.id_role === 6) || (retailerStatus === null || retailerStatus === void 0 ? void 0 : retailerStatus.status) === "RC" && (user.id_role === 1 || user.id_role === 6);
1071
+ var adminFacilitatorCanEvaluate = retailerStatus === "IE" && [1, 4, 5].includes(user.id_role);
1072
+ var adminAuditorCanEvaluate = ["AC", "RP", "RCA"].includes(retailerStatus) && [1, 6].includes(user.id_role);
1073
+ return adminFacilitatorCanEvaluate || adminAuditorCanEvaluate;
1051
1074
  };
1052
1075
 
1053
1076
  var getSectionIcon = function getSectionIcon() {
@@ -1071,7 +1094,8 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
1071
1094
 
1072
1095
  var sendToFacilitator = /*#__PURE__*/function () {
1073
1096
  var _ref10 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee9(result) {
1074
- var concept, productTemp, evalStatus, data, specialistDone, statusArr, newStatus;
1097
+ var concept, productTemp, evalStatus, _articleId, orderId, data, res, _message, specialistDone, _JSON$parse5, newStatus, newOrderStatus;
1098
+
1075
1099
  return _regenerator.default.wrap(function _callee9$(_context9) {
1076
1100
  while (1) {
1077
1101
  switch (_context9.prev = _context9.next) {
@@ -1080,112 +1104,92 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
1080
1104
  _context9.prev = 1;
1081
1105
  concept = getConcept(activeTab);
1082
1106
  productTemp = (0, _objectSpread2.default)({}, product);
1083
- evalStatus = product["".concat(concept, "_status")];
1084
- data = {};
1085
-
1086
- if (!result) {
1087
- _context9.next = 13;
1088
- break;
1089
- }
1090
-
1107
+ evalStatus = retailerStatus;
1108
+ _articleId = product.article.id_article;
1109
+ orderId = product.orderId;
1091
1110
  data = {
1092
- articleId: product.article.id_article,
1093
- orderId: product.orderId,
1111
+ articleId: _articleId,
1112
+ orderId: orderId,
1094
1113
  concept: concept,
1095
- result: result,
1096
1114
  evalStatus: evalStatus,
1097
1115
  retailerId: activeRetailer.id
1098
1116
  };
1099
- _context9.next = 10;
1117
+
1118
+ if (!result) {
1119
+ _context9.next = 16;
1120
+ break;
1121
+ }
1122
+
1123
+ data.result = result;
1124
+ _context9.next = 12;
1100
1125
  return _axios.default.put("".concat(process.env.REACT_APP_EVALUATION_ENDPOINT), data, {
1101
1126
  headers: {
1102
1127
  Authorization: token
1103
1128
  }
1104
1129
  });
1105
1130
 
1106
- case 10:
1131
+ case 12:
1132
+ res = _context9.sent;
1107
1133
  getServices();
1108
- _context9.next = 31;
1134
+ _context9.next = 21;
1109
1135
  break;
1110
1136
 
1111
- case 13:
1112
- specialistDone = evalStatus === "RF" || evalStatus === "RA" || evalStatus === "IN_PROGRESS";
1137
+ case 16:
1138
+ specialistDone = ["RC", "RA", "CA"].includes(evalStatus);
1113
1139
 
1114
1140
  if (specialistDone) {
1115
- setMessage("".concat(activeTab, " enviada a facilitador"));
1116
- getSectionIcon();
1117
- } else if (evalStatus === "QF") {
1118
- setMessage("Evaluación enviada");
1141
+ _message = "".concat(activeTab, " enviada a facilitador");
1119
1142
  getSectionIcon();
1120
- } else if (evalStatus === "AF") {
1121
- setMessage("Evaluación enviada");
1122
- getSectionIcon();
1123
- } else if (evalStatus === "RP") {
1124
- setMessage("Evaluación enviada");
1125
- getSectionIcon();
1126
- } else if (evalStatus === "RC") {
1127
- setMessage("Evaluación enviada");
1143
+ } else if (["IE", "AC", "RP", "RCA"].includes(evalStatus)) {
1144
+ _message = "Evaluación enviada";
1128
1145
  getSectionIcon();
1129
1146
  }
1130
1147
 
1131
- statusArr = [];
1132
- servicesData.forEach(function (srv) {
1133
- srv.service === concept && statusArr.push(srv.status);
1134
- });
1135
- productTemp["".concat(concept, "_status")] = (0, _data2.getNewStatus)(statusArr);
1136
- newStatus = (0, _data2.getNewStatus)([productTemp.datasheet_status, productTemp.description_status, productTemp.images_status]);
1137
- productTemp.status = newStatus;
1138
- data = {
1139
- articleId: product.article.id_article,
1140
- orderId: product.orderId,
1141
- concept: concept,
1142
- evalStatus: evalStatus,
1143
- retailerId: activeRetailer.id
1144
- };
1145
- _context9.t0 = user.id_role;
1146
- _context9.next = _context9.t0 === 7 ? 24 : _context9.t0 === 8 ? 24 : _context9.t0 === 4 ? 26 : _context9.t0 === 5 ? 26 : 28;
1147
- break;
1148
-
1149
- case 24:
1150
- data.especialist = true;
1151
- return _context9.abrupt("break", 29);
1152
-
1153
- case 26:
1154
- data.facilitator = true;
1155
- return _context9.abrupt("break", 29);
1156
-
1157
- case 28:
1158
- return _context9.abrupt("break", 29);
1159
-
1160
- case 29:
1161
- _context9.next = 31;
1148
+ _context9.next = 20;
1162
1149
  return _axios.default.put("".concat(process.env.REACT_APP_SEND_EVAL), data, {
1163
1150
  headers: {
1164
1151
  Authorization: token
1165
1152
  }
1166
1153
  });
1167
1154
 
1168
- case 31:
1169
- loadData();
1155
+ case 20:
1156
+ res = _context9.sent;
1157
+
1158
+ case 21:
1159
+ if (!(res.data.statusCode === 200)) {
1160
+ _context9.next = 30;
1161
+ break;
1162
+ }
1163
+
1164
+ _JSON$parse5 = JSON.parse(res.data.body), newStatus = _JSON$parse5.newStatus, newOrderStatus = _JSON$parse5.newOrderStatus;
1165
+ if (newOrderStatus) productTemp.status = newOrderStatus[orderId];
1166
+ productTemp["".concat(concept, "_status")] = newStatus;
1167
+ _context9.next = 27;
1168
+ return loadData();
1169
+
1170
+ case 27:
1171
+ if (_message) setMessage(_message);
1170
1172
  sessionStorage.setItem("productSelected", JSON.stringify(productTemp));
1171
1173
  setProduct(productTemp);
1172
- _context9.next = 39;
1174
+
1175
+ case 30:
1176
+ _context9.next = 35;
1173
1177
  break;
1174
1178
 
1175
- case 36:
1176
- _context9.prev = 36;
1177
- _context9.t1 = _context9["catch"](1);
1178
- console.log(_context9.t1);
1179
+ case 32:
1180
+ _context9.prev = 32;
1181
+ _context9.t0 = _context9["catch"](1);
1182
+ console.log(_context9.t0);
1179
1183
 
1180
- case 39:
1184
+ case 35:
1181
1185
  setLoading(false);
1182
1186
 
1183
- case 40:
1187
+ case 36:
1184
1188
  case "end":
1185
1189
  return _context9.stop();
1186
1190
  }
1187
1191
  }
1188
- }, _callee9, null, [[1, 36]]);
1192
+ }, _callee9, null, [[1, 32]]);
1189
1193
  }));
1190
1194
 
1191
1195
  return function sendToFacilitator(_x) {
@@ -1292,11 +1296,11 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
1292
1296
  var dsInputsRequired = [];
1293
1297
  var desInputsRequired = 0;
1294
1298
  datasheetServicesArray === null || datasheetServicesArray === void 0 ? void 0 : datasheetServicesArray.forEach(function (datasheet) {
1295
- var _servicesData$filter3 = servicesData === null || servicesData === void 0 ? void 0 : servicesData.filter(function (srv) {
1299
+ var _servicesData$filter = servicesData === null || servicesData === void 0 ? void 0 : servicesData.filter(function (srv) {
1296
1300
  return srv.id_retailer === datasheet.retailer.id && srv.service === getConcept(activeTab);
1297
1301
  }),
1298
- _servicesData$filter4 = (0, _slicedToArray2.default)(_servicesData$filter3, 1),
1299
- requested = _servicesData$filter4[0];
1302
+ _servicesData$filter2 = (0, _slicedToArray2.default)(_servicesData$filter, 1),
1303
+ requested = _servicesData$filter2[0];
1300
1304
 
1301
1305
  requested && (datasheet === null || datasheet === void 0 ? void 0 : datasheet.data) && Object.values(datasheet === null || datasheet === void 0 ? void 0 : datasheet.data).forEach(function (dataGroup) {
1302
1306
  return dsInputsRequired.push.apply(dsInputsRequired, (0, _toConsumableArray2.default)(dataGroup.inputs.filter(function (input) {
@@ -1305,16 +1309,23 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
1305
1309
  });
1306
1310
  });
1307
1311
  objetcTemp["Ficha técnica"] = dsInputsRequired.length;
1312
+ var regex = /(<\/?p>)|(<\/?strong>)|(<br>)/gm;
1308
1313
  descriptionsServicesArray.forEach(function (description) {
1309
- var _servicesData$filter5 = servicesData.filter(function (srv) {
1314
+ var _servicesData$filter3 = servicesData.filter(function (srv) {
1310
1315
  return srv.id_retailer === description.id && srv.service === getConcept(activeTab);
1311
1316
  }),
1312
- _servicesData$filter6 = (0, _slicedToArray2.default)(_servicesData$filter5, 1),
1313
- requested = _servicesData$filter6[0];
1317
+ _servicesData$filter4 = (0, _slicedToArray2.default)(_servicesData$filter3, 1),
1318
+ requested = _servicesData$filter4[0];
1314
1319
 
1315
- requested && description.inputs.forEach(function (input) {
1316
- return input.required && (!input.value || input.value.replace(/(<\/?p>)|(<\/?strong>)|(<br>)/gm, "") === "") && desInputsRequired++;
1317
- });
1320
+ if (requested) {
1321
+ description.inputs.forEach(function (input) {
1322
+ var _input$value;
1323
+
1324
+ if (input.required && (!input.value || ((_input$value = input.value) === null || _input$value === void 0 ? void 0 : _input$value.replace(regex, "")) === "")) {
1325
+ desInputsRequired++;
1326
+ }
1327
+ });
1328
+ }
1318
1329
  });
1319
1330
  objetcTemp["Descripción"] = desInputsRequired;
1320
1331
  var retailersRequested = [];
@@ -1411,14 +1422,16 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
1411
1422
  case 10:
1412
1423
  productTemp = product;
1413
1424
  productTemp.article["id_".concat(concept, "_").concat(assignationType)] = assignationId;
1414
- data = (0, _defineProperty2.default)({
1425
+ data = {
1415
1426
  articleList: [{
1416
1427
  orderId: product.orderId,
1417
1428
  articleId: product === null || product === void 0 ? void 0 : (_product$article13 = product.article) === null || _product$article13 === void 0 ? void 0 : _product$article13.id_article
1418
1429
  }],
1419
- concept: concept
1420
- }, "".concat(assignationType, "Id"), assignationId);
1421
- (0, _axios.default)({
1430
+ concept: concept,
1431
+ userId: assignationId
1432
+ };
1433
+ _context12.next = 15;
1434
+ return (0, _axios.default)({
1422
1435
  method: "post",
1423
1436
  url: process.env.REACT_APP_ASSIGNATIONS_ENDPOINT,
1424
1437
  data: data,
@@ -1426,10 +1439,12 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
1426
1439
  Authorization: token
1427
1440
  }
1428
1441
  });
1442
+
1443
+ case 15:
1429
1444
  loadAssignations(productTemp);
1430
1445
  sessionStorage.setItem("productSelected", JSON.stringify(productTemp));
1431
1446
 
1432
- case 16:
1447
+ case 17:
1433
1448
  case "end":
1434
1449
  return _context12.stop();
1435
1450
  }
@@ -1608,21 +1623,24 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
1608
1623
  productTemp.images_status = productTemp.images_status === "NA" ? "NA" : "".concat(result, "A");
1609
1624
  sessionStorage.setItem("productSelected", JSON.stringify(productTemp));
1610
1625
  setProduct(productTemp);
1611
- loadData();
1612
- _context13.next = 24;
1626
+ _context13.next = 20;
1627
+ return loadData();
1628
+
1629
+ case 20:
1630
+ _context13.next = 25;
1613
1631
  break;
1614
1632
 
1615
- case 21:
1616
- _context13.prev = 21;
1633
+ case 22:
1634
+ _context13.prev = 22;
1617
1635
  _context13.t0 = _context13["catch"](0);
1618
1636
  console.log(_context13.t0);
1619
1637
 
1620
- case 24:
1638
+ case 25:
1621
1639
  case "end":
1622
1640
  return _context13.stop();
1623
1641
  }
1624
1642
  }
1625
- }, _callee13, null, [[0, 21]]);
1643
+ }, _callee13, null, [[0, 22]]);
1626
1644
  }));
1627
1645
 
1628
1646
  return function validateAll(_x7) {
@@ -1695,7 +1713,7 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
1695
1713
  })]);
1696
1714
  },
1697
1715
  showApproveRejectAll: isAuditor && servicesData.every(function (serv) {
1698
- return ["RA", "AA", "AP", "AC", "AF"].includes(serv.status);
1716
+ return ["RA", "AA", "AP", "ACA", "AC"].includes(serv.status);
1699
1717
  }) && approveRejectButtons() && (auditorAssigned() || userAssigned()),
1700
1718
  showValidationButtons: approveRejectButtons() && (auditorAssigned() || userAssigned()),
1701
1719
  approveAll: function approveAll() {
@@ -1725,7 +1743,6 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
1725
1743
  })]);
1726
1744
  }
1727
1745
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_FullTabsMenu.FullTabsMenu, {
1728
- canAssign: ![7, 8].includes(user.id_role),
1729
1746
  tabsSections: tabsSections,
1730
1747
  status: retailerStatus,
1731
1748
  activeTab: activeTab,
@@ -1844,7 +1861,7 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
1844
1861
  }, _callee14);
1845
1862
  }))
1846
1863
  })]
1847
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_GeneralButton.Button, {
1864
+ }), [7, 8].includes(user.id_role) && /*#__PURE__*/(0, _jsxRuntime.jsx)(_GeneralButton.Button, {
1848
1865
  buttonType: evaluationFinished(user.id_role, activeTab, statusArray) && requiredNull[activeTab] === 0 ? "general-green-button" : "general-button-disabled",
1849
1866
  label: "Enviar evaluación",
1850
1867
  onClick: function onClick() {