contentoh-components-library 21.5.72 → 21.5.73

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.
@@ -68,7 +68,7 @@ var ProviderProductEditionProvider = function ProviderProductEditionProvider(_re
68
68
  var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(token) {
69
69
  var _state$product, _state$product2;
70
70
 
71
- var dataObject, _state$product3, res, inputs, filledRequiredCount;
71
+ var dataObject, _state$product3, res, inputs, filledRequiredCount, body, newStatus, _state$product4, productFromLocalStorage, updatedProduct;
72
72
 
73
73
  return _regenerator.default.wrap(function _callee$(_context) {
74
74
  while (1) {
@@ -132,6 +132,32 @@ var ProviderProductEditionProvider = function ProviderProductEditionProvider(_re
132
132
  filledRequiredCount += 1;
133
133
  }
134
134
  });
135
+ body = JSON.parse(res.data.body);
136
+ newStatus = body === null || body === void 0 ? void 0 : body.newStatus;
137
+
138
+ if (newStatus) {
139
+ productFromLocalStorage = JSON.parse(sessionStorage.getItem("productSelected"));
140
+ updatedProduct = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, productFromLocalStorage || state.product), {}, {
141
+ description_status: newStatus,
142
+ statusByRetailer: ((productFromLocalStorage === null || productFromLocalStorage === void 0 ? void 0 : productFromLocalStorage.statusByRetailer) || ((_state$product4 = state.product) === null || _state$product4 === void 0 ? void 0 : _state$product4.statusByRetailer) || []).map(function (retailerStatus) {
143
+ return retailerStatus.service === "description" ? (0, _objectSpread2.default)((0, _objectSpread2.default)({}, retailerStatus), {}, {
144
+ status: newStatus
145
+ }) : retailerStatus;
146
+ })
147
+ });
148
+ sessionStorage.setItem("productSelected", JSON.stringify(updatedProduct));
149
+ dispatch({
150
+ type: "SET_SERVICES_DATA",
151
+ payload: (state.services_data || []).map(function (srv) {
152
+ var _state$active_retaile;
153
+
154
+ return srv.service === "description" && srv.id_retailer === ((_state$active_retaile = state.active_retailer) === null || _state$active_retaile === void 0 ? void 0 : _state$active_retaile.id_retailer) ? (0, _objectSpread2.default)((0, _objectSpread2.default)({}, srv), {}, {
155
+ status: newStatus
156
+ }) : srv;
157
+ })
158
+ });
159
+ }
160
+
135
161
  dispatch({
136
162
  type: "SET_MISSING_REQUIRED_FIELDS",
137
163
  payload: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, state.missing_required_fields), {}, {
@@ -191,9 +217,9 @@ var ProviderProductEditionProvider = function ProviderProductEditionProvider(_re
191
217
 
192
218
  var saveDatasheets = /*#__PURE__*/function () {
193
219
  var _ref3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(token) {
194
- var _state$product4, _state$product5;
220
+ var _state$product5, _state$product6;
195
221
 
196
- var dataObject, _state$product6, res, _state$active_retaile, datasheetInputs, retailerId, filledRequiredCount;
222
+ var dataObject, _state$product7, res, _state$active_retaile2, datasheetInputs, retailerId, filledRequiredCount, body, newStatus, _state$product8, productFromLocalStorage, updatedProduct;
197
223
 
198
224
  return _regenerator.default.wrap(function _callee2$(_context2) {
199
225
  while (1) {
@@ -212,12 +238,12 @@ var ProviderProductEditionProvider = function ProviderProductEditionProvider(_re
212
238
  payload: true
213
239
  });
214
240
  dataObject = {
215
- articleId: (_state$product4 = state.product) === null || _state$product4 === void 0 ? void 0 : _state$product4.id_article,
241
+ articleId: (_state$product5 = state.product) === null || _state$product5 === void 0 ? void 0 : _state$product5.id_article,
216
242
  articleData: state.updated_datasheets_inputs
217
243
  };
218
244
 
219
- if ((_state$product5 = state.product) !== null && _state$product5 !== void 0 && _state$product5.id_order) {
220
- dataObject.orderId = (_state$product6 = state.product) === null || _state$product6 === void 0 ? void 0 : _state$product6.id_order;
245
+ if ((_state$product6 = state.product) !== null && _state$product6 !== void 0 && _state$product6.id_order) {
246
+ dataObject.orderId = (_state$product7 = state.product) === null || _state$product7 === void 0 ? void 0 : _state$product7.id_order;
221
247
  }
222
248
 
223
249
  _context2.prev = 5;
@@ -247,7 +273,7 @@ var ProviderProductEditionProvider = function ProviderProductEditionProvider(_re
247
273
  }); // Contar cuántos campos requeridos que antes estaban vacíos ahora tienen valor
248
274
 
249
275
  datasheetInputs = state.datasheets_inputs[1];
250
- retailerId = (_state$active_retaile = state.active_retailer) === null || _state$active_retaile === void 0 ? void 0 : _state$active_retaile.id_retailer;
276
+ retailerId = (_state$active_retaile2 = state.active_retailer) === null || _state$active_retaile2 === void 0 ? void 0 : _state$active_retaile2.id_retailer;
251
277
  filledRequiredCount = 0;
252
278
  state.updated_datasheets_inputs.forEach(function (updatedInput) {
253
279
  var key = "".concat(updatedInput.attributeId, "_").concat(retailerId);
@@ -257,6 +283,32 @@ var ProviderProductEditionProvider = function ProviderProductEditionProvider(_re
257
283
  filledRequiredCount += 1;
258
284
  }
259
285
  });
286
+ body = JSON.parse(res.data.body);
287
+ newStatus = body === null || body === void 0 ? void 0 : body.newStatus;
288
+
289
+ if (newStatus) {
290
+ productFromLocalStorage = JSON.parse(sessionStorage.getItem("productSelected"));
291
+ updatedProduct = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, productFromLocalStorage || state.product), {}, {
292
+ datasheet_status: newStatus,
293
+ statusByRetailer: ((productFromLocalStorage === null || productFromLocalStorage === void 0 ? void 0 : productFromLocalStorage.statusByRetailer) || ((_state$product8 = state.product) === null || _state$product8 === void 0 ? void 0 : _state$product8.statusByRetailer) || []).map(function (retailerStatus) {
294
+ return retailerStatus.service === "datasheet" ? (0, _objectSpread2.default)((0, _objectSpread2.default)({}, retailerStatus), {}, {
295
+ status: newStatus
296
+ }) : retailerStatus;
297
+ })
298
+ });
299
+ sessionStorage.setItem("productSelected", JSON.stringify(updatedProduct));
300
+ dispatch({
301
+ type: "SET_SERVICES_DATA",
302
+ payload: (state.services_data || []).map(function (srv) {
303
+ var _state$active_retaile3;
304
+
305
+ return srv.service === "datasheet" && srv.id_retailer === ((_state$active_retaile3 = state.active_retailer) === null || _state$active_retaile3 === void 0 ? void 0 : _state$active_retaile3.id_retailer) ? (0, _objectSpread2.default)((0, _objectSpread2.default)({}, srv), {}, {
306
+ status: newStatus
307
+ }) : srv;
308
+ })
309
+ });
310
+ }
311
+
260
312
  dispatch({
261
313
  type: "SET_MISSING_REQUIRED_FIELDS",
262
314
  payload: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, state.missing_required_fields), {}, {
@@ -310,9 +362,10 @@ var ProviderProductEditionProvider = function ProviderProductEditionProvider(_re
310
362
 
311
363
  var updateImages = /*#__PURE__*/function () {
312
364
  var _ref4 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(token) {
313
- var _state$images_values, _state$product7, _state$product8, _state$product9, _data$articleData, _data$updateImages;
365
+ var _state$images_values, _state$product9, _state$product10, _state$product11, _data$articleData, _data$updateImages;
366
+
367
+ var updatedImages, attrForImgs, generalAttrs, retailerKey, retailerAttrs, mergedAttrs, data, valid, promiseArray, res, imageBody, newStatus, _state$product12, productFromLocalStorage, updatedProduct;
314
368
 
315
- var updatedImages, attrForImgs, generalAttrs, retailerKey, retailerAttrs, mergedAttrs, data, valid, promiseArray, res;
316
369
  return _regenerator.default.wrap(function _callee3$(_context3) {
317
370
  while (1) {
318
371
  switch (_context3.prev = _context3.next) {
@@ -346,7 +399,7 @@ var ProviderProductEditionProvider = function ProviderProductEditionProvider(_re
346
399
  return retailerAttr;
347
400
  });
348
401
  data = {
349
- articleId: (_state$product7 = state.product) === null || _state$product7 === void 0 ? void 0 : _state$product7.id_article,
402
+ articleId: (_state$product9 = state.product) === null || _state$product9 === void 0 ? void 0 : _state$product9.id_article,
350
403
  attrReqImgs: mergedAttrs.map(function (e) {
351
404
  var _e$value;
352
405
 
@@ -362,7 +415,7 @@ var ProviderProductEditionProvider = function ProviderProductEditionProvider(_re
362
415
  return e.id;
363
416
  })
364
417
  };
365
- if ((_state$product8 = state.product) !== null && _state$product8 !== void 0 && _state$product8.orderId) data["orderId"] = (_state$product9 = state.product) === null || _state$product9 === void 0 ? void 0 : _state$product9.orderId;
418
+ if ((_state$product10 = state.product) !== null && _state$product10 !== void 0 && _state$product10.orderId) data["orderId"] = (_state$product11 = state.product) === null || _state$product11 === void 0 ? void 0 : _state$product11.orderId;
366
419
  valid = (data === null || data === void 0 ? void 0 : (_data$articleData = data.articleData) === null || _data$articleData === void 0 ? void 0 : _data$articleData.every(function (e) {
367
420
  return e === null || e === void 0 ? void 0 : e.image_id;
368
421
  })) && (data === null || data === void 0 ? void 0 : (_data$updateImages = data.updateImages) === null || _data$updateImages === void 0 ? void 0 : _data$updateImages.every(function (e) {
@@ -437,7 +490,33 @@ var ProviderProductEditionProvider = function ProviderProductEditionProvider(_re
437
490
  dispatch({
438
491
  type: "SET_UPDATED_IMAGES_VALUES",
439
492
  payload: []
440
- }); // Mostrar modal de éxito
493
+ });
494
+ imageBody = JSON.parse(res.data.body);
495
+ newStatus = imageBody === null || imageBody === void 0 ? void 0 : imageBody.newStatus;
496
+
497
+ if (newStatus) {
498
+ productFromLocalStorage = JSON.parse(sessionStorage.getItem("productSelected"));
499
+ updatedProduct = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, productFromLocalStorage || state.product), {}, {
500
+ images_status: newStatus,
501
+ 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) {
502
+ return retailerStatus.service === "images" ? (0, _objectSpread2.default)((0, _objectSpread2.default)({}, retailerStatus), {}, {
503
+ status: newStatus
504
+ }) : retailerStatus;
505
+ })
506
+ });
507
+ sessionStorage.setItem("productSelected", JSON.stringify(updatedProduct));
508
+ dispatch({
509
+ type: "SET_SERVICES_DATA",
510
+ payload: (state.services_data || []).map(function (srv) {
511
+ var _state$active_retaile4;
512
+
513
+ 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), {}, {
514
+ status: newStatus
515
+ }) : srv;
516
+ })
517
+ });
518
+ } // Mostrar modal de éxito
519
+
441
520
 
442
521
  dispatch({
443
522
  type: "SET_MODAL",
@@ -509,9 +588,9 @@ var ProviderProductEditionProvider = function ProviderProductEditionProvider(_re
509
588
 
510
589
  var saveImageAttrs = /*#__PURE__*/function () {
511
590
  var _ref7 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4(token) {
512
- var _state$images_values$, _state$images_values2, _state$images_values3, _state$product10, _state$product11, _state$product12;
591
+ var _state$images_values$, _state$images_values2, _state$images_values3, _state$product13, _state$product14, _state$product15;
513
592
 
514
- var activeImage, attrForImgs, data, _state$product13, _state$product14, res;
593
+ var activeImage, attrForImgs, data, _state$product16, _state$product17, res, attrBody, newStatus, _state$product18, productFromLocalStorage, updatedProduct;
515
594
 
516
595
  return _regenerator.default.wrap(function _callee4$(_context4) {
517
596
  while (1) {
@@ -532,7 +611,7 @@ var ProviderProductEditionProvider = function ProviderProductEditionProvider(_re
532
611
  activeImage = state.images_values.values[state.current_image];
533
612
  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$ : [];
534
613
  data = {
535
- articleId: (_state$product10 = state.product) === null || _state$product10 === void 0 ? void 0 : _state$product10.id_article,
614
+ articleId: (_state$product13 = state.product) === null || _state$product13 === void 0 ? void 0 : _state$product13.id_article,
536
615
  attrReqImgs: attrForImgs.map(function (e) {
537
616
  var _e$value2;
538
617
 
@@ -545,8 +624,8 @@ var ProviderProductEditionProvider = function ProviderProductEditionProvider(_re
545
624
  updateImages: activeImage ? [activeImage] : []
546
625
  };
547
626
 
548
- if ((_state$product11 = state.product) !== null && _state$product11 !== void 0 && _state$product11.orderId || (_state$product12 = state.product) !== null && _state$product12 !== void 0 && _state$product12.id_order) {
549
- data.orderId = ((_state$product13 = state.product) === null || _state$product13 === void 0 ? void 0 : _state$product13.orderId) || ((_state$product14 = state.product) === null || _state$product14 === void 0 ? void 0 : _state$product14.id_order);
627
+ if ((_state$product14 = state.product) !== null && _state$product14 !== void 0 && _state$product14.orderId || (_state$product15 = state.product) !== null && _state$product15 !== void 0 && _state$product15.id_order) {
628
+ data.orderId = ((_state$product16 = state.product) === null || _state$product16 === void 0 ? void 0 : _state$product16.orderId) || ((_state$product17 = state.product) === null || _state$product17 === void 0 ? void 0 : _state$product17.id_order);
550
629
  }
551
630
 
552
631
  _context4.prev = 7;
@@ -569,6 +648,32 @@ var ProviderProductEditionProvider = function ProviderProductEditionProvider(_re
569
648
  type: "SET_UPDATED_ATTR_FOR_IMGS",
570
649
  payload: []
571
650
  });
651
+ attrBody = JSON.parse(res.data.body);
652
+ newStatus = attrBody === null || attrBody === void 0 ? void 0 : attrBody.newStatus;
653
+
654
+ if (newStatus) {
655
+ productFromLocalStorage = JSON.parse(sessionStorage.getItem("productSelected"));
656
+ updatedProduct = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, productFromLocalStorage || state.product), {}, {
657
+ images_status: newStatus,
658
+ statusByRetailer: ((productFromLocalStorage === null || productFromLocalStorage === void 0 ? void 0 : productFromLocalStorage.statusByRetailer) || ((_state$product18 = state.product) === null || _state$product18 === void 0 ? void 0 : _state$product18.statusByRetailer) || []).map(function (retailerStatus) {
659
+ return retailerStatus.service === "images" ? (0, _objectSpread2.default)((0, _objectSpread2.default)({}, retailerStatus), {}, {
660
+ status: newStatus
661
+ }) : retailerStatus;
662
+ })
663
+ });
664
+ sessionStorage.setItem("productSelected", JSON.stringify(updatedProduct));
665
+ dispatch({
666
+ type: "SET_SERVICES_DATA",
667
+ payload: (state.services_data || []).map(function (srv) {
668
+ var _state$active_retaile5;
669
+
670
+ return srv.service === "images" && srv.id_retailer === ((_state$active_retaile5 = state.active_retailer) === null || _state$active_retaile5 === void 0 ? void 0 : _state$active_retaile5.id_retailer) ? (0, _objectSpread2.default)((0, _objectSpread2.default)({}, srv), {}, {
671
+ status: newStatus
672
+ }) : srv;
673
+ })
674
+ });
675
+ }
676
+
572
677
  dispatch({
573
678
  type: "SET_MODAL",
574
679
  payload: {
@@ -623,9 +728,9 @@ var ProviderProductEditionProvider = function ProviderProductEditionProvider(_re
623
728
  }();
624
729
 
625
730
  var handleOnDownloadImages = function handleOnDownloadImages() {
626
- var _state$product15, _state$product16, _state$product16$arti, _state$images_values4, _state$images_values5;
731
+ var _state$product19, _state$product20, _state$product20$arti, _state$images_values4, _state$images_values5;
627
732
 
628
- var upc = ((_state$product15 = state.product) === null || _state$product15 === void 0 ? void 0 : _state$product15.upc) || ((_state$product16 = state.product) === null || _state$product16 === void 0 ? void 0 : (_state$product16$arti = _state$product16.article) === null || _state$product16$arti === void 0 ? void 0 : _state$product16$arti.upc);
733
+ var upc = ((_state$product19 = state.product) === null || _state$product19 === void 0 ? void 0 : _state$product19.upc) || ((_state$product20 = state.product) === null || _state$product20 === void 0 ? void 0 : (_state$product20$arti = _state$product20.article) === null || _state$product20$arti === void 0 ? void 0 : _state$product20$arti.upc);
629
734
  state.selected_images.length > 0 ? state.selected_images.forEach(function (e) {
630
735
  if (e.id) {
631
736
  saveAs("https://".concat(process.env.REACT_APP_IMAGES_BUCKET, ".s3.amazonaws.com/").concat(e.srcDB), "".concat(upc, "_").concat(e.name, ".").concat(e.ext));
@@ -639,7 +744,7 @@ var ProviderProductEditionProvider = function ProviderProductEditionProvider(_re
639
744
 
640
745
  var deleteImages = /*#__PURE__*/function () {
641
746
  var _ref8 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5(token) {
642
- var imgsInBack, _state$product17, data;
747
+ var imgsInBack, _state$product21, data;
643
748
 
644
749
  return _regenerator.default.wrap(function _callee5$(_context5) {
645
750
  while (1) {
@@ -660,7 +765,7 @@ var ProviderProductEditionProvider = function ProviderProductEditionProvider(_re
660
765
  }
661
766
 
662
767
  data = {
663
- articleId: (_state$product17 = state.product) === null || _state$product17 === void 0 ? void 0 : _state$product17.id_article,
768
+ articleId: (_state$product21 = state.product) === null || _state$product21 === void 0 ? void 0 : _state$product21.id_article,
664
769
  deleteImages: imgsInBack
665
770
  };
666
771
  _context5.prev = 4;
@@ -740,7 +845,7 @@ var ProviderProductEditionProvider = function ProviderProductEditionProvider(_re
740
845
 
741
846
  var createComment = /*#__PURE__*/function () {
742
847
  var _ref9 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6(body, token) {
743
- var _state$product18, _state$product19, _state$product20;
848
+ var _state$product22, _state$product23, _state$product24;
744
849
 
745
850
  var concept, data;
746
851
  return _regenerator.default.wrap(function _callee6$(_context6) {
@@ -749,8 +854,8 @@ var ProviderProductEditionProvider = function ProviderProductEditionProvider(_re
749
854
  case 0:
750
855
  concept = (0, _utils.getConceptByTab)(state.active_tab);
751
856
  data = {
752
- articleId: (_state$product18 = state.product) === null || _state$product18 === void 0 ? void 0 : _state$product18.id_article,
753
- orderId: ((_state$product19 = state.product) === null || _state$product19 === void 0 ? void 0 : _state$product19.orderId) || ((_state$product20 = state.product) === null || _state$product20 === void 0 ? void 0 : _state$product20.id_order),
857
+ articleId: (_state$product22 = state.product) === null || _state$product22 === void 0 ? void 0 : _state$product22.id_article,
858
+ orderId: ((_state$product23 = state.product) === null || _state$product23 === void 0 ? void 0 : _state$product23.orderId) || ((_state$product24 = state.product) === null || _state$product24 === void 0 ? void 0 : _state$product24.id_order),
754
859
  message: body,
755
860
  concept: concept,
756
861
  version: state.product.version
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "contentoh-components-library",
3
- "version": "21.5.72",
3
+ "version": "21.5.73",
4
4
  "dependencies": {
5
5
  "@aws-amplify/auth": "^4.5.3",
6
6
  "@aws-amplify/datastore": "^3.11.0",
@@ -95,6 +95,44 @@ export const ProviderProductEditionProvider = ({ children }) => {
95
95
  }
96
96
  });
97
97
 
98
+ const body = JSON.parse(res.data.body);
99
+ const newStatus = body?.newStatus;
100
+
101
+ if (newStatus) {
102
+ const productFromLocalStorage = JSON.parse(
103
+ sessionStorage.getItem("productSelected"),
104
+ );
105
+
106
+ const updatedProduct = {
107
+ ...(productFromLocalStorage || state.product),
108
+ description_status: newStatus,
109
+ statusByRetailer: (
110
+ productFromLocalStorage?.statusByRetailer ||
111
+ state.product?.statusByRetailer ||
112
+ []
113
+ ).map((retailerStatus) =>
114
+ retailerStatus.service === "description"
115
+ ? { ...retailerStatus, status: newStatus }
116
+ : retailerStatus,
117
+ ),
118
+ };
119
+
120
+ sessionStorage.setItem(
121
+ "productSelected",
122
+ JSON.stringify(updatedProduct),
123
+ );
124
+
125
+ dispatch({
126
+ type: "SET_SERVICES_DATA",
127
+ payload: (state.services_data || []).map((srv) =>
128
+ srv.service === "description" &&
129
+ srv.id_retailer === state.active_retailer?.id_retailer
130
+ ? { ...srv, status: newStatus }
131
+ : srv,
132
+ ),
133
+ });
134
+ }
135
+
98
136
  dispatch({
99
137
  type: "SET_MISSING_REQUIRED_FIELDS",
100
138
  payload: {
@@ -195,6 +233,44 @@ export const ProviderProductEditionProvider = ({ children }) => {
195
233
  }
196
234
  });
197
235
 
236
+ const body = JSON.parse(res.data.body);
237
+ const newStatus = body?.newStatus;
238
+
239
+ if (newStatus) {
240
+ const productFromLocalStorage = JSON.parse(
241
+ sessionStorage.getItem("productSelected"),
242
+ );
243
+
244
+ const updatedProduct = {
245
+ ...(productFromLocalStorage || state.product),
246
+ datasheet_status: newStatus,
247
+ statusByRetailer: (
248
+ productFromLocalStorage?.statusByRetailer ||
249
+ state.product?.statusByRetailer ||
250
+ []
251
+ ).map((retailerStatus) =>
252
+ retailerStatus.service === "datasheet"
253
+ ? { ...retailerStatus, status: newStatus }
254
+ : retailerStatus,
255
+ ),
256
+ };
257
+
258
+ sessionStorage.setItem(
259
+ "productSelected",
260
+ JSON.stringify(updatedProduct),
261
+ );
262
+
263
+ dispatch({
264
+ type: "SET_SERVICES_DATA",
265
+ payload: (state.services_data || []).map((srv) =>
266
+ srv.service === "datasheet" &&
267
+ srv.id_retailer === state.active_retailer?.id_retailer
268
+ ? { ...srv, status: newStatus }
269
+ : srv,
270
+ ),
271
+ });
272
+ }
273
+
198
274
  dispatch({
199
275
  type: "SET_MISSING_REQUIRED_FIELDS",
200
276
  payload: {
@@ -319,6 +395,45 @@ export const ProviderProductEditionProvider = ({ children }) => {
319
395
  type: "SET_UPDATED_IMAGES_VALUES",
320
396
  payload: [],
321
397
  });
398
+
399
+ const imageBody = JSON.parse(res.data.body);
400
+ const newStatus = imageBody?.newStatus;
401
+
402
+ if (newStatus) {
403
+ const productFromLocalStorage = JSON.parse(
404
+ sessionStorage.getItem("productSelected"),
405
+ );
406
+
407
+ const updatedProduct = {
408
+ ...(productFromLocalStorage || state.product),
409
+ images_status: newStatus,
410
+ statusByRetailer: (
411
+ productFromLocalStorage?.statusByRetailer ||
412
+ state.product?.statusByRetailer ||
413
+ []
414
+ ).map((retailerStatus) =>
415
+ retailerStatus.service === "images"
416
+ ? { ...retailerStatus, status: newStatus }
417
+ : retailerStatus,
418
+ ),
419
+ };
420
+
421
+ sessionStorage.setItem(
422
+ "productSelected",
423
+ JSON.stringify(updatedProduct),
424
+ );
425
+
426
+ dispatch({
427
+ type: "SET_SERVICES_DATA",
428
+ payload: (state.services_data || []).map((srv) =>
429
+ srv.service === "images" &&
430
+ srv.id_retailer === state.active_retailer?.id_retailer
431
+ ? { ...srv, status: newStatus }
432
+ : srv,
433
+ ),
434
+ });
435
+ }
436
+
322
437
  // Mostrar modal de éxito
323
438
  dispatch({
324
439
  type: "SET_MODAL",
@@ -406,6 +521,44 @@ export const ProviderProductEditionProvider = ({ children }) => {
406
521
  payload: [],
407
522
  });
408
523
 
524
+ const attrBody = JSON.parse(res.data.body);
525
+ const newStatus = attrBody?.newStatus;
526
+
527
+ if (newStatus) {
528
+ const productFromLocalStorage = JSON.parse(
529
+ sessionStorage.getItem("productSelected"),
530
+ );
531
+
532
+ const updatedProduct = {
533
+ ...(productFromLocalStorage || state.product),
534
+ images_status: newStatus,
535
+ statusByRetailer: (
536
+ productFromLocalStorage?.statusByRetailer ||
537
+ state.product?.statusByRetailer ||
538
+ []
539
+ ).map((retailerStatus) =>
540
+ retailerStatus.service === "images"
541
+ ? { ...retailerStatus, status: newStatus }
542
+ : retailerStatus,
543
+ ),
544
+ };
545
+
546
+ sessionStorage.setItem(
547
+ "productSelected",
548
+ JSON.stringify(updatedProduct),
549
+ );
550
+
551
+ dispatch({
552
+ type: "SET_SERVICES_DATA",
553
+ payload: (state.services_data || []).map((srv) =>
554
+ srv.service === "images" &&
555
+ srv.id_retailer === state.active_retailer?.id_retailer
556
+ ? { ...srv, status: newStatus }
557
+ : srv,
558
+ ),
559
+ });
560
+ }
561
+
409
562
  dispatch({
410
563
  type: "SET_MODAL",
411
564
  payload: {