contentoh-components-library 21.1.55 → 21.1.59
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.
- package/dist/components/atoms/GeneralInput/index.js +1 -0
- package/dist/components/molecules/HeaderTop/index.js +1 -4
- package/dist/components/molecules/RetailerSelector/index.js +0 -32
- package/dist/components/molecules/StatusAsignationInfo/index.js +2 -3
- package/dist/components/organisms/FullProductNameHeader/index.js +1 -1
- package/dist/components/organisms/FullTabsMenu/index.js +1 -3
- package/dist/components/pages/ProviderProductEdition/ProviderProductEdition.stories.js +64 -122
- package/dist/components/pages/ProviderProductEdition/index.js +348 -330
- package/dist/components/pages/RegistrationLoginFirstStep/RegistrationLoginFirstStep.stories.js +37 -0
- package/dist/components/pages/RegistrationLoginFirstStep/index.js +269 -0
- package/dist/components/pages/RegistrationLoginFirstStep/styles.js +20 -0
- package/dist/components/pages/RetailerProductEdition/RetailerProductEdition.stories.js +86 -41
- package/dist/components/pages/RetailerProductEdition/index.js +210 -198
- package/dist/components/pages/RetailerProductEdition/styles.js +1 -1
- package/dist/global-files/data.js +2 -1
- package/package.json +1 -1
- package/src/components/atoms/GeneralInput/index.js +1 -0
- package/src/components/atoms/ValidationPanel/index.js +1 -1
- package/src/components/molecules/HeaderTop/index.js +1 -6
- package/src/components/molecules/RetailerSelector/index.js +0 -15
- package/src/components/molecules/StatusAsignationInfo/index.js +2 -3
- package/src/components/organisms/FullProductNameHeader/index.js +1 -1
- package/src/components/organisms/FullTabsMenu/index.js +0 -2
- package/src/components/pages/ProviderProductEdition/ProviderProductEdition.stories.js +70 -140
- package/src/components/pages/ProviderProductEdition/index.js +170 -172
- package/src/components/pages/RetailerProductEdition/RetailerProductEdition.stories.js +87 -38
- package/src/components/pages/RetailerProductEdition/index.js +140 -166
- package/src/components/pages/RetailerProductEdition/styles.js +1 -1
- package/src/global-files/data.js +2 -1
|
@@ -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
|
|
40
|
+
var _data = require("../../../global-files/data");
|
|
43
41
|
|
|
44
42
|
var _GalleryHeader = require("../../molecules/GalleryHeader");
|
|
45
43
|
|
|
@@ -391,20 +389,20 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
|
|
|
391
389
|
case 0:
|
|
392
390
|
_context.prev = 0;
|
|
393
391
|
_context.next = 3;
|
|
394
|
-
return (0,
|
|
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);
|
|
395
393
|
|
|
396
394
|
case 3:
|
|
397
395
|
_services = _context.sent;
|
|
398
396
|
//Converts the data inside the datasheets object to array
|
|
399
397
|
setServices(_services);
|
|
400
|
-
getServices(); //setActiveRetailer(product?.retailers[0]);
|
|
398
|
+
getServices(); // setActiveRetailer(product?.retailers[0]);
|
|
401
399
|
|
|
402
400
|
setImages({
|
|
403
401
|
action: "init",
|
|
404
402
|
init: _services[2]
|
|
405
403
|
});
|
|
406
404
|
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);
|
|
407
|
-
(0,
|
|
405
|
+
(0, _data.getPercentage)({
|
|
408
406
|
data: [product]
|
|
409
407
|
}).then(function (res) {
|
|
410
408
|
return setPercentages(res);
|
|
@@ -435,7 +433,7 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
|
|
|
435
433
|
var _ref3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
|
|
436
434
|
var _product$article4, _product$article5, _servicesResponse$dat;
|
|
437
435
|
|
|
438
|
-
var servicesResponse, parsedResponse, retailers, active;
|
|
436
|
+
var servicesResponse, parsedResponse, retailers, retailerResponse, active;
|
|
439
437
|
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
440
438
|
while (1) {
|
|
441
439
|
switch (_context2.prev = _context2.next) {
|
|
@@ -447,15 +445,16 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
|
|
|
447
445
|
servicesResponse = _context2.sent;
|
|
448
446
|
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;
|
|
449
447
|
retailers = product.retailers || product.retailersAvailable;
|
|
450
|
-
|
|
451
|
-
return
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
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
454
|
!activeRetailer.id && setActiveRetailer(active ? active : retailers[0]);
|
|
456
455
|
setServicesData(parsedResponse);
|
|
457
456
|
|
|
458
|
-
case
|
|
457
|
+
case 9:
|
|
459
458
|
case "end":
|
|
460
459
|
return _context2.stop();
|
|
461
460
|
}
|
|
@@ -469,17 +468,12 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
|
|
|
469
468
|
}();
|
|
470
469
|
|
|
471
470
|
var translateConcept = function translateConcept(concept) {
|
|
472
|
-
var translation =
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
}
|
|
477
|
-
|
|
478
|
-
} else if (concept === "images") {
|
|
479
|
-
translation = "Imágenes";
|
|
480
|
-
}
|
|
481
|
-
|
|
482
|
-
return translation;
|
|
471
|
+
var translation = {
|
|
472
|
+
datasheet: "Ficha técnica",
|
|
473
|
+
description: "Descripción",
|
|
474
|
+
images: "Imágenes"
|
|
475
|
+
};
|
|
476
|
+
return translation[concept];
|
|
483
477
|
};
|
|
484
478
|
|
|
485
479
|
var getComments = /*#__PURE__*/function () {
|
|
@@ -532,7 +526,7 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
|
|
|
532
526
|
getComments();
|
|
533
527
|
_context4.t0 = setUserGroups;
|
|
534
528
|
_context4.next = 5;
|
|
535
|
-
return (0,
|
|
529
|
+
return (0, _data.fetchUsers)(token);
|
|
536
530
|
|
|
537
531
|
case 5:
|
|
538
532
|
_context4.t1 = _context4.sent;
|
|
@@ -543,15 +537,15 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
|
|
|
543
537
|
break;
|
|
544
538
|
|
|
545
539
|
case 11:
|
|
546
|
-
arr = ["
|
|
540
|
+
arr = ["CA", "RC", "RA"];
|
|
547
541
|
return _context4.abrupt("break", 19);
|
|
548
542
|
|
|
549
543
|
case 13:
|
|
550
|
-
arr = ["
|
|
544
|
+
arr = ["RC", "AC", "AA", "AP", "ACA"];
|
|
551
545
|
return _context4.abrupt("break", 19);
|
|
552
546
|
|
|
553
547
|
case 15:
|
|
554
|
-
arr = ["RP", "
|
|
548
|
+
arr = ["RP", "RCA", "AC", "RA"];
|
|
555
549
|
return _context4.abrupt("break", 19);
|
|
556
550
|
|
|
557
551
|
case 17:
|
|
@@ -687,49 +681,60 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
|
|
|
687
681
|
var _ref6 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5() {
|
|
688
682
|
var _product$article9;
|
|
689
683
|
|
|
690
|
-
var productTemp, dataObject;
|
|
684
|
+
var productTemp, articleId, dataObject, res, _JSON$parse2, newStatus, newArticleStatus;
|
|
685
|
+
|
|
691
686
|
return _regenerator.default.wrap(function _callee5$(_context5) {
|
|
692
687
|
while (1) {
|
|
693
688
|
switch (_context5.prev = _context5.next) {
|
|
694
689
|
case 0:
|
|
695
690
|
setLoading(true);
|
|
696
691
|
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;
|
|
697
693
|
dataObject = {
|
|
698
|
-
articleId:
|
|
694
|
+
articleId: articleId,
|
|
699
695
|
articleData: updatedDescriptions
|
|
700
696
|
};
|
|
701
697
|
if (product !== null && product !== void 0 && product.orderId) dataObject["orderId"] = product === null || product === void 0 ? void 0 : product.orderId;
|
|
702
|
-
_context5.prev =
|
|
703
|
-
_context5.next =
|
|
698
|
+
_context5.prev = 5;
|
|
699
|
+
_context5.next = 8;
|
|
704
700
|
return _axios.default.put("".concat(process.env.REACT_APP_ARTICLE_DATA_ENDPOINT, "?description=true&version=").concat(version), dataObject, {
|
|
705
701
|
headers: {
|
|
706
702
|
Authorization: token
|
|
707
703
|
}
|
|
708
704
|
});
|
|
709
705
|
|
|
710
|
-
case
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
706
|
+
case 8:
|
|
707
|
+
res = _context5.sent;
|
|
708
|
+
|
|
709
|
+
if (!(res.data.statusCode === 200)) {
|
|
710
|
+
_context5.next = 18;
|
|
711
|
+
break;
|
|
715
712
|
}
|
|
716
713
|
|
|
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));
|
|
717
719
|
setMessage("Descripciones guardadas con éxito");
|
|
718
|
-
|
|
719
|
-
|
|
720
|
+
_context5.next = 18;
|
|
721
|
+
return loadData();
|
|
722
|
+
|
|
723
|
+
case 18:
|
|
724
|
+
_context5.next = 23;
|
|
720
725
|
break;
|
|
721
726
|
|
|
722
|
-
case
|
|
723
|
-
_context5.prev =
|
|
724
|
-
_context5.t0 = _context5["catch"](
|
|
727
|
+
case 20:
|
|
728
|
+
_context5.prev = 20;
|
|
729
|
+
_context5.t0 = _context5["catch"](5);
|
|
725
730
|
console.log(_context5.t0);
|
|
726
731
|
|
|
727
|
-
case
|
|
732
|
+
case 23:
|
|
728
733
|
case "end":
|
|
729
734
|
return _context5.stop();
|
|
730
735
|
}
|
|
731
736
|
}
|
|
732
|
-
}, _callee5, null, [[
|
|
737
|
+
}, _callee5, null, [[5, 20]]);
|
|
733
738
|
}));
|
|
734
739
|
|
|
735
740
|
return function saveDescriptions() {
|
|
@@ -741,50 +746,60 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
|
|
|
741
746
|
var _ref7 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6() {
|
|
742
747
|
var _product$article10;
|
|
743
748
|
|
|
744
|
-
var productTemp, dataObject;
|
|
749
|
+
var productTemp, articleId, dataObject, res, _JSON$parse3, newStatus, newArticleStatus;
|
|
750
|
+
|
|
745
751
|
return _regenerator.default.wrap(function _callee6$(_context6) {
|
|
746
752
|
while (1) {
|
|
747
753
|
switch (_context6.prev = _context6.next) {
|
|
748
754
|
case 0:
|
|
749
755
|
setLoading(true);
|
|
750
756
|
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;
|
|
751
758
|
dataObject = {
|
|
752
|
-
articleId:
|
|
759
|
+
articleId: articleId,
|
|
753
760
|
articleData: updatedDatasheets
|
|
754
761
|
};
|
|
755
762
|
if (product !== null && product !== void 0 && product.orderId) dataObject["orderId"] = product === null || product === void 0 ? void 0 : product.orderId;
|
|
756
|
-
_context6.prev =
|
|
757
|
-
_context6.next =
|
|
763
|
+
_context6.prev = 5;
|
|
764
|
+
_context6.next = 8;
|
|
758
765
|
return _axios.default.put("".concat(process.env.REACT_APP_ARTICLE_DATA_ENDPOINT, "?datasheet=true&version=").concat(version), dataObject, {
|
|
759
766
|
headers: {
|
|
760
767
|
Authorization: token
|
|
761
768
|
}
|
|
762
769
|
});
|
|
763
770
|
|
|
764
|
-
case
|
|
765
|
-
|
|
771
|
+
case 8:
|
|
772
|
+
res = _context6.sent;
|
|
766
773
|
|
|
767
|
-
if (
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
sessionStorage.setItem("productSelected", JSON.stringify(productTemp));
|
|
774
|
+
if (!(res.data.statusCode === 200)) {
|
|
775
|
+
_context6.next = 18;
|
|
776
|
+
break;
|
|
771
777
|
}
|
|
772
778
|
|
|
773
|
-
|
|
774
|
-
|
|
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;
|
|
775
790
|
break;
|
|
776
791
|
|
|
777
|
-
case
|
|
778
|
-
_context6.prev =
|
|
779
|
-
_context6.t0 = _context6["catch"](
|
|
792
|
+
case 20:
|
|
793
|
+
_context6.prev = 20;
|
|
794
|
+
_context6.t0 = _context6["catch"](5);
|
|
780
795
|
console.log(_context6.t0);
|
|
781
796
|
|
|
782
|
-
case
|
|
797
|
+
case 23:
|
|
783
798
|
case "end":
|
|
784
799
|
return _context6.stop();
|
|
785
800
|
}
|
|
786
801
|
}
|
|
787
|
-
}, _callee6, null, [[
|
|
802
|
+
}, _callee6, null, [[5, 20]]);
|
|
788
803
|
}));
|
|
789
804
|
|
|
790
805
|
return function saveDatasheets() {
|
|
@@ -810,7 +825,7 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
|
|
|
810
825
|
var updateImages = (0, _react.useCallback)( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7() {
|
|
811
826
|
var _images$values2, _product$article11, _data$articleData, _data$articleData2, _data$updateImages;
|
|
812
827
|
|
|
813
|
-
var imagesList, imagesListTemp, duplicated, attrForImgs, data, valid, _data$updateImages2, _data$articleData3, _data$articleData4, _data$articleData5, promiseArray
|
|
828
|
+
var imagesList, imagesListTemp, duplicated, attrForImgs, data, valid, _data$updateImages2, _data$articleData3, _data$articleData4, _data$articleData5, promiseArray;
|
|
814
829
|
|
|
815
830
|
return _regenerator.default.wrap(function _callee7$(_context7) {
|
|
816
831
|
while (1) {
|
|
@@ -863,7 +878,7 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
|
|
|
863
878
|
}
|
|
864
879
|
|
|
865
880
|
if (!(valid && (duplicated === null || duplicated === void 0 ? void 0 : duplicated.length) === 0)) {
|
|
866
|
-
_context7.next =
|
|
881
|
+
_context7.next = 31;
|
|
867
882
|
break;
|
|
868
883
|
}
|
|
869
884
|
|
|
@@ -903,44 +918,38 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
|
|
|
903
918
|
setImagesUploaded(true);
|
|
904
919
|
|
|
905
920
|
case 24:
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
if (productTemp.status === "ASSIGNED") {
|
|
909
|
-
productTemp.status = "IN_PROGRESS";
|
|
910
|
-
setProduct(productTemp);
|
|
911
|
-
sessionStorage.setItem("productSelected", JSON.stringify(productTemp));
|
|
912
|
-
}
|
|
913
|
-
|
|
914
|
-
_context7.next = 31;
|
|
921
|
+
_context7.next = 29;
|
|
915
922
|
break;
|
|
916
923
|
|
|
917
|
-
case
|
|
918
|
-
_context7.prev =
|
|
924
|
+
case 26:
|
|
925
|
+
_context7.prev = 26;
|
|
919
926
|
_context7.t0 = _context7["catch"](11);
|
|
920
927
|
console.log(_context7.t0); // setMainLoading(false);
|
|
921
928
|
|
|
922
|
-
case
|
|
923
|
-
_context7.next =
|
|
929
|
+
case 29:
|
|
930
|
+
_context7.next = 32;
|
|
924
931
|
break;
|
|
925
932
|
|
|
926
|
-
case
|
|
933
|
+
case 31:
|
|
927
934
|
// setMainLoading(false);
|
|
928
935
|
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.");
|
|
929
936
|
|
|
930
|
-
case
|
|
937
|
+
case 32:
|
|
931
938
|
case "end":
|
|
932
939
|
return _context7.stop();
|
|
933
940
|
}
|
|
934
941
|
}
|
|
935
|
-
}, _callee7, null, [[11,
|
|
942
|
+
}, _callee7, null, [[11, 26]]);
|
|
936
943
|
})), [images, imagesUploaded]);
|
|
937
944
|
(0, _react.useEffect)( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee8() {
|
|
945
|
+
var res, productTemp, _JSON$parse4, newStatus, newArticleStatus;
|
|
946
|
+
|
|
938
947
|
return _regenerator.default.wrap(function _callee8$(_context8) {
|
|
939
948
|
while (1) {
|
|
940
949
|
switch (_context8.prev = _context8.next) {
|
|
941
950
|
case 0:
|
|
942
951
|
if (!imagesUploaded) {
|
|
943
|
-
_context8.next =
|
|
952
|
+
_context8.next = 22;
|
|
944
953
|
break;
|
|
945
954
|
}
|
|
946
955
|
|
|
@@ -961,58 +970,72 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
|
|
|
961
970
|
});
|
|
962
971
|
|
|
963
972
|
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));
|
|
964
986
|
setMessage("Imágenes guardadas con éxito");
|
|
965
987
|
sessionStorage.removeItem("imagesList");
|
|
966
|
-
|
|
967
|
-
|
|
988
|
+
_context8.next = 17;
|
|
989
|
+
return loadData();
|
|
990
|
+
|
|
991
|
+
case 17:
|
|
992
|
+
_context8.next = 22;
|
|
968
993
|
break;
|
|
969
994
|
|
|
970
|
-
case
|
|
971
|
-
_context8.prev =
|
|
995
|
+
case 19:
|
|
996
|
+
_context8.prev = 19;
|
|
972
997
|
_context8.t0 = _context8["catch"](2);
|
|
973
998
|
console.log(_context8.t0);
|
|
974
999
|
|
|
975
|
-
case
|
|
1000
|
+
case 22:
|
|
976
1001
|
case "end":
|
|
977
1002
|
return _context8.stop();
|
|
978
1003
|
}
|
|
979
1004
|
}
|
|
980
|
-
}, _callee8, null, [[2,
|
|
1005
|
+
}, _callee8, null, [[2, 19]]);
|
|
981
1006
|
})), [dataImages, imagesUploaded]);
|
|
982
1007
|
|
|
983
1008
|
var evaluationFinished = function evaluationFinished(userId, tab, statusArray) {
|
|
1009
|
+
var _srv$find, _srv$find$status, _product$;
|
|
1010
|
+
|
|
984
1011
|
var srv = servicesData.filter(function (serv) {
|
|
985
1012
|
return serv.service === getConcept(tab);
|
|
986
1013
|
});
|
|
987
|
-
|
|
988
|
-
var _srv$filter = srv.filter(function (serv) {
|
|
1014
|
+
var srvActive = (_srv$find = srv.find(function (serv) {
|
|
989
1015
|
return serv.id_retailer === (activeRetailer === null || activeRetailer === void 0 ? void 0 : activeRetailer.id);
|
|
990
|
-
})
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
var unvalidated = product["".concat(getConcept(tab), "_status")] === "QF" || product["".concat(getConcept(tab), "_status")] === "IN_PROGRESS";
|
|
995
|
-
var auditorUnvalidated = !["RA", "AA", "AC", "AP"].includes(product["".concat(getConcept(tab), "_status")]);
|
|
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);
|
|
996
1020
|
|
|
997
1021
|
switch (userId) {
|
|
998
1022
|
case 7:
|
|
999
1023
|
case 8:
|
|
1000
|
-
return ["RA", "
|
|
1001
|
-
statusArray.includes(srvActive === null || srvActive === void 0 ? void 0 : srvActive.status) || statusArray.includes(product.status) && srv.filter(function (serv) {
|
|
1024
|
+
return statusArray.includes(srvActive) && (["RA", "RC"].includes(product === null || product === void 0 ? void 0 : product.status) || srv.filter(function (serv) {
|
|
1002
1025
|
return statusArray.includes(serv.status);
|
|
1003
|
-
}).length === srv.length;
|
|
1026
|
+
}).length === srv.length);
|
|
1004
1027
|
|
|
1005
1028
|
case 4:
|
|
1006
1029
|
case 5:
|
|
1007
|
-
return unvalidated && ["
|
|
1030
|
+
return unvalidated && ["CA", "IE"].includes(product.status) && // "RC", "AC", "AA", "AP", "ACA"
|
|
1008
1031
|
srv.filter(function (serv) {
|
|
1009
1032
|
return statusArray.includes(serv.status);
|
|
1010
1033
|
}).length === srv.length;
|
|
1011
1034
|
|
|
1012
1035
|
case 6:
|
|
1013
|
-
return statusArray.includes(product.status) && //RP,
|
|
1036
|
+
return statusArray.includes(product.status) && // RP, RCA, AC, RA true
|
|
1014
1037
|
srv.every(function (serv) {
|
|
1015
|
-
return ["RA", "AA", "AP", "
|
|
1038
|
+
return ["RA", "AA", "AP", "ACA"].includes(serv.status);
|
|
1016
1039
|
}) && auditorUnvalidated;
|
|
1017
1040
|
|
|
1018
1041
|
default:
|
|
@@ -1034,16 +1057,16 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
|
|
|
1034
1057
|
};
|
|
1035
1058
|
|
|
1036
1059
|
var approveRejectButtons = function approveRejectButtons(action) {
|
|
1037
|
-
var
|
|
1060
|
+
var _servicesData$find, _servicesData$find$st;
|
|
1038
1061
|
|
|
1039
|
-
var
|
|
1062
|
+
var concept = getConcept(action || activeTab);
|
|
1063
|
+
var retailerStatus = (_servicesData$find = servicesData.find(function (srv) {
|
|
1040
1064
|
return srv.id_retailer === (activeRetailer === null || activeRetailer === void 0 ? void 0 : activeRetailer.id) && srv.service === concept;
|
|
1041
|
-
})
|
|
1042
|
-
_servicesData$filter2 = (0, _slicedToArray2.default)(_servicesData$filter, 1),
|
|
1043
|
-
retailerStatus = _servicesData$filter2[0];
|
|
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
|
|
1044
1066
|
|
|
1045
|
-
|
|
1046
|
-
|
|
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;
|
|
1047
1070
|
};
|
|
1048
1071
|
|
|
1049
1072
|
var getSectionIcon = function getSectionIcon() {
|
|
@@ -1067,7 +1090,8 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
|
|
|
1067
1090
|
|
|
1068
1091
|
var sendToFacilitator = /*#__PURE__*/function () {
|
|
1069
1092
|
var _ref10 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee9(result) {
|
|
1070
|
-
var concept, productTemp, evalStatus, data, specialistDone,
|
|
1093
|
+
var concept, productTemp, evalStatus, _articleId, orderId, data, res, specialistDone, _message, _JSON$parse5, newStatus, newOrderStatus;
|
|
1094
|
+
|
|
1071
1095
|
return _regenerator.default.wrap(function _callee9$(_context9) {
|
|
1072
1096
|
while (1) {
|
|
1073
1097
|
switch (_context9.prev = _context9.next) {
|
|
@@ -1076,112 +1100,92 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
|
|
|
1076
1100
|
_context9.prev = 1;
|
|
1077
1101
|
concept = getConcept(activeTab);
|
|
1078
1102
|
productTemp = (0, _objectSpread2.default)({}, product);
|
|
1079
|
-
evalStatus =
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
if (!result) {
|
|
1083
|
-
_context9.next = 13;
|
|
1084
|
-
break;
|
|
1085
|
-
}
|
|
1086
|
-
|
|
1103
|
+
evalStatus = retailerStatus;
|
|
1104
|
+
_articleId = product.article.id_article;
|
|
1105
|
+
orderId = product.orderId;
|
|
1087
1106
|
data = {
|
|
1088
|
-
articleId:
|
|
1089
|
-
orderId:
|
|
1107
|
+
articleId: _articleId,
|
|
1108
|
+
orderId: orderId,
|
|
1090
1109
|
concept: concept,
|
|
1091
|
-
result: result,
|
|
1092
1110
|
evalStatus: evalStatus,
|
|
1093
1111
|
retailerId: activeRetailer.id
|
|
1094
1112
|
};
|
|
1095
|
-
|
|
1113
|
+
|
|
1114
|
+
if (!result) {
|
|
1115
|
+
_context9.next = 16;
|
|
1116
|
+
break;
|
|
1117
|
+
}
|
|
1118
|
+
|
|
1119
|
+
data.result = result;
|
|
1120
|
+
_context9.next = 12;
|
|
1096
1121
|
return _axios.default.put("".concat(process.env.REACT_APP_EVALUATION_ENDPOINT), data, {
|
|
1097
1122
|
headers: {
|
|
1098
1123
|
Authorization: token
|
|
1099
1124
|
}
|
|
1100
1125
|
});
|
|
1101
1126
|
|
|
1102
|
-
case
|
|
1127
|
+
case 12:
|
|
1128
|
+
res = _context9.sent;
|
|
1103
1129
|
getServices();
|
|
1104
|
-
_context9.next =
|
|
1130
|
+
_context9.next = 21;
|
|
1105
1131
|
break;
|
|
1106
1132
|
|
|
1107
|
-
case
|
|
1108
|
-
specialistDone =
|
|
1133
|
+
case 16:
|
|
1134
|
+
specialistDone = ["RC", "RA", "CA"].includes(evalStatus);
|
|
1109
1135
|
|
|
1110
1136
|
if (specialistDone) {
|
|
1111
|
-
|
|
1112
|
-
getSectionIcon();
|
|
1113
|
-
} else if (evalStatus === "QF") {
|
|
1114
|
-
setMessage("Evaluación enviada");
|
|
1115
|
-
getSectionIcon();
|
|
1116
|
-
} else if (evalStatus === "AF") {
|
|
1117
|
-
setMessage("Evaluación enviada");
|
|
1118
|
-
getSectionIcon();
|
|
1119
|
-
} else if (evalStatus === "RP") {
|
|
1120
|
-
setMessage("Evaluación enviada");
|
|
1137
|
+
_message = "".concat(activeTab, " enviada a facilitador");
|
|
1121
1138
|
getSectionIcon();
|
|
1122
|
-
} else if (
|
|
1123
|
-
|
|
1139
|
+
} else if (["IE", "AC", "RP", "RCA"].includes(evalStatus)) {
|
|
1140
|
+
_message = "Evaluación enviada";
|
|
1124
1141
|
getSectionIcon();
|
|
1125
1142
|
}
|
|
1126
1143
|
|
|
1127
|
-
|
|
1128
|
-
servicesData.forEach(function (srv) {
|
|
1129
|
-
srv.service === concept && statusArr.push(srv.status);
|
|
1130
|
-
});
|
|
1131
|
-
productTemp["".concat(concept, "_status")] = (0, _data2.getNewStatus)(statusArr);
|
|
1132
|
-
newStatus = (0, _data2.getNewStatus)([productTemp.datasheet_status, productTemp.description_status, productTemp.images_status]);
|
|
1133
|
-
productTemp.status = newStatus;
|
|
1134
|
-
data = {
|
|
1135
|
-
articleId: product.article.id_article,
|
|
1136
|
-
orderId: product.orderId,
|
|
1137
|
-
concept: concept,
|
|
1138
|
-
evalStatus: evalStatus,
|
|
1139
|
-
retailerId: activeRetailer.id
|
|
1140
|
-
};
|
|
1141
|
-
_context9.t0 = user.id_role;
|
|
1142
|
-
_context9.next = _context9.t0 === 7 ? 24 : _context9.t0 === 8 ? 24 : _context9.t0 === 4 ? 26 : _context9.t0 === 5 ? 26 : 28;
|
|
1143
|
-
break;
|
|
1144
|
-
|
|
1145
|
-
case 24:
|
|
1146
|
-
data.especialist = true;
|
|
1147
|
-
return _context9.abrupt("break", 29);
|
|
1148
|
-
|
|
1149
|
-
case 26:
|
|
1150
|
-
data.facilitator = true;
|
|
1151
|
-
return _context9.abrupt("break", 29);
|
|
1152
|
-
|
|
1153
|
-
case 28:
|
|
1154
|
-
return _context9.abrupt("break", 29);
|
|
1155
|
-
|
|
1156
|
-
case 29:
|
|
1157
|
-
_context9.next = 31;
|
|
1144
|
+
_context9.next = 20;
|
|
1158
1145
|
return _axios.default.put("".concat(process.env.REACT_APP_SEND_EVAL), data, {
|
|
1159
1146
|
headers: {
|
|
1160
1147
|
Authorization: token
|
|
1161
1148
|
}
|
|
1162
1149
|
});
|
|
1163
1150
|
|
|
1164
|
-
case
|
|
1165
|
-
|
|
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);
|
|
1166
1168
|
sessionStorage.setItem("productSelected", JSON.stringify(productTemp));
|
|
1167
1169
|
setProduct(productTemp);
|
|
1168
|
-
|
|
1170
|
+
|
|
1171
|
+
case 30:
|
|
1172
|
+
_context9.next = 35;
|
|
1169
1173
|
break;
|
|
1170
1174
|
|
|
1171
|
-
case
|
|
1172
|
-
_context9.prev =
|
|
1173
|
-
_context9.
|
|
1174
|
-
console.log(_context9.
|
|
1175
|
+
case 32:
|
|
1176
|
+
_context9.prev = 32;
|
|
1177
|
+
_context9.t0 = _context9["catch"](1);
|
|
1178
|
+
console.log(_context9.t0);
|
|
1175
1179
|
|
|
1176
|
-
case
|
|
1180
|
+
case 35:
|
|
1177
1181
|
setLoading(false);
|
|
1178
1182
|
|
|
1179
|
-
case
|
|
1183
|
+
case 36:
|
|
1180
1184
|
case "end":
|
|
1181
1185
|
return _context9.stop();
|
|
1182
1186
|
}
|
|
1183
1187
|
}
|
|
1184
|
-
}, _callee9, null, [[1,
|
|
1188
|
+
}, _callee9, null, [[1, 32]]);
|
|
1185
1189
|
}));
|
|
1186
1190
|
|
|
1187
1191
|
return function sendToFacilitator(_x) {
|
|
@@ -1288,11 +1292,11 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
|
|
|
1288
1292
|
var dsInputsRequired = [];
|
|
1289
1293
|
var desInputsRequired = 0;
|
|
1290
1294
|
datasheetServicesArray === null || datasheetServicesArray === void 0 ? void 0 : datasheetServicesArray.forEach(function (datasheet) {
|
|
1291
|
-
var _servicesData$
|
|
1295
|
+
var _servicesData$filter = servicesData === null || servicesData === void 0 ? void 0 : servicesData.filter(function (srv) {
|
|
1292
1296
|
return srv.id_retailer === datasheet.retailer.id && srv.service === getConcept(activeTab);
|
|
1293
1297
|
}),
|
|
1294
|
-
_servicesData$
|
|
1295
|
-
requested = _servicesData$
|
|
1298
|
+
_servicesData$filter2 = (0, _slicedToArray2.default)(_servicesData$filter, 1),
|
|
1299
|
+
requested = _servicesData$filter2[0];
|
|
1296
1300
|
|
|
1297
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) {
|
|
1298
1302
|
return dsInputsRequired.push.apply(dsInputsRequired, (0, _toConsumableArray2.default)(dataGroup.inputs.filter(function (input) {
|
|
@@ -1302,14 +1306,16 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
|
|
|
1302
1306
|
});
|
|
1303
1307
|
objetcTemp["Ficha técnica"] = dsInputsRequired.length;
|
|
1304
1308
|
descriptionsServicesArray.forEach(function (description) {
|
|
1305
|
-
var _servicesData$
|
|
1309
|
+
var _servicesData$filter3 = servicesData.filter(function (srv) {
|
|
1306
1310
|
return srv.id_retailer === description.id && srv.service === getConcept(activeTab);
|
|
1307
1311
|
}),
|
|
1308
|
-
_servicesData$
|
|
1309
|
-
requested = _servicesData$
|
|
1312
|
+
_servicesData$filter4 = (0, _slicedToArray2.default)(_servicesData$filter3, 1),
|
|
1313
|
+
requested = _servicesData$filter4[0];
|
|
1310
1314
|
|
|
1311
1315
|
requested && description.inputs.forEach(function (input) {
|
|
1312
|
-
|
|
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++;
|
|
1313
1319
|
});
|
|
1314
1320
|
});
|
|
1315
1321
|
objetcTemp["Descripción"] = desInputsRequired;
|
|
@@ -1407,14 +1413,16 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
|
|
|
1407
1413
|
case 10:
|
|
1408
1414
|
productTemp = product;
|
|
1409
1415
|
productTemp.article["id_".concat(concept, "_").concat(assignationType)] = assignationId;
|
|
1410
|
-
data =
|
|
1416
|
+
data = {
|
|
1411
1417
|
articleList: [{
|
|
1412
1418
|
orderId: product.orderId,
|
|
1413
1419
|
articleId: product === null || product === void 0 ? void 0 : (_product$article13 = product.article) === null || _product$article13 === void 0 ? void 0 : _product$article13.id_article
|
|
1414
1420
|
}],
|
|
1415
|
-
concept: concept
|
|
1416
|
-
|
|
1417
|
-
|
|
1421
|
+
concept: concept,
|
|
1422
|
+
userId: assignationId
|
|
1423
|
+
};
|
|
1424
|
+
_context12.next = 15;
|
|
1425
|
+
return (0, _axios.default)({
|
|
1418
1426
|
method: "post",
|
|
1419
1427
|
url: process.env.REACT_APP_ASSIGNATIONS_ENDPOINT,
|
|
1420
1428
|
data: data,
|
|
@@ -1422,10 +1430,12 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
|
|
|
1422
1430
|
Authorization: token
|
|
1423
1431
|
}
|
|
1424
1432
|
});
|
|
1433
|
+
|
|
1434
|
+
case 15:
|
|
1425
1435
|
loadAssignations(productTemp);
|
|
1426
1436
|
sessionStorage.setItem("productSelected", JSON.stringify(productTemp));
|
|
1427
1437
|
|
|
1428
|
-
case
|
|
1438
|
+
case 17:
|
|
1429
1439
|
case "end":
|
|
1430
1440
|
return _context12.stop();
|
|
1431
1441
|
}
|
|
@@ -1604,21 +1614,24 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
|
|
|
1604
1614
|
productTemp.images_status = productTemp.images_status === "NA" ? "NA" : "".concat(result, "A");
|
|
1605
1615
|
sessionStorage.setItem("productSelected", JSON.stringify(productTemp));
|
|
1606
1616
|
setProduct(productTemp);
|
|
1607
|
-
|
|
1608
|
-
|
|
1617
|
+
_context13.next = 20;
|
|
1618
|
+
return loadData();
|
|
1619
|
+
|
|
1620
|
+
case 20:
|
|
1621
|
+
_context13.next = 25;
|
|
1609
1622
|
break;
|
|
1610
1623
|
|
|
1611
|
-
case
|
|
1612
|
-
_context13.prev =
|
|
1624
|
+
case 22:
|
|
1625
|
+
_context13.prev = 22;
|
|
1613
1626
|
_context13.t0 = _context13["catch"](0);
|
|
1614
1627
|
console.log(_context13.t0);
|
|
1615
1628
|
|
|
1616
|
-
case
|
|
1629
|
+
case 25:
|
|
1617
1630
|
case "end":
|
|
1618
1631
|
return _context13.stop();
|
|
1619
1632
|
}
|
|
1620
1633
|
}
|
|
1621
|
-
}, _callee13, null, [[0,
|
|
1634
|
+
}, _callee13, null, [[0, 22]]);
|
|
1622
1635
|
}));
|
|
1623
1636
|
|
|
1624
1637
|
return function validateAll(_x7) {
|
|
@@ -1691,7 +1704,7 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
|
|
|
1691
1704
|
})]);
|
|
1692
1705
|
},
|
|
1693
1706
|
showApproveRejectAll: isAuditor && servicesData.every(function (serv) {
|
|
1694
|
-
return ["RA", "AA", "AP", "
|
|
1707
|
+
return ["RA", "AA", "AP", "ACA", "AC"].includes(serv.status);
|
|
1695
1708
|
}) && approveRejectButtons() && (auditorAssigned() || userAssigned()),
|
|
1696
1709
|
showValidationButtons: approveRejectButtons() && (auditorAssigned() || userAssigned()),
|
|
1697
1710
|
approveAll: function approveAll() {
|
|
@@ -1721,7 +1734,6 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
|
|
|
1721
1734
|
})]);
|
|
1722
1735
|
}
|
|
1723
1736
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_FullTabsMenu.FullTabsMenu, {
|
|
1724
|
-
canAssign: ![7, 8].includes(user.id_role),
|
|
1725
1737
|
tabsSections: tabsSections,
|
|
1726
1738
|
status: retailerStatus,
|
|
1727
1739
|
activeTab: activeTab,
|
|
@@ -1840,7 +1852,7 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
|
|
|
1840
1852
|
}, _callee14);
|
|
1841
1853
|
}))
|
|
1842
1854
|
})]
|
|
1843
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_GeneralButton.Button, {
|
|
1855
|
+
}), [7, 8].includes(user.id_role) && /*#__PURE__*/(0, _jsxRuntime.jsx)(_GeneralButton.Button, {
|
|
1844
1856
|
buttonType: evaluationFinished(user.id_role, activeTab, statusArray) && requiredNull[activeTab] === 0 ? "general-green-button" : "general-button-disabled",
|
|
1845
1857
|
label: "Enviar evaluación",
|
|
1846
1858
|
onClick: function onClick() {
|