contentoh-components-library 21.1.59 → 21.1.60

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 (30) hide show
  1. package/dist/components/atoms/GeneralInput/index.js +0 -1
  2. package/dist/components/molecules/HeaderTop/index.js +4 -1
  3. package/dist/components/molecules/RetailerSelector/index.js +31 -0
  4. package/dist/components/molecules/StatusAsignationInfo/index.js +3 -2
  5. package/dist/components/organisms/FullProductNameHeader/index.js +1 -1
  6. package/dist/components/organisms/FullTabsMenu/index.js +3 -1
  7. package/dist/components/organisms/ImageDataTable/index.js +3 -6
  8. package/dist/components/pages/ProviderProductEdition/ProviderProductEdition.stories.js +115 -65
  9. package/dist/components/pages/ProviderProductEdition/index.js +333 -382
  10. package/dist/components/pages/RetailerProductEdition/RetailerProductEdition.stories.js +61 -96
  11. package/dist/components/pages/RetailerProductEdition/index.js +217 -225
  12. package/dist/components/pages/RetailerProductEdition/styles.js +1 -1
  13. package/dist/global-files/data.js +9 -10
  14. package/dist/index.js +13 -0
  15. package/package.json +1 -1
  16. package/src/components/atoms/GeneralInput/index.js +0 -1
  17. package/src/components/molecules/HeaderTop/index.js +6 -1
  18. package/src/components/molecules/RetailerSelector/index.js +12 -0
  19. package/src/components/molecules/StatusAsignationInfo/index.js +3 -2
  20. package/src/components/organisms/FullProductNameHeader/index.js +1 -1
  21. package/src/components/organisms/FullTabsMenu/index.js +2 -0
  22. package/src/components/organisms/ImageDataTable/index.js +2 -5
  23. package/src/components/pages/ProviderProductEdition/ProviderProductEdition.stories.js +133 -71
  24. package/src/components/pages/ProviderProductEdition/index.js +208 -222
  25. package/src/components/pages/RetailerProductEdition/RetailerProductEdition.stories.js +58 -96
  26. package/src/components/pages/RetailerProductEdition/index.js +173 -148
  27. package/src/components/pages/RetailerProductEdition/styles.js +1 -1
  28. package/src/global-files/data.js +9 -10
  29. package/src/index.js +1 -0
  30. package/src/components/atoms/StatusTag/StatusTag.stories.js +0 -28
@@ -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
 
@@ -96,9 +98,14 @@ var reducerImages = function reducerImages(state, action) {
96
98
  });
97
99
 
98
100
  case "changeAttrValue":
99
- action.retailersId.forEach(function (ret) {
100
- attrForImgs[ret][action.index].name === action.name && (attrForImgs[ret][action.index].value = action.value);
101
+ var index = attrForImgs.general.findIndex(function (f) {
102
+ return f.id = action.id;
101
103
  });
104
+
105
+ if (index !== -1) {
106
+ attrForImgs.general[index].value = action.value;
107
+ }
108
+
102
109
  return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, state), {}, {
103
110
  attrForImgs: attrForImgs,
104
111
  values: values
@@ -389,20 +396,20 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
389
396
  case 0:
390
397
  _context.prev = 0;
391
398
  _context.next = 3;
392
- 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);
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);
393
400
 
394
401
  case 3:
395
402
  _services = _context.sent;
396
403
  //Converts the data inside the datasheets object to array
397
404
  setServices(_services);
398
- getServices(); // setActiveRetailer(product?.retailers[0]);
405
+ getServices(); //setActiveRetailer(product?.retailers[0]);
399
406
 
400
407
  setImages({
401
408
  action: "init",
402
409
  init: _services[2]
403
410
  });
404
411
  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);
405
- (0, _data.getPercentage)({
412
+ (0, _data2.getPercentage)({
406
413
  data: [product]
407
414
  }).then(function (res) {
408
415
  return setPercentages(res);
@@ -433,7 +440,7 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
433
440
  var _ref3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
434
441
  var _product$article4, _product$article5, _servicesResponse$dat;
435
442
 
436
- var servicesResponse, parsedResponse, retailers, retailerResponse, active;
443
+ var servicesResponse, parsedResponse, retailers, active;
437
444
  return _regenerator.default.wrap(function _callee2$(_context2) {
438
445
  while (1) {
439
446
  switch (_context2.prev = _context2.next) {
@@ -445,16 +452,15 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
445
452
  servicesResponse = _context2.sent;
446
453
  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;
447
454
  retailers = product.retailers || product.retailersAvailable;
448
- retailerResponse = parsedResponse === null || parsedResponse === void 0 ? void 0 : parsedResponse.map(function (srv) {
449
- return srv.id_retailer;
450
- });
451
- active = retailers === null || retailers === void 0 ? void 0 : retailers.find(function (retailer) {
452
- return retailerResponse.includes(retailer.id);
453
- });
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];
454
460
  !activeRetailer.id && setActiveRetailer(active ? active : retailers[0]);
455
461
  setServicesData(parsedResponse);
456
462
 
457
- case 9:
463
+ case 8:
458
464
  case "end":
459
465
  return _context2.stop();
460
466
  }
@@ -468,12 +474,17 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
468
474
  }();
469
475
 
470
476
  var translateConcept = function translateConcept(concept) {
471
- var translation = {
472
- datasheet: "Ficha técnica",
473
- description: "Descripción",
474
- images: "Imágenes"
475
- };
476
- return translation[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;
477
488
  };
478
489
 
479
490
  var getComments = /*#__PURE__*/function () {
@@ -526,7 +537,7 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
526
537
  getComments();
527
538
  _context4.t0 = setUserGroups;
528
539
  _context4.next = 5;
529
- return (0, _data.fetchUsers)(token);
540
+ return (0, _data2.fetchUsers)(token);
530
541
 
531
542
  case 5:
532
543
  _context4.t1 = _context4.sent;
@@ -537,15 +548,15 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
537
548
  break;
538
549
 
539
550
  case 11:
540
- arr = ["CA", "RC", "RA"];
551
+ arr = ["IN_PROGRESS", "RF", "RA"];
541
552
  return _context4.abrupt("break", 19);
542
553
 
543
554
  case 13:
544
- arr = ["RC", "AC", "AA", "AP", "ACA"];
555
+ arr = ["RF", "AF", "AA", "AP", "AC"];
545
556
  return _context4.abrupt("break", 19);
546
557
 
547
558
  case 15:
548
- arr = ["RP", "RCA", "AC", "RA"];
559
+ arr = ["RP", "RC", "AF", "RA"];
549
560
  return _context4.abrupt("break", 19);
550
561
 
551
562
  case 17:
@@ -681,60 +692,49 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
681
692
  var _ref6 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5() {
682
693
  var _product$article9;
683
694
 
684
- var productTemp, articleId, dataObject, res, _JSON$parse2, newStatus, newArticleStatus;
685
-
695
+ var productTemp, dataObject;
686
696
  return _regenerator.default.wrap(function _callee5$(_context5) {
687
697
  while (1) {
688
698
  switch (_context5.prev = _context5.next) {
689
699
  case 0:
690
700
  setLoading(true);
691
701
  productTemp = product;
692
- articleId = product === null || product === void 0 ? void 0 : (_product$article9 = product.article) === null || _product$article9 === void 0 ? void 0 : _product$article9.id_article;
693
702
  dataObject = {
694
- articleId: articleId,
703
+ articleId: product === null || product === void 0 ? void 0 : (_product$article9 = product.article) === null || _product$article9 === void 0 ? void 0 : _product$article9.id_article,
695
704
  articleData: updatedDescriptions
696
705
  };
697
706
  if (product !== null && product !== void 0 && product.orderId) dataObject["orderId"] = product === null || product === void 0 ? void 0 : product.orderId;
698
- _context5.prev = 5;
699
- _context5.next = 8;
707
+ _context5.prev = 4;
708
+ _context5.next = 7;
700
709
  return _axios.default.put("".concat(process.env.REACT_APP_ARTICLE_DATA_ENDPOINT, "?description=true&version=").concat(version), dataObject, {
701
710
  headers: {
702
711
  Authorization: token
703
712
  }
704
713
  });
705
714
 
706
- case 8:
707
- res = _context5.sent;
708
-
709
- if (!(res.data.statusCode === 200)) {
710
- _context5.next = 18;
711
- break;
715
+ case 7:
716
+ if (productTemp.status === "ASSIGNED") {
717
+ productTemp.status = "IN_PROGRESS";
718
+ setProduct(productTemp);
719
+ sessionStorage.setItem("productSelected", JSON.stringify(productTemp));
712
720
  }
713
721
 
714
- _JSON$parse2 = JSON.parse(res.data.body), newStatus = _JSON$parse2.newStatus, newArticleStatus = _JSON$parse2.newArticleStatus;
715
- if (newArticleStatus) productTemp.status = newArticleStatus[articleId];
716
- if (newStatus) productTemp.description_status = newStatus;
717
- setProduct(productTemp);
718
- sessionStorage.setItem("productSelected", JSON.stringify(productTemp));
719
722
  setMessage("Descripciones guardadas con éxito");
720
- _context5.next = 18;
721
- return loadData();
722
-
723
- case 18:
724
- _context5.next = 23;
723
+ loadData();
724
+ _context5.next = 15;
725
725
  break;
726
726
 
727
- case 20:
728
- _context5.prev = 20;
729
- _context5.t0 = _context5["catch"](5);
727
+ case 12:
728
+ _context5.prev = 12;
729
+ _context5.t0 = _context5["catch"](4);
730
730
  console.log(_context5.t0);
731
731
 
732
- case 23:
732
+ case 15:
733
733
  case "end":
734
734
  return _context5.stop();
735
735
  }
736
736
  }
737
- }, _callee5, null, [[5, 20]]);
737
+ }, _callee5, null, [[4, 12]]);
738
738
  }));
739
739
 
740
740
  return function saveDescriptions() {
@@ -746,60 +746,50 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
746
746
  var _ref7 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6() {
747
747
  var _product$article10;
748
748
 
749
- var productTemp, articleId, dataObject, res, _JSON$parse3, newStatus, newArticleStatus;
750
-
749
+ var productTemp, dataObject;
751
750
  return _regenerator.default.wrap(function _callee6$(_context6) {
752
751
  while (1) {
753
752
  switch (_context6.prev = _context6.next) {
754
753
  case 0:
755
754
  setLoading(true);
756
755
  productTemp = product;
757
- articleId = product === null || product === void 0 ? void 0 : (_product$article10 = product.article) === null || _product$article10 === void 0 ? void 0 : _product$article10.id_article;
758
756
  dataObject = {
759
- articleId: articleId,
757
+ articleId: product === null || product === void 0 ? void 0 : (_product$article10 = product.article) === null || _product$article10 === void 0 ? void 0 : _product$article10.id_article,
760
758
  articleData: updatedDatasheets
761
759
  };
762
760
  if (product !== null && product !== void 0 && product.orderId) dataObject["orderId"] = product === null || product === void 0 ? void 0 : product.orderId;
763
- _context6.prev = 5;
764
- _context6.next = 8;
761
+ _context6.prev = 4;
762
+ _context6.next = 7;
765
763
  return _axios.default.put("".concat(process.env.REACT_APP_ARTICLE_DATA_ENDPOINT, "?datasheet=true&version=").concat(version), dataObject, {
766
764
  headers: {
767
765
  Authorization: token
768
766
  }
769
767
  });
770
768
 
771
- case 8:
772
- res = _context6.sent;
769
+ case 7:
770
+ setMessage("Fichas técnicas guardadas");
773
771
 
774
- if (!(res.data.statusCode === 200)) {
775
- _context6.next = 18;
776
- break;
772
+ if (productTemp.status === "ASSIGNED") {
773
+ productTemp.status = "IN_PROGRESS";
774
+ setProduct(productTemp);
775
+ sessionStorage.setItem("productSelected", JSON.stringify(productTemp));
777
776
  }
778
777
 
779
- _JSON$parse3 = JSON.parse(res.data.body), newStatus = _JSON$parse3.newStatus, newArticleStatus = _JSON$parse3.newArticleStatus;
780
- if (newArticleStatus) productTemp.status = newArticleStatus[articleId];
781
- if (newStatus) productTemp.datasheet_status = newStatus;
782
- setProduct(productTemp);
783
- sessionStorage.setItem("productSelected", JSON.stringify(productTemp));
784
- setMessage("Fichas técnicas guardadas");
785
- _context6.next = 18;
786
- return loadData();
787
-
788
- case 18:
789
- _context6.next = 23;
778
+ loadData();
779
+ _context6.next = 15;
790
780
  break;
791
781
 
792
- case 20:
793
- _context6.prev = 20;
794
- _context6.t0 = _context6["catch"](5);
782
+ case 12:
783
+ _context6.prev = 12;
784
+ _context6.t0 = _context6["catch"](4);
795
785
  console.log(_context6.t0);
796
786
 
797
- case 23:
787
+ case 15:
798
788
  case "end":
799
789
  return _context6.stop();
800
790
  }
801
791
  }
802
- }, _callee6, null, [[5, 20]]);
792
+ }, _callee6, null, [[4, 12]]);
803
793
  }));
804
794
 
805
795
  return function saveDatasheets() {
@@ -825,7 +815,7 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
825
815
  var updateImages = (0, _react.useCallback)( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7() {
826
816
  var _images$values2, _product$article11, _data$articleData, _data$articleData2, _data$updateImages;
827
817
 
828
- var imagesList, imagesListTemp, duplicated, attrForImgs, data, valid, _data$updateImages2, _data$articleData3, _data$articleData4, _data$articleData5, promiseArray;
818
+ var imagesList, imagesListTemp, duplicated, attrForImgs, data, valid, _data$updateImages2, _data$articleData3, _data$articleData4, _data$articleData5, promiseArray, productTemp;
829
819
 
830
820
  return _regenerator.default.wrap(function _callee7$(_context7) {
831
821
  while (1) {
@@ -839,16 +829,15 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
839
829
  duplicated = imagesList === null || imagesList === void 0 ? void 0 : imagesList.filter(function (image) {
840
830
  return imagesListTemp[image === null || image === void 0 ? void 0 : image.image_id];
841
831
  });
842
- attrForImgs = Object.values(images === null || images === void 0 ? void 0 : images.attrForImgs);
843
- attrForImgs.pop();
832
+ attrForImgs = Object.values(images === null || images === void 0 ? void 0 : images.attrForImgs).pop();
844
833
  data = {
845
834
  articleId: product === null || product === void 0 ? void 0 : (_product$article11 = product.article) === null || _product$article11 === void 0 ? void 0 : _product$article11.id_article,
846
835
  attrReqImgs: attrForImgs === null || attrForImgs === void 0 ? void 0 : attrForImgs.map(function (e) {
847
- var _e$, _e$2;
836
+ var _e$value;
848
837
 
849
838
  return {
850
- attrId: (_e$ = e[0]) === null || _e$ === void 0 ? void 0 : _e$.id,
851
- value: (_e$2 = e[0]) === null || _e$2 === void 0 ? void 0 : _e$2.value
839
+ attrId: e.id,
840
+ value: (_e$value = e.value) !== null && _e$value !== void 0 ? _e$value : "-"
852
841
  };
853
842
  }),
854
843
  articleData: imagesList === null || imagesList === void 0 ? void 0 : imagesList.filter(function (e) {
@@ -878,19 +867,19 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
878
867
  }
879
868
 
880
869
  if (!(valid && (duplicated === null || duplicated === void 0 ? void 0 : duplicated.length) === 0)) {
881
- _context7.next = 31;
870
+ _context7.next = 32;
882
871
  break;
883
872
  }
884
873
 
885
874
  setLoading(true);
886
- _context7.prev = 11;
875
+ _context7.prev = 10;
887
876
  data === null || data === void 0 ? void 0 : (_data$articleData3 = data.articleData) === null || _data$articleData3 === void 0 ? void 0 : _data$articleData3.forEach(function (e) {
888
877
  e.uuid = (0, _uuid.v4)();
889
878
  });
890
879
  setDataImages(data);
891
880
 
892
881
  if (!((data === null || data === void 0 ? void 0 : (_data$articleData4 = data.articleData) === null || _data$articleData4 === void 0 ? void 0 : _data$articleData4.length) > 0)) {
893
- _context7.next = 23;
882
+ _context7.next = 22;
894
883
  break;
895
884
  }
896
885
 
@@ -906,50 +895,56 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
906
895
  };
907
896
  promiseArray.push(myBucket.putObject(params).promise());
908
897
  });
909
- _context7.next = 20;
898
+ _context7.next = 19;
910
899
  return Promise.all(promiseArray);
911
900
 
912
- case 20:
901
+ case 19:
913
902
  setImagesUploaded(true);
914
- _context7.next = 24;
903
+ _context7.next = 23;
915
904
  break;
916
905
 
917
- case 23:
906
+ case 22:
918
907
  setImagesUploaded(true);
919
908
 
920
- case 24:
921
- _context7.next = 29;
909
+ 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;
922
919
  break;
923
920
 
924
- case 26:
925
- _context7.prev = 26;
926
- _context7.t0 = _context7["catch"](11);
921
+ case 27:
922
+ _context7.prev = 27;
923
+ _context7.t0 = _context7["catch"](10);
927
924
  console.log(_context7.t0); // setMainLoading(false);
928
925
 
929
- case 29:
930
- _context7.next = 32;
926
+ case 30:
927
+ _context7.next = 33;
931
928
  break;
932
929
 
933
- case 31:
930
+ case 32:
934
931
  // setMainLoading(false);
935
932
  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.");
936
933
 
937
- case 32:
934
+ case 33:
938
935
  case "end":
939
936
  return _context7.stop();
940
937
  }
941
938
  }
942
- }, _callee7, null, [[11, 26]]);
939
+ }, _callee7, null, [[10, 27]]);
943
940
  })), [images, imagesUploaded]);
944
941
  (0, _react.useEffect)( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee8() {
945
- var res, productTemp, _JSON$parse4, newStatus, newArticleStatus;
946
-
947
942
  return _regenerator.default.wrap(function _callee8$(_context8) {
948
943
  while (1) {
949
944
  switch (_context8.prev = _context8.next) {
950
945
  case 0:
951
946
  if (!imagesUploaded) {
952
- _context8.next = 22;
947
+ _context8.next = 13;
953
948
  break;
954
949
  }
955
950
 
@@ -970,72 +965,58 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
970
965
  });
971
966
 
972
967
  case 5:
973
- res = _context8.sent;
974
-
975
- if (!(res.data.statusCode === 200)) {
976
- _context8.next = 17;
977
- break;
978
- }
979
-
980
- productTemp = product;
981
- _JSON$parse4 = JSON.parse(res.data.body), newStatus = _JSON$parse4.newStatus, newArticleStatus = _JSON$parse4.newArticleStatus;
982
- if (newArticleStatus) productTemp.status = newArticleStatus[articleId];
983
- if (newStatus) productTemp.images_status = newStatus;
984
- setProduct(productTemp);
985
- sessionStorage.setItem("productSelected", JSON.stringify(productTemp));
986
968
  setMessage("Imágenes guardadas con éxito");
987
969
  sessionStorage.removeItem("imagesList");
988
- _context8.next = 17;
989
- return loadData();
990
-
991
- case 17:
992
- _context8.next = 22;
970
+ loadData();
971
+ _context8.next = 13;
993
972
  break;
994
973
 
995
- case 19:
996
- _context8.prev = 19;
974
+ case 10:
975
+ _context8.prev = 10;
997
976
  _context8.t0 = _context8["catch"](2);
998
977
  console.log(_context8.t0);
999
978
 
1000
- case 22:
979
+ case 13:
1001
980
  case "end":
1002
981
  return _context8.stop();
1003
982
  }
1004
983
  }
1005
- }, _callee8, null, [[2, 19]]);
984
+ }, _callee8, null, [[2, 10]]);
1006
985
  })), [dataImages, imagesUploaded]);
1007
986
 
1008
987
  var evaluationFinished = function evaluationFinished(userId, tab, statusArray) {
1009
- var _srv$find, _srv$find$status, _product$;
1010
-
1011
988
  var srv = servicesData.filter(function (serv) {
1012
989
  return serv.service === getConcept(tab);
1013
990
  });
1014
- var srvActive = (_srv$find = srv.find(function (serv) {
991
+
992
+ var _srv$filter = srv.filter(function (serv) {
1015
993
  return serv.id_retailer === (activeRetailer === null || activeRetailer === void 0 ? void 0 : activeRetailer.id);
1016
- })) === 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(/.*\//, "");
1017
- var currStatus = (_product$ = product["".concat(getConcept(tab), "_status")]) === null || _product$ === void 0 ? void 0 : _product$.replace(/.*\//, "");
1018
- var unvalidated = ["IE", "CA"].includes(currStatus);
1019
- var auditorUnvalidated = !["RA", "AA", "ACA", "AP"].includes(currStatus);
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
1000
 
1021
1001
  switch (userId) {
1022
1002
  case 7:
1023
1003
  case 8:
1024
- return statusArray.includes(srvActive) && (["RA", "RC"].includes(product === null || product === void 0 ? void 0 : product.status) || srv.filter(function (serv) {
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) {
1025
1006
  return statusArray.includes(serv.status);
1026
- }).length === srv.length);
1007
+ }).length === srv.length;
1027
1008
 
1028
1009
  case 4:
1029
1010
  case 5:
1030
- return unvalidated && ["CA", "IE"].includes(product.status) && // "RC", "AC", "AA", "AP", "ACA"
1011
+ return unvalidated && ["IN_PROGRESS", "QF"].includes(product.status) && //"RF", "AF", "AA", "AP", "AC
1031
1012
  srv.filter(function (serv) {
1032
1013
  return statusArray.includes(serv.status);
1033
1014
  }).length === srv.length;
1034
1015
 
1035
1016
  case 6:
1036
- return statusArray.includes(product.status) && // RP, RCA, AC, RA true
1017
+ return statusArray.includes(product.status) && //RP, RC, AF, RA true
1037
1018
  srv.every(function (serv) {
1038
- return ["RA", "AA", "AP", "ACA"].includes(serv.status);
1019
+ return ["RA", "AA", "AP", "AC"].includes(serv.status);
1039
1020
  }) && auditorUnvalidated;
1040
1021
 
1041
1022
  default:
@@ -1057,16 +1038,16 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
1057
1038
  };
1058
1039
 
1059
1040
  var approveRejectButtons = function approveRejectButtons(action) {
1060
- var _servicesData$find, _servicesData$find$st;
1061
-
1062
1041
  var concept = getConcept(action || activeTab);
1063
- var retailerStatus = (_servicesData$find = servicesData.find(function (srv) {
1042
+
1043
+ var _servicesData$filter = servicesData.filter(function (srv) {
1064
1044
  return srv.id_retailer === (activeRetailer === null || activeRetailer === void 0 ? void 0 : activeRetailer.id) && srv.service === concept;
1065
- })) === 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
1045
+ }),
1046
+ _servicesData$filter2 = (0, _slicedToArray2.default)(_servicesData$filter, 1),
1047
+ retailerStatus = _servicesData$filter2[0];
1066
1048
 
1067
- var adminFacilitatorCanEvaluate = retailerStatus === "IE" && [1, 4, 5].includes(user.id_role);
1068
- var adminAuditorCanEvaluate = ["AC", "RP", "RCA"].includes(retailerStatus) && [1, 6].includes(user.id_role);
1069
- return adminFacilitatorCanEvaluate || adminAuditorCanEvaluate;
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);
1070
1051
  };
1071
1052
 
1072
1053
  var getSectionIcon = function getSectionIcon() {
@@ -1090,8 +1071,7 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
1090
1071
 
1091
1072
  var sendToFacilitator = /*#__PURE__*/function () {
1092
1073
  var _ref10 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee9(result) {
1093
- var concept, productTemp, evalStatus, _articleId, orderId, data, res, specialistDone, _message, _JSON$parse5, newStatus, newOrderStatus;
1094
-
1074
+ var concept, productTemp, evalStatus, data, specialistDone, statusArr, newStatus;
1095
1075
  return _regenerator.default.wrap(function _callee9$(_context9) {
1096
1076
  while (1) {
1097
1077
  switch (_context9.prev = _context9.next) {
@@ -1100,92 +1080,112 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
1100
1080
  _context9.prev = 1;
1101
1081
  concept = getConcept(activeTab);
1102
1082
  productTemp = (0, _objectSpread2.default)({}, product);
1103
- evalStatus = retailerStatus;
1104
- _articleId = product.article.id_article;
1105
- orderId = product.orderId;
1106
- data = {
1107
- articleId: _articleId,
1108
- orderId: orderId,
1109
- concept: concept,
1110
- evalStatus: evalStatus,
1111
- retailerId: activeRetailer.id
1112
- };
1083
+ evalStatus = product["".concat(concept, "_status")];
1084
+ data = {};
1113
1085
 
1114
1086
  if (!result) {
1115
- _context9.next = 16;
1087
+ _context9.next = 13;
1116
1088
  break;
1117
1089
  }
1118
1090
 
1119
- data.result = result;
1120
- _context9.next = 12;
1091
+ data = {
1092
+ articleId: product.article.id_article,
1093
+ orderId: product.orderId,
1094
+ concept: concept,
1095
+ result: result,
1096
+ evalStatus: evalStatus,
1097
+ retailerId: activeRetailer.id
1098
+ };
1099
+ _context9.next = 10;
1121
1100
  return _axios.default.put("".concat(process.env.REACT_APP_EVALUATION_ENDPOINT), data, {
1122
1101
  headers: {
1123
1102
  Authorization: token
1124
1103
  }
1125
1104
  });
1126
1105
 
1127
- case 12:
1128
- res = _context9.sent;
1106
+ case 10:
1129
1107
  getServices();
1130
- _context9.next = 21;
1108
+ _context9.next = 31;
1131
1109
  break;
1132
1110
 
1133
- case 16:
1134
- specialistDone = ["RC", "RA", "CA"].includes(evalStatus);
1111
+ case 13:
1112
+ specialistDone = evalStatus === "RF" || evalStatus === "RA" || evalStatus === "IN_PROGRESS";
1135
1113
 
1136
1114
  if (specialistDone) {
1137
- _message = "".concat(activeTab, " enviada a facilitador");
1115
+ setMessage("".concat(activeTab, " enviada a facilitador"));
1116
+ getSectionIcon();
1117
+ } else if (evalStatus === "QF") {
1118
+ setMessage("Evaluación enviada");
1119
+ getSectionIcon();
1120
+ } else if (evalStatus === "AF") {
1121
+ setMessage("Evaluación enviada");
1122
+ getSectionIcon();
1123
+ } else if (evalStatus === "RP") {
1124
+ setMessage("Evaluación enviada");
1138
1125
  getSectionIcon();
1139
- } else if (["IE", "AC", "RP", "RCA"].includes(evalStatus)) {
1140
- _message = "Evaluación enviada";
1126
+ } else if (evalStatus === "RC") {
1127
+ setMessage("Evaluación enviada");
1141
1128
  getSectionIcon();
1142
1129
  }
1143
1130
 
1144
- _context9.next = 20;
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;
1145
1162
  return _axios.default.put("".concat(process.env.REACT_APP_SEND_EVAL), data, {
1146
1163
  headers: {
1147
1164
  Authorization: token
1148
1165
  }
1149
1166
  });
1150
1167
 
1151
- case 20:
1152
- res = _context9.sent;
1153
-
1154
- case 21:
1155
- if (!(res.data.statusCode === 200)) {
1156
- _context9.next = 30;
1157
- break;
1158
- }
1159
-
1160
- _JSON$parse5 = JSON.parse(res.data.body), newStatus = _JSON$parse5.newStatus, newOrderStatus = _JSON$parse5.newOrderStatus;
1161
- if (newOrderStatus) productTemp.status = newOrderStatus[orderId];
1162
- productTemp["".concat(concept, "_status")] = newStatus;
1163
- _context9.next = 27;
1164
- return loadData();
1165
-
1166
- case 27:
1167
- if (message) setMessage(message);
1168
+ case 31:
1169
+ loadData();
1168
1170
  sessionStorage.setItem("productSelected", JSON.stringify(productTemp));
1169
1171
  setProduct(productTemp);
1170
-
1171
- case 30:
1172
- _context9.next = 35;
1172
+ _context9.next = 39;
1173
1173
  break;
1174
1174
 
1175
- case 32:
1176
- _context9.prev = 32;
1177
- _context9.t0 = _context9["catch"](1);
1178
- console.log(_context9.t0);
1175
+ case 36:
1176
+ _context9.prev = 36;
1177
+ _context9.t1 = _context9["catch"](1);
1178
+ console.log(_context9.t1);
1179
1179
 
1180
- case 35:
1180
+ case 39:
1181
1181
  setLoading(false);
1182
1182
 
1183
- case 36:
1183
+ case 40:
1184
1184
  case "end":
1185
1185
  return _context9.stop();
1186
1186
  }
1187
1187
  }
1188
- }, _callee9, null, [[1, 32]]);
1188
+ }, _callee9, null, [[1, 36]]);
1189
1189
  }));
1190
1190
 
1191
1191
  return function sendToFacilitator(_x) {
@@ -1292,11 +1292,11 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
1292
1292
  var dsInputsRequired = [];
1293
1293
  var desInputsRequired = 0;
1294
1294
  datasheetServicesArray === null || datasheetServicesArray === void 0 ? void 0 : datasheetServicesArray.forEach(function (datasheet) {
1295
- var _servicesData$filter = servicesData === null || servicesData === void 0 ? void 0 : servicesData.filter(function (srv) {
1295
+ var _servicesData$filter3 = servicesData === null || servicesData === void 0 ? void 0 : servicesData.filter(function (srv) {
1296
1296
  return srv.id_retailer === datasheet.retailer.id && srv.service === getConcept(activeTab);
1297
1297
  }),
1298
- _servicesData$filter2 = (0, _slicedToArray2.default)(_servicesData$filter, 1),
1299
- requested = _servicesData$filter2[0];
1298
+ _servicesData$filter4 = (0, _slicedToArray2.default)(_servicesData$filter3, 1),
1299
+ requested = _servicesData$filter4[0];
1300
1300
 
1301
1301
  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
1302
  return dsInputsRequired.push.apply(dsInputsRequired, (0, _toConsumableArray2.default)(dataGroup.inputs.filter(function (input) {
@@ -1306,16 +1306,14 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
1306
1306
  });
1307
1307
  objetcTemp["Ficha técnica"] = dsInputsRequired.length;
1308
1308
  descriptionsServicesArray.forEach(function (description) {
1309
- var _servicesData$filter3 = servicesData.filter(function (srv) {
1309
+ var _servicesData$filter5 = servicesData.filter(function (srv) {
1310
1310
  return srv.id_retailer === description.id && srv.service === getConcept(activeTab);
1311
1311
  }),
1312
- _servicesData$filter4 = (0, _slicedToArray2.default)(_servicesData$filter3, 1),
1313
- requested = _servicesData$filter4[0];
1312
+ _servicesData$filter6 = (0, _slicedToArray2.default)(_servicesData$filter5, 1),
1313
+ requested = _servicesData$filter6[0];
1314
1314
 
1315
1315
  requested && description.inputs.forEach(function (input) {
1316
- var _input$value;
1317
-
1318
- return input.required && (!input.value || ((_input$value = input.value) === null || _input$value === void 0 ? void 0 : _input$value.replace(/(<\/?p>)|(<\/?strong>)|(<br>)/gm, "")) === "") && desInputsRequired++;
1316
+ return input.required && (!input.value || input.value.replace(/(<\/?p>)|(<\/?strong>)|(<br>)/gm, "") === "") && desInputsRequired++;
1319
1317
  });
1320
1318
  });
1321
1319
  objetcTemp["Descripción"] = desInputsRequired;
@@ -1413,16 +1411,14 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
1413
1411
  case 10:
1414
1412
  productTemp = product;
1415
1413
  productTemp.article["id_".concat(concept, "_").concat(assignationType)] = assignationId;
1416
- data = {
1414
+ data = (0, _defineProperty2.default)({
1417
1415
  articleList: [{
1418
1416
  orderId: product.orderId,
1419
1417
  articleId: product === null || product === void 0 ? void 0 : (_product$article13 = product.article) === null || _product$article13 === void 0 ? void 0 : _product$article13.id_article
1420
1418
  }],
1421
- concept: concept,
1422
- userId: assignationId
1423
- };
1424
- _context12.next = 15;
1425
- return (0, _axios.default)({
1419
+ concept: concept
1420
+ }, "".concat(assignationType, "Id"), assignationId);
1421
+ (0, _axios.default)({
1426
1422
  method: "post",
1427
1423
  url: process.env.REACT_APP_ASSIGNATIONS_ENDPOINT,
1428
1424
  data: data,
@@ -1430,12 +1426,10 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
1430
1426
  Authorization: token
1431
1427
  }
1432
1428
  });
1433
-
1434
- case 15:
1435
1429
  loadAssignations(productTemp);
1436
1430
  sessionStorage.setItem("productSelected", JSON.stringify(productTemp));
1437
1431
 
1438
- case 17:
1432
+ case 16:
1439
1433
  case "end":
1440
1434
  return _context12.stop();
1441
1435
  }
@@ -1614,24 +1608,21 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
1614
1608
  productTemp.images_status = productTemp.images_status === "NA" ? "NA" : "".concat(result, "A");
1615
1609
  sessionStorage.setItem("productSelected", JSON.stringify(productTemp));
1616
1610
  setProduct(productTemp);
1617
- _context13.next = 20;
1618
- return loadData();
1619
-
1620
- case 20:
1621
- _context13.next = 25;
1611
+ loadData();
1612
+ _context13.next = 24;
1622
1613
  break;
1623
1614
 
1624
- case 22:
1625
- _context13.prev = 22;
1615
+ case 21:
1616
+ _context13.prev = 21;
1626
1617
  _context13.t0 = _context13["catch"](0);
1627
1618
  console.log(_context13.t0);
1628
1619
 
1629
- case 25:
1620
+ case 24:
1630
1621
  case "end":
1631
1622
  return _context13.stop();
1632
1623
  }
1633
1624
  }
1634
- }, _callee13, null, [[0, 22]]);
1625
+ }, _callee13, null, [[0, 21]]);
1635
1626
  }));
1636
1627
 
1637
1628
  return function validateAll(_x7) {
@@ -1704,7 +1695,7 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
1704
1695
  })]);
1705
1696
  },
1706
1697
  showApproveRejectAll: isAuditor && servicesData.every(function (serv) {
1707
- return ["RA", "AA", "AP", "ACA", "AC"].includes(serv.status);
1698
+ return ["RA", "AA", "AP", "AC", "AF"].includes(serv.status);
1708
1699
  }) && approveRejectButtons() && (auditorAssigned() || userAssigned()),
1709
1700
  showValidationButtons: approveRejectButtons() && (auditorAssigned() || userAssigned()),
1710
1701
  approveAll: function approveAll() {
@@ -1734,6 +1725,7 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
1734
1725
  })]);
1735
1726
  }
1736
1727
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_FullTabsMenu.FullTabsMenu, {
1728
+ canAssign: ![7, 8].includes(user.id_role),
1737
1729
  tabsSections: tabsSections,
1738
1730
  status: retailerStatus,
1739
1731
  activeTab: activeTab,
@@ -1852,7 +1844,7 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
1852
1844
  }, _callee14);
1853
1845
  }))
1854
1846
  })]
1855
- }), [7, 8].includes(user.id_role) && /*#__PURE__*/(0, _jsxRuntime.jsx)(_GeneralButton.Button, {
1847
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_GeneralButton.Button, {
1856
1848
  buttonType: evaluationFinished(user.id_role, activeTab, statusArray) && requiredNull[activeTab] === 0 ? "general-green-button" : "general-button-disabled",
1857
1849
  label: "Enviar evaluación",
1858
1850
  onClick: function onClick() {