contentoh-components-library 21.1.68 → 21.1.71

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 (44) hide show
  1. package/dist/components/atoms/AsignationOption/index.js +2 -2
  2. package/dist/components/atoms/ProductPercentCard/Percent.stories.js +1 -1
  3. package/dist/components/atoms/ProductPercentCard/styles.js +1 -1
  4. package/dist/components/atoms/Status/Status.stories.js +31 -0
  5. package/dist/components/atoms/Status/index.js +23 -0
  6. package/dist/components/atoms/Status/styles.js +20 -0
  7. package/dist/components/molecules/AssignedWork/AssignedWork.stories.js +1 -1
  8. package/dist/components/molecules/AssignedWork/styles.js +1 -1
  9. package/dist/components/molecules/ProductNameHeader/index.js +2 -2
  10. package/dist/components/molecules/StatusAsignationInfo/index.js +3 -3
  11. package/dist/components/organisms/FullProductNameHeader/index.js +1 -1
  12. package/dist/components/pages/ProviderProductEdition/ProviderProductEdition.stories.js +2 -6
  13. package/dist/components/pages/ProviderProductEdition/index.js +433 -433
  14. package/dist/components/pages/RetailerProductEdition/index.js +217 -200
  15. package/dist/global-files/customHooks.js +7 -7
  16. package/dist/global-files/data.js +8 -8
  17. package/dist/index.js +1 -1
  18. package/package.json +1 -1
  19. package/src/components/atoms/AsignationOption/index.js +2 -2
  20. package/src/components/atoms/ProductPercentCard/Percent.stories.js +11 -12
  21. package/src/components/atoms/ProductPercentCard/styles.js +9 -9
  22. package/src/components/atoms/Status/Status.stories.js +14 -0
  23. package/src/components/atoms/Status/index.js +9 -0
  24. package/src/components/atoms/{StatusTag → Status}/styles.js +7 -10
  25. package/src/components/molecules/AssignedWork/AssignedWork.stories.js +8 -8
  26. package/src/components/molecules/AssignedWork/styles.js +9 -10
  27. package/src/components/molecules/ProductNameHeader/index.js +2 -2
  28. package/src/components/molecules/StatusAsignationInfo/index.js +1 -1
  29. package/src/components/organisms/FullProductNameHeader/index.js +2 -2
  30. package/src/components/pages/ProviderProductEdition/ProviderProductEdition.stories.js +2 -3
  31. package/src/components/pages/ProviderProductEdition/index.js +233 -250
  32. package/src/components/pages/RetailerProductEdition/index.js +149 -173
  33. package/src/global-files/customHooks.js +12 -11
  34. package/src/global-files/data.js +8 -8
  35. package/src/index.js +1 -1
  36. package/dist/components/atoms/ProgressBar/styles.js +0 -22
  37. package/dist/components/atoms/StatusTag/StatusTag.stories.js +0 -48
  38. package/dist/components/atoms/StatusTag/index.js +0 -58
  39. package/dist/components/atoms/StatusTag/styles.js +0 -20
  40. package/dist/components/pages/RegistrationLoginFirstStep/RegistrationLoginFirstStep.stories.js +0 -37
  41. package/dist/components/pages/RegistrationLoginFirstStep/index.js +0 -269
  42. package/dist/components/pages/RegistrationLoginFirstStep/styles.js +0 -20
  43. package/src/components/atoms/ProgressBar/styles.js +0 -69
  44. package/src/components/atoms/StatusTag/index.js +0 -37
@@ -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
 
@@ -413,20 +411,20 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
413
411
  case 0:
414
412
  _context.prev = 0;
415
413
  _context.next = 3;
416
- 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), version);
414
+ 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), version);
417
415
 
418
416
  case 3:
419
417
  _services = _context.sent;
420
418
  //Converts the data inside the datasheets object to array
421
419
  setServices(_services);
422
- getServices(); //setActiveRetailer(product?.retailers[0]);
420
+ getServices(); // setActiveRetailer(product?.retailers[0]);
423
421
 
424
422
  setImages({
425
423
  action: "init",
426
424
  init: _services[2]
427
425
  });
428
426
  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);
429
- (0, _data2.getPercentage)({
427
+ (0, _data.getPercentage)({
430
428
  data: [product]
431
429
  }).then(function (res) {
432
430
  return setPercentages(res);
@@ -457,7 +455,7 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
457
455
  var _ref3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
458
456
  var _product$article4, _product$article5, _servicesResponse$dat;
459
457
 
460
- var servicesResponse, parsedResponse, retailers, active;
458
+ var servicesResponse, parsedResponse, retailers, retailerResponse, active;
461
459
  return _regenerator.default.wrap(function _callee2$(_context2) {
462
460
  while (1) {
463
461
  switch (_context2.prev = _context2.next) {
@@ -469,15 +467,16 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
469
467
  servicesResponse = _context2.sent;
470
468
  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;
471
469
  retailers = product.retailers || product.retailersAvailable;
472
- active = retailers === null || retailers === void 0 ? void 0 : retailers.filter(function (retailer) {
473
- return parsedResponse === null || parsedResponse === void 0 ? void 0 : parsedResponse.map(function (srv) {
474
- return srv.id_retailer;
475
- }).includes(retailer.id);
476
- })[0];
470
+ retailerResponse = parsedResponse === null || parsedResponse === void 0 ? void 0 : parsedResponse.map(function (srv) {
471
+ return srv.id_retailer;
472
+ });
473
+ active = retailers === null || retailers === void 0 ? void 0 : retailers.find(function (retailer) {
474
+ return retailerResponse.includes(retailer.id);
475
+ });
477
476
  !activeRetailer.id && setActiveRetailer(active ? active : retailers[0]);
478
477
  setServicesData(parsedResponse);
479
478
 
480
- case 8:
479
+ case 9:
481
480
  case "end":
482
481
  return _context2.stop();
483
482
  }
@@ -491,17 +490,12 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
491
490
  }();
492
491
 
493
492
  var translateConcept = function translateConcept(concept) {
494
- var translation = "";
495
-
496
- if (concept === "datasheet") {
497
- translation = "Ficha técnica";
498
- } else if (concept === "description") {
499
- translation = "Descripción";
500
- } else if (concept === "images") {
501
- translation = "Imágenes";
502
- }
503
-
504
- return translation;
493
+ var translation = {
494
+ datasheet: "Ficha técnica",
495
+ description: "Descripción",
496
+ images: "Imágenes"
497
+ };
498
+ return translation[concept];
505
499
  };
506
500
 
507
501
  var getComments = /*#__PURE__*/function () {
@@ -555,7 +549,7 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
555
549
  getComments();
556
550
  _context4.t0 = setUserGroups;
557
551
  _context4.next = 6;
558
- return (0, _data2.fetchUsers)(token);
552
+ return (0, _data.fetchUsers)(token);
559
553
 
560
554
  case 6:
561
555
  _context4.t1 = _context4.sent;
@@ -566,15 +560,15 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
566
560
  break;
567
561
 
568
562
  case 12:
569
- arr = ["IN_PROGRESS", "RF", "RA"];
563
+ arr = ["CA", "RC", "RA"];
570
564
  return _context4.abrupt("break", 20);
571
565
 
572
566
  case 14:
573
- arr = ["RF", "AF", "AA", "AP", "AC"];
567
+ arr = ["RC", "AC", "AA", "AP", "ACA"];
574
568
  return _context4.abrupt("break", 20);
575
569
 
576
570
  case 16:
577
- arr = ["RP", "RC", "AF", "RA"];
571
+ arr = ["RP", "RCA", "AC", "RA"];
578
572
  return _context4.abrupt("break", 20);
579
573
 
580
574
  case 18:
@@ -710,49 +704,60 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
710
704
  var _ref6 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5() {
711
705
  var _product$article9;
712
706
 
713
- var productTemp, dataObject;
707
+ var productTemp, articleId, dataObject, res, _JSON$parse2, newStatus, newArticleStatus;
708
+
714
709
  return _regenerator.default.wrap(function _callee5$(_context5) {
715
710
  while (1) {
716
711
  switch (_context5.prev = _context5.next) {
717
712
  case 0:
718
713
  setLoading(true);
719
714
  productTemp = product;
715
+ articleId = product === null || product === void 0 ? void 0 : (_product$article9 = product.article) === null || _product$article9 === void 0 ? void 0 : _product$article9.id_article;
720
716
  dataObject = {
721
- articleId: product === null || product === void 0 ? void 0 : (_product$article9 = product.article) === null || _product$article9 === void 0 ? void 0 : _product$article9.id_article,
717
+ articleId: articleId,
722
718
  articleData: updatedDescriptions
723
719
  };
724
720
  if (product !== null && product !== void 0 && product.orderId) dataObject["orderId"] = product === null || product === void 0 ? void 0 : product.orderId;
725
- _context5.prev = 4;
726
- _context5.next = 7;
721
+ _context5.prev = 5;
722
+ _context5.next = 8;
727
723
  return _axios.default.put("".concat(process.env.REACT_APP_ARTICLE_DATA_ENDPOINT, "?description=true&version=").concat(version), dataObject, {
728
724
  headers: {
729
725
  Authorization: token
730
726
  }
731
727
  });
732
728
 
733
- case 7:
734
- if (productTemp.status === "ASSIGNED") {
735
- productTemp.status = "IN_PROGRESS";
736
- setProduct(productTemp);
737
- sessionStorage.setItem("productSelected", JSON.stringify(productTemp));
729
+ case 8:
730
+ res = _context5.sent;
731
+
732
+ if (!(res.data.statusCode === 200)) {
733
+ _context5.next = 18;
734
+ break;
738
735
  }
739
736
 
737
+ _JSON$parse2 = JSON.parse(res.data.body), newStatus = _JSON$parse2.newStatus, newArticleStatus = _JSON$parse2.newArticleStatus;
738
+ if (newArticleStatus) productTemp.status = newArticleStatus[articleId];
739
+ if (newStatus) productTemp.description_status = newStatus;
740
+ setProduct(productTemp);
741
+ sessionStorage.setItem("productSelected", JSON.stringify(productTemp));
740
742
  setMessage("Descripciones guardadas con éxito");
741
- loadData();
742
- _context5.next = 15;
743
+ _context5.next = 18;
744
+ return loadData();
745
+
746
+ case 18:
747
+ _context5.next = 23;
743
748
  break;
744
749
 
745
- case 12:
746
- _context5.prev = 12;
747
- _context5.t0 = _context5["catch"](4);
750
+ case 20:
751
+ _context5.prev = 20;
752
+ _context5.t0 = _context5["catch"](5);
748
753
  console.log(_context5.t0);
749
754
 
750
- case 15:
755
+ case 23:
751
756
  case "end":
752
757
  return _context5.stop();
753
758
  }
754
759
  }
755
- }, _callee5, null, [[4, 12]]);
760
+ }, _callee5, null, [[5, 20]]);
756
761
  }));
757
762
 
758
763
  return function saveDescriptions() {
@@ -764,50 +769,60 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
764
769
  var _ref7 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6() {
765
770
  var _product$article10;
766
771
 
767
- var productTemp, dataObject;
772
+ var productTemp, articleId, dataObject, res, _JSON$parse3, newStatus, newArticleStatus;
773
+
768
774
  return _regenerator.default.wrap(function _callee6$(_context6) {
769
775
  while (1) {
770
776
  switch (_context6.prev = _context6.next) {
771
777
  case 0:
772
778
  setLoading(true);
773
779
  productTemp = product;
780
+ articleId = product === null || product === void 0 ? void 0 : (_product$article10 = product.article) === null || _product$article10 === void 0 ? void 0 : _product$article10.id_article;
774
781
  dataObject = {
775
- articleId: product === null || product === void 0 ? void 0 : (_product$article10 = product.article) === null || _product$article10 === void 0 ? void 0 : _product$article10.id_article,
782
+ articleId: articleId,
776
783
  articleData: updatedDatasheets
777
784
  };
778
785
  if (product !== null && product !== void 0 && product.orderId) dataObject["orderId"] = product === null || product === void 0 ? void 0 : product.orderId;
779
- _context6.prev = 4;
780
- _context6.next = 7;
786
+ _context6.prev = 5;
787
+ _context6.next = 8;
781
788
  return _axios.default.put("".concat(process.env.REACT_APP_ARTICLE_DATA_ENDPOINT, "?datasheet=true&version=").concat(version), dataObject, {
782
789
  headers: {
783
790
  Authorization: token
784
791
  }
785
792
  });
786
793
 
787
- case 7:
788
- setMessage("Fichas técnicas guardadas");
794
+ case 8:
795
+ res = _context6.sent;
789
796
 
790
- if (productTemp.status === "ASSIGNED") {
791
- productTemp.status = "IN_PROGRESS";
792
- setProduct(productTemp);
793
- sessionStorage.setItem("productSelected", JSON.stringify(productTemp));
797
+ if (!(res.data.statusCode === 200)) {
798
+ _context6.next = 18;
799
+ break;
794
800
  }
795
801
 
796
- loadData();
797
- _context6.next = 15;
802
+ _JSON$parse3 = JSON.parse(res.data.body), newStatus = _JSON$parse3.newStatus, newArticleStatus = _JSON$parse3.newArticleStatus;
803
+ if (newArticleStatus) productTemp.status = newArticleStatus[articleId];
804
+ if (newStatus) productTemp.datasheet_status = newStatus;
805
+ setProduct(productTemp);
806
+ sessionStorage.setItem("productSelected", JSON.stringify(productTemp));
807
+ setMessage("Fichas técnicas guardadas");
808
+ _context6.next = 18;
809
+ return loadData();
810
+
811
+ case 18:
812
+ _context6.next = 23;
798
813
  break;
799
814
 
800
- case 12:
801
- _context6.prev = 12;
802
- _context6.t0 = _context6["catch"](4);
815
+ case 20:
816
+ _context6.prev = 20;
817
+ _context6.t0 = _context6["catch"](5);
803
818
  console.log(_context6.t0);
804
819
 
805
- case 15:
820
+ case 23:
806
821
  case "end":
807
822
  return _context6.stop();
808
823
  }
809
824
  }
810
- }, _callee6, null, [[4, 12]]);
825
+ }, _callee6, null, [[5, 20]]);
811
826
  }));
812
827
 
813
828
  return function saveDatasheets() {
@@ -833,7 +848,7 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
833
848
  var updateImages = (0, _react.useCallback)( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7() {
834
849
  var _images$values2, _product$article11, _data$articleData, _data$articleData2, _data$updateImages;
835
850
 
836
- var imagesList, imagesListTemp, duplicated, attrForImgs, data, valid, _data$updateImages2, _data$articleData3, _data$articleData4, _data$articleData5, promiseArray, productTemp;
851
+ var imagesList, imagesListTemp, duplicated, attrForImgs, data, valid, _data$updateImages2, _data$articleData3, _data$articleData4, _data$articleData5, promiseArray;
837
852
 
838
853
  return _regenerator.default.wrap(function _callee7$(_context7) {
839
854
  while (1) {
@@ -885,7 +900,7 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
885
900
  }
886
901
 
887
902
  if (!(valid && (duplicated === null || duplicated === void 0 ? void 0 : duplicated.length) === 0)) {
888
- _context7.next = 32;
903
+ _context7.next = 30;
889
904
  break;
890
905
  }
891
906
 
@@ -925,44 +940,38 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
925
940
  setImagesUploaded(true);
926
941
 
927
942
  case 23:
928
- productTemp = product;
929
-
930
- if (productTemp.status === "ASSIGNED") {
931
- productTemp.status = "IN_PROGRESS";
932
- setProduct(productTemp);
933
- sessionStorage.setItem("productSelected", JSON.stringify(productTemp));
934
- }
935
-
936
- _context7.next = 30;
943
+ _context7.next = 28;
937
944
  break;
938
945
 
939
- case 27:
940
- _context7.prev = 27;
946
+ case 25:
947
+ _context7.prev = 25;
941
948
  _context7.t0 = _context7["catch"](10);
942
949
  console.log(_context7.t0); // setMainLoading(false);
943
950
 
944
- case 30:
945
- _context7.next = 33;
951
+ case 28:
952
+ _context7.next = 31;
946
953
  break;
947
954
 
948
- case 32:
955
+ case 30:
949
956
  // setMainLoading(false);
950
957
  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.");
951
958
 
952
- case 33:
959
+ case 31:
953
960
  case "end":
954
961
  return _context7.stop();
955
962
  }
956
963
  }
957
- }, _callee7, null, [[10, 27]]);
964
+ }, _callee7, null, [[10, 25]]);
958
965
  })), [images, imagesUploaded]);
959
966
  (0, _react.useEffect)( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee8() {
967
+ var res, productTemp, _JSON$parse4, newStatus, newArticleStatus;
968
+
960
969
  return _regenerator.default.wrap(function _callee8$(_context8) {
961
970
  while (1) {
962
971
  switch (_context8.prev = _context8.next) {
963
972
  case 0:
964
973
  if (!imagesUploaded) {
965
- _context8.next = 13;
974
+ _context8.next = 22;
966
975
  break;
967
976
  }
968
977
 
@@ -983,58 +992,72 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
983
992
  });
984
993
 
985
994
  case 5:
995
+ res = _context8.sent;
996
+
997
+ if (!(res.data.statusCode === 200)) {
998
+ _context8.next = 17;
999
+ break;
1000
+ }
1001
+
1002
+ productTemp = product;
1003
+ _JSON$parse4 = JSON.parse(res.data.body), newStatus = _JSON$parse4.newStatus, newArticleStatus = _JSON$parse4.newArticleStatus;
1004
+ if (newArticleStatus) productTemp.status = newArticleStatus[articleId];
1005
+ if (newStatus) productTemp.images_status = newStatus;
1006
+ setProduct(productTemp);
1007
+ sessionStorage.setItem("productSelected", JSON.stringify(productTemp));
986
1008
  setMessage("Imágenes guardadas con éxito");
987
1009
  sessionStorage.removeItem("imagesList");
988
- loadData();
989
- _context8.next = 13;
1010
+ _context8.next = 17;
1011
+ return loadData();
1012
+
1013
+ case 17:
1014
+ _context8.next = 22;
990
1015
  break;
991
1016
 
992
- case 10:
993
- _context8.prev = 10;
1017
+ case 19:
1018
+ _context8.prev = 19;
994
1019
  _context8.t0 = _context8["catch"](2);
995
1020
  console.log(_context8.t0);
996
1021
 
997
- case 13:
1022
+ case 22:
998
1023
  case "end":
999
1024
  return _context8.stop();
1000
1025
  }
1001
1026
  }
1002
- }, _callee8, null, [[2, 10]]);
1027
+ }, _callee8, null, [[2, 19]]);
1003
1028
  })), [dataImages, imagesUploaded]);
1004
1029
 
1005
1030
  var evaluationFinished = function evaluationFinished(userId, tab, statusArray) {
1031
+ var _srv$find, _srv$find$status, _product$;
1032
+
1006
1033
  var srv = servicesData.filter(function (serv) {
1007
1034
  return serv.service === getConcept(tab);
1008
1035
  });
1009
-
1010
- var _srv$filter = srv.filter(function (serv) {
1036
+ var srvActive = (_srv$find = srv.find(function (serv) {
1011
1037
  return serv.id_retailer === (activeRetailer === null || activeRetailer === void 0 ? void 0 : activeRetailer.id);
1012
- }),
1013
- _srv$filter2 = (0, _slicedToArray2.default)(_srv$filter, 1),
1014
- srvActive = _srv$filter2[0];
1015
-
1016
- var unvalidated = product["".concat(getConcept(tab), "_status")] === "QF" || product["".concat(getConcept(tab), "_status")] === "IN_PROGRESS";
1017
- var auditorUnvalidated = !["RA", "AA", "AC", "AP"].includes(product["".concat(getConcept(tab), "_status")]);
1038
+ })) === 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(/.*\//, "");
1039
+ var currStatus = (_product$ = product["".concat(getConcept(tab), "_status")]) === null || _product$ === void 0 ? void 0 : _product$.replace(/.*\//, "");
1040
+ var unvalidated = ["IE", "CA"].includes(currStatus);
1041
+ var auditorUnvalidated = !["RA", "AA", "ACA", "AP"].includes(currStatus);
1018
1042
 
1019
1043
  switch (userId) {
1020
1044
  case 7:
1021
1045
  case 8:
1022
- return ["RA", "RF"].includes(product === null || product === void 0 ? void 0 : product.status) && //"IN_PROGRESS", "RF", "RA"
1023
- statusArray.includes(srvActive === null || srvActive === void 0 ? void 0 : srvActive.status) || statusArray.includes(product.status) && srv.filter(function (serv) {
1046
+ return statusArray.includes(srvActive) && (["RA", "RC"].includes(product === null || product === void 0 ? void 0 : product.status) || srv.filter(function (serv) {
1024
1047
  return statusArray.includes(serv.status);
1025
- }).length === srv.length;
1048
+ }).length === srv.length);
1026
1049
 
1027
1050
  case 4:
1028
1051
  case 5:
1029
- return unvalidated && ["IN_PROGRESS", "QF"].includes(product.status) && //"RF", "AF", "AA", "AP", "AC
1052
+ return unvalidated && ["CA", "IE"].includes(product.status) && // "RC", "AC", "AA", "AP", "ACA"
1030
1053
  srv.filter(function (serv) {
1031
1054
  return statusArray.includes(serv.status);
1032
1055
  }).length === srv.length;
1033
1056
 
1034
1057
  case 6:
1035
- return statusArray.includes(product.status) && //RP, RC, AF, RA true
1058
+ return statusArray.includes(product.status) && // RP, RCA, AC, RA true
1036
1059
  srv.every(function (serv) {
1037
- return ["RA", "AA", "AP", "AC"].includes(serv.status);
1060
+ return ["RA", "AA", "AP", "ACA"].includes(serv.status);
1038
1061
  }) && auditorUnvalidated;
1039
1062
 
1040
1063
  default:
@@ -1056,16 +1079,16 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
1056
1079
  };
1057
1080
 
1058
1081
  var approveRejectButtons = function approveRejectButtons(action) {
1059
- var concept = getConcept(action || activeTab);
1082
+ var _servicesData$find, _servicesData$find$st;
1060
1083
 
1061
- var _servicesData$filter = servicesData.filter(function (srv) {
1084
+ var concept = getConcept(action || activeTab);
1085
+ var retailerStatus = (_servicesData$find = servicesData.find(function (srv) {
1062
1086
  return srv.id_retailer === (activeRetailer === null || activeRetailer === void 0 ? void 0 : activeRetailer.id) && srv.service === concept;
1063
- }),
1064
- _servicesData$filter2 = (0, _slicedToArray2.default)(_servicesData$filter, 1),
1065
- retailerStatus = _servicesData$filter2[0];
1087
+ })) === 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
1066
1088
 
1067
- 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
1068
- 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);
1089
+ var adminFacilitatorCanEvaluate = retailerStatus === "IE" && [1, 4, 5].includes(user.id_role);
1090
+ var adminAuditorCanEvaluate = ["AC", "RP", "RCA"].includes(retailerStatus) && [1, 6].includes(user.id_role);
1091
+ return adminFacilitatorCanEvaluate || adminAuditorCanEvaluate;
1069
1092
  };
1070
1093
 
1071
1094
  var getSectionIcon = function getSectionIcon() {
@@ -1089,7 +1112,8 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
1089
1112
 
1090
1113
  var sendToFacilitator = /*#__PURE__*/function () {
1091
1114
  var _ref10 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee9(result) {
1092
- var concept, productTemp, evalStatus, data, specialistDone, statusArr, newStatus;
1115
+ var concept, productTemp, evalStatus, _articleId, orderId, data, res, _message, specialistDone, _JSON$parse5, newStatus, newOrderStatus;
1116
+
1093
1117
  return _regenerator.default.wrap(function _callee9$(_context9) {
1094
1118
  while (1) {
1095
1119
  switch (_context9.prev = _context9.next) {
@@ -1098,112 +1122,92 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
1098
1122
  _context9.prev = 1;
1099
1123
  concept = getConcept(activeTab);
1100
1124
  productTemp = (0, _objectSpread2.default)({}, product);
1101
- evalStatus = product["".concat(concept, "_status")];
1102
- data = {};
1103
-
1104
- if (!result) {
1105
- _context9.next = 13;
1106
- break;
1107
- }
1108
-
1125
+ evalStatus = retailerStatus;
1126
+ _articleId = product.article.id_article;
1127
+ orderId = product.orderId;
1109
1128
  data = {
1110
- articleId: product.article.id_article,
1111
- orderId: product.orderId,
1129
+ articleId: _articleId,
1130
+ orderId: orderId,
1112
1131
  concept: concept,
1113
- result: result,
1114
1132
  evalStatus: evalStatus,
1115
1133
  retailerId: activeRetailer.id
1116
1134
  };
1117
- _context9.next = 10;
1135
+
1136
+ if (!result) {
1137
+ _context9.next = 16;
1138
+ break;
1139
+ }
1140
+
1141
+ data.result = result;
1142
+ _context9.next = 12;
1118
1143
  return _axios.default.put("".concat(process.env.REACT_APP_EVALUATION_ENDPOINT), data, {
1119
1144
  headers: {
1120
1145
  Authorization: token
1121
1146
  }
1122
1147
  });
1123
1148
 
1124
- case 10:
1149
+ case 12:
1150
+ res = _context9.sent;
1125
1151
  getServices();
1126
- _context9.next = 31;
1152
+ _context9.next = 21;
1127
1153
  break;
1128
1154
 
1129
- case 13:
1130
- specialistDone = evalStatus === "RF" || evalStatus === "RA" || evalStatus === "IN_PROGRESS";
1155
+ case 16:
1156
+ specialistDone = ["RC", "RA", "CA"].includes(evalStatus);
1131
1157
 
1132
1158
  if (specialistDone) {
1133
- setMessage("".concat(activeTab, " enviada a facilitador"));
1134
- getSectionIcon();
1135
- } else if (evalStatus === "QF") {
1136
- setMessage("Evaluación enviada");
1137
- getSectionIcon();
1138
- } else if (evalStatus === "AF") {
1139
- setMessage("Evaluación enviada");
1159
+ _message = "".concat(activeTab, " enviada a facilitador");
1140
1160
  getSectionIcon();
1141
- } else if (evalStatus === "RP") {
1142
- setMessage("Evaluación enviada");
1143
- getSectionIcon();
1144
- } else if (evalStatus === "RC") {
1145
- setMessage("Evaluación enviada");
1161
+ } else if (["IE", "AC", "RP", "RCA"].includes(evalStatus)) {
1162
+ _message = "Evaluación enviada";
1146
1163
  getSectionIcon();
1147
1164
  }
1148
1165
 
1149
- statusArr = [];
1150
- servicesData.forEach(function (srv) {
1151
- srv.service === concept && statusArr.push(srv.status);
1152
- });
1153
- productTemp["".concat(concept, "_status")] = (0, _data2.getNewStatus)(statusArr);
1154
- newStatus = (0, _data2.getNewStatus)([productTemp.datasheet_status, productTemp.description_status, productTemp.images_status]);
1155
- productTemp.status = newStatus;
1156
- data = {
1157
- articleId: product.article.id_article,
1158
- orderId: product.orderId,
1159
- concept: concept,
1160
- evalStatus: evalStatus,
1161
- retailerId: activeRetailer.id
1162
- };
1163
- _context9.t0 = user.id_role;
1164
- _context9.next = _context9.t0 === 7 ? 24 : _context9.t0 === 8 ? 24 : _context9.t0 === 4 ? 26 : _context9.t0 === 5 ? 26 : 28;
1165
- break;
1166
-
1167
- case 24:
1168
- data.especialist = true;
1169
- return _context9.abrupt("break", 29);
1170
-
1171
- case 26:
1172
- data.facilitator = true;
1173
- return _context9.abrupt("break", 29);
1174
-
1175
- case 28:
1176
- return _context9.abrupt("break", 29);
1177
-
1178
- case 29:
1179
- _context9.next = 31;
1166
+ _context9.next = 20;
1180
1167
  return _axios.default.put("".concat(process.env.REACT_APP_SEND_EVAL), data, {
1181
1168
  headers: {
1182
1169
  Authorization: token
1183
1170
  }
1184
1171
  });
1185
1172
 
1186
- case 31:
1187
- loadData();
1173
+ case 20:
1174
+ res = _context9.sent;
1175
+
1176
+ case 21:
1177
+ if (!(res.data.statusCode === 200)) {
1178
+ _context9.next = 30;
1179
+ break;
1180
+ }
1181
+
1182
+ _JSON$parse5 = JSON.parse(res.data.body), newStatus = _JSON$parse5.newStatus, newOrderStatus = _JSON$parse5.newOrderStatus;
1183
+ if (newOrderStatus) productTemp.status = newOrderStatus[orderId];
1184
+ productTemp["".concat(concept, "_status")] = newStatus;
1185
+ _context9.next = 27;
1186
+ return loadData();
1187
+
1188
+ case 27:
1189
+ if (_message) setMessage(_message);
1188
1190
  sessionStorage.setItem("productSelected", JSON.stringify(productTemp));
1189
1191
  setProduct(productTemp);
1190
- _context9.next = 39;
1192
+
1193
+ case 30:
1194
+ _context9.next = 35;
1191
1195
  break;
1192
1196
 
1193
- case 36:
1194
- _context9.prev = 36;
1195
- _context9.t1 = _context9["catch"](1);
1196
- console.log(_context9.t1);
1197
+ case 32:
1198
+ _context9.prev = 32;
1199
+ _context9.t0 = _context9["catch"](1);
1200
+ console.log(_context9.t0);
1197
1201
 
1198
- case 39:
1202
+ case 35:
1199
1203
  setLoading(false);
1200
1204
 
1201
- case 40:
1205
+ case 36:
1202
1206
  case "end":
1203
1207
  return _context9.stop();
1204
1208
  }
1205
1209
  }
1206
- }, _callee9, null, [[1, 36]]);
1210
+ }, _callee9, null, [[1, 32]]);
1207
1211
  }));
1208
1212
 
1209
1213
  return function sendToFacilitator(_x) {
@@ -1310,11 +1314,11 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
1310
1314
  var dsInputsRequired = [];
1311
1315
  var desInputsRequired = 0;
1312
1316
  datasheetServicesArray === null || datasheetServicesArray === void 0 ? void 0 : datasheetServicesArray.forEach(function (datasheet) {
1313
- var _servicesData$filter3 = servicesData === null || servicesData === void 0 ? void 0 : servicesData.filter(function (srv) {
1317
+ var _servicesData$filter = servicesData === null || servicesData === void 0 ? void 0 : servicesData.filter(function (srv) {
1314
1318
  return srv.id_retailer === datasheet.retailer.id && srv.service === getConcept(activeTab);
1315
1319
  }),
1316
- _servicesData$filter4 = (0, _slicedToArray2.default)(_servicesData$filter3, 1),
1317
- requested = _servicesData$filter4[0];
1320
+ _servicesData$filter2 = (0, _slicedToArray2.default)(_servicesData$filter, 1),
1321
+ requested = _servicesData$filter2[0];
1318
1322
 
1319
1323
  requested && (datasheet === null || datasheet === void 0 ? void 0 : datasheet.data) && Object.values(datasheet === null || datasheet === void 0 ? void 0 : datasheet.data).forEach(function (dataGroup) {
1320
1324
  return dsInputsRequired.push.apply(dsInputsRequired, (0, _toConsumableArray2.default)(dataGroup.inputs.filter(function (input) {
@@ -1323,16 +1327,23 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
1323
1327
  });
1324
1328
  });
1325
1329
  objetcTemp["Ficha técnica"] = dsInputsRequired.length;
1330
+ var regex = /(<\/?p>)|(<\/?strong>)|(<br>)/gm;
1326
1331
  descriptionsServicesArray.forEach(function (description) {
1327
- var _servicesData$filter5 = servicesData.filter(function (srv) {
1332
+ var _servicesData$filter3 = servicesData.filter(function (srv) {
1328
1333
  return srv.id_retailer === description.id && srv.service === getConcept(activeTab);
1329
1334
  }),
1330
- _servicesData$filter6 = (0, _slicedToArray2.default)(_servicesData$filter5, 1),
1331
- requested = _servicesData$filter6[0];
1335
+ _servicesData$filter4 = (0, _slicedToArray2.default)(_servicesData$filter3, 1),
1336
+ requested = _servicesData$filter4[0];
1332
1337
 
1333
- requested && description.inputs.forEach(function (input) {
1334
- return input.required && (!input.value || input.value.replace(/(<\/?p>)|(<\/?strong>)|(<br>)/gm, "") === "") && desInputsRequired++;
1335
- });
1338
+ if (requested) {
1339
+ description.inputs.forEach(function (input) {
1340
+ var _input$value;
1341
+
1342
+ if (input.required && (!input.value || ((_input$value = input.value) === null || _input$value === void 0 ? void 0 : _input$value.replace(regex, "")) === "")) {
1343
+ desInputsRequired++;
1344
+ }
1345
+ });
1346
+ }
1336
1347
  });
1337
1348
  objetcTemp["Descripción"] = desInputsRequired;
1338
1349
  var retailersRequested = [];
@@ -1429,14 +1440,16 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
1429
1440
  case 10:
1430
1441
  productTemp = product;
1431
1442
  productTemp.article["id_".concat(concept, "_").concat(assignationType)] = assignationId;
1432
- data = (0, _defineProperty2.default)({
1443
+ data = {
1433
1444
  articleList: [{
1434
1445
  orderId: product.orderId,
1435
1446
  articleId: product === null || product === void 0 ? void 0 : (_product$article13 = product.article) === null || _product$article13 === void 0 ? void 0 : _product$article13.id_article
1436
1447
  }],
1437
- concept: concept
1438
- }, "".concat(assignationType, "Id"), assignationId);
1439
- (0, _axios.default)({
1448
+ concept: concept,
1449
+ userId: assignationId
1450
+ };
1451
+ _context12.next = 15;
1452
+ return (0, _axios.default)({
1440
1453
  method: "post",
1441
1454
  url: process.env.REACT_APP_ASSIGNATIONS_ENDPOINT,
1442
1455
  data: data,
@@ -1444,10 +1457,12 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
1444
1457
  Authorization: token
1445
1458
  }
1446
1459
  });
1460
+
1461
+ case 15:
1447
1462
  loadAssignations(productTemp);
1448
1463
  sessionStorage.setItem("productSelected", JSON.stringify(productTemp));
1449
1464
 
1450
- case 16:
1465
+ case 17:
1451
1466
  case "end":
1452
1467
  return _context12.stop();
1453
1468
  }
@@ -1626,21 +1641,24 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
1626
1641
  productTemp.images_status = productTemp.images_status === "NA" ? "NA" : "".concat(result, "A");
1627
1642
  sessionStorage.setItem("productSelected", JSON.stringify(productTemp));
1628
1643
  setProduct(productTemp);
1629
- loadData();
1630
- _context13.next = 24;
1644
+ _context13.next = 20;
1645
+ return loadData();
1646
+
1647
+ case 20:
1648
+ _context13.next = 25;
1631
1649
  break;
1632
1650
 
1633
- case 21:
1634
- _context13.prev = 21;
1651
+ case 22:
1652
+ _context13.prev = 22;
1635
1653
  _context13.t0 = _context13["catch"](0);
1636
1654
  console.log(_context13.t0);
1637
1655
 
1638
- case 24:
1656
+ case 25:
1639
1657
  case "end":
1640
1658
  return _context13.stop();
1641
1659
  }
1642
1660
  }
1643
- }, _callee13, null, [[0, 21]]);
1661
+ }, _callee13, null, [[0, 22]]);
1644
1662
  }));
1645
1663
 
1646
1664
  return function validateAll(_x7) {
@@ -1713,7 +1731,7 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
1713
1731
  })]);
1714
1732
  },
1715
1733
  showApproveRejectAll: isAuditor && servicesData.every(function (serv) {
1716
- return ["RA", "AA", "AP", "AC", "AF"].includes(serv.status);
1734
+ return ["RA", "AA", "AP", "ACA", "AC"].includes(serv.status);
1717
1735
  }) && approveRejectButtons() && (auditorAssigned() || userAssigned()),
1718
1736
  showValidationButtons: approveRejectButtons() && (auditorAssigned() || userAssigned()),
1719
1737
  approveAll: function approveAll() {
@@ -1743,7 +1761,6 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
1743
1761
  })]);
1744
1762
  }
1745
1763
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_FullTabsMenu.FullTabsMenu, {
1746
- canAssign: ![7, 8].includes(user.id_role),
1747
1764
  tabsSections: tabsSections,
1748
1765
  status: retailerStatus,
1749
1766
  activeTab: activeTab,
@@ -1864,7 +1881,7 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
1864
1881
  }, _callee14);
1865
1882
  }))
1866
1883
  })]
1867
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_GeneralButton.Button, {
1884
+ }), [7, 8].includes(user.id_role) && /*#__PURE__*/(0, _jsxRuntime.jsx)(_GeneralButton.Button, {
1868
1885
  buttonType: evaluationFinished(user.id_role, activeTab, statusArray) && requiredNull[activeTab] === 0 ? "general-green-button" : "general-button-disabled",
1869
1886
  label: "Enviar evaluación",
1870
1887
  onClick: function onClick() {