contentoh-components-library 21.1.82 → 21.1.85

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 (40) hide show
  1. package/dist/components/atoms/AsignationOption/index.js +2 -2
  2. package/dist/components/atoms/InputFormatter/index.js +3 -3
  3. package/dist/components/atoms/ProductPercentCard/Percent.stories.js +1 -1
  4. package/dist/components/atoms/ProductPercentCard/styles.js +1 -1
  5. package/dist/components/atoms/ProgressBar/styles.js +1 -1
  6. package/dist/components/atoms/SliderToolTip/index.js +9 -23
  7. package/dist/components/atoms/Status/Status.stories.js +31 -0
  8. package/dist/components/atoms/Status/index.js +23 -0
  9. package/dist/components/atoms/Status/styles.js +20 -0
  10. package/dist/components/molecules/AssignedWork/AssignedWork.stories.js +1 -1
  11. package/dist/components/molecules/AssignedWork/styles.js +1 -1
  12. package/dist/components/molecules/ProductNameHeader/index.js +2 -2
  13. package/dist/components/molecules/StatusAsignationInfo/index.js +7 -6
  14. package/dist/components/organisms/FullProductNameHeader/index.js +1 -1
  15. package/dist/components/pages/ProviderProductEdition/ProviderProductEdition.stories.js +2 -6
  16. package/dist/components/pages/ProviderProductEdition/index.js +435 -434
  17. package/dist/components/pages/RetailerProductEdition/index.js +219 -201
  18. package/dist/global-files/data.js +8 -8
  19. package/dist/index.js +1 -14
  20. package/package.json +1 -1
  21. package/src/components/atoms/AsignationOption/index.js +2 -2
  22. package/src/components/atoms/InputFormatter/index.js +8 -3
  23. package/src/components/atoms/ProductPercentCard/Percent.stories.js +11 -12
  24. package/src/components/atoms/ProductPercentCard/styles.js +9 -9
  25. package/src/components/atoms/ProgressBar/styles.js +7 -8
  26. package/src/components/atoms/SliderToolTip/index.js +6 -22
  27. package/src/components/atoms/Status/Status.stories.js +14 -0
  28. package/src/components/atoms/Status/index.js +13 -0
  29. package/src/components/atoms/{StatusTag → Status}/styles.js +7 -10
  30. package/src/components/molecules/AssignedWork/AssignedWork.stories.js +8 -8
  31. package/src/components/molecules/AssignedWork/styles.js +9 -10
  32. package/src/components/molecules/ProductNameHeader/index.js +2 -2
  33. package/src/components/molecules/StatusAsignationInfo/index.js +5 -4
  34. package/src/components/organisms/FullProductNameHeader/index.js +2 -2
  35. package/src/components/pages/ProviderProductEdition/ProviderProductEdition.stories.js +2 -3
  36. package/src/components/pages/ProviderProductEdition/index.js +234 -251
  37. package/src/components/pages/RetailerProductEdition/index.js +150 -173
  38. package/src/global-files/data.js +8 -8
  39. package/src/index.js +1 -2
  40. package/src/components/atoms/StatusTag/index.js +0 -37
@@ -39,7 +39,7 @@ var _GalleryElement = require("../../molecules/GalleryElement");
39
39
 
40
40
  var _fileSaver = require("file-saver");
41
41
 
42
- var _data2 = require("../../../global-files/data");
42
+ var _data = require("../../../global-files/data");
43
43
 
44
44
  var _GalleryHeader = require("../../molecules/GalleryHeader");
45
45
 
@@ -353,98 +353,83 @@ var ProviderProductEdition = function ProviderProductEdition(_ref) {
353
353
  setVersion = _useState42[1];
354
354
 
355
355
  var _useState43 = (0, _react.useState)({}),
356
- _useState44 = (0, _slicedToArray2.default)(_useState43, 2),
357
- comments = _useState44[0],
358
- setComments = _useState44[1];
356
+ _useState44 = (0, _slicedToArray2.default)(_useState43, 1),
357
+ comments = _useState44[0];
359
358
 
360
359
  var _useState45 = (0, _react.useState)(""),
361
360
  _useState46 = (0, _slicedToArray2.default)(_useState45, 2),
362
361
  comment = _useState46[0],
363
362
  setComment = _useState46[1];
364
363
 
365
- var _useState47 = (0, _react.useState)({
366
- "Ficha técnica": 0,
367
- Descripción: 0,
368
- Imágenes: 0
369
- }),
364
+ var _useState47 = (0, _react.useState)(false),
370
365
  _useState48 = (0, _slicedToArray2.default)(_useState47, 2),
371
- requiredNull = _useState48[0],
372
- setRequiredNull = _useState48[1];
366
+ crossComment = _useState48[0],
367
+ setCrossComment = _useState48[1];
373
368
 
374
- var _useState49 = (0, _react.useState)(false),
369
+ var _useState49 = (0, _react.useState)([]),
375
370
  _useState50 = (0, _slicedToArray2.default)(_useState49, 2),
376
- crossComment = _useState50[0],
377
- setCrossComment = _useState50[1];
371
+ userGroups = _useState50[0],
372
+ setUserGroups = _useState50[1];
378
373
 
379
- var _useState51 = (0, _react.useState)([]),
374
+ var _useState51 = (0, _react.useState)({}),
380
375
  _useState52 = (0, _slicedToArray2.default)(_useState51, 2),
381
- userGroups = _useState52[0],
382
- setUserGroups = _useState52[1];
376
+ assig = _useState52[0],
377
+ setAssig = _useState52[1];
383
378
 
384
- var _useState53 = (0, _react.useState)({}),
379
+ var _useState53 = (0, _react.useState)([]),
385
380
  _useState54 = (0, _slicedToArray2.default)(_useState53, 2),
386
- assig = _useState54[0],
387
- setAssig = _useState54[1];
381
+ selectedImages = _useState54[0],
382
+ setSelectedImages = _useState54[1];
388
383
 
389
384
  var _useState55 = (0, _react.useState)([]),
390
385
  _useState56 = (0, _slicedToArray2.default)(_useState55, 2),
391
- selectedImages = _useState56[0],
392
- setSelectedImages = _useState56[1];
386
+ componentsArray = _useState56[0],
387
+ setComponentsArray = _useState56[1];
393
388
 
394
- var _useState57 = (0, _react.useState)([]),
389
+ var _useState57 = (0, _react.useState)(false),
395
390
  _useState58 = (0, _slicedToArray2.default)(_useState57, 2),
396
- componentsArray = _useState58[0],
397
- setComponentsArray = _useState58[1];
398
-
399
- var _useState59 = (0, _react.useState)(false),
400
- _useState60 = (0, _slicedToArray2.default)(_useState59, 2),
401
- checkAll = _useState60[0],
402
- setCheckAll = _useState60[1];
391
+ checkAll = _useState58[0],
392
+ setCheckAll = _useState58[1];
403
393
 
404
394
  var isRetailer = user === null || user === void 0 ? void 0 : user.is_retailer;
405
395
 
406
- var _useState61 = (0, _react.useState)(true),
407
- _useState62 = (0, _slicedToArray2.default)(_useState61, 2),
408
- loading = _useState62[0],
409
- setLoading = _useState62[1];
410
-
411
- var _useState63 = (0, _react.useState)([]),
412
- _useState64 = (0, _slicedToArray2.default)(_useState63, 2),
413
- statusArray = _useState64[0],
414
- setStatusArray = _useState64[1];
396
+ var _useState59 = (0, _react.useState)(true),
397
+ _useState60 = (0, _slicedToArray2.default)(_useState59, 2),
398
+ loading = _useState60[0],
399
+ setLoading = _useState60[1];
415
400
 
416
401
  var originProp = location === null || location === void 0 ? void 0 : (_location$state = location.state) === null || _location$state === void 0 ? void 0 : _location$state.origin;
417
402
 
418
- var _useState65 = (0, _react.useState)({
403
+ var _useState61 = (0, _react.useState)({
419
404
  "Ficha técnica": originProp,
420
405
  Descripción: originProp,
421
406
  Imágenes: originProp
422
407
  }),
408
+ _useState62 = (0, _slicedToArray2.default)(_useState61, 2),
409
+ origin = _useState62[0],
410
+ setOrigin = _useState62[1];
411
+
412
+ var _useState63 = (0, _react.useState)(false),
413
+ _useState64 = (0, _slicedToArray2.default)(_useState63, 2),
414
+ inCart = _useState64[0],
415
+ setInCart = _useState64[1];
416
+
417
+ var _useState65 = (0, _react.useState)(false),
423
418
  _useState66 = (0, _slicedToArray2.default)(_useState65, 2),
424
- origin = _useState66[0],
425
- setOrigin = _useState66[1];
419
+ modalSent = _useState66[0],
420
+ setModalSent = _useState66[1];
426
421
 
427
422
  var _useState67 = (0, _react.useState)(false),
428
423
  _useState68 = (0, _slicedToArray2.default)(_useState67, 2),
429
- inCart = _useState68[0],
430
- setInCart = _useState68[1];
424
+ modalViewError = _useState68[0],
425
+ setModalViewError = _useState68[1];
431
426
 
432
427
  var _useState69 = (0, _react.useState)(false),
433
428
  _useState70 = (0, _slicedToArray2.default)(_useState69, 2),
434
- modalSent = _useState70[0],
435
- setModalSent = _useState70[1];
436
-
437
- var _useState71 = (0, _react.useState)(false),
438
- _useState72 = (0, _slicedToArray2.default)(_useState71, 2),
439
- modalViewError = _useState72[0],
440
- setModalViewError = _useState72[1];
441
-
442
- var _useState73 = (0, _react.useState)(false),
443
- _useState74 = (0, _slicedToArray2.default)(_useState73, 2),
444
- showGenericModal = _useState74[0],
445
- setShowGenericModal = _useState74[1];
429
+ showGenericModal = _useState70[0],
430
+ setShowGenericModal = _useState70[1];
446
431
 
447
- var _useState75 = (0, _react.useState)({
432
+ var _useState71 = (0, _react.useState)({
448
433
  message: "¿Estás seguro de continuar?",
449
434
  detail: " ".concat(user.is_retailer ? "Asegurate de haber revisado las tres secciones" : "Envíar el producto a la cadena"),
450
435
  button1: {
@@ -461,34 +446,39 @@ var ProviderProductEdition = function ProviderProductEdition(_ref) {
461
446
  },
462
447
  img: _defaultProfileImage.default
463
448
  }),
449
+ _useState72 = (0, _slicedToArray2.default)(_useState71, 2),
450
+ dataGenericModal = _useState72[0],
451
+ setDataGenericModal = _useState72[1];
452
+
453
+ var _useState73 = (0, _react.useState)(false),
454
+ _useState74 = (0, _slicedToArray2.default)(_useState73, 2),
455
+ modalViewTextArea = _useState74[0],
456
+ setModalViewTextArea = _useState74[1];
457
+
458
+ var _useState75 = (0, _react.useState)(null),
464
459
  _useState76 = (0, _slicedToArray2.default)(_useState75, 2),
465
- dataGenericModal = _useState76[0],
466
- setDataGenericModal = _useState76[1];
460
+ socketType = _useState76[0],
461
+ setSocketType = _useState76[1];
467
462
 
468
- var _useState77 = (0, _react.useState)(false),
463
+ var _useState77 = (0, _react.useState)(loading),
469
464
  _useState78 = (0, _slicedToArray2.default)(_useState77, 2),
470
- modalViewTextArea = _useState78[0],
471
- setModalViewTextArea = _useState78[1];
465
+ saving = _useState78[0],
466
+ setSaving = _useState78[1];
472
467
 
473
- var _useState79 = (0, _react.useState)(null),
468
+ var _useState79 = (0, _react.useState)(product.statusByRetailer),
474
469
  _useState80 = (0, _slicedToArray2.default)(_useState79, 2),
475
- socketType = _useState80[0],
476
- setSocketType = _useState80[1];
470
+ retailerStatus = _useState80[0],
471
+ setRetailerStatus = _useState80[1];
477
472
 
478
- var _useState81 = (0, _react.useState)(loading),
473
+ var _useState81 = (0, _react.useState)(false),
479
474
  _useState82 = (0, _slicedToArray2.default)(_useState81, 2),
480
- saving = _useState82[0],
481
- setSaving = _useState82[1];
482
-
483
- var _useState83 = (0, _react.useState)(false),
484
- _useState84 = (0, _slicedToArray2.default)(_useState83, 2),
485
- showCreateVersion = _useState84[0],
486
- setShowCreateVersion = _useState84[1];
475
+ showCreateVersion = _useState82[0],
476
+ setShowCreateVersion = _useState82[1];
487
477
 
488
- var _closeModals = (0, _customHooks.closeModals)("version-selector"),
489
- _closeModals2 = (0, _slicedToArray2.default)(_closeModals, 2),
490
- showVersionSelector = _closeModals2[0],
491
- setShowVersionSelector = _closeModals2[1];
478
+ var _useCloseModal = (0, _customHooks.useCloseModal)("version-selector"),
479
+ _useCloseModal2 = (0, _slicedToArray2.default)(_useCloseModal, 2),
480
+ showVersionSelector = _useCloseModal2[0],
481
+ setShowVersionSelector = _useCloseModal2[1];
492
482
 
493
483
  (0, _react.useEffect)(function () {
494
484
  checkAll && setSelectedImages(images.values);
@@ -504,7 +494,7 @@ var ProviderProductEdition = function ProviderProductEdition(_ref) {
504
494
  switch (_context2.prev = _context2.next) {
505
495
  case 0:
506
496
  _context2.next = 2;
507
- return (0, _data2.getRetailerServices)((product === null || product === void 0 ? void 0 : product.id_article) || (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.company_name) || (product === null || product === void 0 ? void 0 : product.categoryName), 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.id_category)), version);
497
+ return (0, _data.getRetailerServices)((product === null || product === void 0 ? void 0 : product.id_article) || (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.company_name) || (product === null || product === void 0 ? void 0 : product.categoryName), 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.id_category)), version);
508
498
 
509
499
  case 2:
510
500
  services = _context2.sent;
@@ -514,7 +504,7 @@ var ProviderProductEdition = function ProviderProductEdition(_ref) {
514
504
 
515
505
  if (!originProp) {
516
506
  setActiveRetailer(product !== null && product !== void 0 && product.retailers ? product === null || product === void 0 ? void 0 : product.retailers[0] : product === null || product === void 0 ? void 0 : product.retailersAvailable[0]);
517
- } //setActiveRetailer(product?.retailers[0]);
507
+ } // setActiveRetailer(product?.retailers[0]);
518
508
 
519
509
 
520
510
  setImages({
@@ -522,7 +512,7 @@ var ProviderProductEdition = function ProviderProductEdition(_ref) {
522
512
  init: services[2]
523
513
  });
524
514
  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);
525
- (0, _data2.getPercentage)({
515
+ (0, _data.getPercentage)({
526
516
  data: [product]
527
517
  }).then(function (res) {
528
518
  return setPercentages(res);
@@ -546,7 +536,7 @@ var ProviderProductEdition = function ProviderProductEdition(_ref) {
546
536
  var _ref4 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
547
537
  var _product$article4;
548
538
 
549
- var productInOrder, idArticle, _product$id_order, _servicesResponse$dat, servicesResponse, parsedResponse, retailers, active;
539
+ var productInOrder, idArticle, _product$id_order, _servicesResponse$dat, servicesResponse, parsedResponse, retailerResponse, retailers, active;
550
540
 
551
541
  return _regenerator.default.wrap(function _callee3$(_context3) {
552
542
  while (1) {
@@ -556,7 +546,7 @@ var ProviderProductEdition = function ProviderProductEdition(_ref) {
556
546
  idArticle = (product === null || product === void 0 ? void 0 : product.id_article) || (product === null || product === void 0 ? void 0 : (_product$article4 = product.article) === null || _product$article4 === void 0 ? void 0 : _product$article4.id_article);
557
547
 
558
548
  if (!(isRevision() || productInOrder)) {
559
- _context3.next = 11;
549
+ _context3.next = 12;
560
550
  break;
561
551
  }
562
552
 
@@ -566,16 +556,17 @@ var ProviderProductEdition = function ProviderProductEdition(_ref) {
566
556
  case 5:
567
557
  servicesResponse = _context3.sent;
568
558
  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;
559
+ retailerResponse = parsedResponse === null || parsedResponse === void 0 ? void 0 : parsedResponse.map(function (srv) {
560
+ return srv.id_retailer;
561
+ });
569
562
  retailers = product.retailers || product.retailersAvailable;
570
- active = retailers === null || retailers === void 0 ? void 0 : retailers.filter(function (retailer) {
571
- return parsedResponse === null || parsedResponse === void 0 ? void 0 : parsedResponse.map(function (srv) {
572
- return srv.id_retailer;
573
- }).includes(retailer.id);
574
- })[0];
563
+ active = retailers === null || retailers === void 0 ? void 0 : retailers.find(function (retailer) {
564
+ return retailerResponse.includes(retailer.id);
565
+ });
575
566
  !activeRetailer.id && setActiveRetailer(active ? active : retailers[0]);
576
567
  setServicesData(parsedResponse);
577
568
 
578
- case 11:
569
+ case 12:
579
570
  case "end":
580
571
  return _context3.stop();
581
572
  }
@@ -603,7 +594,10 @@ var ProviderProductEdition = function ProviderProductEdition(_ref) {
603
594
  if (_revision && currentService === "AP") return true;
604
595
  } else {
605
596
  var _product = productEdit.product;
606
- if (orgn === "Contentoh" || ["RECEIVED", "IN_PROGRESS"].includes(currentService) && orgn === "RequestWithoutContentoh" || currentService === "AA" && orgn === "RequestWithContentoh" || currentService === "RC" && orgn === "RequestWithoutContentoh" && (!_product.id_order || !_product.orderId)) return true;
597
+ var isRequestWithoutContentoh = orgn === "RequestWithoutContentoh" && (["R", "CA"].includes(currentService) || currentService === "RCA" && (!_product.id_order || !_product.orderId));
598
+ var isRequestWithContentoh = orgn === "RequestWithContentoh" && currentService === "AA";
599
+ var isContentoh = orgn === "Contentoh" && currentService === "AA";
600
+ if (isContentoh || isRequestWithoutContentoh || isRequestWithContentoh) return true;
607
601
  }
608
602
  }
609
603
 
@@ -646,54 +640,14 @@ var ProviderProductEdition = function ProviderProductEdition(_ref) {
646
640
  };
647
641
  }();
648
642
 
649
- (0, _react.useEffect)( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5() {
650
- var arr;
651
- return _regenerator.default.wrap(function _callee5$(_context5) {
652
- while (1) {
653
- switch (_context5.prev = _context5.next) {
654
- case 0:
655
- setLoading(true);
656
- sessionStorage.setItem("user", JSON.stringify(user));
657
- loadData();
658
- getCart();
659
- _context5.t0 = setUserGroups;
660
- _context5.next = 7;
661
- return (0, _data2.fetchUsers)(token);
662
-
663
- case 7:
664
- _context5.t1 = _context5.sent;
665
- (0, _context5.t0)(_context5.t1);
666
- arr = [];
667
- _context5.t2 = user.id_role;
668
- _context5.next = _context5.t2 === 7 ? 13 : _context5.t2 === 8 ? 13 : _context5.t2 === 4 ? 15 : _context5.t2 === 5 ? 15 : _context5.t2 === 6 ? 17 : 19;
669
- break;
670
-
671
- case 13:
672
- arr = ["IN_PROGRESS", "RF", "RA"];
673
- return _context5.abrupt("break", 21);
674
-
675
- case 15:
676
- arr = ["RF", "AF", "AA", "AP", "AC"];
677
- return _context5.abrupt("break", 21);
678
-
679
- case 17:
680
- arr = ["RP", "RC", "AF"];
681
- return _context5.abrupt("break", 21);
682
-
683
- case 19:
684
- arr = [];
685
- return _context5.abrupt("break", 21);
686
-
687
- case 21:
688
- setStatusArray(arr);
689
-
690
- case 22:
691
- case "end":
692
- return _context5.stop();
693
- }
694
- }
695
- }, _callee5);
696
- })), [product, version]);
643
+ (0, _react.useEffect)(function () {
644
+ sessionStorage.setItem("user", JSON.stringify(user));
645
+ loadData();
646
+ getCart();
647
+ (0, _data.fetchUsers)(token).then(function (res) {
648
+ return setUserGroups(res);
649
+ });
650
+ }, [product]);
697
651
 
698
652
  var loadAssignations = function loadAssignations(currentProduct) {
699
653
  setAssig(product === null || product === void 0 ? void 0 : product.asignations);
@@ -708,11 +662,11 @@ var ProviderProductEdition = function ProviderProductEdition(_ref) {
708
662
  var productTemp = product;
709
663
  var retailers = (productTemp === null || productTemp === void 0 ? void 0 : productTemp.retailersAvailable) || (productTemp === null || productTemp === void 0 ? void 0 : productTemp.retailers);
710
664
  retailers === null || retailers === void 0 ? void 0 : retailers.forEach(function (retailer) {
711
- var _percentages$filter$;
665
+ var _percentages$find;
712
666
 
713
- retailer["percentage"] = percentages === null || percentages === void 0 ? void 0 : (_percentages$filter$ = percentages.filter(function (percent) {
667
+ retailer["percentage"] = percentages === null || percentages === void 0 ? void 0 : (_percentages$find = percentages.find(function (percent) {
714
668
  return (retailer === null || retailer === void 0 ? void 0 : retailer.id) === (percent === null || percent === void 0 ? void 0 : percent.id_retailer);
715
- })[0]) === null || _percentages$filter$ === void 0 ? void 0 : _percentages$filter$.percentage;
669
+ })) === null || _percentages$find === void 0 ? void 0 : _percentages$find.percentage;
716
670
  });
717
671
  setProduct(productTemp);
718
672
  setActivePercentage((_retailers$ = retailers[0]) === null || _retailers$ === void 0 ? void 0 : _retailers$.percentage);
@@ -791,11 +745,12 @@ var ProviderProductEdition = function ProviderProductEdition(_ref) {
791
745
  }, [images]);
792
746
 
793
747
  var saveDescriptions = /*#__PURE__*/function () {
794
- var _ref7 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6() {
795
- var dataObject;
796
- return _regenerator.default.wrap(function _callee6$(_context6) {
748
+ var _ref6 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5() {
749
+ var dataObject, _res;
750
+
751
+ return _regenerator.default.wrap(function _callee5$(_context5) {
797
752
  while (1) {
798
- switch (_context6.prev = _context6.next) {
753
+ switch (_context5.prev = _context5.next) {
799
754
  case 0:
800
755
  setLoading(true);
801
756
  dataObject = {
@@ -803,8 +758,8 @@ var ProviderProductEdition = function ProviderProductEdition(_ref) {
803
758
  articleData: updatedDescriptions
804
759
  };
805
760
  if (product !== null && product !== void 0 && product.orderId) dataObject["orderId"] = product === null || product === void 0 ? void 0 : product.orderId;
806
- _context6.prev = 3;
807
- _context6.next = 6;
761
+ _context5.prev = 3;
762
+ _context5.next = 6;
808
763
  return _axios.default.put("".concat(process.env.REACT_APP_ARTICLE_DATA_ENDPOINT, "?description=true&version=").concat(version), dataObject, {
809
764
  headers: {
810
765
  Authorization: token
@@ -812,35 +767,45 @@ var ProviderProductEdition = function ProviderProductEdition(_ref) {
812
767
  });
813
768
 
814
769
  case 6:
770
+ _res = _context5.sent;
771
+
772
+ if (!(_res.data.statusCode === 200)) {
773
+ _context5.next = 11;
774
+ break;
775
+ }
776
+
815
777
  setMessage("Descripciones guardadas con éxito");
816
- loadData();
817
- _context6.next = 13;
818
- break;
778
+ _context5.next = 11;
779
+ return loadData();
819
780
 
820
- case 10:
821
- _context6.prev = 10;
822
- _context6.t0 = _context6["catch"](3);
823
- console.log(_context6.t0);
781
+ case 11:
782
+ _context5.next = 16;
783
+ break;
824
784
 
825
785
  case 13:
786
+ _context5.prev = 13;
787
+ _context5.t0 = _context5["catch"](3);
788
+ console.log(_context5.t0);
789
+
790
+ case 16:
826
791
  case "end":
827
- return _context6.stop();
792
+ return _context5.stop();
828
793
  }
829
794
  }
830
- }, _callee6, null, [[3, 10]]);
795
+ }, _callee5, null, [[3, 13]]);
831
796
  }));
832
797
 
833
798
  return function saveDescriptions() {
834
- return _ref7.apply(this, arguments);
799
+ return _ref6.apply(this, arguments);
835
800
  };
836
801
  }();
837
802
 
838
803
  var saveDatasheets = /*#__PURE__*/function () {
839
- var _ref8 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7() {
804
+ var _ref7 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6() {
840
805
  var dataObject;
841
- return _regenerator.default.wrap(function _callee7$(_context7) {
806
+ return _regenerator.default.wrap(function _callee6$(_context6) {
842
807
  while (1) {
843
- switch (_context7.prev = _context7.next) {
808
+ switch (_context6.prev = _context6.next) {
844
809
  case 0:
845
810
  setLoading(true);
846
811
  dataObject = {
@@ -848,8 +813,8 @@ var ProviderProductEdition = function ProviderProductEdition(_ref) {
848
813
  articleData: updatedDatasheets
849
814
  };
850
815
  if (product !== null && product !== void 0 && product.orderId) dataObject["orderId"] = product === null || product === void 0 ? void 0 : product.orderId;
851
- _context7.prev = 3;
852
- _context7.next = 6;
816
+ _context6.prev = 3;
817
+ _context6.next = 6;
853
818
  return _axios.default.put("".concat(process.env.REACT_APP_ARTICLE_DATA_ENDPOINT, "?datasheet=true&version=").concat(version), dataObject, {
854
819
  headers: {
855
820
  Authorization: token
@@ -857,37 +822,45 @@ var ProviderProductEdition = function ProviderProductEdition(_ref) {
857
822
  });
858
823
 
859
824
  case 6:
825
+ if (!(res.data.statusCode === 200)) {
826
+ _context6.next = 10;
827
+ break;
828
+ }
829
+
860
830
  setMessage("Fichas técnicas guardadas");
861
- loadData();
862
- _context7.next = 13;
863
- break;
831
+ _context6.next = 10;
832
+ return loadData();
864
833
 
865
834
  case 10:
866
- _context7.prev = 10;
867
- _context7.t0 = _context7["catch"](3);
868
- console.log(_context7.t0);
835
+ _context6.next = 15;
836
+ break;
869
837
 
870
- case 13:
838
+ case 12:
839
+ _context6.prev = 12;
840
+ _context6.t0 = _context6["catch"](3);
841
+ console.log(_context6.t0);
842
+
843
+ case 15:
871
844
  case "end":
872
- return _context7.stop();
845
+ return _context6.stop();
873
846
  }
874
847
  }
875
- }, _callee7, null, [[3, 10]]);
848
+ }, _callee6, null, [[3, 12]]);
876
849
  }));
877
850
 
878
851
  return function saveDatasheets() {
879
- return _ref8.apply(this, arguments);
852
+ return _ref7.apply(this, arguments);
880
853
  };
881
854
  }();
882
855
 
883
- var updateImages = (0, _react.useCallback)( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee8() {
856
+ var updateImages = (0, _react.useCallback)( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7() {
884
857
  var _images$values2, _data$articleData, _data$articleData2, _data$updateImages;
885
858
 
886
859
  var imagesList, imagesListTemp, duplicated, attrForImgs, data, valid, _data$updateImages2, _data$articleData3, _data$articleData4, _data$articleData5, promiseArray;
887
860
 
888
- return _regenerator.default.wrap(function _callee8$(_context8) {
861
+ return _regenerator.default.wrap(function _callee7$(_context7) {
889
862
  while (1) {
890
- switch (_context8.prev = _context8.next) {
863
+ switch (_context7.prev = _context7.next) {
891
864
  case 0:
892
865
  imagesList = images === null || images === void 0 ? void 0 : (_images$values2 = images.values) === null || _images$values2 === void 0 ? void 0 : _images$values2.slice();
893
866
  imagesListTemp = imagesList === null || imagesList === void 0 ? void 0 : imagesList.reduce(function (acc, image) {
@@ -936,19 +909,19 @@ var ProviderProductEdition = function ProviderProductEdition(_ref) {
936
909
  }
937
910
 
938
911
  if (!(valid && (duplicated === null || duplicated === void 0 ? void 0 : duplicated.length) === 0)) {
939
- _context8.next = 31;
912
+ _context7.next = 31;
940
913
  break;
941
914
  }
942
915
 
943
916
  setLoading(true);
944
- _context8.prev = 11;
917
+ _context7.prev = 11;
945
918
  data === null || data === void 0 ? void 0 : (_data$articleData3 = data.articleData) === null || _data$articleData3 === void 0 ? void 0 : _data$articleData3.forEach(function (e) {
946
919
  e.uuid = (0, _uuid.v4)();
947
920
  });
948
921
  setDataImages(data);
949
922
 
950
923
  if (!((data === null || data === void 0 ? void 0 : (_data$articleData4 = data.articleData) === null || _data$articleData4 === void 0 ? void 0 : _data$articleData4.length) > 0)) {
951
- _context8.next = 23;
924
+ _context7.next = 23;
952
925
  break;
953
926
  }
954
927
 
@@ -964,28 +937,28 @@ var ProviderProductEdition = function ProviderProductEdition(_ref) {
964
937
  };
965
938
  promiseArray.push(myBucket.putObject(params).promise());
966
939
  });
967
- _context8.next = 20;
940
+ _context7.next = 20;
968
941
  return Promise.all(promiseArray);
969
942
 
970
943
  case 20:
971
944
  setImagesUploaded(true);
972
- _context8.next = 24;
945
+ _context7.next = 24;
973
946
  break;
974
947
 
975
948
  case 23:
976
949
  setImagesUploaded(true);
977
950
 
978
951
  case 24:
979
- _context8.next = 29;
952
+ _context7.next = 29;
980
953
  break;
981
954
 
982
955
  case 26:
983
- _context8.prev = 26;
984
- _context8.t0 = _context8["catch"](11);
985
- console.log(_context8.t0); // setMainLoading(false);
956
+ _context7.prev = 26;
957
+ _context7.t0 = _context7["catch"](11);
958
+ console.log(_context7.t0); // setMainLoading(false);
986
959
 
987
960
  case 29:
988
- _context8.next = 32;
961
+ _context7.next = 32;
989
962
  break;
990
963
 
991
964
  case 31:
@@ -994,18 +967,20 @@ var ProviderProductEdition = function ProviderProductEdition(_ref) {
994
967
 
995
968
  case 32:
996
969
  case "end":
997
- return _context8.stop();
970
+ return _context7.stop();
998
971
  }
999
972
  }
1000
- }, _callee8, null, [[11, 26]]);
973
+ }, _callee7, null, [[11, 26]]);
1001
974
  })), [images, imagesUploaded]);
1002
- (0, _react.useEffect)( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee9() {
1003
- return _regenerator.default.wrap(function _callee9$(_context9) {
975
+ (0, _react.useEffect)( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee8() {
976
+ var _res2;
977
+
978
+ return _regenerator.default.wrap(function _callee8$(_context8) {
1004
979
  while (1) {
1005
- switch (_context9.prev = _context9.next) {
980
+ switch (_context8.prev = _context8.next) {
1006
981
  case 0:
1007
982
  if (!imagesUploaded) {
1008
- _context9.next = 13;
983
+ _context8.next = 16;
1009
984
  break;
1010
985
  }
1011
986
 
@@ -1017,8 +992,8 @@ var ProviderProductEdition = function ProviderProductEdition(_ref) {
1017
992
  if (product !== null && product !== void 0 && product.orderId) e["orderId"] = product === null || product === void 0 ? void 0 : product.orderId;
1018
993
  return e;
1019
994
  });
1020
- _context9.prev = 2;
1021
- _context9.next = 5;
995
+ _context8.prev = 2;
996
+ _context8.next = 5;
1022
997
  return _axios.default.put("".concat(process.env.REACT_APP_ARTICLE_DATA_ENDPOINT, "?image=true&version=").concat(version), dataImages, {
1023
998
  headers: {
1024
999
  Authorization: token
@@ -1026,23 +1001,33 @@ var ProviderProductEdition = function ProviderProductEdition(_ref) {
1026
1001
  });
1027
1002
 
1028
1003
  case 5:
1004
+ _res2 = _context8.sent;
1005
+
1006
+ if (!(_res2.data.statusCode === 200)) {
1007
+ _context8.next = 11;
1008
+ break;
1009
+ }
1010
+
1029
1011
  setMessage("Imágenes guardadas con éxito");
1030
1012
  sessionStorage.removeItem("imagesList");
1031
- loadData();
1032
- _context9.next = 13;
1033
- break;
1013
+ _context8.next = 11;
1014
+ return loadData();
1034
1015
 
1035
- case 10:
1036
- _context9.prev = 10;
1037
- _context9.t0 = _context9["catch"](2);
1038
- console.log(_context9.t0);
1016
+ case 11:
1017
+ _context8.next = 16;
1018
+ break;
1039
1019
 
1040
1020
  case 13:
1021
+ _context8.prev = 13;
1022
+ _context8.t0 = _context8["catch"](2);
1023
+ console.log(_context8.t0);
1024
+
1025
+ case 16:
1041
1026
  case "end":
1042
- return _context9.stop();
1027
+ return _context8.stop();
1043
1028
  }
1044
1029
  }
1045
- }, _callee9, null, [[2, 10]]);
1030
+ }, _callee8, null, [[2, 13]]);
1046
1031
  })), [dataImages, imagesUploaded]);
1047
1032
 
1048
1033
  var getConcept = function getConcept(tab) {
@@ -1078,28 +1063,28 @@ var ProviderProductEdition = function ProviderProductEdition(_ref) {
1078
1063
  };
1079
1064
 
1080
1065
  var createComment = /*#__PURE__*/function () {
1081
- var _ref11 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee10(e, body, tab) {
1066
+ var _ref10 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee9(e, body, tab) {
1082
1067
  var concept, data;
1083
- return _regenerator.default.wrap(function _callee10$(_context10) {
1068
+ return _regenerator.default.wrap(function _callee9$(_context9) {
1084
1069
  while (1) {
1085
- switch (_context10.prev = _context10.next) {
1070
+ switch (_context9.prev = _context9.next) {
1086
1071
  case 0:
1087
1072
  concept = "";
1088
- _context10.t0 = activeTab;
1089
- _context10.next = _context10.t0 === "Ficha técnica" ? 4 : _context10.t0 === "Imágenes" ? 6 : 8;
1073
+ _context9.t0 = activeTab;
1074
+ _context9.next = _context9.t0 === "Ficha técnica" ? 4 : _context9.t0 === "Imágenes" ? 6 : 8;
1090
1075
  break;
1091
1076
 
1092
1077
  case 4:
1093
1078
  concept = "datasheet";
1094
- return _context10.abrupt("break", 10);
1079
+ return _context9.abrupt("break", 10);
1095
1080
 
1096
1081
  case 6:
1097
1082
  concept = "images";
1098
- return _context10.abrupt("break", 10);
1083
+ return _context9.abrupt("break", 10);
1099
1084
 
1100
1085
  case 8:
1101
1086
  concept = "description";
1102
- return _context10.abrupt("break", 10);
1087
+ return _context9.abrupt("break", 10);
1103
1088
 
1104
1089
  case 10:
1105
1090
  data = {
@@ -1109,7 +1094,7 @@ var ProviderProductEdition = function ProviderProductEdition(_ref) {
1109
1094
  concept: concept,
1110
1095
  version: version
1111
1096
  };
1112
- _context10.next = 13;
1097
+ _context9.next = 13;
1113
1098
  return _axios.default.post("".concat(process.env.REACT_APP_COMMENTS_ENDPOINT), data, {
1114
1099
  headers: {
1115
1100
  Authorization: token
@@ -1118,14 +1103,14 @@ var ProviderProductEdition = function ProviderProductEdition(_ref) {
1118
1103
 
1119
1104
  case 13:
1120
1105
  case "end":
1121
- return _context10.stop();
1106
+ return _context9.stop();
1122
1107
  }
1123
1108
  }
1124
- }, _callee10);
1109
+ }, _callee9);
1125
1110
  }));
1126
1111
 
1127
1112
  return function createComment(_x2, _x3, _x4) {
1128
- return _ref11.apply(this, arguments);
1113
+ return _ref10.apply(this, arguments);
1129
1114
  };
1130
1115
  }();
1131
1116
 
@@ -1134,16 +1119,16 @@ var ProviderProductEdition = function ProviderProductEdition(_ref) {
1134
1119
  }, [activeTab]);
1135
1120
 
1136
1121
  var commentRevised = /*#__PURE__*/function () {
1137
- var _ref12 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee11() {
1122
+ var _ref11 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee10() {
1138
1123
  var data;
1139
- return _regenerator.default.wrap(function _callee11$(_context11) {
1124
+ return _regenerator.default.wrap(function _callee10$(_context10) {
1140
1125
  while (1) {
1141
- switch (_context11.prev = _context11.next) {
1126
+ switch (_context10.prev = _context10.next) {
1142
1127
  case 0:
1143
1128
  data = {
1144
1129
  commentId: comment.id
1145
1130
  };
1146
- _context11.next = 3;
1131
+ _context10.next = 3;
1147
1132
  return _axios.default.put("".concat(process.env.REACT_APP_COMMENTS_ENDPOINT), data, {
1148
1133
  headers: {
1149
1134
  Authorization: token
@@ -1155,52 +1140,54 @@ var ProviderProductEdition = function ProviderProductEdition(_ref) {
1155
1140
 
1156
1141
  case 4:
1157
1142
  case "end":
1158
- return _context11.stop();
1143
+ return _context10.stop();
1159
1144
  }
1160
1145
  }
1161
- }, _callee11);
1146
+ }, _callee10);
1162
1147
  }));
1163
1148
 
1164
1149
  return function commentRevised() {
1165
- return _ref12.apply(this, arguments);
1150
+ return _ref11.apply(this, arguments);
1166
1151
  };
1167
1152
  }();
1168
1153
 
1169
1154
  var setAssignation = /*#__PURE__*/function () {
1170
- var _ref13 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee12(assignationType, assignationId) {
1155
+ var _ref12 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee11(assignationType, assignationId) {
1171
1156
  var concept, productTemp, data;
1172
- return _regenerator.default.wrap(function _callee12$(_context12) {
1157
+ return _regenerator.default.wrap(function _callee11$(_context11) {
1173
1158
  while (1) {
1174
- switch (_context12.prev = _context12.next) {
1159
+ switch (_context11.prev = _context11.next) {
1175
1160
  case 0:
1176
1161
  concept = "";
1177
- _context12.t0 = activeTab;
1178
- _context12.next = _context12.t0 === "Ficha técnica" ? 4 : _context12.t0 === "Imágenes" ? 6 : 8;
1162
+ _context11.t0 = activeTab;
1163
+ _context11.next = _context11.t0 === "Ficha técnica" ? 4 : _context11.t0 === "Imágenes" ? 6 : 8;
1179
1164
  break;
1180
1165
 
1181
1166
  case 4:
1182
1167
  concept = "datasheet";
1183
- return _context12.abrupt("break", 10);
1168
+ return _context11.abrupt("break", 10);
1184
1169
 
1185
1170
  case 6:
1186
1171
  concept = "images";
1187
- return _context12.abrupt("break", 10);
1172
+ return _context11.abrupt("break", 10);
1188
1173
 
1189
1174
  case 8:
1190
1175
  concept = "description";
1191
- return _context12.abrupt("break", 10);
1176
+ return _context11.abrupt("break", 10);
1192
1177
 
1193
1178
  case 10:
1194
1179
  productTemp = product;
1195
1180
  productTemp.article["id_".concat(concept, "_").concat(assignationType)] = assignationId;
1196
- data = (0, _defineProperty2.default)({
1181
+ data = {
1197
1182
  articleList: [{
1198
1183
  orderId: product.orderId,
1199
1184
  articleId: product === null || product === void 0 ? void 0 : product.id_article
1200
1185
  }],
1201
- concept: concept
1202
- }, "".concat(assignationType, "Id"), assignationId);
1203
- (0, _axios.default)({
1186
+ concept: concept,
1187
+ userId: assignationId
1188
+ };
1189
+ _context11.next = 15;
1190
+ return (0, _axios.default)({
1204
1191
  method: "post",
1205
1192
  url: process.env.REACT_APP_ASSIGNATIONS_ENDPOINT,
1206
1193
  data: data,
@@ -1208,19 +1195,21 @@ var ProviderProductEdition = function ProviderProductEdition(_ref) {
1208
1195
  Authorization: token
1209
1196
  }
1210
1197
  });
1198
+
1199
+ case 15:
1211
1200
  loadAssignations(productTemp);
1212
1201
  sessionStorage.setItem("productSelected", JSON.stringify(productTemp));
1213
1202
 
1214
- case 16:
1203
+ case 17:
1215
1204
  case "end":
1216
- return _context12.stop();
1205
+ return _context11.stop();
1217
1206
  }
1218
1207
  }
1219
- }, _callee12);
1208
+ }, _callee11);
1220
1209
  }));
1221
1210
 
1222
1211
  return function setAssignation(_x5, _x6) {
1223
- return _ref13.apply(this, arguments);
1212
+ return _ref12.apply(this, arguments);
1224
1213
  };
1225
1214
  }();
1226
1215
 
@@ -1236,7 +1225,7 @@ var ProviderProductEdition = function ProviderProductEdition(_ref) {
1236
1225
  });
1237
1226
  }
1238
1227
 
1239
- var statusArray = user.is_retailer === 1 ? ["AC", "RC"] : ["AP", "RP", "AC"];
1228
+ var statusArray = user.is_retailer === 1 ? ["ACA", "RCA"] : ["AP", "RP", "ACA"];
1240
1229
  return serv.length > 0 && serv.every(function (item) {
1241
1230
  return statusArray.includes(item.status);
1242
1231
  });
@@ -1325,7 +1314,7 @@ var ProviderProductEdition = function ProviderProductEdition(_ref) {
1325
1314
  var datasheet_status = product.datasheet_status,
1326
1315
  description_status = product.description_status,
1327
1316
  images_status = product.images_status;
1328
- var completionStates = user.is_retailer === 1 ? ["AC", "Evaluated", "NS"] : ["AP", "Evaluated", "NS"];
1317
+ var completionStates = user.is_retailer === 1 ? ["ACA", "Evaluated", "NS"] : ["AP", "Evaluated", "NS"];
1329
1318
  var dsEvaluated = completionStates.includes(datasheet_status);
1330
1319
  var descsEvaluated = completionStates.includes(description_status);
1331
1320
  var imgsEvaluated = completionStates.includes(images_status);
@@ -1334,144 +1323,169 @@ var ProviderProductEdition = function ProviderProductEdition(_ref) {
1334
1323
  };
1335
1324
 
1336
1325
  var sendEvaluation = /*#__PURE__*/function () {
1337
- var _ref14 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee13(result) {
1338
- var data, retailerId, _product$id_order2, _product$id_order3, productTemp, concept;
1326
+ var _ref13 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee12(result) {
1327
+ var _productTemp$id_order;
1339
1328
 
1340
- return _regenerator.default.wrap(function _callee13$(_context13) {
1329
+ var concept, productTemp, articleId, orderId, sectionStatusKey, evalStatus, data, retailerId, res, newStatuses, orderStatus, serviceStatus, newProductEdit, _JSON$parse, newArticleStatus, newServiceStatus, newStatus, retailerStatusCopy, status;
1330
+
1331
+ return _regenerator.default.wrap(function _callee12$(_context12) {
1341
1332
  while (1) {
1342
- switch (_context13.prev = _context13.next) {
1333
+ switch (_context12.prev = _context12.next) {
1343
1334
  case 0:
1344
1335
  setLoading(true);
1345
- data = {};
1336
+ concept = getConcept(activeTab);
1337
+ productTemp = product;
1338
+ articleId = productTemp.id_article;
1339
+ orderId = (_productTemp$id_order = productTemp.id_order) !== null && _productTemp$id_order !== void 0 ? _productTemp$id_order : productTemp.orderId;
1340
+ sectionStatusKey = "".concat(getConcept(activeTab), "_status");
1341
+ evalStatus = product[sectionStatusKey] || (product === null || product === void 0 ? void 0 : product.version_status);
1342
+ data = {
1343
+ articleId: articleId,
1344
+ orderId: orderId,
1345
+ concept: concept,
1346
+ evalStatus: evalStatus
1347
+ };
1346
1348
  retailerId = activeRetailer === null || activeRetailer === void 0 ? void 0 : activeRetailer.id;
1349
+ _context12.prev = 9;
1347
1350
 
1348
1351
  if (!result) {
1349
- _context13.next = 9;
1352
+ _context12.next = 25;
1350
1353
  break;
1351
1354
  }
1352
1355
 
1353
- data = {
1354
- articleId: product.id_article,
1355
- orderId: (_product$id_order2 = product.id_order) !== null && _product$id_order2 !== void 0 ? _product$id_order2 : product.orderId,
1356
- concept: getConcept(activeTab),
1357
- result: result,
1358
- retailerId: retailerId
1359
- };
1360
- _context13.next = 7;
1356
+ data.result = result;
1357
+ data.retailerId = retailerId;
1358
+ _context12.next = 15;
1361
1359
  return _axios.default.put("".concat(process.env.REACT_APP_EVALUATION_ENDPOINT), data, {
1362
1360
  headers: {
1363
1361
  Authorization: token
1364
1362
  }
1365
1363
  });
1366
1364
 
1367
- case 7:
1368
- _context13.next = 19;
1365
+ case 15:
1366
+ res = _context12.sent;
1367
+ newStatuses = JSON.parse(res.data.body);
1368
+ orderStatus = newStatuses.newOrderStatus;
1369
+ serviceStatus = newStatuses.newServiceStatus[articleId]["".concat(getConcept(activeTab), "Status")];
1370
+ newProductEdit = productEdit;
1371
+ newProductEdit.product[sectionStatusKey] = serviceStatus;
1372
+ setProductEdit(newProductEdit);
1373
+ showSurvey && showSurvey(!user.is_retailer && orderStatus[orderId] === "AP");
1374
+ _context12.next = 28;
1369
1375
  break;
1370
1376
 
1371
- case 9:
1372
- productTemp = product;
1373
- concept = getConcept(activeTab);
1374
- productTemp["".concat(concept, "_status")] = "Evaluated";
1375
- data = {
1376
- articleId: product.id_article,
1377
- orderId: (_product$id_order3 = product.id_order) !== null && _product$id_order3 !== void 0 ? _product$id_order3 : product.orderId,
1378
- concept: concept
1379
- };
1380
-
1381
- _axios.default.put("".concat(process.env.REACT_APP_SEND_EVAL), data, {
1377
+ case 25:
1378
+ _context12.next = 27;
1379
+ return _axios.default.put("".concat(process.env.REACT_APP_SEND_EVAL), data, {
1382
1380
  headers: {
1383
1381
  Authorization: token
1384
1382
  }
1385
1383
  });
1386
1384
 
1387
- setProduct(productTemp);
1388
- sessionStorage.setItem("productSelected", JSON.stringify(productTemp));
1389
- setProductEdit({
1390
- ArticleId: productTemp.id_article,
1391
- idCategory: productTemp.article.id_category,
1392
- product: productTemp
1393
- });
1394
- sessionStorage.setItem("productEdit", JSON.stringify({
1395
- ArticleId: productTemp.id_article,
1396
- idCategory: productTemp.article.id_category,
1397
- product: productTemp
1398
- }));
1399
- setOrigin(function (prev) {
1400
- return (0, _objectSpread3.default)((0, _objectSpread3.default)({}, prev), {}, (0, _defineProperty2.default)({}, concept, "Evaluated"));
1401
- });
1385
+ case 27:
1386
+ res = _context12.sent;
1387
+
1388
+ case 28:
1389
+ if (res.data.statusCode === 200) {
1390
+ _JSON$parse = JSON.parse(res.data.body), newArticleStatus = _JSON$parse.newArticleStatus, newServiceStatus = _JSON$parse.newServiceStatus, newStatus = _JSON$parse.newStatus;
1391
+ if (newArticleStatus) productTemp.status = newArticleStatus[articleId];
1392
+ retailerStatusCopy = (0, _objectSpread3.default)({}, retailerStatus);
1393
+ retailerStatusCopy[activeRetailer.id][concept] = newStatus;
1394
+ setRetailerStatus(retailerStatusCopy);
1395
+ productTemp.statusByRetailer = retailerStatusCopy;
1396
+
1397
+ if (newServiceStatus) {
1398
+ status = newServiceStatus[articleId]["".concat(concept, "Status")];
1399
+ productTemp["".concat(concept, "_status")] = status;
1400
+ }
1401
+
1402
+ setProduct(productTemp);
1403
+ sessionStorage.setItem("productSelected", JSON.stringify(productTemp));
1404
+ setOrigin(function (prev) {
1405
+ return (0, _objectSpread3.default)((0, _objectSpread3.default)({}, prev), {}, (0, _defineProperty2.default)({}, concept, status));
1406
+ });
1407
+ }
1408
+
1409
+ _context12.next = 34;
1410
+ break;
1411
+
1412
+ case 31:
1413
+ _context12.prev = 31;
1414
+ _context12.t0 = _context12["catch"](9);
1415
+ console.log(_context12.t0);
1402
1416
 
1403
- case 19:
1417
+ case 34:
1404
1418
  loadData();
1405
- showSurvey && showSurvey(confirmStatusComplete());
1406
1419
 
1407
- case 21:
1420
+ case 35:
1408
1421
  case "end":
1409
- return _context13.stop();
1422
+ return _context12.stop();
1410
1423
  }
1411
1424
  }
1412
- }, _callee13);
1425
+ }, _callee12, null, [[9, 31]]);
1413
1426
  }));
1414
1427
 
1415
1428
  return function sendEvaluation(_x7) {
1416
- return _ref14.apply(this, arguments);
1429
+ return _ref13.apply(this, arguments);
1417
1430
  };
1418
1431
  }();
1419
1432
 
1420
1433
  var validateAll = /*#__PURE__*/function () {
1421
- var _ref15 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee14(result) {
1422
- var evaluationArray, sendAll, conceptArray, productTemp;
1423
- return _regenerator.default.wrap(function _callee14$(_context14) {
1434
+ var _ref14 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee13(result) {
1435
+ var _product$id_order2, evaluationArray, sendAll, conceptArray, dataGeneral, productTemp, retailerStatusCopy;
1436
+
1437
+ return _regenerator.default.wrap(function _callee13$(_context13) {
1424
1438
  while (1) {
1425
- switch (_context14.prev = _context14.next) {
1439
+ switch (_context13.prev = _context13.next) {
1426
1440
  case 0:
1427
- _context14.prev = 0;
1441
+ _context13.prev = 0;
1428
1442
  setLoading(true);
1429
1443
  evaluationArray = [];
1430
1444
  sendAll = [];
1431
1445
  conceptArray = ["description", "datasheet", "images"];
1446
+ dataGeneral = {
1447
+ articleId: product.id_article,
1448
+ orderId: (_product$id_order2 = product.id_order) !== null && _product$id_order2 !== void 0 ? _product$id_order2 : product.orderId,
1449
+ result: result
1450
+ };
1432
1451
  servicesData === null || servicesData === void 0 ? void 0 : servicesData.forEach(function (ret) {
1433
- var _product$id_order4;
1434
-
1435
- var data = {
1436
- articleId: product.id_article,
1437
- orderId: (_product$id_order4 = product.id_order) !== null && _product$id_order4 !== void 0 ? _product$id_order4 : product.orderId,
1438
- concept: ret.service,
1439
- result: result,
1440
- retailerId: ret.id_retailer
1441
- };
1452
+ var service = ret.service,
1453
+ id_retailer = ret.id_retailer;
1454
+ var data = (0, _objectSpread3.default)((0, _objectSpread3.default)({}, dataGeneral), {}, {
1455
+ concept: service,
1456
+ retailerId: id_retailer,
1457
+ evalStatus: retailerStatus[id_retailer][service]
1458
+ });
1442
1459
  evaluationArray.push(_axios.default.put("".concat(process.env.REACT_APP_EVALUATION_ENDPOINT), data, {
1443
1460
  headers: {
1444
1461
  Authorization: token
1445
1462
  }
1446
1463
  }));
1447
- });
1448
- _context14.next = 8;
1449
- return Promise.all(evaluationArray);
1450
-
1451
- case 8:
1452
- conceptArray === null || conceptArray === void 0 ? void 0 : conceptArray.forEach(function (concept) {
1453
- var _product$id_order5;
1454
-
1455
- var data = {
1456
- articleId: product.id_article,
1457
- orderId: (_product$id_order5 = product.id_order) !== null && _product$id_order5 !== void 0 ? _product$id_order5 : product.orderId,
1458
- concept: concept
1459
- };
1460
1464
  sendAll.push(_axios.default.put("".concat(process.env.REACT_APP_SEND_EVAL), data, {
1461
1465
  headers: {
1462
1466
  Authorization: token
1463
1467
  }
1464
1468
  }));
1465
1469
  });
1466
- _context14.next = 11;
1467
- return Promise.all(sendAll);
1470
+ _context13.next = 9;
1471
+ return Promise.all([].concat(evaluationArray, sendAll));
1468
1472
 
1469
- case 11:
1473
+ case 9:
1470
1474
  productTemp = product;
1471
- productTemp.article_status = "".concat(result, "C");
1472
- productTemp.datasheet_status = productTemp.datasheet_status === "NA" ? "NA" : "".concat(result, "C");
1473
- productTemp.description_status = productTemp.description_status === "NA" ? "NA" : "".concat(result, "C");
1474
- productTemp.images_status = productTemp.images_status === "NA" ? "NA" : "".concat(result, "C");
1475
+ productTemp.article_status = "".concat(result, "CA");
1476
+ productTemp.datasheet_status = productTemp.datasheet_status === "NA" ? "NA" : "".concat(result, "CA");
1477
+ productTemp.description_status = productTemp.description_status === "NA" ? "NA" : "".concat(result, "CA");
1478
+ productTemp.images_status = productTemp.images_status === "NA" ? "NA" : "".concat(result, "CA");
1479
+ retailerStatusCopy = (0, _objectSpread3.default)({}, retailerStatus);
1480
+ Object.keys(retailerStatusCopy).forEach(function (key) {
1481
+ conceptArray.forEach(function (concept) {
1482
+ if (retailerStatusCopy[key][concept]) {
1483
+ retailerStatusCopy[key][concept] = "".concat(result, "CA");
1484
+ }
1485
+ });
1486
+ });
1487
+ setRetailerStatus(retailerStatusCopy);
1488
+ productTemp.statusByRetailer = retailerStatusCopy;
1475
1489
  setProduct(productTemp);
1476
1490
  sessionStorage.setItem("productSelected", JSON.stringify(productTemp));
1477
1491
  setProductEdit({
@@ -1484,34 +1498,37 @@ var ProviderProductEdition = function ProviderProductEdition(_ref) {
1484
1498
  idCategory: productTemp.article.id_category,
1485
1499
  product: productTemp
1486
1500
  }));
1487
- loadData();
1488
- _context14.next = 26;
1489
- break;
1501
+ _context13.next = 24;
1502
+ return loadData();
1490
1503
 
1491
- case 23:
1492
- _context14.prev = 23;
1493
- _context14.t0 = _context14["catch"](0);
1494
- console.log(_context14.t0);
1504
+ case 24:
1505
+ _context13.next = 29;
1506
+ break;
1495
1507
 
1496
1508
  case 26:
1509
+ _context13.prev = 26;
1510
+ _context13.t0 = _context13["catch"](0);
1511
+ console.log(_context13.t0);
1512
+
1513
+ case 29:
1497
1514
  case "end":
1498
- return _context14.stop();
1515
+ return _context13.stop();
1499
1516
  }
1500
1517
  }
1501
- }, _callee14, null, [[0, 23]]);
1518
+ }, _callee13, null, [[0, 26]]);
1502
1519
  }));
1503
1520
 
1504
1521
  return function validateAll(_x8) {
1505
- return _ref15.apply(this, arguments);
1522
+ return _ref14.apply(this, arguments);
1506
1523
  };
1507
1524
  }();
1508
1525
 
1509
1526
  var evaluationToRetailer = /*#__PURE__*/function () {
1510
- var _ref16 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee15(result) {
1527
+ var _ref15 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee14(result) {
1511
1528
  var data, prod, statusComplete;
1512
- return _regenerator.default.wrap(function _callee15$(_context15) {
1529
+ return _regenerator.default.wrap(function _callee14$(_context14) {
1513
1530
  while (1) {
1514
- switch (_context15.prev = _context15.next) {
1531
+ switch (_context14.prev = _context14.next) {
1515
1532
  case 0:
1516
1533
  data = {
1517
1534
  articleId: product.id_article,
@@ -1519,7 +1536,7 @@ var ProviderProductEdition = function ProviderProductEdition(_ref) {
1519
1536
  versionId: product.version,
1520
1537
  status: result
1521
1538
  };
1522
- _context15.next = 3;
1539
+ _context14.next = 3;
1523
1540
  return _axios.default.put("".concat(process.env.REACT_APP_RETAILER_REQUEST), data, {
1524
1541
  headers: {
1525
1542
  Authorization: token
@@ -1528,7 +1545,7 @@ var ProviderProductEdition = function ProviderProductEdition(_ref) {
1528
1545
 
1529
1546
  case 3:
1530
1547
  prod = productEdit;
1531
- statusComplete = user.is_retailer ? "".concat(result, "C") : "".concat(result, "P");
1548
+ statusComplete = user.is_retailer ? "".concat(result, "CA") : "".concat(result, "P");
1532
1549
  prod.product.datasheet_status = statusComplete;
1533
1550
  prod.product.description_status = statusComplete;
1534
1551
  prod.product.images_status = statusComplete;
@@ -1537,33 +1554,33 @@ var ProviderProductEdition = function ProviderProductEdition(_ref) {
1537
1554
  sessionStorage.setItem("productEdit", JSON.stringify(prod));
1538
1555
  setProduct(prod);
1539
1556
  setShowGenericModal && setShowGenericModal(false);
1540
- loadData();
1557
+ _context14.next = 15;
1558
+ return loadData();
1541
1559
 
1542
- case 14:
1560
+ case 15:
1543
1561
  case "end":
1544
- return _context15.stop();
1562
+ return _context14.stop();
1545
1563
  }
1546
1564
  }
1547
- }, _callee15);
1565
+ }, _callee14);
1548
1566
  }));
1549
1567
 
1550
1568
  return function evaluationToRetailer(_x9) {
1551
- return _ref16.apply(this, arguments);
1569
+ return _ref15.apply(this, arguments);
1552
1570
  };
1553
1571
  }();
1554
1572
 
1555
1573
  var getSectionStatus = function getSectionStatus() {
1556
1574
  var concept = getConcept(activeTab);
1557
- return ["AA", "AP", "RECEIVED", "IN_PROGRESS", "RC"].includes(productEdit.product["".concat(concept, "_status")]);
1575
+ return ["AA", "AP", "R", "CA", "RCA"].includes(productEdit.product["".concat(concept, "_status")]);
1558
1576
  };
1559
1577
 
1560
1578
  var enableActions = function enableActions(versionStatus) {
1561
1579
  try {
1562
- var userIsRetailer = user.is_retailer;
1563
- if (userIsRetailer) return false;
1580
+ if (user.is_retailer) return false;
1564
1581
 
1565
1582
  if (versionStatus) {
1566
- return ["AP", "AC", "RC", null].includes(versionStatus);
1583
+ return ["AP", "ACA", "RCA", null].includes(versionStatus);
1567
1584
  }
1568
1585
 
1569
1586
  return true;
@@ -1644,53 +1661,49 @@ var ProviderProductEdition = function ProviderProductEdition(_ref) {
1644
1661
  });
1645
1662
  });
1646
1663
  setShowGenericModal(true);
1647
- } else {
1648
- if (user.is_retailer) {
1649
- if (product.id_order || product.orderId) {
1650
- validateAll("A");
1651
- } else {
1652
- setDataGenericModal(function (prev) {
1653
- return (0, _objectSpread3.default)((0, _objectSpread3.default)({}, prev), {}, {
1654
- button2: {
1655
- name: "Continuar",
1656
- action: function action() {
1657
- return evaluationToRetailer("A");
1658
- }
1664
+ } else if (user.is_retailer) {
1665
+ if (product.id_order || product.orderId) {
1666
+ validateAll("A");
1667
+ } else {
1668
+ setDataGenericModal(function (prev) {
1669
+ return (0, _objectSpread3.default)((0, _objectSpread3.default)({}, prev), {}, {
1670
+ button2: {
1671
+ name: "Continuar",
1672
+ action: function action() {
1673
+ return evaluationToRetailer("A");
1659
1674
  }
1660
- });
1675
+ }
1661
1676
  });
1662
- setShowGenericModal(true);
1663
- }
1664
- } else {
1665
- validateAll("A");
1677
+ });
1678
+ setShowGenericModal(true);
1666
1679
  }
1680
+ } else {
1681
+ validateAll("A");
1667
1682
  }
1668
1683
  },
1669
1684
  rejectAll: function rejectAll() {
1670
1685
  if (originProp === "RequestWithoutContentoh" && !user.is_retailer && (!product.id_order || !product.orderId)) {
1671
1686
  return;
1672
- } else {
1673
- if (user.is_retailer) {
1674
- if (product.id_order || product.orderId) {
1675
- validateAll("R");
1676
- setModalViewError(true);
1677
- } else {
1678
- setDataGenericModal(function (prev) {
1679
- return (0, _objectSpread3.default)((0, _objectSpread3.default)({}, prev), {}, {
1680
- button2: {
1681
- name: "Continuar",
1682
- action: function action() {
1683
- return evaluationToRetailer("R");
1684
- }
1685
- }
1686
- });
1687
- });
1688
- setShowGenericModal(true);
1689
- }
1690
- } else {
1687
+ } else if (user.is_retailer) {
1688
+ if (product.id_order || product.orderId) {
1691
1689
  validateAll("R");
1692
1690
  setModalViewError(true);
1691
+ } else {
1692
+ setDataGenericModal(function (prev) {
1693
+ return (0, _objectSpread3.default)((0, _objectSpread3.default)({}, prev), {}, {
1694
+ button2: {
1695
+ name: "Continuar",
1696
+ action: function action() {
1697
+ return evaluationToRetailer("R");
1698
+ }
1699
+ }
1700
+ });
1701
+ });
1702
+ setShowGenericModal(true);
1693
1703
  }
1704
+ } else {
1705
+ validateAll("R");
1706
+ setModalViewError(true);
1694
1707
  }
1695
1708
  },
1696
1709
  approve: function approve() {
@@ -1706,58 +1719,54 @@ var ProviderProductEdition = function ProviderProductEdition(_ref) {
1706
1719
  });
1707
1720
  });
1708
1721
  setShowGenericModal(true);
1709
- } else {
1710
- if (user.is_retailer) {
1711
- if (product.id_order || product.orderId) {
1712
- sendEvaluation("A");
1713
- } else {
1714
- setDataGenericModal(function (prev) {
1715
- return (0, _objectSpread3.default)((0, _objectSpread3.default)({}, prev), {}, {
1716
- button2: {
1717
- name: "Continuar",
1718
- action: function action() {
1719
- return evaluationToRetailer("A");
1720
- }
1722
+ } else if (user.is_retailer) {
1723
+ if (product.id_order || product.orderId) {
1724
+ sendEvaluation("A");
1725
+ } else {
1726
+ setDataGenericModal(function (prev) {
1727
+ return (0, _objectSpread3.default)((0, _objectSpread3.default)({}, prev), {}, {
1728
+ button2: {
1729
+ name: "Continuar",
1730
+ action: function action() {
1731
+ return evaluationToRetailer("A");
1721
1732
  }
1722
- });
1733
+ }
1723
1734
  });
1724
- setShowGenericModal(true);
1725
- }
1726
- } else {
1727
- sendEvaluation("A");
1735
+ });
1736
+ setShowGenericModal(true);
1728
1737
  }
1738
+ } else {
1739
+ sendEvaluation("A");
1729
1740
  }
1730
1741
  },
1731
1742
  reject: function reject() {
1732
1743
  if (origin[activeTab] === "RequestWithoutContentoh" && !user.is_retailer && (!product.id_order || !product.orderId)) {
1733
1744
  return;
1734
- } else {
1735
- if (user.is_retailer) {
1736
- if (product.id_order || product.orderId) {
1737
- sendEvaluation("R");
1738
- setModalViewError(true);
1739
- } else {
1740
- setDataGenericModal(function (prev) {
1741
- return (0, _objectSpread3.default)((0, _objectSpread3.default)({}, prev), {}, {
1742
- button2: {
1743
- name: "Continuar",
1744
- action: function action() {
1745
- return evaluationToRetailer("R");
1746
- }
1747
- }
1748
- });
1749
- });
1750
- setShowGenericModal(true);
1751
- }
1752
- } else {
1745
+ } else if (user.is_retailer) {
1746
+ if (product.id_order || product.orderId) {
1753
1747
  sendEvaluation("R");
1754
1748
  setModalViewError(true);
1749
+ } else {
1750
+ setDataGenericModal(function (prev) {
1751
+ return (0, _objectSpread3.default)((0, _objectSpread3.default)({}, prev), {}, {
1752
+ button2: {
1753
+ name: "Continuar",
1754
+ action: function action() {
1755
+ return evaluationToRetailer("R");
1756
+ }
1757
+ }
1758
+ });
1759
+ });
1760
+ setShowGenericModal(true);
1755
1761
  }
1762
+ } else {
1763
+ sendEvaluation("R");
1764
+ setModalViewError(true);
1756
1765
  }
1757
1766
  }
1758
1767
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_FullTabsMenu.FullTabsMenu, {
1759
1768
  tabsSections: tabsSections,
1760
- status: product["".concat(getConcept(activeTab), "_status")] || (product === null || product === void 0 ? void 0 : product.version_status),
1769
+ status: activeRetailer.id ? retailerStatus[activeRetailer === null || activeRetailer === void 0 ? void 0 : activeRetailer.id][getConcept(activeTab)] || "NS" : "-",
1761
1770
  activeTab: activeTab,
1762
1771
  setActiveTab: setActiveTab,
1763
1772
  setImageLayout: setImageLayout,
@@ -1833,9 +1842,9 @@ var ProviderProductEdition = function ProviderProductEdition(_ref) {
1833
1842
  headerType: "input-name-header"
1834
1843
  }))]
1835
1844
  })
1836
- }), isRevision() && getSectionStatus() ? /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
1845
+ }), isRevision() && getSectionStatus() ? /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
1837
1846
  className: "commentary-box",
1838
- children: [!comment ? /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
1847
+ children: !comment ? /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
1839
1848
  className: "commentary",
1840
1849
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_index.TagAndInput, {
1841
1850
  label: "Caja de Comentario",
@@ -1861,32 +1870,24 @@ var ProviderProductEdition = function ProviderProductEdition(_ref) {
1861
1870
  reviewed: crossComment
1862
1871
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_GeneralButton.Button, {
1863
1872
  buttonType: "circular-button accept-button",
1864
- onClick: /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee16() {
1865
- return _regenerator.default.wrap(function _callee16$(_context16) {
1873
+ onClick: /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee15() {
1874
+ return _regenerator.default.wrap(function _callee15$(_context15) {
1866
1875
  while (1) {
1867
- switch (_context16.prev = _context16.next) {
1876
+ switch (_context15.prev = _context15.next) {
1868
1877
  case 0:
1869
1878
  setCrossComment(true);
1870
1879
  commentRevised();
1871
1880
 
1872
1881
  case 2:
1873
1882
  case "end":
1874
- return _context16.stop();
1883
+ return _context15.stop();
1875
1884
  }
1876
1885
  }
1877
- }, _callee16);
1886
+ }, _callee15);
1878
1887
  }))
1879
1888
  })]
1880
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_GeneralButton.Button, {
1881
- buttonType: evaluationComplete(activeTab) && (productEdit.product.id_order || productEdit.product.orderId) ? "general-green-button" : "general-button-disabled",
1882
- label: "Enviar evaluación",
1883
- onClick: function onClick() {
1884
- //setModalSent(true);
1885
- sendEvaluation();
1886
- setMessage("\xA1Evaluaci\xF3n de ".concat(activeTab, " completada!"));
1887
- }
1888
- })]
1889
- }) : revision ? null : /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
1889
+ })
1890
+ }) : !revision && /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
1890
1891
  className: "required-inputs-message",
1891
1892
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
1892
1893
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)("p", {