contentoh-components-library 21.5.93 → 21.5.94
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.
|
@@ -80,7 +80,7 @@ var _styles = require("./styles");
|
|
|
80
80
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
81
81
|
|
|
82
82
|
var ProviderProductEditionView = function ProviderProductEditionView(_ref) {
|
|
83
|
-
var _location$state4, _location$state5, _location$state6, _state$active_retaile3, _state$active_retaile4, _state$images_values$2, _state$images_values10, _state$images_values11, _state$active_retaile5, _state$product5, _state$active_retaile6, _state$active_retaile7, _state$active_retaile8, _state$product6, _state$product7, _state$product8, _state$datasheets_inp, _state$
|
|
83
|
+
var _location$state4, _location$state5, _location$state6, _state$active_retaile3, _state$active_retaile4, _state$images_values$2, _state$images_values10, _state$images_values11, _state$active_retaile5, _state$product5, _state$active_retaile6, _state$active_retaile7, _state$active_retaile8, _state$product6, _state$product7, _state$product8, _state$datasheets_inp, _state$product9, _state$images_values12;
|
|
84
84
|
|
|
85
85
|
var tabsSections = _ref.tabsSections,
|
|
86
86
|
_ref$productSelected = _ref.productSelected,
|
|
@@ -244,16 +244,24 @@ var ProviderProductEditionView = function ProviderProductEditionView(_ref) {
|
|
|
244
244
|
type: "SET_PRODUCT",
|
|
245
245
|
payload: productNormalized
|
|
246
246
|
});
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
247
|
+
|
|
248
|
+
if (productNormalized.categoryRetailerInOrder.length > 0 && productNormalized.statusByRetailer) {
|
|
249
|
+
dispatch({
|
|
250
|
+
type: "SET_ACTIVE_RETAILER",
|
|
251
|
+
payload: productNormalized.categoryRetailerInOrder[0]
|
|
252
|
+
});
|
|
253
|
+
var firstRetailerStatus = productNormalized.statusByRetailer[productNormalized.categoryRetailerInOrder[0].id_retailer];
|
|
254
|
+
var initialTab = firstRetailerStatus.description ? "Descripción" : firstRetailerStatus.datasheet ? "Ficha técnica" : firstRetailerStatus.images ? "Imágenes" : "Imágenes";
|
|
255
|
+
dispatch({
|
|
256
|
+
type: "SET_ACTIVE_TAB",
|
|
257
|
+
payload: initialTab
|
|
258
|
+
});
|
|
259
|
+
} else {
|
|
260
|
+
dispatch({
|
|
261
|
+
type: "SET_ACTIVE_RETAILER",
|
|
262
|
+
payload: productNormalized.categoryRetailer[0]
|
|
263
|
+
});
|
|
264
|
+
}
|
|
257
265
|
} catch (error) {
|
|
258
266
|
console.log("Error setting product data: ", error);
|
|
259
267
|
}
|
|
@@ -276,7 +284,7 @@ var ProviderProductEditionView = function ProviderProductEditionView(_ref) {
|
|
|
276
284
|
|
|
277
285
|
var fetchData = /*#__PURE__*/function () {
|
|
278
286
|
var _ref3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
|
|
279
|
-
var _JSON$parse$0$relatio, _JSON$parse, _JSON$parse$, _percentageRes$, data, headers, _yield$Promise$all, _yield$Promise$all2, services, percentageRes, servicesDataRes, percentages, orderMap, orderedValues;
|
|
287
|
+
var _JSON$parse$0$relatio, _JSON$parse, _JSON$parse$, _percentageRes$, _services$2$inputsByR, _services$2$values, data, headers, _yield$Promise$all, _yield$Promise$all2, services, percentageRes, servicesDataRes, percentages, orderMap, orderedValues;
|
|
280
288
|
|
|
281
289
|
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
282
290
|
while (1) {
|
|
@@ -316,11 +324,11 @@ var ProviderProductEditionView = function ProviderProductEditionView(_ref) {
|
|
|
316
324
|
percentageRes = _yield$Promise$all2[1];
|
|
317
325
|
servicesDataRes = _yield$Promise$all2[2];
|
|
318
326
|
percentages = (_JSON$parse$0$relatio = (_JSON$parse = JSON.parse(percentageRes === null || percentageRes === void 0 ? void 0 : (_percentageRes$ = percentageRes[0]) === null || _percentageRes$ === void 0 ? void 0 : _percentageRes$.body)) === null || _JSON$parse === void 0 ? void 0 : (_JSON$parse$ = _JSON$parse[0]) === null || _JSON$parse$ === void 0 ? void 0 : _JSON$parse$.relations) !== null && _JSON$parse$0$relatio !== void 0 ? _JSON$parse$0$relatio : [];
|
|
319
|
-
orderMap = services[2].inputsByRetailer.flat().reduce(function (acc, item) {
|
|
327
|
+
orderMap = (_services$2$inputsByR = services[2].inputsByRetailer) !== null && _services$2$inputsByR !== void 0 ? _services$2$inputsByR : [].flat().reduce(function (acc, item) {
|
|
320
328
|
acc[item.id_image] = item.order;
|
|
321
329
|
return acc;
|
|
322
330
|
}, {});
|
|
323
|
-
orderedValues = (0, _toConsumableArray2.default)(services[2].values).sort(function (a, b) {
|
|
331
|
+
orderedValues = (0, _toConsumableArray2.default)((_services$2$values = services[2].values) !== null && _services$2$values !== void 0 ? _services$2$values : []).sort(function (a, b) {
|
|
324
332
|
var _orderMap$a$image_id, _orderMap$b$image_id;
|
|
325
333
|
|
|
326
334
|
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;
|
|
@@ -1468,14 +1476,16 @@ var ProviderProductEditionView = function ProviderProductEditionView(_ref) {
|
|
|
1468
1476
|
text: "No cuentas con este servicio",
|
|
1469
1477
|
headerType: "input-name-header"
|
|
1470
1478
|
})), state.active_tab === "Ficha técnica" && (((_state$product8 = state.product) === null || _state$product8 === void 0 ? void 0 : _state$product8.datasheet_status) !== "NS" ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
|
|
1471
|
-
children: (_state$datasheets_inp = state.datasheets_inputs[0]) === null || _state$datasheets_inp === void 0 ? void 0 :
|
|
1479
|
+
children: (_state$datasheets_inp = state.datasheets_inputs[0].data) === null || _state$datasheets_inp === void 0 ? void 0 : _state$datasheets_inp.map(function (dataGroup, index) {
|
|
1480
|
+
var _state$datasheets_inp2;
|
|
1481
|
+
|
|
1472
1482
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_InputGroup.InputGroup, {
|
|
1473
1483
|
index: index,
|
|
1474
1484
|
articleId: state.product.id_article,
|
|
1475
1485
|
version: state.version,
|
|
1476
1486
|
activeSection: state.active_tab,
|
|
1477
1487
|
inputGroup: dataGroup,
|
|
1478
|
-
dataInputs: state.datasheets_inputs[1],
|
|
1488
|
+
dataInputs: (_state$datasheets_inp2 = state.datasheets_inputs[1]) !== null && _state$datasheets_inp2 !== void 0 ? _state$datasheets_inp2 : [],
|
|
1479
1489
|
activeRetailer: state.services.datasheets[state.active_retailer.id_retailer],
|
|
1480
1490
|
groupData: state.services.datasheets[state.active_retailer.id_retailer].data,
|
|
1481
1491
|
updatedDatasheets: state.updated_datasheets_inputs,
|
package/package.json
CHANGED
|
@@ -154,25 +154,36 @@ const ProviderProductEditionView = ({
|
|
|
154
154
|
type: "SET_PRODUCT",
|
|
155
155
|
payload: productNormalized,
|
|
156
156
|
});
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
157
|
+
|
|
158
|
+
if (
|
|
159
|
+
productNormalized.categoryRetailerInOrder.length > 0 &&
|
|
160
|
+
productNormalized.statusByRetailer
|
|
161
|
+
) {
|
|
162
|
+
dispatch({
|
|
163
|
+
type: "SET_ACTIVE_RETAILER",
|
|
164
|
+
payload: productNormalized.categoryRetailerInOrder[0],
|
|
165
|
+
});
|
|
166
|
+
const firstRetailerStatus =
|
|
167
|
+
productNormalized.statusByRetailer[
|
|
168
|
+
productNormalized.categoryRetailerInOrder[0].id_retailer
|
|
169
|
+
];
|
|
170
|
+
const initialTab = firstRetailerStatus.description
|
|
171
|
+
? "Descripción"
|
|
172
|
+
: firstRetailerStatus.datasheet
|
|
173
|
+
? "Ficha técnica"
|
|
174
|
+
: firstRetailerStatus.images
|
|
175
|
+
? "Imágenes"
|
|
176
|
+
: "Imágenes";
|
|
177
|
+
dispatch({
|
|
178
|
+
type: "SET_ACTIVE_TAB",
|
|
179
|
+
payload: initialTab,
|
|
180
|
+
});
|
|
181
|
+
} else {
|
|
182
|
+
dispatch({
|
|
183
|
+
type: "SET_ACTIVE_RETAILER",
|
|
184
|
+
payload: productNormalized.categoryRetailer[0],
|
|
185
|
+
});
|
|
186
|
+
}
|
|
176
187
|
} catch (error) {
|
|
177
188
|
console.log("Error setting product data: ", error);
|
|
178
189
|
}
|
|
@@ -230,14 +241,14 @@ const ProviderProductEditionView = ({
|
|
|
230
241
|
const percentages =
|
|
231
242
|
JSON.parse(percentageRes?.[0]?.body)?.[0]?.relations ?? [];
|
|
232
243
|
|
|
233
|
-
const orderMap =
|
|
234
|
-
.
|
|
235
|
-
.reduce((acc, item) => {
|
|
244
|
+
const orderMap =
|
|
245
|
+
services[2].inputsByRetailer ??
|
|
246
|
+
[].flat().reduce((acc, item) => {
|
|
236
247
|
acc[item.id_image] = item.order;
|
|
237
248
|
return acc;
|
|
238
249
|
}, {});
|
|
239
250
|
|
|
240
|
-
const orderedValues = [...services[2].values].sort((a, b) => {
|
|
251
|
+
const orderedValues = [...(services[2].values ?? [])].sort((a, b) => {
|
|
241
252
|
const orderA = orderMap[a.image_id] ?? Number.MAX_SAFE_INTEGER;
|
|
242
253
|
const orderB = orderMap[b.image_id] ?? Number.MAX_SAFE_INTEGER;
|
|
243
254
|
|
|
@@ -1297,7 +1308,7 @@ const ProviderProductEditionView = ({
|
|
|
1297
1308
|
{state.active_tab === "Ficha técnica" &&
|
|
1298
1309
|
(state.product?.datasheet_status !== "NS" ? (
|
|
1299
1310
|
<>
|
|
1300
|
-
{state.datasheets_inputs[0]
|
|
1311
|
+
{state.datasheets_inputs[0].data?.map(
|
|
1301
1312
|
(dataGroup, index) => (
|
|
1302
1313
|
<InputGroup
|
|
1303
1314
|
index={index}
|
|
@@ -1306,7 +1317,7 @@ const ProviderProductEditionView = ({
|
|
|
1306
1317
|
version={state.version}
|
|
1307
1318
|
activeSection={state.active_tab}
|
|
1308
1319
|
inputGroup={dataGroup}
|
|
1309
|
-
dataInputs={state.datasheets_inputs[1]}
|
|
1320
|
+
dataInputs={state.datasheets_inputs[1] ?? []}
|
|
1310
1321
|
activeRetailer={
|
|
1311
1322
|
state.services.datasheets[
|
|
1312
1323
|
state.active_retailer.id_retailer
|