contentoh-components-library 21.6.29 → 21.6.31
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/ProviderProductEdition/index.js +209 -130
- package/dist/components/pages/RetailerProductEdition/context/provider-product-edition.context.js +44 -26
- package/dist/components/pages/RetailerProductEdition/index.js +600 -172
- package/dist/components/pages/RetailerProductEdition/styles.js +5 -2
- package/dist/components/pages/RetailerProductEdition/utils.js +8 -0
- package/package.json +1 -1
- package/src/components/pages/ProviderProductEdition/index.js +50 -15
- package/src/components/pages/RetailerProductEdition/context/provider-product-edition.context.jsx +22 -2
- package/src/components/pages/RetailerProductEdition/index.js +291 -2
- package/src/components/pages/RetailerProductEdition/styles.js +96 -0
- package/src/components/pages/RetailerProductEdition/utils.js +8 -0
package/dist/components/pages/RetailerProductEdition/context/provider-product-edition.context.js
CHANGED
|
@@ -190,12 +190,19 @@ var ProviderProductEditionProvider = function ProviderProductEditionProvider(_re
|
|
|
190
190
|
return _ref2.apply(this, arguments);
|
|
191
191
|
};
|
|
192
192
|
}();
|
|
193
|
+
/*
|
|
194
|
+
`propagation` es opcional y solo lo manda la ficha de un producto padre, con
|
|
195
|
+
lo que el usuario eligió en el diálogo. Sin ese bloque el backend no propaga
|
|
196
|
+
nada: bajar un cambio a las variantes es una decisión, no un efecto
|
|
197
|
+
secundario de guardar.
|
|
198
|
+
*/
|
|
199
|
+
|
|
193
200
|
|
|
194
201
|
var saveDatasheets = /*#__PURE__*/function () {
|
|
195
|
-
var _ref3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(token) {
|
|
202
|
+
var _ref3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(token, propagation) {
|
|
196
203
|
var _state$product4, _state$product5;
|
|
197
204
|
|
|
198
|
-
var dataObject, _state$product6, res, _state$active_retaile, datasheetInputs, retailerId, filledRequiredCount;
|
|
205
|
+
var dataObject, _state$product6, res, _state$services$datas, _state$services, _state$services$datas2, _state$services$datas3, _state$product7, _state$active_retaile, esVariante, datasheetInputs, retailerId, filledRequiredCount;
|
|
199
206
|
|
|
200
207
|
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
201
208
|
while (1) {
|
|
@@ -213,10 +220,12 @@ var ProviderProductEditionProvider = function ProviderProductEditionProvider(_re
|
|
|
213
220
|
type: "SET_SAVING",
|
|
214
221
|
payload: true
|
|
215
222
|
});
|
|
216
|
-
dataObject = {
|
|
223
|
+
dataObject = (0, _objectSpread2.default)({
|
|
217
224
|
articleId: (_state$product4 = state.product) === null || _state$product4 === void 0 ? void 0 : _state$product4.id_article,
|
|
218
225
|
articleData: state.updated_datasheets_inputs
|
|
219
|
-
}
|
|
226
|
+
}, propagation ? {
|
|
227
|
+
propagation: propagation
|
|
228
|
+
} : {});
|
|
220
229
|
|
|
221
230
|
if ((_state$product5 = state.product) !== null && _state$product5 !== void 0 && _state$product5.id_order) {
|
|
222
231
|
dataObject.orderId = (_state$product6 = state.product) === null || _state$product6 === void 0 ? void 0 : _state$product6.id_order;
|
|
@@ -242,10 +251,19 @@ var ProviderProductEditionProvider = function ProviderProductEditionProvider(_re
|
|
|
242
251
|
dispatch({
|
|
243
252
|
type: "SET_UPDATED_DATASHEETS_INPUTS",
|
|
244
253
|
payload: []
|
|
245
|
-
});
|
|
254
|
+
}); // En una variante, todo atributo que el hijo toca deja de ser heredado:
|
|
255
|
+
// update-articles-data le pone is_overridden = 1 en la base. Sin
|
|
256
|
+
// reflejarlo aquí, el chip sigue diciendo "Heredado" hasta la siguiente
|
|
257
|
+
// carga de la ficha, y el usuario ve una marca que ya es falsa.
|
|
258
|
+
|
|
259
|
+
esVariante = (_state$services$datas = (_state$services = state.services) === null || _state$services === void 0 ? void 0 : (_state$services$datas2 = _state$services.datasheets) === null || _state$services$datas2 === void 0 ? void 0 : (_state$services$datas3 = _state$services$datas2.variant) === null || _state$services$datas3 === void 0 ? void 0 : _state$services$datas3.isVariant) !== null && _state$services$datas !== void 0 ? _state$services$datas : !!((_state$product7 = state.product) !== null && _state$product7 !== void 0 && _state$product7.parentArticleId);
|
|
246
260
|
dispatch({
|
|
247
261
|
type: "UPDATE_DATASHEETS_INPUTS",
|
|
248
|
-
payload: state.updated_datasheets_inputs
|
|
262
|
+
payload: esVariante ? state.updated_datasheets_inputs.map(function (item) {
|
|
263
|
+
return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, item), {}, {
|
|
264
|
+
isOverridden: 1
|
|
265
|
+
});
|
|
266
|
+
}) : state.updated_datasheets_inputs
|
|
249
267
|
}); // Contar cuántos campos requeridos que antes estaban vacíos ahora tienen valor
|
|
250
268
|
|
|
251
269
|
datasheetInputs = state.datasheets_inputs[1];
|
|
@@ -305,14 +323,14 @@ var ProviderProductEditionProvider = function ProviderProductEditionProvider(_re
|
|
|
305
323
|
}, _callee2, null, [[5, 12, 16, 19]]);
|
|
306
324
|
}));
|
|
307
325
|
|
|
308
|
-
return function saveDatasheets(_x2) {
|
|
326
|
+
return function saveDatasheets(_x2, _x3) {
|
|
309
327
|
return _ref3.apply(this, arguments);
|
|
310
328
|
};
|
|
311
329
|
}();
|
|
312
330
|
|
|
313
331
|
var updateImages = /*#__PURE__*/function () {
|
|
314
332
|
var _ref4 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(token) {
|
|
315
|
-
var _state$images_values, _state$images_values$, _state$images_values2, _state$
|
|
333
|
+
var _state$images_values, _state$images_values$, _state$images_values2, _state$product8, _state$product9, _state$product10, _data$articleData, _data$updateImages;
|
|
316
334
|
|
|
317
335
|
var newImages, updatedImages, attrForImgs, generalAttrs, retailerKey, retailerAttrs, mergedAttrs, data, valid, promiseArray, res;
|
|
318
336
|
return _regenerator.default.wrap(function _callee3$(_context3) {
|
|
@@ -353,7 +371,7 @@ var ProviderProductEditionProvider = function ProviderProductEditionProvider(_re
|
|
|
353
371
|
return retailerAttr;
|
|
354
372
|
});
|
|
355
373
|
data = {
|
|
356
|
-
articleId: (_state$
|
|
374
|
+
articleId: (_state$product8 = state.product) === null || _state$product8 === void 0 ? void 0 : _state$product8.id_article,
|
|
357
375
|
attrReqImgs: mergedAttrs.map(function (e) {
|
|
358
376
|
var _e$value;
|
|
359
377
|
|
|
@@ -369,7 +387,7 @@ var ProviderProductEditionProvider = function ProviderProductEditionProvider(_re
|
|
|
369
387
|
return e.id;
|
|
370
388
|
})
|
|
371
389
|
};
|
|
372
|
-
if ((_state$
|
|
390
|
+
if ((_state$product9 = state.product) !== null && _state$product9 !== void 0 && _state$product9.orderId) data["orderId"] = (_state$product10 = state.product) === null || _state$product10 === void 0 ? void 0 : _state$product10.orderId;
|
|
373
391
|
valid = (data === null || data === void 0 ? void 0 : (_data$articleData = data.articleData) === null || _data$articleData === void 0 ? void 0 : _data$articleData.every(function (e) {
|
|
374
392
|
return e === null || e === void 0 ? void 0 : e.image_id;
|
|
375
393
|
})) && (data === null || data === void 0 ? void 0 : (_data$updateImages = data.updateImages) === null || _data$updateImages === void 0 ? void 0 : _data$updateImages.every(function (e) {
|
|
@@ -508,16 +526,16 @@ var ProviderProductEditionProvider = function ProviderProductEditionProvider(_re
|
|
|
508
526
|
}, _callee3, null, [[16, 28, 33, 36]]);
|
|
509
527
|
}));
|
|
510
528
|
|
|
511
|
-
return function updateImages(
|
|
529
|
+
return function updateImages(_x4) {
|
|
512
530
|
return _ref4.apply(this, arguments);
|
|
513
531
|
};
|
|
514
532
|
}();
|
|
515
533
|
|
|
516
534
|
var saveImageAttrs = /*#__PURE__*/function () {
|
|
517
535
|
var _ref7 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4(token) {
|
|
518
|
-
var _state$images_values$2, _state$images_values3, _state$images_values4, _state$
|
|
536
|
+
var _state$images_values$2, _state$images_values3, _state$images_values4, _state$product11, _state$product12, _state$product13;
|
|
519
537
|
|
|
520
|
-
var activeImage, attrForImgs, data, _state$
|
|
538
|
+
var activeImage, attrForImgs, data, _state$product14, _state$product15, res;
|
|
521
539
|
|
|
522
540
|
return _regenerator.default.wrap(function _callee4$(_context4) {
|
|
523
541
|
while (1) {
|
|
@@ -538,7 +556,7 @@ var ProviderProductEditionProvider = function ProviderProductEditionProvider(_re
|
|
|
538
556
|
activeImage = state.images_values.values[state.current_image];
|
|
539
557
|
attrForImgs = (_state$images_values$2 = (_state$images_values3 = state.images_values) === null || _state$images_values3 === void 0 ? void 0 : (_state$images_values4 = _state$images_values3.attrForImgs) === null || _state$images_values4 === void 0 ? void 0 : _state$images_values4.general) !== null && _state$images_values$2 !== void 0 ? _state$images_values$2 : [];
|
|
540
558
|
data = {
|
|
541
|
-
articleId: (_state$
|
|
559
|
+
articleId: (_state$product11 = state.product) === null || _state$product11 === void 0 ? void 0 : _state$product11.id_article,
|
|
542
560
|
attrReqImgs: attrForImgs.map(function (e) {
|
|
543
561
|
var _e$value2;
|
|
544
562
|
|
|
@@ -551,8 +569,8 @@ var ProviderProductEditionProvider = function ProviderProductEditionProvider(_re
|
|
|
551
569
|
updateImages: activeImage ? [activeImage] : []
|
|
552
570
|
};
|
|
553
571
|
|
|
554
|
-
if ((_state$
|
|
555
|
-
data.orderId = ((_state$
|
|
572
|
+
if ((_state$product12 = state.product) !== null && _state$product12 !== void 0 && _state$product12.orderId || (_state$product13 = state.product) !== null && _state$product13 !== void 0 && _state$product13.id_order) {
|
|
573
|
+
data.orderId = ((_state$product14 = state.product) === null || _state$product14 === void 0 ? void 0 : _state$product14.orderId) || ((_state$product15 = state.product) === null || _state$product15 === void 0 ? void 0 : _state$product15.id_order);
|
|
556
574
|
}
|
|
557
575
|
|
|
558
576
|
_context4.prev = 7;
|
|
@@ -623,15 +641,15 @@ var ProviderProductEditionProvider = function ProviderProductEditionProvider(_re
|
|
|
623
641
|
}, _callee4, null, [[7, 14, 19, 22]]);
|
|
624
642
|
}));
|
|
625
643
|
|
|
626
|
-
return function saveImageAttrs(
|
|
644
|
+
return function saveImageAttrs(_x5) {
|
|
627
645
|
return _ref7.apply(this, arguments);
|
|
628
646
|
};
|
|
629
647
|
}();
|
|
630
648
|
|
|
631
649
|
var handleOnDownloadImages = function handleOnDownloadImages() {
|
|
632
|
-
var _state$
|
|
650
|
+
var _state$product16, _state$product17, _state$product17$arti, _state$images_values5, _state$images_values6;
|
|
633
651
|
|
|
634
|
-
var upc = ((_state$
|
|
652
|
+
var upc = ((_state$product16 = state.product) === null || _state$product16 === void 0 ? void 0 : _state$product16.upc) || ((_state$product17 = state.product) === null || _state$product17 === void 0 ? void 0 : (_state$product17$arti = _state$product17.article) === null || _state$product17$arti === void 0 ? void 0 : _state$product17$arti.upc);
|
|
635
653
|
state.selected_images.length > 0 ? state.selected_images.forEach(function (e) {
|
|
636
654
|
if (e.id) {
|
|
637
655
|
saveAs("https://".concat(process.env.REACT_APP_IMAGES_BUCKET, ".s3.amazonaws.com/").concat(e.srcDB), "".concat(upc, "_").concat(e.name, ".").concat(e.ext));
|
|
@@ -645,7 +663,7 @@ var ProviderProductEditionProvider = function ProviderProductEditionProvider(_re
|
|
|
645
663
|
|
|
646
664
|
var deleteImages = /*#__PURE__*/function () {
|
|
647
665
|
var _ref8 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5(token) {
|
|
648
|
-
var imgsInBack, _state$
|
|
666
|
+
var imgsInBack, _state$product18, data;
|
|
649
667
|
|
|
650
668
|
return _regenerator.default.wrap(function _callee5$(_context5) {
|
|
651
669
|
while (1) {
|
|
@@ -666,7 +684,7 @@ var ProviderProductEditionProvider = function ProviderProductEditionProvider(_re
|
|
|
666
684
|
}
|
|
667
685
|
|
|
668
686
|
data = {
|
|
669
|
-
articleId: (_state$
|
|
687
|
+
articleId: (_state$product18 = state.product) === null || _state$product18 === void 0 ? void 0 : _state$product18.id_article,
|
|
670
688
|
deleteImages: imgsInBack
|
|
671
689
|
};
|
|
672
690
|
_context5.prev = 4;
|
|
@@ -739,14 +757,14 @@ var ProviderProductEditionProvider = function ProviderProductEditionProvider(_re
|
|
|
739
757
|
}, _callee5, null, [[4, 10, 15, 18]]);
|
|
740
758
|
}));
|
|
741
759
|
|
|
742
|
-
return function deleteImages(
|
|
760
|
+
return function deleteImages(_x6) {
|
|
743
761
|
return _ref8.apply(this, arguments);
|
|
744
762
|
};
|
|
745
763
|
}();
|
|
746
764
|
|
|
747
765
|
var createComment = /*#__PURE__*/function () {
|
|
748
766
|
var _ref9 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6(body, token) {
|
|
749
|
-
var _state$
|
|
767
|
+
var _state$product19, _state$product20, _state$product21;
|
|
750
768
|
|
|
751
769
|
var concept, data;
|
|
752
770
|
return _regenerator.default.wrap(function _callee6$(_context6) {
|
|
@@ -755,8 +773,8 @@ var ProviderProductEditionProvider = function ProviderProductEditionProvider(_re
|
|
|
755
773
|
case 0:
|
|
756
774
|
concept = (0, _utils.getConceptByTab)(state.active_tab);
|
|
757
775
|
data = {
|
|
758
|
-
articleId: (_state$
|
|
759
|
-
orderId: ((_state$
|
|
776
|
+
articleId: (_state$product19 = state.product) === null || _state$product19 === void 0 ? void 0 : _state$product19.id_article,
|
|
777
|
+
orderId: ((_state$product20 = state.product) === null || _state$product20 === void 0 ? void 0 : _state$product20.orderId) || ((_state$product21 = state.product) === null || _state$product21 === void 0 ? void 0 : _state$product21.id_order),
|
|
760
778
|
message: body,
|
|
761
779
|
concept: concept,
|
|
762
780
|
version: state.product.version
|
|
@@ -786,7 +804,7 @@ var ProviderProductEditionProvider = function ProviderProductEditionProvider(_re
|
|
|
786
804
|
}, _callee6, null, [[2, 7]]);
|
|
787
805
|
}));
|
|
788
806
|
|
|
789
|
-
return function createComment(
|
|
807
|
+
return function createComment(_x7, _x8) {
|
|
790
808
|
return _ref9.apply(this, arguments);
|
|
791
809
|
};
|
|
792
810
|
}();
|