contentoh-components-library 21.5.71 → 21.5.72
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
|
@@ -310,9 +310,9 @@ var ProviderProductEditionProvider = function ProviderProductEditionProvider(_re
|
|
|
310
310
|
|
|
311
311
|
var updateImages = /*#__PURE__*/function () {
|
|
312
312
|
var _ref4 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(token) {
|
|
313
|
-
var _state$
|
|
313
|
+
var _state$images_values, _state$product7, _state$product8, _state$product9, _data$articleData, _data$updateImages;
|
|
314
314
|
|
|
315
|
-
var updatedImages, data, valid, promiseArray, res;
|
|
315
|
+
var updatedImages, attrForImgs, generalAttrs, retailerKey, retailerAttrs, mergedAttrs, data, valid, promiseArray, res;
|
|
316
316
|
return _regenerator.default.wrap(function _callee3$(_context3) {
|
|
317
317
|
while (1) {
|
|
318
318
|
switch (_context3.prev = _context3.next) {
|
|
@@ -326,14 +326,33 @@ var ProviderProductEditionProvider = function ProviderProductEditionProvider(_re
|
|
|
326
326
|
|
|
327
327
|
case 2:
|
|
328
328
|
updatedImages = state.updated_images_values;
|
|
329
|
+
attrForImgs = ((_state$images_values = state.images_values) === null || _state$images_values === void 0 ? void 0 : _state$images_values.attrForImgs) || {};
|
|
330
|
+
generalAttrs = attrForImgs.general || [];
|
|
331
|
+
retailerKey = Object.keys(attrForImgs).find(function (key) {
|
|
332
|
+
return key !== "general";
|
|
333
|
+
});
|
|
334
|
+
retailerAttrs = retailerKey ? attrForImgs[retailerKey] : [];
|
|
335
|
+
mergedAttrs = retailerAttrs.map(function (retailerAttr) {
|
|
336
|
+
var generalAttr = generalAttrs.find(function (g) {
|
|
337
|
+
return g.id === retailerAttr.id;
|
|
338
|
+
});
|
|
339
|
+
|
|
340
|
+
if (generalAttr && generalAttr.value !== retailerAttr.value) {
|
|
341
|
+
return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, retailerAttr), {}, {
|
|
342
|
+
value: generalAttr.value
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
return retailerAttr;
|
|
347
|
+
});
|
|
329
348
|
data = {
|
|
330
349
|
articleId: (_state$product7 = state.product) === null || _state$product7 === void 0 ? void 0 : _state$product7.id_article,
|
|
331
|
-
attrReqImgs:
|
|
332
|
-
var _e
|
|
350
|
+
attrReqImgs: mergedAttrs.map(function (e) {
|
|
351
|
+
var _e$value;
|
|
333
352
|
|
|
334
353
|
return {
|
|
335
|
-
attrId:
|
|
336
|
-
value: (_e$
|
|
354
|
+
attrId: e.id,
|
|
355
|
+
value: (_e$value = e.value) !== null && _e$value !== void 0 ? _e$value : ""
|
|
337
356
|
};
|
|
338
357
|
}),
|
|
339
358
|
articleData: state.images_values.values.filter(function (e) {
|
|
@@ -354,7 +373,7 @@ var ProviderProductEditionProvider = function ProviderProductEditionProvider(_re
|
|
|
354
373
|
});
|
|
355
374
|
|
|
356
375
|
if (!valid) {
|
|
357
|
-
_context3.next =
|
|
376
|
+
_context3.next = 38;
|
|
358
377
|
break;
|
|
359
378
|
}
|
|
360
379
|
|
|
@@ -373,7 +392,7 @@ var ProviderProductEditionProvider = function ProviderProductEditionProvider(_re
|
|
|
373
392
|
isApproved: true
|
|
374
393
|
});
|
|
375
394
|
});
|
|
376
|
-
_context3.prev =
|
|
395
|
+
_context3.prev = 16;
|
|
377
396
|
promiseArray = data.articleData.map(function (e) {
|
|
378
397
|
var file = Buffer.from(e.src.replace(/^data:image\/\w+;base64,/, ""), "base64");
|
|
379
398
|
var params = {
|
|
@@ -384,10 +403,10 @@ var ProviderProductEditionProvider = function ProviderProductEditionProvider(_re
|
|
|
384
403
|
};
|
|
385
404
|
return myBucket.putObject(params).promise();
|
|
386
405
|
});
|
|
387
|
-
_context3.next =
|
|
406
|
+
_context3.next = 20;
|
|
388
407
|
return Promise.all(promiseArray);
|
|
389
408
|
|
|
390
|
-
case
|
|
409
|
+
case 20:
|
|
391
410
|
// Eliminar el buffer base64 antes de enviar al endpoint para evitar error 413
|
|
392
411
|
data.articleData = data.articleData.map(function (_ref5) {
|
|
393
412
|
var src = _ref5.src,
|
|
@@ -399,7 +418,7 @@ var ProviderProductEditionProvider = function ProviderProductEditionProvider(_re
|
|
|
399
418
|
rest = (0, _objectWithoutProperties2.default)(_ref6, _excluded2);
|
|
400
419
|
return rest;
|
|
401
420
|
});
|
|
402
|
-
_context3.next =
|
|
421
|
+
_context3.next = 24;
|
|
403
422
|
return _axios.default.put(process.env.REACT_APP_ARTICLE_DATA_ENDPOINT, data, {
|
|
404
423
|
params: {
|
|
405
424
|
image: true,
|
|
@@ -410,7 +429,7 @@ var ProviderProductEditionProvider = function ProviderProductEditionProvider(_re
|
|
|
410
429
|
}
|
|
411
430
|
});
|
|
412
431
|
|
|
413
|
-
case
|
|
432
|
+
case 24:
|
|
414
433
|
res = _context3.sent;
|
|
415
434
|
|
|
416
435
|
if (res.data.statusCode === 200) {
|
|
@@ -418,10 +437,6 @@ var ProviderProductEditionProvider = function ProviderProductEditionProvider(_re
|
|
|
418
437
|
dispatch({
|
|
419
438
|
type: "SET_UPDATED_IMAGES_VALUES",
|
|
420
439
|
payload: []
|
|
421
|
-
});
|
|
422
|
-
dispatch({
|
|
423
|
-
type: "SET_UPDATED_ATTR_FOR_IMGS",
|
|
424
|
-
payload: []
|
|
425
440
|
}); // Mostrar modal de éxito
|
|
426
441
|
|
|
427
442
|
dispatch({
|
|
@@ -435,12 +450,12 @@ var ProviderProductEditionProvider = function ProviderProductEditionProvider(_re
|
|
|
435
450
|
});
|
|
436
451
|
}
|
|
437
452
|
|
|
438
|
-
_context3.next =
|
|
453
|
+
_context3.next = 33;
|
|
439
454
|
break;
|
|
440
455
|
|
|
441
|
-
case
|
|
442
|
-
_context3.prev =
|
|
443
|
-
_context3.t0 = _context3["catch"](
|
|
456
|
+
case 28:
|
|
457
|
+
_context3.prev = 28;
|
|
458
|
+
_context3.t0 = _context3["catch"](16);
|
|
444
459
|
console.log(_context3.t0);
|
|
445
460
|
dispatch({
|
|
446
461
|
type: "SET_ERRORS",
|
|
@@ -456,19 +471,19 @@ var ProviderProductEditionProvider = function ProviderProductEditionProvider(_re
|
|
|
456
471
|
}
|
|
457
472
|
});
|
|
458
473
|
|
|
459
|
-
case
|
|
460
|
-
_context3.prev =
|
|
474
|
+
case 33:
|
|
475
|
+
_context3.prev = 33;
|
|
461
476
|
dispatch({
|
|
462
477
|
type: "SET_SAVING",
|
|
463
478
|
payload: false
|
|
464
479
|
});
|
|
465
|
-
return _context3.finish(
|
|
480
|
+
return _context3.finish(33);
|
|
466
481
|
|
|
467
|
-
case
|
|
468
|
-
_context3.next =
|
|
482
|
+
case 36:
|
|
483
|
+
_context3.next = 39;
|
|
469
484
|
break;
|
|
470
485
|
|
|
471
|
-
case
|
|
486
|
+
case 38:
|
|
472
487
|
dispatch({
|
|
473
488
|
type: "SET_MODAL",
|
|
474
489
|
payload: {
|
|
@@ -479,12 +494,12 @@ var ProviderProductEditionProvider = function ProviderProductEditionProvider(_re
|
|
|
479
494
|
}
|
|
480
495
|
});
|
|
481
496
|
|
|
482
|
-
case
|
|
497
|
+
case 39:
|
|
483
498
|
case "end":
|
|
484
499
|
return _context3.stop();
|
|
485
500
|
}
|
|
486
501
|
}
|
|
487
|
-
}, _callee3, null, [[
|
|
502
|
+
}, _callee3, null, [[16, 28, 33, 36]]);
|
|
488
503
|
}));
|
|
489
504
|
|
|
490
505
|
return function updateImages(_x3) {
|
|
@@ -519,11 +534,11 @@ var ProviderProductEditionProvider = function ProviderProductEditionProvider(_re
|
|
|
519
534
|
data = {
|
|
520
535
|
articleId: (_state$product10 = state.product) === null || _state$product10 === void 0 ? void 0 : _state$product10.id_article,
|
|
521
536
|
attrReqImgs: attrForImgs.map(function (e) {
|
|
522
|
-
var _e$
|
|
537
|
+
var _e$value2;
|
|
523
538
|
|
|
524
539
|
return {
|
|
525
540
|
attrId: e.id,
|
|
526
|
-
value: (_e$
|
|
541
|
+
value: (_e$value2 = e.value) !== null && _e$value2 !== void 0 ? _e$value2 : "-"
|
|
527
542
|
};
|
|
528
543
|
}),
|
|
529
544
|
articleData: [],
|
package/package.json
CHANGED
package/src/components/pages/RetailerProductEdition/context/provider-product-edition.context.jsx
CHANGED
|
@@ -231,14 +231,27 @@ export const ProviderProductEditionProvider = ({ children }) => {
|
|
|
231
231
|
if (state.updated_images_values.length === 0) return;
|
|
232
232
|
const updatedImages = state.updated_images_values;
|
|
233
233
|
|
|
234
|
+
const attrForImgs = state.images_values?.attrForImgs || {};
|
|
235
|
+
const generalAttrs = attrForImgs.general || [];
|
|
236
|
+
const retailerKey = Object.keys(attrForImgs).find(
|
|
237
|
+
(key) => key !== "general",
|
|
238
|
+
);
|
|
239
|
+
const retailerAttrs = retailerKey ? attrForImgs[retailerKey] : [];
|
|
240
|
+
|
|
241
|
+
const mergedAttrs = retailerAttrs.map((retailerAttr) => {
|
|
242
|
+
const generalAttr = generalAttrs.find((g) => g.id === retailerAttr.id);
|
|
243
|
+
if (generalAttr && generalAttr.value !== retailerAttr.value) {
|
|
244
|
+
return { ...retailerAttr, value: generalAttr.value };
|
|
245
|
+
}
|
|
246
|
+
return retailerAttr;
|
|
247
|
+
});
|
|
248
|
+
|
|
234
249
|
const data = {
|
|
235
250
|
articleId: state.product?.id_article,
|
|
236
|
-
attrReqImgs:
|
|
237
|
-
.
|
|
238
|
-
.
|
|
239
|
-
|
|
240
|
-
value: e[0]?.value ?? "",
|
|
241
|
-
})),
|
|
251
|
+
attrReqImgs: mergedAttrs.map((e) => ({
|
|
252
|
+
attrId: e.id,
|
|
253
|
+
value: e.value ?? "",
|
|
254
|
+
})),
|
|
242
255
|
articleData: state.images_values.values.filter((e) => !e.id),
|
|
243
256
|
updateImages: state.images_values.values.filter((e) => e.id),
|
|
244
257
|
};
|
|
@@ -306,11 +319,6 @@ export const ProviderProductEditionProvider = ({ children }) => {
|
|
|
306
319
|
type: "SET_UPDATED_IMAGES_VALUES",
|
|
307
320
|
payload: [],
|
|
308
321
|
});
|
|
309
|
-
dispatch({
|
|
310
|
-
type: "SET_UPDATED_ATTR_FOR_IMGS",
|
|
311
|
-
payload: [],
|
|
312
|
-
});
|
|
313
|
-
|
|
314
322
|
// Mostrar modal de éxito
|
|
315
323
|
dispatch({
|
|
316
324
|
type: "SET_MODAL",
|