contentoh-components-library 21.5.74 → 21.5.75
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/pages/RetailerProductEdition/context/provider-product-edition.context.js
CHANGED
|
@@ -35,6 +35,8 @@ var _errorModal = _interopRequireDefault(require("../../../../assets/images/gene
|
|
|
35
35
|
|
|
36
36
|
var _utils = require("../utils");
|
|
37
37
|
|
|
38
|
+
var _data = require("../../../../global-files/data");
|
|
39
|
+
|
|
38
40
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
39
41
|
|
|
40
42
|
var _excluded = ["src"],
|
|
@@ -372,7 +374,7 @@ var ProviderProductEditionProvider = function ProviderProductEditionProvider(_re
|
|
|
372
374
|
var _ref4 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(token) {
|
|
373
375
|
var _state$images_values, _state$product9, _state$product10, _state$product11, _data$articleData, _data$updateImages;
|
|
374
376
|
|
|
375
|
-
var updatedImages, attrForImgs, generalAttrs, retailerKey, retailerAttrs, mergedAttrs, data, valid, promiseArray, res, imageBody, newStatus, _state$product12, productFromLocalStorage, updatedProduct;
|
|
377
|
+
var updatedImages, attrForImgs, generalAttrs, retailerKey, retailerAttrs, mergedAttrs, data, valid, promiseArray, res, imageBody, newStatus, _state$product12, productFromLocalStorage, updatedProduct, _freshImages$values, _state$product13, id_article, version, _state$active_retaile5, category, id_category, id_retailer, imagesRes, freshImages, orderMap, orderedValues, filteredValues;
|
|
376
378
|
|
|
377
379
|
return _regenerator.default.wrap(function _callee3$(_context3) {
|
|
378
380
|
while (1) {
|
|
@@ -434,7 +436,7 @@ var ProviderProductEditionProvider = function ProviderProductEditionProvider(_re
|
|
|
434
436
|
});
|
|
435
437
|
|
|
436
438
|
if (!valid) {
|
|
437
|
-
_context3.next =
|
|
439
|
+
_context3.next = 61;
|
|
438
440
|
break;
|
|
439
441
|
}
|
|
440
442
|
|
|
@@ -493,64 +495,134 @@ var ProviderProductEditionProvider = function ProviderProductEditionProvider(_re
|
|
|
493
495
|
case 24:
|
|
494
496
|
res = _context3.sent;
|
|
495
497
|
|
|
496
|
-
if (res.data.statusCode === 200) {
|
|
497
|
-
|
|
498
|
+
if (!(res.data.statusCode === 200)) {
|
|
499
|
+
_context3.next = 49;
|
|
500
|
+
break;
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
// Limpiar las imágenes actualizadas
|
|
504
|
+
dispatch({
|
|
505
|
+
type: "SET_UPDATED_IMAGES_VALUES",
|
|
506
|
+
payload: []
|
|
507
|
+
});
|
|
508
|
+
imageBody = JSON.parse(res.data.body);
|
|
509
|
+
newStatus = imageBody === null || imageBody === void 0 ? void 0 : imageBody.newStatus;
|
|
510
|
+
|
|
511
|
+
if (newStatus) {
|
|
512
|
+
productFromLocalStorage = JSON.parse(sessionStorage.getItem("productSelected"));
|
|
513
|
+
updatedProduct = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, productFromLocalStorage || state.product), {}, {
|
|
514
|
+
images_status: newStatus,
|
|
515
|
+
statusByRetailer: ((productFromLocalStorage === null || productFromLocalStorage === void 0 ? void 0 : productFromLocalStorage.statusByRetailer) || ((_state$product12 = state.product) === null || _state$product12 === void 0 ? void 0 : _state$product12.statusByRetailer) || []).map(function (retailerStatus) {
|
|
516
|
+
return retailerStatus.service === "images" ? (0, _objectSpread2.default)((0, _objectSpread2.default)({}, retailerStatus), {}, {
|
|
517
|
+
status: newStatus
|
|
518
|
+
}) : retailerStatus;
|
|
519
|
+
})
|
|
520
|
+
});
|
|
521
|
+
sessionStorage.setItem("productSelected", JSON.stringify(updatedProduct));
|
|
498
522
|
dispatch({
|
|
499
|
-
type: "
|
|
500
|
-
payload:
|
|
523
|
+
type: "UPDATE_IMAGES_STATUS",
|
|
524
|
+
payload: newStatus
|
|
501
525
|
});
|
|
502
|
-
|
|
503
|
-
|
|
526
|
+
dispatch({
|
|
527
|
+
type: "SET_SERVICES_DATA",
|
|
528
|
+
payload: (state.services_data || []).map(function (srv) {
|
|
529
|
+
var _state$active_retaile4;
|
|
504
530
|
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
status: newStatus
|
|
512
|
-
}) : retailerStatus;
|
|
513
|
-
})
|
|
514
|
-
});
|
|
515
|
-
sessionStorage.setItem("productSelected", JSON.stringify(updatedProduct));
|
|
516
|
-
dispatch({
|
|
517
|
-
type: "UPDATE_IMAGES_STATUS",
|
|
518
|
-
payload: newStatus
|
|
519
|
-
});
|
|
520
|
-
dispatch({
|
|
521
|
-
type: "SET_SERVICES_DATA",
|
|
522
|
-
payload: (state.services_data || []).map(function (srv) {
|
|
523
|
-
var _state$active_retaile4;
|
|
531
|
+
return srv.service === "images" && srv.id_retailer === ((_state$active_retaile4 = state.active_retailer) === null || _state$active_retaile4 === void 0 ? void 0 : _state$active_retaile4.id_retailer) ? (0, _objectSpread2.default)((0, _objectSpread2.default)({}, srv), {}, {
|
|
532
|
+
status: newStatus
|
|
533
|
+
}) : srv;
|
|
534
|
+
})
|
|
535
|
+
});
|
|
536
|
+
} // Refrescar images_values con datos reales del backend
|
|
524
537
|
|
|
525
|
-
return srv.service === "images" && srv.id_retailer === ((_state$active_retaile4 = state.active_retailer) === null || _state$active_retaile4 === void 0 ? void 0 : _state$active_retaile4.id_retailer) ? (0, _objectSpread2.default)((0, _objectSpread2.default)({}, srv), {}, {
|
|
526
|
-
status: newStatus
|
|
527
|
-
}) : srv;
|
|
528
|
-
})
|
|
529
|
-
});
|
|
530
|
-
} // Mostrar modal de éxito
|
|
531
538
|
|
|
539
|
+
_context3.prev = 30;
|
|
540
|
+
_state$product13 = state.product, id_article = _state$product13.id_article, version = _state$product13.version;
|
|
541
|
+
_state$active_retaile5 = state.active_retailer, category = _state$active_retaile5.category, id_category = _state$active_retaile5.id_category, id_retailer = _state$active_retaile5.id_retailer;
|
|
542
|
+
_context3.next = 35;
|
|
543
|
+
return _axios.default.post("".concat(process.env.REACT_APP_ARTICLE_DATA_IMAGES_ENDPOINT, "?articleId=").concat(id_article, "&version=").concat(version), {
|
|
544
|
+
category: category,
|
|
545
|
+
retailersList: [id_retailer]
|
|
546
|
+
}, {
|
|
547
|
+
headers: {
|
|
548
|
+
Authorization: token
|
|
549
|
+
}
|
|
550
|
+
});
|
|
532
551
|
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
552
|
+
case 35:
|
|
553
|
+
imagesRes = _context3.sent;
|
|
554
|
+
freshImages = JSON.parse(imagesRes.data.body).data;
|
|
555
|
+
freshImages.values = freshImages === null || freshImages === void 0 ? void 0 : (_freshImages$values = freshImages.values) === null || _freshImages$values === void 0 ? void 0 : _freshImages$values.map(function (value) {
|
|
556
|
+
var _freshImages$inputs$f;
|
|
557
|
+
|
|
558
|
+
value.name = (_freshImages$inputs$f = freshImages.inputs.find(function (e) {
|
|
559
|
+
return e.id === value.image_id;
|
|
560
|
+
})) === null || _freshImages$inputs$f === void 0 ? void 0 : _freshImages$inputs$f.name;
|
|
561
|
+
return (0, _data.getImage)(value);
|
|
562
|
+
});
|
|
563
|
+
orderMap = freshImages.inputsByRetailer.flat().reduce(function (acc, item) {
|
|
564
|
+
acc[item.id_image] = item.order;
|
|
565
|
+
return acc;
|
|
566
|
+
}, {});
|
|
567
|
+
orderedValues = (0, _toConsumableArray2.default)(freshImages.values).sort(function (a, b) {
|
|
568
|
+
var _orderMap$a$image_id, _orderMap$b$image_id;
|
|
569
|
+
|
|
570
|
+
var orderA = (_orderMap$a$image_id = orderMap[a.image_id]) !== null && _orderMap$a$image_id !== void 0 ? _orderMap$a$image_id : Number.MAX_SAFE_INTEGER;
|
|
571
|
+
var orderB = (_orderMap$b$image_id = orderMap[b.image_id]) !== null && _orderMap$b$image_id !== void 0 ? _orderMap$b$image_id : Number.MAX_SAFE_INTEGER;
|
|
572
|
+
return orderA - orderB;
|
|
573
|
+
});
|
|
574
|
+
filteredValues = freshImages.values.filter(function (value) {
|
|
575
|
+
return freshImages.inputsByRetailer.some(function (retailerInput) {
|
|
576
|
+
return retailerInput.some(function (input) {
|
|
577
|
+
return input.id_retailer === id_retailer && input.id_image === value.image_id;
|
|
578
|
+
});
|
|
541
579
|
});
|
|
542
|
-
}
|
|
580
|
+
});
|
|
581
|
+
dispatch({
|
|
582
|
+
type: "SET_IMAGES_VALUES",
|
|
583
|
+
payload: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, freshImages), {}, {
|
|
584
|
+
values: filteredValues
|
|
585
|
+
})
|
|
586
|
+
});
|
|
587
|
+
dispatch({
|
|
588
|
+
type: "SET_SERVICES",
|
|
589
|
+
payload: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, state.services), {}, {
|
|
590
|
+
images: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, freshImages), {}, {
|
|
591
|
+
values: orderedValues
|
|
592
|
+
})
|
|
593
|
+
})
|
|
594
|
+
});
|
|
595
|
+
_context3.next = 48;
|
|
596
|
+
break;
|
|
543
597
|
|
|
544
|
-
|
|
598
|
+
case 45:
|
|
599
|
+
_context3.prev = 45;
|
|
600
|
+
_context3.t0 = _context3["catch"](30);
|
|
601
|
+
console.log("Error al refrescar images_values:", _context3.t0);
|
|
602
|
+
|
|
603
|
+
case 48:
|
|
604
|
+
// Mostrar modal de éxito
|
|
605
|
+
dispatch({
|
|
606
|
+
type: "SET_MODAL",
|
|
607
|
+
payload: {
|
|
608
|
+
show: true,
|
|
609
|
+
title: "",
|
|
610
|
+
message: "Imágenes guardadas con éxito",
|
|
611
|
+
image: _genericModalCheck.default
|
|
612
|
+
}
|
|
613
|
+
});
|
|
614
|
+
|
|
615
|
+
case 49:
|
|
616
|
+
_context3.next = 56;
|
|
545
617
|
break;
|
|
546
618
|
|
|
547
|
-
case
|
|
548
|
-
_context3.prev =
|
|
549
|
-
_context3.
|
|
550
|
-
console.log(_context3.
|
|
619
|
+
case 51:
|
|
620
|
+
_context3.prev = 51;
|
|
621
|
+
_context3.t1 = _context3["catch"](16);
|
|
622
|
+
console.log(_context3.t1);
|
|
551
623
|
dispatch({
|
|
552
624
|
type: "SET_ERRORS",
|
|
553
|
-
payload: [].concat((0, _toConsumableArray2.default)(state.errors), [_context3.
|
|
625
|
+
payload: [].concat((0, _toConsumableArray2.default)(state.errors), [_context3.t1])
|
|
554
626
|
});
|
|
555
627
|
dispatch({
|
|
556
628
|
type: "SET_MODAL",
|
|
@@ -562,19 +634,19 @@ var ProviderProductEditionProvider = function ProviderProductEditionProvider(_re
|
|
|
562
634
|
}
|
|
563
635
|
});
|
|
564
636
|
|
|
565
|
-
case
|
|
566
|
-
_context3.prev =
|
|
637
|
+
case 56:
|
|
638
|
+
_context3.prev = 56;
|
|
567
639
|
dispatch({
|
|
568
640
|
type: "SET_SAVING",
|
|
569
641
|
payload: false
|
|
570
642
|
});
|
|
571
|
-
return _context3.finish(
|
|
643
|
+
return _context3.finish(56);
|
|
572
644
|
|
|
573
|
-
case
|
|
574
|
-
_context3.next =
|
|
645
|
+
case 59:
|
|
646
|
+
_context3.next = 62;
|
|
575
647
|
break;
|
|
576
648
|
|
|
577
|
-
case
|
|
649
|
+
case 61:
|
|
578
650
|
dispatch({
|
|
579
651
|
type: "SET_MODAL",
|
|
580
652
|
payload: {
|
|
@@ -585,12 +657,12 @@ var ProviderProductEditionProvider = function ProviderProductEditionProvider(_re
|
|
|
585
657
|
}
|
|
586
658
|
});
|
|
587
659
|
|
|
588
|
-
case
|
|
660
|
+
case 62:
|
|
589
661
|
case "end":
|
|
590
662
|
return _context3.stop();
|
|
591
663
|
}
|
|
592
664
|
}
|
|
593
|
-
}, _callee3, null, [[16,
|
|
665
|
+
}, _callee3, null, [[16, 51, 56, 59], [30, 45]]);
|
|
594
666
|
}));
|
|
595
667
|
|
|
596
668
|
return function updateImages(_x3) {
|
|
@@ -600,9 +672,9 @@ var ProviderProductEditionProvider = function ProviderProductEditionProvider(_re
|
|
|
600
672
|
|
|
601
673
|
var saveImageAttrs = /*#__PURE__*/function () {
|
|
602
674
|
var _ref7 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4(token) {
|
|
603
|
-
var _state$images_values$, _state$images_values2, _state$images_values3, _state$
|
|
675
|
+
var _state$images_values$, _state$images_values2, _state$images_values3, _state$product14, _state$product15, _state$product16;
|
|
604
676
|
|
|
605
|
-
var activeImage, attrForImgs, data, _state$
|
|
677
|
+
var activeImage, attrForImgs, data, _state$product17, _state$product18, res, attrBody, newStatus, _state$product19, productFromLocalStorage, updatedProduct;
|
|
606
678
|
|
|
607
679
|
return _regenerator.default.wrap(function _callee4$(_context4) {
|
|
608
680
|
while (1) {
|
|
@@ -623,7 +695,7 @@ var ProviderProductEditionProvider = function ProviderProductEditionProvider(_re
|
|
|
623
695
|
activeImage = state.images_values.values[state.current_image];
|
|
624
696
|
attrForImgs = (_state$images_values$ = (_state$images_values2 = state.images_values) === null || _state$images_values2 === void 0 ? void 0 : (_state$images_values3 = _state$images_values2.attrForImgs) === null || _state$images_values3 === void 0 ? void 0 : _state$images_values3.general) !== null && _state$images_values$ !== void 0 ? _state$images_values$ : [];
|
|
625
697
|
data = {
|
|
626
|
-
articleId: (_state$
|
|
698
|
+
articleId: (_state$product14 = state.product) === null || _state$product14 === void 0 ? void 0 : _state$product14.id_article,
|
|
627
699
|
attrReqImgs: attrForImgs.map(function (e) {
|
|
628
700
|
var _e$value2;
|
|
629
701
|
|
|
@@ -636,8 +708,8 @@ var ProviderProductEditionProvider = function ProviderProductEditionProvider(_re
|
|
|
636
708
|
updateImages: activeImage ? [activeImage] : []
|
|
637
709
|
};
|
|
638
710
|
|
|
639
|
-
if ((_state$
|
|
640
|
-
data.orderId = ((_state$
|
|
711
|
+
if ((_state$product15 = state.product) !== null && _state$product15 !== void 0 && _state$product15.orderId || (_state$product16 = state.product) !== null && _state$product16 !== void 0 && _state$product16.id_order) {
|
|
712
|
+
data.orderId = ((_state$product17 = state.product) === null || _state$product17 === void 0 ? void 0 : _state$product17.orderId) || ((_state$product18 = state.product) === null || _state$product18 === void 0 ? void 0 : _state$product18.id_order);
|
|
641
713
|
}
|
|
642
714
|
|
|
643
715
|
_context4.prev = 7;
|
|
@@ -667,7 +739,7 @@ var ProviderProductEditionProvider = function ProviderProductEditionProvider(_re
|
|
|
667
739
|
productFromLocalStorage = JSON.parse(sessionStorage.getItem("productSelected"));
|
|
668
740
|
updatedProduct = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, productFromLocalStorage || state.product), {}, {
|
|
669
741
|
images_status: newStatus,
|
|
670
|
-
statusByRetailer: ((productFromLocalStorage === null || productFromLocalStorage === void 0 ? void 0 : productFromLocalStorage.statusByRetailer) || ((_state$
|
|
742
|
+
statusByRetailer: ((productFromLocalStorage === null || productFromLocalStorage === void 0 ? void 0 : productFromLocalStorage.statusByRetailer) || ((_state$product19 = state.product) === null || _state$product19 === void 0 ? void 0 : _state$product19.statusByRetailer) || []).map(function (retailerStatus) {
|
|
671
743
|
return retailerStatus.service === "images" ? (0, _objectSpread2.default)((0, _objectSpread2.default)({}, retailerStatus), {}, {
|
|
672
744
|
status: newStatus
|
|
673
745
|
}) : retailerStatus;
|
|
@@ -681,9 +753,9 @@ var ProviderProductEditionProvider = function ProviderProductEditionProvider(_re
|
|
|
681
753
|
dispatch({
|
|
682
754
|
type: "SET_SERVICES_DATA",
|
|
683
755
|
payload: (state.services_data || []).map(function (srv) {
|
|
684
|
-
var _state$
|
|
756
|
+
var _state$active_retaile6;
|
|
685
757
|
|
|
686
|
-
return srv.service === "images" && srv.id_retailer === ((_state$
|
|
758
|
+
return srv.service === "images" && srv.id_retailer === ((_state$active_retaile6 = state.active_retailer) === null || _state$active_retaile6 === void 0 ? void 0 : _state$active_retaile6.id_retailer) ? (0, _objectSpread2.default)((0, _objectSpread2.default)({}, srv), {}, {
|
|
687
759
|
status: newStatus
|
|
688
760
|
}) : srv;
|
|
689
761
|
})
|
|
@@ -744,9 +816,9 @@ var ProviderProductEditionProvider = function ProviderProductEditionProvider(_re
|
|
|
744
816
|
}();
|
|
745
817
|
|
|
746
818
|
var handleOnDownloadImages = function handleOnDownloadImages() {
|
|
747
|
-
var _state$
|
|
819
|
+
var _state$product20, _state$product21, _state$product21$arti, _state$images_values4, _state$images_values5;
|
|
748
820
|
|
|
749
|
-
var upc = ((_state$
|
|
821
|
+
var upc = ((_state$product20 = state.product) === null || _state$product20 === void 0 ? void 0 : _state$product20.upc) || ((_state$product21 = state.product) === null || _state$product21 === void 0 ? void 0 : (_state$product21$arti = _state$product21.article) === null || _state$product21$arti === void 0 ? void 0 : _state$product21$arti.upc);
|
|
750
822
|
state.selected_images.length > 0 ? state.selected_images.forEach(function (e) {
|
|
751
823
|
if (e.id) {
|
|
752
824
|
saveAs("https://".concat(process.env.REACT_APP_IMAGES_BUCKET, ".s3.amazonaws.com/").concat(e.srcDB), "".concat(upc, "_").concat(e.name, ".").concat(e.ext));
|
|
@@ -760,7 +832,7 @@ var ProviderProductEditionProvider = function ProviderProductEditionProvider(_re
|
|
|
760
832
|
|
|
761
833
|
var deleteImages = /*#__PURE__*/function () {
|
|
762
834
|
var _ref8 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5(token) {
|
|
763
|
-
var imgsInBack, _state$
|
|
835
|
+
var imgsInBack, _state$product22, data;
|
|
764
836
|
|
|
765
837
|
return _regenerator.default.wrap(function _callee5$(_context5) {
|
|
766
838
|
while (1) {
|
|
@@ -781,7 +853,7 @@ var ProviderProductEditionProvider = function ProviderProductEditionProvider(_re
|
|
|
781
853
|
}
|
|
782
854
|
|
|
783
855
|
data = {
|
|
784
|
-
articleId: (_state$
|
|
856
|
+
articleId: (_state$product22 = state.product) === null || _state$product22 === void 0 ? void 0 : _state$product22.id_article,
|
|
785
857
|
deleteImages: imgsInBack
|
|
786
858
|
};
|
|
787
859
|
_context5.prev = 4;
|
|
@@ -861,7 +933,7 @@ var ProviderProductEditionProvider = function ProviderProductEditionProvider(_re
|
|
|
861
933
|
|
|
862
934
|
var createComment = /*#__PURE__*/function () {
|
|
863
935
|
var _ref9 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6(body, token) {
|
|
864
|
-
var _state$
|
|
936
|
+
var _state$product23, _state$product24, _state$product25;
|
|
865
937
|
|
|
866
938
|
var concept, data;
|
|
867
939
|
return _regenerator.default.wrap(function _callee6$(_context6) {
|
|
@@ -870,8 +942,8 @@ var ProviderProductEditionProvider = function ProviderProductEditionProvider(_re
|
|
|
870
942
|
case 0:
|
|
871
943
|
concept = (0, _utils.getConceptByTab)(state.active_tab);
|
|
872
944
|
data = {
|
|
873
|
-
articleId: (_state$
|
|
874
|
-
orderId: ((_state$
|
|
945
|
+
articleId: (_state$product23 = state.product) === null || _state$product23 === void 0 ? void 0 : _state$product23.id_article,
|
|
946
|
+
orderId: ((_state$product24 = state.product) === null || _state$product24 === void 0 ? void 0 : _state$product24.orderId) || ((_state$product25 = state.product) === null || _state$product25 === void 0 ? void 0 : _state$product25.id_order),
|
|
875
947
|
message: body,
|
|
876
948
|
concept: concept,
|
|
877
949
|
version: state.product.version
|
|
@@ -935,5 +1007,10 @@ var useProviderProductEdition = function useProviderProductEdition() {
|
|
|
935
1007
|
|
|
936
1008
|
return context;
|
|
937
1009
|
};
|
|
1010
|
+
/*
|
|
1011
|
+
src: "https://d24s337exbt5zr.cloudfront.net/eyJidWNrZXQiOiJjb250ZW50LW1hbmFnZW1lbnQtaW1hZ2VzLXByb2QiLCJrZXkiOiJpZC0xNDQ3MTEvMy8xLTRjZGVjNTZkLTVjYWMtNGY3NC04ZWM0LWZmMmRmOTFjZDdiOS5qcGciLCJlZGl0cyI6eyJyZXNpemUiOnsid2lkdGgiOjEwMDAsImhlaWdodCI6MTAwMCwiZml0IjoiY29udGFpbiIsImJhY2tncm91bmQiOnsiciI6MjU1LCJnIjoyNTUsImIiOjI1NSwiYWxwaGEiOjF9fX19"
|
|
1012
|
+
srcDB: "id-144711/3/1-4cdec56d-5cac-4f74-8ec4-ff2df91cd7b9.jpg"
|
|
1013
|
+
*/
|
|
1014
|
+
|
|
938
1015
|
|
|
939
1016
|
exports.useProviderProductEdition = useProviderProductEdition;
|
package/package.json
CHANGED
package/src/components/pages/RetailerProductEdition/context/provider-product-edition.context.jsx
CHANGED
|
@@ -12,6 +12,7 @@ import { v4 as uuidv4 } from "uuid";
|
|
|
12
12
|
import successIcon from "../../../../assets/images/genericModal/genericModalCheck.svg";
|
|
13
13
|
import errorIcon from "../../../../assets/images/genericModal/errorModal.svg";
|
|
14
14
|
import { getConceptByTab } from "../utils";
|
|
15
|
+
import { getImage } from "../../../../global-files/data";
|
|
15
16
|
|
|
16
17
|
const S3_BUCKET = process.env.REACT_APP_IMAGES_BUCKET;
|
|
17
18
|
const REGION = "us-east-1";
|
|
@@ -440,6 +441,59 @@ export const ProviderProductEditionProvider = ({ children }) => {
|
|
|
440
441
|
});
|
|
441
442
|
}
|
|
442
443
|
|
|
444
|
+
// Refrescar images_values con datos reales del backend
|
|
445
|
+
try {
|
|
446
|
+
const { id_article, version } = state.product;
|
|
447
|
+
const { category, id_category, id_retailer } = state.active_retailer;
|
|
448
|
+
const imagesRes = await axios.post(
|
|
449
|
+
`${process.env.REACT_APP_ARTICLE_DATA_IMAGES_ENDPOINT}?articleId=${id_article}&version=${version}`,
|
|
450
|
+
{ category, retailersList: [id_retailer] },
|
|
451
|
+
{ headers: { Authorization: token } },
|
|
452
|
+
);
|
|
453
|
+
const freshImages = JSON.parse(imagesRes.data.body).data;
|
|
454
|
+
freshImages.values = freshImages?.values?.map((value) => {
|
|
455
|
+
value.name = freshImages.inputs.find((e) => e.id === value.image_id)?.name;
|
|
456
|
+
return getImage(value);
|
|
457
|
+
});
|
|
458
|
+
|
|
459
|
+
const orderMap = freshImages.inputsByRetailer
|
|
460
|
+
.flat()
|
|
461
|
+
.reduce((acc, item) => {
|
|
462
|
+
acc[item.id_image] = item.order;
|
|
463
|
+
return acc;
|
|
464
|
+
}, {});
|
|
465
|
+
|
|
466
|
+
const orderedValues = [...freshImages.values].sort((a, b) => {
|
|
467
|
+
const orderA = orderMap[a.image_id] ?? Number.MAX_SAFE_INTEGER;
|
|
468
|
+
const orderB = orderMap[b.image_id] ?? Number.MAX_SAFE_INTEGER;
|
|
469
|
+
return orderA - orderB;
|
|
470
|
+
});
|
|
471
|
+
|
|
472
|
+
const filteredValues = freshImages.values.filter((value) =>
|
|
473
|
+
freshImages.inputsByRetailer.some((retailerInput) =>
|
|
474
|
+
retailerInput.some(
|
|
475
|
+
(input) =>
|
|
476
|
+
input.id_retailer === id_retailer &&
|
|
477
|
+
input.id_image === value.image_id,
|
|
478
|
+
),
|
|
479
|
+
),
|
|
480
|
+
);
|
|
481
|
+
|
|
482
|
+
dispatch({
|
|
483
|
+
type: "SET_IMAGES_VALUES",
|
|
484
|
+
payload: { ...freshImages, values: filteredValues },
|
|
485
|
+
});
|
|
486
|
+
dispatch({
|
|
487
|
+
type: "SET_SERVICES",
|
|
488
|
+
payload: {
|
|
489
|
+
...state.services,
|
|
490
|
+
images: { ...freshImages, values: orderedValues },
|
|
491
|
+
},
|
|
492
|
+
});
|
|
493
|
+
} catch (refreshError) {
|
|
494
|
+
console.log("Error al refrescar images_values:", refreshError);
|
|
495
|
+
}
|
|
496
|
+
|
|
443
497
|
// Mostrar modal de éxito
|
|
444
498
|
dispatch({
|
|
445
499
|
type: "SET_MODAL",
|
|
@@ -732,3 +786,8 @@ export const useProviderProductEdition = () => {
|
|
|
732
786
|
|
|
733
787
|
return context;
|
|
734
788
|
};
|
|
789
|
+
|
|
790
|
+
/*
|
|
791
|
+
src: "https://d24s337exbt5zr.cloudfront.net/eyJidWNrZXQiOiJjb250ZW50LW1hbmFnZW1lbnQtaW1hZ2VzLXByb2QiLCJrZXkiOiJpZC0xNDQ3MTEvMy8xLTRjZGVjNTZkLTVjYWMtNGY3NC04ZWM0LWZmMmRmOTFjZDdiOS5qcGciLCJlZGl0cyI6eyJyZXNpemUiOnsid2lkdGgiOjEwMDAsImhlaWdodCI6MTAwMCwiZml0IjoiY29udGFpbiIsImJhY2tncm91bmQiOnsiciI6MjU1LCJnIjoyNTUsImIiOjI1NSwiYWxwaGEiOjF9fX19"
|
|
792
|
+
srcDB: "id-144711/3/1-4cdec56d-5cac-4f74-8ec4-ff2df91cd7b9.jpg"
|
|
793
|
+
*/
|