contentoh-components-library 21.1.78 → 21.1.79

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