contentoh-components-library 21.6.12 → 21.6.14
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/atoms/GeneralInput/index.js +1 -14
- package/dist/components/organisms/FullProductNameHeader/index.js +10 -9
- package/dist/components/pages/ProviderProductEdition/index.js +57 -39
- package/dist/components/pages/ProviderProductEdition/utils.js +2 -2
- package/dist/components/pages/RetailerProductEdition/context/provider-product-edition.context.js +41 -32
- package/dist/components/pages/RetailerProductEdition/index.js +227 -24
- package/dist/global-files/data.js +5 -4
- package/package.json +1 -1
- package/src/components/atoms/GeneralInput/index.js +1 -11
- package/src/components/organisms/FullProductNameHeader/index.js +20 -13
- package/src/components/pages/ProviderProductEdition/index.js +93 -66
- package/src/components/pages/ProviderProductEdition/utils.js +7 -3
- package/src/components/pages/RetailerProductEdition/context/provider-product-edition.context.jsx +22 -7
- package/src/components/pages/RetailerProductEdition/index.js +170 -39
- package/src/global-files/data.js +2 -1
|
@@ -86,19 +86,6 @@ var GeneralInput = function GeneralInput(_ref) {
|
|
|
86
86
|
_ref$handleChangeSugg = _ref.handleChangeSuggestion,
|
|
87
87
|
handleChangeSuggestion = _ref$handleChangeSugg === void 0 ? function () {} : _ref$handleChangeSugg;
|
|
88
88
|
|
|
89
|
-
var parseOptionList = function parseOptionList(list) {
|
|
90
|
-
if (Array.isArray(list)) return list;
|
|
91
|
-
if (!list) return [];
|
|
92
|
-
|
|
93
|
-
try {
|
|
94
|
-
return JSON.parse(list);
|
|
95
|
-
} catch (_unused) {
|
|
96
|
-
return String(list).split(",").map(function (s) {
|
|
97
|
-
return s.trim();
|
|
98
|
-
}).filter(Boolean);
|
|
99
|
-
}
|
|
100
|
-
};
|
|
101
|
-
|
|
102
89
|
var _useAiProductEdition = (0, _AiProductEdition.useAiProductEdition)(),
|
|
103
90
|
isCreators = _useAiProductEdition.isCreators,
|
|
104
91
|
suggestions = _useAiProductEdition.suggestions,
|
|
@@ -261,7 +248,7 @@ var GeneralInput = function GeneralInput(_ref) {
|
|
|
261
248
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("option", {
|
|
262
249
|
value: "",
|
|
263
250
|
children: description
|
|
264
|
-
}),
|
|
251
|
+
}), JSON.parse(optionList || "[]").map(function (element, index) {
|
|
265
252
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)("option", {
|
|
266
253
|
value: element,
|
|
267
254
|
children: element
|
|
@@ -22,7 +22,7 @@ var _react = require("react");
|
|
|
22
22
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
23
23
|
|
|
24
24
|
var FullProductNameHeader = function FullProductNameHeader(_ref) {
|
|
25
|
-
var _headerData$article2, _headerData$article3, _headerData$article4, _headerData$article5, _headerData$article6, _headerData$article6$, _headerData$article6$2, _headerData$categoryR2, _headerData$categoryR3, _headerData$article7;
|
|
25
|
+
var _headerData$article2, _headerData$article3, _headerData$article4, _headerData$article5, _headerData$article6, _headerData$article6$, _headerData$article6$2, _headerData$categoryR, _headerData$categoryR2, _headerData$categoryR3, _headerData$categoryR4, _headerData$article7;
|
|
26
26
|
|
|
27
27
|
var headerData = _ref.headerData,
|
|
28
28
|
percent = _ref.percent,
|
|
@@ -38,7 +38,9 @@ var FullProductNameHeader = function FullProductNameHeader(_ref) {
|
|
|
38
38
|
productObservation = _ref.productObservation,
|
|
39
39
|
isObservationVisible = _ref.isObservationVisible,
|
|
40
40
|
toggleObservation = _ref.toggleObservation,
|
|
41
|
-
hideObservation = _ref.hideObservation
|
|
41
|
+
hideObservation = _ref.hideObservation,
|
|
42
|
+
_ref$showStatus = _ref.showStatus,
|
|
43
|
+
showStatus = _ref$showStatus === void 0 ? true : _ref$showStatus;
|
|
42
44
|
|
|
43
45
|
var _useState = (0, _react.useState)([]),
|
|
44
46
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
@@ -70,19 +72,18 @@ var FullProductNameHeader = function FullProductNameHeader(_ref) {
|
|
|
70
72
|
};
|
|
71
73
|
|
|
72
74
|
(0, _react.useEffect)(function () {
|
|
73
|
-
var _headerData$article
|
|
75
|
+
var _headerData$article, _source$findIndex;
|
|
74
76
|
|
|
75
|
-
var
|
|
77
|
+
var source = (headerData === null || headerData === void 0 ? void 0 : (_headerData$article = headerData.article) === null || _headerData$article === void 0 ? void 0 : _headerData$article.categoryRetailer) || (headerData === null || headerData === void 0 ? void 0 : headerData.categoryRetailerInOrder) || (headerData === null || headerData === void 0 ? void 0 : headerData.categoryRetailer);
|
|
78
|
+
var index = (_source$findIndex = source === null || source === void 0 ? void 0 : source.findIndex(function (retailer) {
|
|
76
79
|
return (retailer === null || retailer === void 0 ? void 0 : retailer.id_retailer) === (activeRetailer === null || activeRetailer === void 0 ? void 0 : activeRetailer.id);
|
|
77
|
-
})) !== null &&
|
|
78
|
-
return (retailer === null || retailer === void 0 ? void 0 : retailer.retailer_id) === (activeRetailer === null || activeRetailer === void 0 ? void 0 : activeRetailer.id);
|
|
79
|
-
});
|
|
80
|
+
})) !== null && _source$findIndex !== void 0 ? _source$findIndex : -1;
|
|
80
81
|
setRetailerIndex(index);
|
|
81
82
|
}, [activeRetailer]);
|
|
82
83
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_styles.Container, {
|
|
83
84
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_ProductNameHeader.ProductNameHeader, {
|
|
84
85
|
productName: (headerData === null || headerData === void 0 ? void 0 : (_headerData$article2 = headerData.article) === null || _headerData$article2 === void 0 ? void 0 : _headerData$article2.name) || (headerData === null || headerData === void 0 ? void 0 : headerData.name),
|
|
85
|
-
statusType: (headerData === null || headerData === void 0 ? void 0 : headerData.version_status) || (headerData === null || headerData === void 0 ? void 0 : headerData.status) || (headerData === null || headerData === void 0 ? void 0 : headerData.article_status),
|
|
86
|
+
statusType: showStatus ? (headerData === null || headerData === void 0 ? void 0 : headerData.version_status) || (headerData === null || headerData === void 0 ? void 0 : headerData.status) || (headerData === null || headerData === void 0 ? void 0 : headerData.article_status) : null,
|
|
86
87
|
percentRequired: percent,
|
|
87
88
|
percent: percent === null || percent === void 0 ? void 0 : percent.toFixed(0),
|
|
88
89
|
priority: headerData === null || headerData === void 0 ? void 0 : headerData.prio,
|
|
@@ -104,7 +105,7 @@ var FullProductNameHeader = function FullProductNameHeader(_ref) {
|
|
|
104
105
|
value: (headerData === null || headerData === void 0 ? void 0 : (_headerData$article5 = headerData.article) === null || _headerData$article5 === void 0 ? void 0 : _headerData$article5.sku) || (headerData === null || headerData === void 0 ? void 0 : headerData.sku)
|
|
105
106
|
}, {
|
|
106
107
|
feature: "Categoría",
|
|
107
|
-
value: (headerData === null || headerData === void 0 ? void 0 : (_headerData$article6 = headerData.article) === null || _headerData$article6 === void 0 ? void 0 : (_headerData$article6$ = _headerData$article6.categoryRetailer) === null || _headerData$article6$ === void 0 ? void 0 : (_headerData$article6$2 = _headerData$article6$[retailerIndex]) === null || _headerData$article6$2 === void 0 ? void 0 : _headerData$article6$2.category_name) || (headerData === null || headerData === void 0 ? void 0 : (_headerData$
|
|
108
|
+
value: ((headerData === null || headerData === void 0 ? void 0 : (_headerData$article6 = headerData.article) === null || _headerData$article6 === void 0 ? void 0 : (_headerData$article6$ = _headerData$article6.categoryRetailer) === null || _headerData$article6$ === void 0 ? void 0 : (_headerData$article6$2 = _headerData$article6$[retailerIndex]) === null || _headerData$article6$2 === void 0 ? void 0 : _headerData$article6$2.category_name) || (headerData === null || headerData === void 0 ? void 0 : (_headerData$categoryR = headerData.categoryRetailerInOrder) === null || _headerData$categoryR === void 0 ? void 0 : (_headerData$categoryR2 = _headerData$categoryR[retailerIndex]) === null || _headerData$categoryR2 === void 0 ? void 0 : _headerData$categoryR2.category) || (headerData === null || headerData === void 0 ? void 0 : (_headerData$categoryR3 = headerData.categoryRetailer) === null || _headerData$categoryR3 === void 0 ? void 0 : (_headerData$categoryR4 = _headerData$categoryR3[retailerIndex]) === null || _headerData$categoryR4 === void 0 ? void 0 : _headerData$categoryR4.category) || headerData.categoryName || "").replace(/\|/g, " | ")
|
|
108
109
|
}, {
|
|
109
110
|
feature: "Prov",
|
|
110
111
|
value: headerData === null || headerData === void 0 ? void 0 : (_headerData$article7 = headerData.article) === null || _headerData$article7 === void 0 ? void 0 : _headerData$article7.company_name
|
|
@@ -84,7 +84,7 @@ var _AiProductEdition = require("../../../contexts/AiProductEdition");
|
|
|
84
84
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
85
85
|
|
|
86
86
|
var ProviderProductEditionView = function ProviderProductEditionView(_ref) {
|
|
87
|
-
var _location$state4, _state$product2, _state$product3, _state$product4, _state$product5, _state$product6, _state$product7, _location$state5, _location$state6, _state$active_retaile3, _state$active_retaile4, _state$images_values$2, _state$images_values10, _state$images_values11, _state$active_retaile5, _state$product11, _state$active_retaile6, _state$active_retaile7, _state$active_retaile8, _state$product12, _state$product13, _state$product14, _state$datasheets_inp, _state$datasheets_inp2, _state$product15, _state$images_values12;
|
|
87
|
+
var _location$state4, _state$product2, _state$product3, _state$product4, _state$product5, _state$product6, _state$product7, _location$state5, _location$state6, _state$active_retaile3, _state$active_retaile4, _state$images_values$2, _state$images_values10, _state$images_values11, _state$active_retaile5, _state$product11, _state$active_percent, _state$active_percent2, _state$active_retaile6, _state$active_retaile7, _state$active_retaile8, _state$product12, _state$descriptions_i, _state$product13, _state$product14, _state$datasheets_inp, _state$datasheets_inp2, _state$datasheets_inp3, _state$product15, _state$images_values12;
|
|
88
88
|
|
|
89
89
|
var tabsSections = _ref.tabsSections,
|
|
90
90
|
_ref$productSelected = _ref.productSelected,
|
|
@@ -290,7 +290,7 @@ var ProviderProductEditionView = function ProviderProductEditionView(_ref) {
|
|
|
290
290
|
|
|
291
291
|
var fetchData = /*#__PURE__*/function () {
|
|
292
292
|
var _ref3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
|
|
293
|
-
var
|
|
293
|
+
var _ref4, _percentageRaw$, _JSON$parse, _JSON$parse$, _percentageRaw$body, _services$2$inputsByR, _services$2$values, _state$product$percen, data, headers, _yield$Promise$all, _yield$Promise$all2, services, percentageRes, servicesDataRes, percentageRaw, percentages, orderMap, orderedValues, updatedStatusByRetailer, getServiceMinorStatus, imagesMinorStatus, descriptionMinorStatus, datasheetMinorStatus, activePercentage;
|
|
294
294
|
|
|
295
295
|
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
296
296
|
while (1) {
|
|
@@ -329,7 +329,8 @@ var ProviderProductEditionView = function ProviderProductEditionView(_ref) {
|
|
|
329
329
|
services = _yield$Promise$all2[0];
|
|
330
330
|
percentageRes = _yield$Promise$all2[1];
|
|
331
331
|
servicesDataRes = _yield$Promise$all2[2];
|
|
332
|
-
|
|
332
|
+
percentageRaw = percentageRes === null || percentageRes === void 0 ? void 0 : percentageRes[0];
|
|
333
|
+
percentages = (_ref4 = Array.isArray(percentageRaw) ? (_percentageRaw$ = percentageRaw[0]) === null || _percentageRaw$ === void 0 ? void 0 : _percentageRaw$.relations : (_JSON$parse = JSON.parse((_percentageRaw$body = percentageRaw === null || percentageRaw === void 0 ? void 0 : percentageRaw.body) !== null && _percentageRaw$body !== void 0 ? _percentageRaw$body : "null")) === null || _JSON$parse === void 0 ? void 0 : (_JSON$parse$ = _JSON$parse[0]) === null || _JSON$parse$ === void 0 ? void 0 : _JSON$parse$.relations) !== null && _ref4 !== void 0 ? _ref4 : [];
|
|
333
334
|
orderMap = (_services$2$inputsByR = services[2].inputsByRetailer) !== null && _services$2$inputsByR !== void 0 ? _services$2$inputsByR : [].flat().reduce(function (acc, item) {
|
|
334
335
|
acc[item.id_image] = item.order;
|
|
335
336
|
return acc;
|
|
@@ -394,18 +395,22 @@ var ProviderProductEditionView = function ProviderProductEditionView(_ref) {
|
|
|
394
395
|
type: "SET_PERCENTAGES",
|
|
395
396
|
payload: percentages
|
|
396
397
|
});
|
|
398
|
+
activePercentage = percentages.find(function (_ref5) {
|
|
399
|
+
var rId = _ref5.id_retailer;
|
|
400
|
+
return rId === id_retailer;
|
|
401
|
+
}) || ((_state$product$percen = state.product.percentages) === null || _state$product$percen === void 0 ? void 0 : _state$product$percen.find(function (_ref6) {
|
|
402
|
+
var rId = _ref6.id_retailer;
|
|
403
|
+
return rId === id_retailer;
|
|
404
|
+
}));
|
|
397
405
|
dispatch({
|
|
398
406
|
type: "SET_ACTIVE_PERCENTAGES",
|
|
399
|
-
payload:
|
|
400
|
-
var rId = _ref4.id_retailer;
|
|
401
|
-
return rId === id_retailer;
|
|
402
|
-
})
|
|
407
|
+
payload: activePercentage
|
|
403
408
|
});
|
|
404
|
-
_context2.next =
|
|
409
|
+
_context2.next = 32;
|
|
405
410
|
break;
|
|
406
411
|
|
|
407
|
-
case
|
|
408
|
-
_context2.prev =
|
|
412
|
+
case 28:
|
|
413
|
+
_context2.prev = 28;
|
|
409
414
|
_context2.t0 = _context2["catch"](1);
|
|
410
415
|
console.error("Error fetching data:", _context2.t0);
|
|
411
416
|
dispatch({
|
|
@@ -413,20 +418,20 @@ var ProviderProductEditionView = function ProviderProductEditionView(_ref) {
|
|
|
413
418
|
payload: _context2.t0
|
|
414
419
|
});
|
|
415
420
|
|
|
416
|
-
case
|
|
417
|
-
_context2.prev =
|
|
421
|
+
case 32:
|
|
422
|
+
_context2.prev = 32;
|
|
418
423
|
dispatch({
|
|
419
424
|
type: "SET_LOADING",
|
|
420
425
|
payload: false
|
|
421
426
|
});
|
|
422
|
-
return _context2.finish(
|
|
427
|
+
return _context2.finish(32);
|
|
423
428
|
|
|
424
|
-
case
|
|
429
|
+
case 35:
|
|
425
430
|
case "end":
|
|
426
431
|
return _context2.stop();
|
|
427
432
|
}
|
|
428
433
|
}
|
|
429
|
-
}, _callee2, null, [[1,
|
|
434
|
+
}, _callee2, null, [[1, 28, 32, 35]]);
|
|
430
435
|
}));
|
|
431
436
|
|
|
432
437
|
return function fetchData() {
|
|
@@ -446,13 +451,21 @@ var ProviderProductEditionView = function ProviderProductEditionView(_ref) {
|
|
|
446
451
|
|
|
447
452
|
if (state.services.datasheets) {
|
|
448
453
|
var retailerDatasheets = state.services.datasheets[state.active_retailer.id_retailer];
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
454
|
+
|
|
455
|
+
if (retailerDatasheets) {
|
|
456
|
+
var datasheetsActiveRetailer = (0, _objectSpread4.default)((0, _objectSpread4.default)({}, retailerDatasheets), {}, {
|
|
457
|
+
data: Object.values(retailerDatasheets.data)
|
|
458
|
+
});
|
|
459
|
+
dispatch({
|
|
460
|
+
type: "SET_DATASHEETS_INPUTS",
|
|
461
|
+
payload: [datasheetsActiveRetailer, state.services.datasheets.inputs]
|
|
462
|
+
});
|
|
463
|
+
} else {
|
|
464
|
+
dispatch({
|
|
465
|
+
type: "SET_DATASHEETS_INPUTS",
|
|
466
|
+
payload: []
|
|
467
|
+
});
|
|
468
|
+
}
|
|
456
469
|
}
|
|
457
470
|
|
|
458
471
|
if (state.services.descriptions) {
|
|
@@ -831,7 +844,7 @@ var ProviderProductEditionView = function ProviderProductEditionView(_ref) {
|
|
|
831
844
|
};
|
|
832
845
|
|
|
833
846
|
var sendEvaluation = /*#__PURE__*/function () {
|
|
834
|
-
var
|
|
847
|
+
var _ref7 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(result) {
|
|
835
848
|
var _state$product$id_ord, _state$active_retaile2, _state$product$status, _state$product$status2, _state$product10;
|
|
836
849
|
|
|
837
850
|
var concept, articleId, orderId, retailerId, evalStatus, data, _newStatuses$newStatu, _state$services_data, res, newStatuses, serviceStatus, updatedStatusByRetailer, updatedProduct, updatedServicesData;
|
|
@@ -943,12 +956,12 @@ var ProviderProductEditionView = function ProviderProductEditionView(_ref) {
|
|
|
943
956
|
}));
|
|
944
957
|
|
|
945
958
|
return function sendEvaluation(_x2) {
|
|
946
|
-
return
|
|
959
|
+
return _ref7.apply(this, arguments);
|
|
947
960
|
};
|
|
948
961
|
}();
|
|
949
962
|
|
|
950
963
|
var evaluationToRetailer = /*#__PURE__*/function () {
|
|
951
|
-
var
|
|
964
|
+
var _ref8 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4(result) {
|
|
952
965
|
var data, statusComplete, updatedProduct;
|
|
953
966
|
return _regenerator.default.wrap(function _callee4$(_context4) {
|
|
954
967
|
while (1) {
|
|
@@ -1029,7 +1042,7 @@ var ProviderProductEditionView = function ProviderProductEditionView(_ref) {
|
|
|
1029
1042
|
}));
|
|
1030
1043
|
|
|
1031
1044
|
return function evaluationToRetailer(_x3) {
|
|
1032
|
-
return
|
|
1045
|
+
return _ref8.apply(this, arguments);
|
|
1033
1046
|
};
|
|
1034
1047
|
}();
|
|
1035
1048
|
|
|
@@ -1160,7 +1173,7 @@ var ProviderProductEditionView = function ProviderProductEditionView(_ref) {
|
|
|
1160
1173
|
};
|
|
1161
1174
|
|
|
1162
1175
|
var handleOnEvaluateAll = /*#__PURE__*/function () {
|
|
1163
|
-
var
|
|
1176
|
+
var _ref9 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5(result) {
|
|
1164
1177
|
var _state$product$id_ord2, _state$services_data2, evaluationArray, conceptArray, dataGeneral, isProvider, userType, status, updatedStatusByRetailer, updatedProduct;
|
|
1165
1178
|
|
|
1166
1179
|
return _regenerator.default.wrap(function _callee5$(_context5) {
|
|
@@ -1282,7 +1295,7 @@ var ProviderProductEditionView = function ProviderProductEditionView(_ref) {
|
|
|
1282
1295
|
}));
|
|
1283
1296
|
|
|
1284
1297
|
return function handleOnEvaluateAll(_x4) {
|
|
1285
|
-
return
|
|
1298
|
+
return _ref9.apply(this, arguments);
|
|
1286
1299
|
};
|
|
1287
1300
|
}();
|
|
1288
1301
|
|
|
@@ -1488,7 +1501,7 @@ var ProviderProductEditionView = function ProviderProductEditionView(_ref) {
|
|
|
1488
1501
|
className: "product-information",
|
|
1489
1502
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_FullProductNameHeader.FullProductNameHeader, {
|
|
1490
1503
|
headerData: state.product,
|
|
1491
|
-
percent: state.active_percentage.percentagesGeneral.required,
|
|
1504
|
+
percent: (_state$active_percent = state.active_percentage) === null || _state$active_percent === void 0 ? void 0 : (_state$active_percent2 = _state$active_percent.percentagesGeneral) === null || _state$active_percent2 === void 0 ? void 0 : _state$active_percent2.required,
|
|
1492
1505
|
activeRetailer: {
|
|
1493
1506
|
id: (_state$active_retaile6 = state.active_retailer) === null || _state$active_retaile6 === void 0 ? void 0 : _state$active_retaile6.id_retailer,
|
|
1494
1507
|
name: (_state$active_retaile7 = state.active_retailer) === null || _state$active_retaile7 === void 0 ? void 0 : _state$active_retaile7.retailer,
|
|
@@ -1503,7 +1516,8 @@ var ProviderProductEditionView = function ProviderProductEditionView(_ref) {
|
|
|
1503
1516
|
return handleOnSendEvaluation("A");
|
|
1504
1517
|
},
|
|
1505
1518
|
reject: handleOnReject,
|
|
1506
|
-
setActiveRetailer: handleOnChangeActiveRetailer
|
|
1519
|
+
setActiveRetailer: handleOnChangeActiveRetailer,
|
|
1520
|
+
showStatus: false
|
|
1507
1521
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_FullTabsMenu.FullTabsMenu, {
|
|
1508
1522
|
tabsSections: tabsSections,
|
|
1509
1523
|
status: getStatusByCurrentServiceAndRetailer(),
|
|
@@ -1535,7 +1549,7 @@ var ProviderProductEditionView = function ProviderProductEditionView(_ref) {
|
|
|
1535
1549
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
1536
1550
|
className: "services-information-container " + (imageLayout && state.active_tab === "Imágenes" ? "image-services" : ""),
|
|
1537
1551
|
children: state.saving ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_Loading.Loading, {}) : /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
1538
|
-
children: [state.active_tab === "Descripción" && (((_state$product12 = state.product) === null || _state$product12 === void 0 ? void 0 : _state$product12.description_status) !== "NS" ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_InputGroup.InputGroup, {
|
|
1552
|
+
children: [state.active_tab === "Descripción" && (((_state$product12 = state.product) === null || _state$product12 === void 0 ? void 0 : _state$product12.description_status) !== "NS" ? (_state$descriptions_i = state.descriptions_inputs) !== null && _state$descriptions_i !== void 0 && _state$descriptions_i[0] ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_InputGroup.InputGroup, {
|
|
1539
1553
|
activeSection: state.active_tab,
|
|
1540
1554
|
inputGroup: state.descriptions_inputs[0],
|
|
1541
1555
|
updatedDescriptions: state.updated_descriptions_inputs,
|
|
@@ -1544,14 +1558,16 @@ var ProviderProductEditionView = function ProviderProductEditionView(_ref) {
|
|
|
1544
1558
|
isShowbox: false,
|
|
1545
1559
|
dinamicHeight: true,
|
|
1546
1560
|
setUpdatedDescriptions: handleOnSetUpdatedDescriptions,
|
|
1547
|
-
updateApprovedInputs: handleOnUpdateApprovedInputs
|
|
1548
|
-
|
|
1561
|
+
updateApprovedInputs: handleOnUpdateApprovedInputs
|
|
1562
|
+
}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_ScreenHeader.ScreenHeader, {
|
|
1563
|
+
text: "No hay descripción para esta cadena",
|
|
1564
|
+
headerType: "input-name-header"
|
|
1549
1565
|
}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_ScreenHeader.ScreenHeader, {
|
|
1550
1566
|
text: "No cuentas con este servicio",
|
|
1551
1567
|
headerType: "input-name-header"
|
|
1552
1568
|
})), state.active_tab === "Ficha técnica" && (((_state$product14 = state.product) === null || _state$product14 === void 0 ? void 0 : _state$product14.datasheet_status) !== "NS" ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
|
|
1553
|
-
children: (_state$datasheets_inp = state.datasheets_inputs
|
|
1554
|
-
var _state$
|
|
1569
|
+
children: ((_state$datasheets_inp = state.datasheets_inputs) === null || _state$datasheets_inp === void 0 ? void 0 : (_state$datasheets_inp2 = _state$datasheets_inp[0]) === null || _state$datasheets_inp2 === void 0 ? void 0 : (_state$datasheets_inp3 = _state$datasheets_inp2.data) === null || _state$datasheets_inp3 === void 0 ? void 0 : _state$datasheets_inp3.length) > 0 ? state.datasheets_inputs[0].data.map(function (dataGroup, index) {
|
|
1570
|
+
var _state$datasheets_inp4, _state$services$datas;
|
|
1555
1571
|
|
|
1556
1572
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_InputGroup.InputGroup, {
|
|
1557
1573
|
index: index,
|
|
@@ -1559,18 +1575,20 @@ var ProviderProductEditionView = function ProviderProductEditionView(_ref) {
|
|
|
1559
1575
|
version: state.version,
|
|
1560
1576
|
activeSection: state.active_tab,
|
|
1561
1577
|
inputGroup: dataGroup,
|
|
1562
|
-
dataInputs: (_state$
|
|
1578
|
+
dataInputs: (_state$datasheets_inp4 = state.datasheets_inputs[1]) !== null && _state$datasheets_inp4 !== void 0 ? _state$datasheets_inp4 : [],
|
|
1563
1579
|
activeRetailer: state.services.datasheets[state.active_retailer.id_retailer],
|
|
1564
|
-
groupData: state.services.datasheets[state.active_retailer.id_retailer].data,
|
|
1580
|
+
groupData: (_state$services$datas = state.services.datasheets[state.active_retailer.id_retailer]) === null || _state$services$datas === void 0 ? void 0 : _state$services$datas.data,
|
|
1565
1581
|
updatedDatasheets: state.updated_datasheets_inputs,
|
|
1566
1582
|
setUpdatedDatasheets: handleOnSetUpdatedDatasheets,
|
|
1567
1583
|
isShowbox: true,
|
|
1568
1584
|
setUpdatedBoxData: function setUpdatedBoxData(e) {
|
|
1569
1585
|
setBoxData(e);
|
|
1570
1586
|
},
|
|
1571
|
-
updateApprovedInputs: handleOnUpdateApprovedInputs
|
|
1572
|
-
|
|
1587
|
+
updateApprovedInputs: handleOnUpdateApprovedInputs
|
|
1573
1588
|
}, index + "-" + state.active_retailer.retailer);
|
|
1589
|
+
}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_ScreenHeader.ScreenHeader, {
|
|
1590
|
+
text: "No hay ficha técnica para esta cadena",
|
|
1591
|
+
headerType: "input-name-header"
|
|
1574
1592
|
})
|
|
1575
1593
|
}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_ScreenHeader.ScreenHeader, {
|
|
1576
1594
|
text: "No cuentas con este servicio",
|
|
@@ -25,9 +25,9 @@ var normalizeProduct = function normalizeProduct(product) {
|
|
|
25
25
|
var retailersIdsFromStatusByRetailer = Object.keys(productData.statusByRetailer || {}).map(function (id) {
|
|
26
26
|
return parseInt(id, 10);
|
|
27
27
|
});
|
|
28
|
-
var categoryRetailerInOrder = categoryRetailerNormalized.filter(function (rel) {
|
|
28
|
+
var categoryRetailerInOrder = categoryRetailerNormalized ? retailersIdsFromStatusByRetailer.length > 0 ? categoryRetailerNormalized.filter(function (rel) {
|
|
29
29
|
return retailersIdsFromStatusByRetailer.includes(rel.id_retailer);
|
|
30
|
-
});
|
|
30
|
+
}) : categoryRetailerNormalized : [];
|
|
31
31
|
return {
|
|
32
32
|
// from products
|
|
33
33
|
id_article: productData.id_article || article.id_article || 0,
|
package/dist/components/pages/RetailerProductEdition/context/provider-product-edition.context.js
CHANGED
|
@@ -33,12 +33,14 @@ var _genericModalCheck = _interopRequireDefault(require("../../../../assets/imag
|
|
|
33
33
|
|
|
34
34
|
var _errorModal = _interopRequireDefault(require("../../../../assets/images/genericModal/errorModal.svg"));
|
|
35
35
|
|
|
36
|
+
var _genericModalWarning = _interopRequireDefault(require("../../../../assets/images/genericModal/genericModalWarning.svg"));
|
|
37
|
+
|
|
36
38
|
var _utils = require("../utils");
|
|
37
39
|
|
|
38
40
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
39
41
|
|
|
40
|
-
var _excluded = ["src"],
|
|
41
|
-
_excluded2 = ["src"];
|
|
42
|
+
var _excluded = ["src", "video_src"],
|
|
43
|
+
_excluded2 = ["src", "video_src"];
|
|
42
44
|
var S3_BUCKET = process.env.REACT_APP_IMAGES_BUCKET;
|
|
43
45
|
var REGION = "us-east-1";
|
|
44
46
|
|
|
@@ -310,23 +312,28 @@ var ProviderProductEditionProvider = function ProviderProductEditionProvider(_re
|
|
|
310
312
|
|
|
311
313
|
var updateImages = /*#__PURE__*/function () {
|
|
312
314
|
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;
|
|
315
|
+
var _state$images_values, _state$images_values$, _state$images_values2, _state$product7, _state$product8, _state$product9, _data$articleData, _data$updateImages;
|
|
314
316
|
|
|
315
|
-
var updatedImages, attrForImgs, generalAttrs, retailerKey, retailerAttrs, mergedAttrs, data, valid, promiseArray, res;
|
|
317
|
+
var newImages, updatedImages, attrForImgs, generalAttrs, retailerKey, retailerAttrs, mergedAttrs, data, valid, promiseArray, res;
|
|
316
318
|
return _regenerator.default.wrap(function _callee3$(_context3) {
|
|
317
319
|
while (1) {
|
|
318
320
|
switch (_context3.prev = _context3.next) {
|
|
319
321
|
case 0:
|
|
320
|
-
|
|
321
|
-
|
|
322
|
+
// Imágenes/videos recién agregados a la galería (aún sin id en BD).
|
|
323
|
+
newImages = ((_state$images_values = state.images_values) === null || _state$images_values === void 0 ? void 0 : (_state$images_values$ = _state$images_values.values) === null || _state$images_values$ === void 0 ? void 0 : _state$images_values$.filter(function (e) {
|
|
324
|
+
return !e.id;
|
|
325
|
+
})) || []; // Salir solo si no hay nada que crear ni que actualizar.
|
|
326
|
+
|
|
327
|
+
if (!(state.updated_images_values.length === 0 && newImages.length === 0)) {
|
|
328
|
+
_context3.next = 3;
|
|
322
329
|
break;
|
|
323
330
|
}
|
|
324
331
|
|
|
325
332
|
return _context3.abrupt("return");
|
|
326
333
|
|
|
327
|
-
case
|
|
334
|
+
case 3:
|
|
328
335
|
updatedImages = state.updated_images_values;
|
|
329
|
-
attrForImgs = ((_state$
|
|
336
|
+
attrForImgs = ((_state$images_values2 = state.images_values) === null || _state$images_values2 === void 0 ? void 0 : _state$images_values2.attrForImgs) || {};
|
|
330
337
|
generalAttrs = attrForImgs.general || [];
|
|
331
338
|
retailerKey = Object.keys(attrForImgs).find(function (key) {
|
|
332
339
|
return key !== "general";
|
|
@@ -370,7 +377,7 @@ var ProviderProductEditionProvider = function ProviderProductEditionProvider(_re
|
|
|
370
377
|
})); // console.log({ data });
|
|
371
378
|
|
|
372
379
|
if (!valid) {
|
|
373
|
-
_context3.next =
|
|
380
|
+
_context3.next = 38;
|
|
374
381
|
break;
|
|
375
382
|
}
|
|
376
383
|
|
|
@@ -389,9 +396,9 @@ var ProviderProductEditionProvider = function ProviderProductEditionProvider(_re
|
|
|
389
396
|
isApproved: true
|
|
390
397
|
});
|
|
391
398
|
});
|
|
392
|
-
_context3.prev =
|
|
399
|
+
_context3.prev = 16;
|
|
393
400
|
promiseArray = data.articleData.map(function (e) {
|
|
394
|
-
var file = Buffer.from(e.src.replace(/^data:image\/\w+;base64,/, ""), "base64");
|
|
401
|
+
var file = e.ext === "mp4" ? Buffer.from((e.video_src || "").replace(/^data:video\/\w+;base64,/, ""), "base64") : Buffer.from(e.src.replace(/^data:image\/\w+;base64,/, ""), "base64");
|
|
395
402
|
var params = {
|
|
396
403
|
ACL: "public-read",
|
|
397
404
|
Body: file,
|
|
@@ -400,22 +407,24 @@ var ProviderProductEditionProvider = function ProviderProductEditionProvider(_re
|
|
|
400
407
|
};
|
|
401
408
|
return myBucket.putObject(params).promise();
|
|
402
409
|
});
|
|
403
|
-
_context3.next =
|
|
410
|
+
_context3.next = 20;
|
|
404
411
|
return Promise.all(promiseArray);
|
|
405
412
|
|
|
406
|
-
case
|
|
413
|
+
case 20:
|
|
407
414
|
// Eliminar el buffer base64 antes de enviar al endpoint para evitar error 413
|
|
408
415
|
data.articleData = data.articleData.map(function (_ref5) {
|
|
409
416
|
var src = _ref5.src,
|
|
417
|
+
video_src = _ref5.video_src,
|
|
410
418
|
rest = (0, _objectWithoutProperties2.default)(_ref5, _excluded);
|
|
411
419
|
return rest;
|
|
412
420
|
});
|
|
413
421
|
data.updateImages = data.updateImages.map(function (_ref6) {
|
|
414
422
|
var src = _ref6.src,
|
|
423
|
+
video_src = _ref6.video_src,
|
|
415
424
|
rest = (0, _objectWithoutProperties2.default)(_ref6, _excluded2);
|
|
416
425
|
return rest;
|
|
417
426
|
});
|
|
418
|
-
_context3.next =
|
|
427
|
+
_context3.next = 24;
|
|
419
428
|
return _axios.default.put(process.env.REACT_APP_ARTICLE_DATA_ENDPOINT, data, {
|
|
420
429
|
params: {
|
|
421
430
|
image: true,
|
|
@@ -426,7 +435,7 @@ var ProviderProductEditionProvider = function ProviderProductEditionProvider(_re
|
|
|
426
435
|
}
|
|
427
436
|
});
|
|
428
437
|
|
|
429
|
-
case
|
|
438
|
+
case 24:
|
|
430
439
|
res = _context3.sent;
|
|
431
440
|
|
|
432
441
|
if (res.data.statusCode === 200) {
|
|
@@ -447,12 +456,12 @@ var ProviderProductEditionProvider = function ProviderProductEditionProvider(_re
|
|
|
447
456
|
});
|
|
448
457
|
}
|
|
449
458
|
|
|
450
|
-
_context3.next =
|
|
459
|
+
_context3.next = 33;
|
|
451
460
|
break;
|
|
452
461
|
|
|
453
|
-
case
|
|
454
|
-
_context3.prev =
|
|
455
|
-
_context3.t0 = _context3["catch"](
|
|
462
|
+
case 28:
|
|
463
|
+
_context3.prev = 28;
|
|
464
|
+
_context3.t0 = _context3["catch"](16);
|
|
456
465
|
console.log(_context3.t0);
|
|
457
466
|
dispatch({
|
|
458
467
|
type: "SET_ERRORS",
|
|
@@ -468,35 +477,35 @@ var ProviderProductEditionProvider = function ProviderProductEditionProvider(_re
|
|
|
468
477
|
}
|
|
469
478
|
});
|
|
470
479
|
|
|
471
|
-
case
|
|
472
|
-
_context3.prev =
|
|
480
|
+
case 33:
|
|
481
|
+
_context3.prev = 33;
|
|
473
482
|
dispatch({
|
|
474
483
|
type: "SET_SAVING",
|
|
475
484
|
payload: false
|
|
476
485
|
});
|
|
477
|
-
return _context3.finish(
|
|
486
|
+
return _context3.finish(33);
|
|
478
487
|
|
|
479
|
-
case
|
|
480
|
-
_context3.next =
|
|
488
|
+
case 36:
|
|
489
|
+
_context3.next = 39;
|
|
481
490
|
break;
|
|
482
491
|
|
|
483
|
-
case
|
|
492
|
+
case 38:
|
|
484
493
|
dispatch({
|
|
485
494
|
type: "SET_MODAL",
|
|
486
495
|
payload: {
|
|
487
496
|
show: true,
|
|
488
497
|
title: "Campos incompletos o duplicados",
|
|
489
498
|
message: "Completa los campos que solicita cada una de la imágenes o hay imágenes con el mismo tipo de toma. Recuerda hay campos obligatorios y no podras avanzar si no estan completos.",
|
|
490
|
-
image:
|
|
499
|
+
image: _genericModalWarning.default
|
|
491
500
|
}
|
|
492
501
|
});
|
|
493
502
|
|
|
494
|
-
case
|
|
503
|
+
case 39:
|
|
495
504
|
case "end":
|
|
496
505
|
return _context3.stop();
|
|
497
506
|
}
|
|
498
507
|
}
|
|
499
|
-
}, _callee3, null, [[
|
|
508
|
+
}, _callee3, null, [[16, 28, 33, 36]]);
|
|
500
509
|
}));
|
|
501
510
|
|
|
502
511
|
return function updateImages(_x3) {
|
|
@@ -506,7 +515,7 @@ var ProviderProductEditionProvider = function ProviderProductEditionProvider(_re
|
|
|
506
515
|
|
|
507
516
|
var saveImageAttrs = /*#__PURE__*/function () {
|
|
508
517
|
var _ref7 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4(token) {
|
|
509
|
-
var _state$images_values
|
|
518
|
+
var _state$images_values$2, _state$images_values3, _state$images_values4, _state$product10, _state$product11, _state$product12;
|
|
510
519
|
|
|
511
520
|
var activeImage, attrForImgs, data, _state$product13, _state$product14, res;
|
|
512
521
|
|
|
@@ -527,7 +536,7 @@ var ProviderProductEditionProvider = function ProviderProductEditionProvider(_re
|
|
|
527
536
|
payload: true
|
|
528
537
|
});
|
|
529
538
|
activeImage = state.images_values.values[state.current_image];
|
|
530
|
-
attrForImgs = (_state$images_values$ = (_state$
|
|
539
|
+
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 : [];
|
|
531
540
|
data = {
|
|
532
541
|
articleId: (_state$product10 = state.product) === null || _state$product10 === void 0 ? void 0 : _state$product10.id_article,
|
|
533
542
|
attrReqImgs: attrForImgs.map(function (e) {
|
|
@@ -620,14 +629,14 @@ var ProviderProductEditionProvider = function ProviderProductEditionProvider(_re
|
|
|
620
629
|
}();
|
|
621
630
|
|
|
622
631
|
var handleOnDownloadImages = function handleOnDownloadImages() {
|
|
623
|
-
var _state$product15, _state$product16, _state$product16$arti, _state$
|
|
632
|
+
var _state$product15, _state$product16, _state$product16$arti, _state$images_values5, _state$images_values6;
|
|
624
633
|
|
|
625
634
|
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);
|
|
626
635
|
state.selected_images.length > 0 ? state.selected_images.forEach(function (e) {
|
|
627
636
|
if (e.id) {
|
|
628
637
|
saveAs("https://".concat(process.env.REACT_APP_IMAGES_BUCKET, ".s3.amazonaws.com/").concat(e.srcDB), "".concat(upc, "_").concat(e.name, ".").concat(e.ext));
|
|
629
638
|
}
|
|
630
|
-
}) : (_state$
|
|
639
|
+
}) : (_state$images_values5 = state.images_values) === null || _state$images_values5 === void 0 ? void 0 : (_state$images_values6 = _state$images_values5.values) === null || _state$images_values6 === void 0 ? void 0 : _state$images_values6.forEach(function (e) {
|
|
631
640
|
if (e.id) {
|
|
632
641
|
saveAs("https://".concat(process.env.REACT_APP_IMAGES_BUCKET, ".s3.amazonaws.com/").concat(e.srcDB), "".concat(upc, "_").concat(e.name, ".").concat(e.ext));
|
|
633
642
|
}
|