contentoh-components-library 21.6.28 → 21.6.30

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.
@@ -90,7 +90,7 @@ var _AiProductEdition = require("../../../contexts/AiProductEdition");
90
90
  var _jsxRuntime = require("react/jsx-runtime");
91
91
 
92
92
  var ProviderProductEditionView = function ProviderProductEditionView(_ref) {
93
- var _location$state4, _state$product2, _state$product3, _state$product4, _state$product5, _state$product6, _state$product7, _family$variants, _state$product15, _state$product16, _state$product17, _state$active_retaile4, _location$state5, _location$state6, _state$active_retaile5, _state$active_retaile6, _state$images_values$2, _state$images_values10, _state$images_values11, _state$active_retaile7, _state$product18, _state$product19, _state$product20, _state$product21, _family$variants2, _family$variants3, _state$active_percent, _state$active_percent2, _state$active_retaile8, _state$active_retaile9, _state$active_retaile10, _state$product22, _state$descriptions_i, _state$product23, _state$product24, _state$datasheets_inp, _state$datasheets_inp2, _state$datasheets_inp3, _state$product25, _state$images_values12;
93
+ var _location$state4, _state$product2, _state$product3, _state$product4, _state$product5, _state$product6, _state$product7, _family$variants2, _state$product15, _state$product16, _state$product17, _state$active_retaile4, _location$state5, _location$state6, _state$active_retaile5, _state$active_retaile6, _state$images_values$2, _state$images_values10, _state$images_values11, _state$active_retaile7, _state$product18, _state$product19, _state$product20, _state$product21, _family$variants3, _family$variants4, _family$variants5, _state$active_percent, _state$active_percent2, _state$active_retaile8, _state$active_retaile9, _state$active_retaile10, _state$product22, _state$descriptions_i, _state$product23, _state$product24, _state$datasheets_inp, _state$datasheets_inp2, _state$datasheets_inp3, _state$product25, _state$images_values12;
94
94
 
95
95
  var tabsSections = _ref.tabsSections,
96
96
  _ref$productSelected = _ref.productSelected,
@@ -162,37 +162,42 @@ var ProviderProductEditionView = function ProviderProductEditionView(_ref) {
162
162
 
163
163
  var _useState17 = (0, _react.useState)(false),
164
164
  _useState18 = (0, _slicedToArray2.default)(_useState17, 2),
165
- showRejectModal = _useState18[0],
166
- setShowRejectModal = _useState18[1];
165
+ preparandoEdicionMultiple = _useState18[0],
166
+ setPreparandoEdicionMultiple = _useState18[1];
167
167
 
168
- var _useState19 = (0, _react.useState)(0),
168
+ var _useState19 = (0, _react.useState)(false),
169
169
  _useState20 = (0, _slicedToArray2.default)(_useState19, 2),
170
- headerTop = _useState20[0],
171
- setHeaderTop = _useState20[1];
170
+ showRejectModal = _useState20[0],
171
+ setShowRejectModal = _useState20[1];
172
172
 
173
- var _useState21 = (0, _react.useState)({}),
173
+ var _useState21 = (0, _react.useState)(0),
174
174
  _useState22 = (0, _slicedToArray2.default)(_useState21, 2),
175
- assig = _useState22[0],
176
- setAssig = _useState22[1];
175
+ headerTop = _useState22[0],
176
+ setHeaderTop = _useState22[1];
177
177
 
178
- var _useState23 = (0, _react.useState)(false),
178
+ var _useState23 = (0, _react.useState)({}),
179
179
  _useState24 = (0, _slicedToArray2.default)(_useState23, 2),
180
- imageLayout = _useState24[0],
181
- setImageLayout = _useState24[1];
180
+ assig = _useState24[0],
181
+ setAssig = _useState24[1];
182
182
 
183
183
  var _useState25 = (0, _react.useState)(false),
184
184
  _useState26 = (0, _slicedToArray2.default)(_useState25, 2),
185
- rejectAll = _useState26[0],
186
- setRejectAll = _useState26[1];
185
+ imageLayout = _useState26[0],
186
+ setImageLayout = _useState26[1];
187
187
 
188
- var _useState27 = (0, _react.useState)({
188
+ var _useState27 = (0, _react.useState)(false),
189
+ _useState28 = (0, _slicedToArray2.default)(_useState27, 2),
190
+ rejectAll = _useState28[0],
191
+ setRejectAll = _useState28[1];
192
+
193
+ var _useState29 = (0, _react.useState)({
189
194
  "Ficha técnica": null,
190
195
  Descripción: null,
191
196
  Imágenes: null
192
197
  }),
193
- _useState28 = (0, _slicedToArray2.default)(_useState27, 2),
194
- origin = _useState28[0],
195
- setOrigin = _useState28[1];
198
+ _useState30 = (0, _slicedToArray2.default)(_useState29, 2),
199
+ origin = _useState30[0],
200
+ setOrigin = _useState30[1];
196
201
 
197
202
  var _useCloseModal = (0, _customHooks.useCloseModal)("version-selector"),
198
203
  _useCloseModal2 = (0, _slicedToArray2.default)(_useCloseModal, 2),
@@ -975,18 +980,126 @@ var ProviderProductEditionView = function ProviderProductEditionView(_ref) {
975
980
  raíz —que la ficha lea de la URL— toca todas las plataformas y no cabe aquí.
976
981
  */
977
982
 
983
+ /*
984
+ Abre la edición múltiple con las variantes de la familia ya cargadas.
985
+ Esa pantalla lee `multipleEditionList` de sessionStorage —así la deja el
986
+ listado al pulsar "editar varios"— y necesita el PRODUCTO COMPLETO de cada
987
+ uno, no solo su id: pinta el UPC, el nombre, parte `categoryName` por "|",
988
+ cuenta `retailersAvailable` y decide columnas según `id_order`. Con un objeto
989
+ reducido revienta al entrar.
990
+ Por eso se piden a /new-articles, que devuelve justo la forma del listado, y
991
+ se filtran por id y no por UPC: hay 12,024 UPC repetidos entre artículos
992
+ activos y el UPC no identifica un producto.
993
+ Va SIN el producto padre a propósito, aunque el botón viva en su ficha. En la
994
+ edición múltiple no existe el diálogo de propagación, así que incluirlo
995
+ abriría un camino para cambiar el padre sin decidir si eso baja a los hijos
996
+ —justo la decisión que su propia ficha obliga a tomar—.
997
+ */
978
998
 
979
- var openVariant = /*#__PURE__*/function () {
980
- var _ref8 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4(articleId) {
981
- var res, _readPayload, data, encontrado;
999
+
1000
+ var openMultipleEdition = /*#__PURE__*/function () {
1001
+ var _ref8 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4() {
1002
+ var _family$variants;
1003
+
1004
+ var ids, res, _readPayload, data, productos;
982
1005
 
983
1006
  return _regenerator.default.wrap(function _callee4$(_context4) {
984
1007
  while (1) {
985
1008
  switch (_context4.prev = _context4.next) {
1009
+ case 0:
1010
+ ids = ((_family$variants = family === null || family === void 0 ? void 0 : family.variants) !== null && _family$variants !== void 0 ? _family$variants : []).map(function (variant) {
1011
+ return variant.articleId;
1012
+ });
1013
+
1014
+ if (ids.length) {
1015
+ _context4.next = 3;
1016
+ break;
1017
+ }
1018
+
1019
+ return _context4.abrupt("return");
1020
+
1021
+ case 3:
1022
+ setPreparandoEdicionMultiple(true);
1023
+ _context4.prev = 4;
1024
+ _context4.next = 7;
1025
+ return _axios.default.get("".concat(process.env.REACT_APP_NEW_ARTICLES_ENDPOINT), {
1026
+ params: {
1027
+ listType: "general",
1028
+ filterByArticleId: ids.join(",")
1029
+ },
1030
+ headers: {
1031
+ Authorization: token
1032
+ }
1033
+ });
1034
+
1035
+ case 7:
1036
+ res = _context4.sent;
1037
+ _readPayload = (0, _api.readPayload)(res), data = _readPayload.data;
1038
+ productos = (data !== null && data !== void 0 ? data : []).filter(function (item) {
1039
+ return ids.includes(Number(item.id_article));
1040
+ });
1041
+
1042
+ if (productos.length) {
1043
+ _context4.next = 13;
1044
+ break;
1045
+ }
1046
+
1047
+ console.error("openMultipleEdition: sin productos que abrir");
1048
+ return _context4.abrupt("return");
1049
+
1050
+ case 13:
1051
+ sessionStorage.setItem("multipleEditionList", JSON.stringify(productos.sort(function (a, b) {
1052
+ return a.id_article - b.id_article;
1053
+ })));
1054
+ window.location.assign("/products/multipleEdition");
1055
+ _context4.next = 21;
1056
+ break;
1057
+
1058
+ case 17:
1059
+ _context4.prev = 17;
1060
+ _context4.t0 = _context4["catch"](4);
1061
+ // Se avisa y se queda donde está: navegar con la lista vieja abriría otros
1062
+ // productos, y navegar sin lista deja la pantalla rota.
1063
+ console.error("openMultipleEdition: ", _context4.t0);
1064
+ dispatch({
1065
+ type: "SET_MODAL",
1066
+ payload: {
1067
+ show: true,
1068
+ title: "",
1069
+ message: "No se pudieron cargar las variantes para editarlas juntas.",
1070
+ image: _errorModal.default
1071
+ }
1072
+ });
1073
+
1074
+ case 21:
1075
+ _context4.prev = 21;
1076
+ setPreparandoEdicionMultiple(false);
1077
+ return _context4.finish(21);
1078
+
1079
+ case 24:
1080
+ case "end":
1081
+ return _context4.stop();
1082
+ }
1083
+ }
1084
+ }, _callee4, null, [[4, 17, 21, 24]]);
1085
+ }));
1086
+
1087
+ return function openMultipleEdition() {
1088
+ return _ref8.apply(this, arguments);
1089
+ };
1090
+ }();
1091
+
1092
+ var openVariant = /*#__PURE__*/function () {
1093
+ var _ref9 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5(articleId) {
1094
+ var res, _readPayload2, data, encontrado;
1095
+
1096
+ return _regenerator.default.wrap(function _callee5$(_context5) {
1097
+ while (1) {
1098
+ switch (_context5.prev = _context5.next) {
986
1099
  case 0:
987
1100
  setLoadingVariant(articleId);
988
- _context4.prev = 1;
989
- _context4.next = 4;
1101
+ _context5.prev = 1;
1102
+ _context5.next = 4;
990
1103
  return _axios.default.get("".concat(process.env.REACT_APP_NEW_ARTICLES_ENDPOINT), {
991
1104
  params: {
992
1105
  listType: "general",
@@ -998,9 +1111,9 @@ var ProviderProductEditionView = function ProviderProductEditionView(_ref) {
998
1111
  });
999
1112
 
1000
1113
  case 4:
1001
- res = _context4.sent;
1114
+ res = _context5.sent;
1002
1115
  // read-articles-v2 responde { count, data: [...] }.
1003
- _readPayload = (0, _api.readPayload)(res), data = _readPayload.data;
1116
+ _readPayload2 = (0, _api.readPayload)(res), data = _readPayload2.data;
1004
1117
  encontrado = (data !== null && data !== void 0 ? data : []).find(function (item) {
1005
1118
  return Number(item.id_article) === Number(articleId);
1006
1119
  });
@@ -1018,33 +1131,33 @@ var ProviderProductEditionView = function ProviderProductEditionView(_ref) {
1018
1131
  }));
1019
1132
  }
1020
1133
 
1021
- _context4.next = 13;
1134
+ _context5.next = 13;
1022
1135
  break;
1023
1136
 
1024
1137
  case 10:
1025
- _context4.prev = 10;
1026
- _context4.t0 = _context4["catch"](1);
1138
+ _context5.prev = 10;
1139
+ _context5.t0 = _context5["catch"](1);
1027
1140
  // Si la consulta falla se navega igual: la pantalla mostrará el producto
1028
1141
  // que hubiera en sessionStorage, que es el comportamiento de siempre.
1029
1142
  // Peor sería dejar el clic sin efecto y que pareciera que no responde.
1030
- console.error("openVariant: ", _context4.t0);
1143
+ console.error("openVariant: ", _context5.t0);
1031
1144
 
1032
1145
  case 13:
1033
- _context4.prev = 13;
1146
+ _context5.prev = 13;
1034
1147
  setLoadingVariant(null);
1035
1148
  window.location.assign("/products/".concat(articleId, "/datasheet"));
1036
- return _context4.finish(13);
1149
+ return _context5.finish(13);
1037
1150
 
1038
1151
  case 17:
1039
1152
  case "end":
1040
- return _context4.stop();
1153
+ return _context5.stop();
1041
1154
  }
1042
1155
  }
1043
- }, _callee4, null, [[1, 10, 13, 17]]);
1156
+ }, _callee5, null, [[1, 10, 13, 17]]);
1044
1157
  }));
1045
1158
 
1046
1159
  return function openVariant(_x2) {
1047
- return _ref8.apply(this, arguments);
1160
+ return _ref9.apply(this, arguments);
1048
1161
  };
1049
1162
  }();
1050
1163
  /*
@@ -1105,24 +1218,24 @@ var ProviderProductEditionView = function ProviderProductEditionView(_ref) {
1105
1218
 
1106
1219
 
1107
1220
  var handleOnRestoreInheritance = /*#__PURE__*/function () {
1108
- var _ref9 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5(attributeId) {
1221
+ var _ref10 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6(attributeId) {
1109
1222
  var _state$product13;
1110
1223
 
1111
1224
  var res, data;
1112
- return _regenerator.default.wrap(function _callee5$(_context5) {
1225
+ return _regenerator.default.wrap(function _callee6$(_context6) {
1113
1226
  while (1) {
1114
- switch (_context5.prev = _context5.next) {
1227
+ switch (_context6.prev = _context6.next) {
1115
1228
  case 0:
1116
1229
  if (!(!attributeId || !((_state$product13 = state.product) !== null && _state$product13 !== void 0 && _state$product13.id_article))) {
1117
- _context5.next = 2;
1230
+ _context6.next = 2;
1118
1231
  break;
1119
1232
  }
1120
1233
 
1121
- return _context5.abrupt("return");
1234
+ return _context6.abrupt("return");
1122
1235
 
1123
1236
  case 2:
1124
- _context5.prev = 2;
1125
- _context5.next = 5;
1237
+ _context6.prev = 2;
1238
+ _context6.next = 5;
1126
1239
  return _axios.default.post("".concat(process.env.REACT_APP_VARIANTS_ENDPOINT, "/restore"), {
1127
1240
  articleId: state.product.id_article,
1128
1241
  attributes: [Number(attributeId)]
@@ -1133,7 +1246,7 @@ var ProviderProductEditionView = function ProviderProductEditionView(_ref) {
1133
1246
  });
1134
1247
 
1135
1248
  case 5:
1136
- res = _context5.sent;
1249
+ res = _context6.sent;
1137
1250
  // El API responde 200 aunque la lambda haya devuelto 400: el resultado
1138
1251
  // real viaja en el cuerpo y readPayload lo convierte en excepción.
1139
1252
  data = (0, _api.readPayload)(res);
@@ -1147,24 +1260,24 @@ var ProviderProductEditionView = function ProviderProductEditionView(_ref) {
1147
1260
  };
1148
1261
  })
1149
1262
  });
1150
- _context5.next = 13;
1263
+ _context6.next = 13;
1151
1264
  break;
1152
1265
 
1153
1266
  case 10:
1154
- _context5.prev = 10;
1155
- _context5.t0 = _context5["catch"](2);
1156
- console.error("restoreInheritance: ", _context5.t0);
1267
+ _context6.prev = 10;
1268
+ _context6.t0 = _context6["catch"](2);
1269
+ console.error("restoreInheritance: ", _context6.t0);
1157
1270
 
1158
1271
  case 13:
1159
1272
  case "end":
1160
- return _context5.stop();
1273
+ return _context6.stop();
1161
1274
  }
1162
1275
  }
1163
- }, _callee5, null, [[2, 10]]);
1276
+ }, _callee6, null, [[2, 10]]);
1164
1277
  }));
1165
1278
 
1166
1279
  return function handleOnRestoreInheritance(_x3) {
1167
- return _ref9.apply(this, arguments);
1280
+ return _ref10.apply(this, arguments);
1168
1281
  };
1169
1282
  }();
1170
1283
 
@@ -1199,14 +1312,14 @@ var ProviderProductEditionView = function ProviderProductEditionView(_ref) {
1199
1312
  };
1200
1313
 
1201
1314
  var sendEvaluation = /*#__PURE__*/function () {
1202
- var _ref10 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6(result) {
1315
+ var _ref11 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7(result) {
1203
1316
  var _state$product$id_ord, _state$active_retaile3, _state$product$status, _state$product$status2, _state$product14;
1204
1317
 
1205
1318
  var concept, articleId, orderId, retailerId, evalStatus, data, _newStatuses$newStatu, _state$services_data, res, newStatuses, serviceStatus, updatedStatusByRetailer, updatedProduct, updatedServicesData;
1206
1319
 
1207
- return _regenerator.default.wrap(function _callee6$(_context6) {
1320
+ return _regenerator.default.wrap(function _callee7$(_context7) {
1208
1321
  while (1) {
1209
- switch (_context6.prev = _context6.next) {
1322
+ switch (_context7.prev = _context7.next) {
1210
1323
  case 0:
1211
1324
  dispatch({
1212
1325
  type: "SET_SAVING",
@@ -1223,16 +1336,16 @@ var ProviderProductEditionView = function ProviderProductEditionView(_ref) {
1223
1336
  concept: concept,
1224
1337
  evalStatus: evalStatus
1225
1338
  };
1226
- _context6.prev = 7;
1339
+ _context7.prev = 7;
1227
1340
 
1228
1341
  if (!result) {
1229
- _context6.next = 22;
1342
+ _context7.next = 22;
1230
1343
  break;
1231
1344
  }
1232
1345
 
1233
1346
  data.result = result;
1234
1347
  data.retailerId = retailerId;
1235
- _context6.next = 13;
1348
+ _context7.next = 13;
1236
1349
  return _axios.default.put("".concat(process.env.REACT_APP_EVALUATION_ENDPOINT), data, {
1237
1350
  headers: {
1238
1351
  Authorization: token
@@ -1240,7 +1353,7 @@ var ProviderProductEditionView = function ProviderProductEditionView(_ref) {
1240
1353
  });
1241
1354
 
1242
1355
  case 13:
1243
- res = _context6.sent;
1356
+ res = _context7.sent;
1244
1357
  newStatuses = JSON.parse(res.data.body);
1245
1358
  serviceStatus = newStatuses.newServiceStatus[articleId]["".concat(concept, "Status")]; // Actualizar el producto con los nuevos estados
1246
1359
 
@@ -1277,13 +1390,13 @@ var ProviderProductEditionView = function ProviderProductEditionView(_ref) {
1277
1390
  });
1278
1391
 
1279
1392
  case 22:
1280
- _context6.next = 28;
1393
+ _context7.next = 28;
1281
1394
  break;
1282
1395
 
1283
1396
  case 24:
1284
- _context6.prev = 24;
1285
- _context6.t0 = _context6["catch"](7);
1286
- console.error("Error sending evaluation:", _context6.t0);
1397
+ _context7.prev = 24;
1398
+ _context7.t0 = _context7["catch"](7);
1399
+ console.error("Error sending evaluation:", _context7.t0);
1287
1400
  dispatch({
1288
1401
  type: "SET_MODAL",
1289
1402
  payload: {
@@ -1295,32 +1408,32 @@ var ProviderProductEditionView = function ProviderProductEditionView(_ref) {
1295
1408
  });
1296
1409
 
1297
1410
  case 28:
1298
- _context6.prev = 28;
1411
+ _context7.prev = 28;
1299
1412
  dispatch({
1300
1413
  type: "SET_SAVING",
1301
1414
  payload: false
1302
1415
  });
1303
- return _context6.finish(28);
1416
+ return _context7.finish(28);
1304
1417
 
1305
1418
  case 31:
1306
1419
  case "end":
1307
- return _context6.stop();
1420
+ return _context7.stop();
1308
1421
  }
1309
1422
  }
1310
- }, _callee6, null, [[7, 24, 28, 31]]);
1423
+ }, _callee7, null, [[7, 24, 28, 31]]);
1311
1424
  }));
1312
1425
 
1313
1426
  return function sendEvaluation(_x4) {
1314
- return _ref10.apply(this, arguments);
1427
+ return _ref11.apply(this, arguments);
1315
1428
  };
1316
1429
  }();
1317
1430
 
1318
1431
  var evaluationToRetailer = /*#__PURE__*/function () {
1319
- var _ref11 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7(result) {
1432
+ var _ref12 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee8(result) {
1320
1433
  var data, statusComplete, updatedProduct;
1321
- return _regenerator.default.wrap(function _callee7$(_context7) {
1434
+ return _regenerator.default.wrap(function _callee8$(_context8) {
1322
1435
  while (1) {
1323
- switch (_context7.prev = _context7.next) {
1436
+ switch (_context8.prev = _context8.next) {
1324
1437
  case 0:
1325
1438
  dispatch({
1326
1439
  type: "SET_SAVING",
@@ -1332,8 +1445,8 @@ var ProviderProductEditionView = function ProviderProductEditionView(_ref) {
1332
1445
  versionId: state.product.version,
1333
1446
  status: result
1334
1447
  };
1335
- _context7.prev = 2;
1336
- _context7.next = 5;
1448
+ _context8.prev = 2;
1449
+ _context8.next = 5;
1337
1450
  return _axios.default.put("".concat(process.env.REACT_APP_RETAILER_REQUEST), data, {
1338
1451
  headers: {
1339
1452
  Authorization: token
@@ -1363,13 +1476,13 @@ var ProviderProductEditionView = function ProviderProductEditionView(_ref) {
1363
1476
  image: _genericModalCheck.default
1364
1477
  }
1365
1478
  });
1366
- _context7.next = 15;
1479
+ _context8.next = 15;
1367
1480
  break;
1368
1481
 
1369
1482
  case 11:
1370
- _context7.prev = 11;
1371
- _context7.t0 = _context7["catch"](2);
1372
- console.error("Error evaluating to retailer:", _context7.t0);
1483
+ _context8.prev = 11;
1484
+ _context8.t0 = _context8["catch"](2);
1485
+ console.error("Error evaluating to retailer:", _context8.t0);
1373
1486
  dispatch({
1374
1487
  type: "SET_MODAL",
1375
1488
  payload: {
@@ -1381,23 +1494,23 @@ var ProviderProductEditionView = function ProviderProductEditionView(_ref) {
1381
1494
  });
1382
1495
 
1383
1496
  case 15:
1384
- _context7.prev = 15;
1497
+ _context8.prev = 15;
1385
1498
  dispatch({
1386
1499
  type: "SET_SAVING",
1387
1500
  payload: false
1388
1501
  });
1389
- return _context7.finish(15);
1502
+ return _context8.finish(15);
1390
1503
 
1391
1504
  case 18:
1392
1505
  case "end":
1393
- return _context7.stop();
1506
+ return _context8.stop();
1394
1507
  }
1395
1508
  }
1396
- }, _callee7, null, [[2, 11, 15, 18]]);
1509
+ }, _callee8, null, [[2, 11, 15, 18]]);
1397
1510
  }));
1398
1511
 
1399
1512
  return function evaluationToRetailer(_x5) {
1400
- return _ref11.apply(this, arguments);
1513
+ return _ref12.apply(this, arguments);
1401
1514
  };
1402
1515
  }();
1403
1516
 
@@ -1528,18 +1641,18 @@ var ProviderProductEditionView = function ProviderProductEditionView(_ref) {
1528
1641
  };
1529
1642
 
1530
1643
  var handleOnEvaluateAll = /*#__PURE__*/function () {
1531
- var _ref12 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee8(result) {
1644
+ var _ref13 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee9(result) {
1532
1645
  var _state$product$id_ord2, _state$services_data2, evaluationArray, conceptArray, dataGeneral, isProvider, userType, status, updatedStatusByRetailer, updatedProduct;
1533
1646
 
1534
- return _regenerator.default.wrap(function _callee8$(_context8) {
1647
+ return _regenerator.default.wrap(function _callee9$(_context9) {
1535
1648
  while (1) {
1536
- switch (_context8.prev = _context8.next) {
1649
+ switch (_context9.prev = _context9.next) {
1537
1650
  case 0:
1538
1651
  dispatch({
1539
1652
  type: "SET_SAVING",
1540
1653
  payload: true
1541
1654
  });
1542
- _context8.prev = 1;
1655
+ _context9.prev = 1;
1543
1656
  evaluationArray = [];
1544
1657
  conceptArray = ["description", "datasheet", "images"];
1545
1658
  dataGeneral = {
@@ -1570,7 +1683,7 @@ var ProviderProductEditionView = function ProviderProductEditionView(_ref) {
1570
1683
  }));
1571
1684
  }); // Ejecutar todas las evaluaciones
1572
1685
 
1573
- _context8.next = 9;
1686
+ _context9.next = 9;
1574
1687
  return Promise.all(evaluationArray);
1575
1688
 
1576
1689
  case 9:
@@ -1615,13 +1728,13 @@ var ProviderProductEditionView = function ProviderProductEditionView(_ref) {
1615
1728
  image: _genericModalCheck.default
1616
1729
  }
1617
1730
  });
1618
- _context8.next = 24;
1731
+ _context9.next = 24;
1619
1732
  break;
1620
1733
 
1621
1734
  case 20:
1622
- _context8.prev = 20;
1623
- _context8.t0 = _context8["catch"](1);
1624
- console.error("Error evaluating all:", _context8.t0);
1735
+ _context9.prev = 20;
1736
+ _context9.t0 = _context9["catch"](1);
1737
+ console.error("Error evaluating all:", _context9.t0);
1625
1738
  dispatch({
1626
1739
  type: "SET_MODAL",
1627
1740
  payload: {
@@ -1633,24 +1746,24 @@ var ProviderProductEditionView = function ProviderProductEditionView(_ref) {
1633
1746
  });
1634
1747
 
1635
1748
  case 24:
1636
- _context8.prev = 24;
1749
+ _context9.prev = 24;
1637
1750
  dispatch({
1638
1751
  type: "SET_SAVING",
1639
1752
  payload: false
1640
1753
  });
1641
1754
  setRejectAll(false);
1642
- return _context8.finish(24);
1755
+ return _context9.finish(24);
1643
1756
 
1644
1757
  case 28:
1645
1758
  case "end":
1646
- return _context8.stop();
1759
+ return _context9.stop();
1647
1760
  }
1648
1761
  }
1649
- }, _callee8, null, [[1, 20, 24, 28]]);
1762
+ }, _callee9, null, [[1, 20, 24, 28]]);
1650
1763
  }));
1651
1764
 
1652
1765
  return function handleOnEvaluateAll(_x6) {
1653
- return _ref12.apply(this, arguments);
1766
+ return _ref13.apply(this, arguments);
1654
1767
  };
1655
1768
  }();
1656
1769
 
@@ -1700,7 +1813,7 @@ var ProviderProductEditionView = function ProviderProductEditionView(_ref) {
1700
1813
  jwt: token
1701
1814
  }), pendingPropagation && /*#__PURE__*/(0, _jsxRuntime.jsx)(_PropagateChangesModal.PropagateChangesModal, {
1702
1815
  changedAttributes: pendingPropagation.cambios,
1703
- variants: ((_family$variants = family === null || family === void 0 ? void 0 : family.variants) !== null && _family$variants !== void 0 ? _family$variants : []).filter(function (v) {
1816
+ variants: ((_family$variants2 = family === null || family === void 0 ? void 0 : family.variants) !== null && _family$variants2 !== void 0 ? _family$variants2 : []).filter(function (v) {
1704
1817
  return !v.isCurrent;
1705
1818
  }),
1706
1819
  saving: state.saving,
@@ -1781,21 +1894,21 @@ var ProviderProductEditionView = function ProviderProductEditionView(_ref) {
1781
1894
  type: "pink",
1782
1895
  label: "Aceptar",
1783
1896
  size: 12,
1784
- onClick: /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee9() {
1897
+ onClick: /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee10() {
1785
1898
  var elements, isMessageEmpty, container, existingAlert, alert, fullMessage;
1786
- return _regenerator.default.wrap(function _callee9$(_context9) {
1899
+ return _regenerator.default.wrap(function _callee10$(_context10) {
1787
1900
  while (1) {
1788
- switch (_context9.prev = _context9.next) {
1901
+ switch (_context10.prev = _context10.next) {
1789
1902
  case 0:
1790
1903
  elements = document.querySelectorAll("#modal-message-box .ql-container .ql-editor > p");
1791
1904
 
1792
1905
  if (!(!elements || elements.length === 0)) {
1793
- _context9.next = 4;
1906
+ _context10.next = 4;
1794
1907
  break;
1795
1908
  }
1796
1909
 
1797
1910
  console.error("Elemento no encontrado");
1798
- return _context9.abrupt("return");
1911
+ return _context10.abrupt("return");
1799
1912
 
1800
1913
  case 4:
1801
1914
  isMessageEmpty = Array.from(elements).every(function (el) {
@@ -1804,7 +1917,7 @@ var ProviderProductEditionView = function ProviderProductEditionView(_ref) {
1804
1917
  });
1805
1918
 
1806
1919
  if (!isMessageEmpty) {
1807
- _context9.next = 10;
1920
+ _context10.next = 10;
1808
1921
  break;
1809
1922
  }
1810
1923
 
@@ -1819,13 +1932,13 @@ var ProviderProductEditionView = function ProviderProductEditionView(_ref) {
1819
1932
  container.appendChild(alert);
1820
1933
  }
1821
1934
 
1822
- return _context9.abrupt("return");
1935
+ return _context10.abrupt("return");
1823
1936
 
1824
1937
  case 10:
1825
1938
  fullMessage = Array.from(elements).map(function (element) {
1826
1939
  return element.innerHTML;
1827
1940
  }).join("").replace(/<br\s*\/?>/gi, "\n");
1828
- _context9.next = 13;
1941
+ _context10.next = 13;
1829
1942
  return createComment(fullMessage, token);
1830
1943
 
1831
1944
  case 13:
@@ -1834,10 +1947,10 @@ var ProviderProductEditionView = function ProviderProductEditionView(_ref) {
1834
1947
 
1835
1948
  case 15:
1836
1949
  case "end":
1837
- return _context9.stop();
1950
+ return _context10.stop();
1838
1951
  }
1839
1952
  }
1840
- }, _callee9);
1953
+ }, _callee10);
1841
1954
  }))
1842
1955
  }, "btn-Aceptar")]
1843
1956
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_HeaderTop.HeaderTop, {
@@ -1943,7 +2056,7 @@ var ProviderProductEditionView = function ProviderProductEditionView(_ref) {
1943
2056
  className: "upc",
1944
2057
  children: family.parent.upc
1945
2058
  })]
1946
- }), family === null || family === void 0 ? void 0 : (_family$variants2 = family.variants) === null || _family$variants2 === void 0 ? void 0 : _family$variants2.map(function (variant) {
2059
+ }), family === null || family === void 0 ? void 0 : (_family$variants3 = family.variants) === null || _family$variants3 === void 0 ? void 0 : _family$variants3.map(function (variant) {
1947
2060
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)("button", {
1948
2061
  type: "button",
1949
2062
  className: "family-row".concat(variant.isCurrent ? " current" : ""),
@@ -1962,9 +2075,15 @@ var ProviderProductEditionView = function ProviderProductEditionView(_ref) {
1962
2075
  children: variant.upc
1963
2076
  })]
1964
2077
  }, variant.articleId);
1965
- }), family && !family.error && !((_family$variants3 = family.variants) !== null && _family$variants3 !== void 0 && _family$variants3.length) && /*#__PURE__*/(0, _jsxRuntime.jsx)("p", {
2078
+ }), family && !family.error && !((_family$variants4 = family.variants) !== null && _family$variants4 !== void 0 && _family$variants4.length) && /*#__PURE__*/(0, _jsxRuntime.jsx)("p", {
1966
2079
  className: "loading",
1967
2080
  children: "Este producto no tiene variantes."
2081
+ }), (family === null || family === void 0 ? void 0 : (_family$variants5 = family.variants) === null || _family$variants5 === void 0 ? void 0 : _family$variants5.length) > 1 && /*#__PURE__*/(0, _jsxRuntime.jsx)("button", {
2082
+ type: "button",
2083
+ className: "editar-juntas",
2084
+ disabled: preparandoEdicionMultiple,
2085
+ onClick: openMultipleEdition,
2086
+ children: preparandoEdicionMultiple ? "Abriendo…" : "Editar las ".concat(family.variants.length, " variantes juntas")
1968
2087
  })]
1969
2088
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_FullProductNameHeader.FullProductNameHeader, {
1970
2089
  headerData: state.product,
@@ -18,9 +18,9 @@ var _templateObject;
18
18
  // Rosa ContentOh, el mismo del modal de ligar productos.
19
19
  var PINK = "#E13AA8";
20
20
 
21
- var Container = _styledComponents.default.div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n display: flex;\n flex-direction: column;\n height: 100%;\n flex: 1;\n overflow: auto;\n\n .data-container {\n display: flex;\n flex: 0%;\n height: calc(100% - ", "px);\n .image-data-panel {\n width: 340px;\n\n & + * {\n margin-left: 10px;\n }\n }\n\n .product-information {\n width: 100%;\n height: 100%;\n display: flex;\n flex-direction: column;\n\n .services-information-container {\n height: 100%;\n overflow: auto;\n }\n\n .image-services {\n aside {\n display: grid;\n grid-template-columns: repeat(auto-fill, 179px);\n column-gap: 15px;\n row-gap: 15px;\n padding: 20px;\n }\n }\n\n .commentary-box {\n display: flex;\n justify-content: space-between;\n align-items: flex-end;\n padding: 10px;\n padding-left: 0;\n\n .commentary {\n display: flex;\n align-items: flex-end;\n\n .input-container {\n width: 500px;\n\n .quill {\n height: 100px;\n }\n\n & + * {\n margin-left: 5px;\n }\n }\n\n .buttons-box {\n display: flex;\n width: 210px;\n flex-wrap: wrap;\n\n .general-transparent-button {\n & + * {\n margin-top: 5px;\n }\n }\n\n .general-transparent-button,\n .general-green-button,\n .general-button-disabled {\n width: fit-content;\n min-width: 201px;\n height: 40px;\n }\n }\n }\n }\n\n .feedback-box {\n display: flex;\n }\n\n .required-inputs-message {\n font-family: ", ";\n font-size: 13px;\n color: ", ";\n padding: 10px;\n display: flex;\n align-items: center;\n\n p + * {\n margin-top: 10px;\n }\n\n button {\n min-width: fit-content;\n }\n }\n }\n }\n #modal-message-box {\n width: 400px;\n height: 100px;\n }\n .container {\n width: 100%;\n height: 90%;\n .dropzone {\n height: 100%;\n width: 100%;\n position: relative;\n transition: all 0.5s ease;\n\n &.drag-active {\n background-color: rgba(", ", 0.05);\n border: 2px dashed ", ";\n border-radius: 8px;\n\n aside {\n opacity: 0.3;\n pointer-events: none;\n }\n }\n\n .drag-overlay {\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n display: flex;\n align-items: center;\n justify-content: center;\n background-color: rgba(", ", 0.1);\n border-radius: 8px;\n pointer-events: none;\n z-index: 10;\n\n p {\n font-family: ", ";\n font-size: 24px;\n font-weight: 600;\n color: ", ";\n text-align: center;\n padding: 20px;\n background-color: ", ";\n border-radius: 8px;\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);\n }\n }\n }\n }\n .variants-actions {\n display: flex;\n align-items: center;\n gap: 10px;\n margin-bottom: 8px;\n\n .link-variants {\n border: 1px solid ", ";\n border-radius: 6px;\n background: none;\n padding: 6px 12px;\n font-family: ", ";\n font-size: 11px;\n color: ", ";\n cursor: pointer;\n }\n\n .variants-count {\n border: none;\n background: none;\n padding: 0;\n cursor: pointer;\n font-family: ", ";\n font-size: 11px;\n color: ", ";\n text-decoration: underline;\n }\n }\n\n .variants-family {\n display: flex;\n flex-direction: column;\n gap: 4px;\n margin-bottom: 10px;\n padding: 8px;\n border: 1px solid ", ";\n border-radius: 6px;\n\n .loading {\n margin: 0;\n font-family: ", ";\n font-size: 11px;\n color: ", ";\n }\n\n .family-row {\n display: flex;\n align-items: baseline;\n gap: 8px;\n padding: 6px 8px;\n border: none;\n border-radius: 4px;\n background: none;\n cursor: pointer;\n text-align: left;\n font-family: ", ";\n font-size: 12px;\n color: ", ";\n }\n\n .family-row:hover:not(:disabled) {\n background-color: ", ";\n }\n\n .family-row:disabled {\n cursor: default;\n opacity: 0.7;\n }\n\n .family-row .role {\n min-width: 96px;\n font-size: 10px;\n color: ", ";\n }\n\n .family-row.current .role {\n color: ", ";\n }\n\n .family-row .name {\n flex: 1;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n\n .family-row .upc {\n font-size: 11px;\n color: ", ";\n }\n }\n"])), function (_ref) {
21
+ var Container = _styledComponents.default.div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n display: flex;\n flex-direction: column;\n height: 100%;\n flex: 1;\n overflow: auto;\n\n .data-container {\n display: flex;\n flex: 0%;\n height: calc(100% - ", "px);\n .image-data-panel {\n width: 340px;\n\n & + * {\n margin-left: 10px;\n }\n }\n\n .product-information {\n width: 100%;\n height: 100%;\n display: flex;\n flex-direction: column;\n\n .services-information-container {\n height: 100%;\n overflow: auto;\n }\n\n .image-services {\n aside {\n display: grid;\n grid-template-columns: repeat(auto-fill, 179px);\n column-gap: 15px;\n row-gap: 15px;\n padding: 20px;\n }\n }\n\n .commentary-box {\n display: flex;\n justify-content: space-between;\n align-items: flex-end;\n padding: 10px;\n padding-left: 0;\n\n .commentary {\n display: flex;\n align-items: flex-end;\n\n .input-container {\n width: 500px;\n\n .quill {\n height: 100px;\n }\n\n & + * {\n margin-left: 5px;\n }\n }\n\n .buttons-box {\n display: flex;\n width: 210px;\n flex-wrap: wrap;\n\n .general-transparent-button {\n & + * {\n margin-top: 5px;\n }\n }\n\n .general-transparent-button,\n .general-green-button,\n .general-button-disabled {\n width: fit-content;\n min-width: 201px;\n height: 40px;\n }\n }\n }\n }\n\n .feedback-box {\n display: flex;\n }\n\n .required-inputs-message {\n font-family: ", ";\n font-size: 13px;\n color: ", ";\n padding: 10px;\n display: flex;\n align-items: center;\n\n p + * {\n margin-top: 10px;\n }\n\n button {\n min-width: fit-content;\n }\n }\n }\n }\n #modal-message-box {\n width: 400px;\n height: 100px;\n }\n .container {\n width: 100%;\n height: 90%;\n .dropzone {\n height: 100%;\n width: 100%;\n position: relative;\n transition: all 0.5s ease;\n\n &.drag-active {\n background-color: rgba(", ", 0.05);\n border: 2px dashed ", ";\n border-radius: 8px;\n\n aside {\n opacity: 0.3;\n pointer-events: none;\n }\n }\n\n .drag-overlay {\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n display: flex;\n align-items: center;\n justify-content: center;\n background-color: rgba(", ", 0.1);\n border-radius: 8px;\n pointer-events: none;\n z-index: 10;\n\n p {\n font-family: ", ";\n font-size: 24px;\n font-weight: 600;\n color: ", ";\n text-align: center;\n padding: 20px;\n background-color: ", ";\n border-radius: 8px;\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);\n }\n }\n }\n }\n .variants-actions {\n display: flex;\n align-items: center;\n gap: 10px;\n margin-bottom: 8px;\n\n .link-variants {\n border: 1px solid ", ";\n border-radius: 6px;\n background: none;\n padding: 6px 12px;\n font-family: ", ";\n font-size: 11px;\n color: ", ";\n cursor: pointer;\n }\n\n .variants-count {\n border: none;\n background: none;\n padding: 0;\n cursor: pointer;\n font-family: ", ";\n font-size: 11px;\n color: ", ";\n text-decoration: underline;\n }\n }\n\n .variants-family {\n display: flex;\n flex-direction: column;\n gap: 4px;\n margin-bottom: 10px;\n padding: 8px;\n border: 1px solid ", ";\n border-radius: 6px;\n\n .loading {\n margin: 0;\n font-family: ", ";\n font-size: 11px;\n color: ", ";\n }\n\n .family-row {\n display: flex;\n align-items: baseline;\n gap: 8px;\n padding: 6px 8px;\n border: none;\n border-radius: 4px;\n background: none;\n cursor: pointer;\n text-align: left;\n font-family: ", ";\n font-size: 12px;\n color: ", ";\n }\n\n .family-row:hover:not(:disabled) {\n background-color: ", ";\n }\n\n .family-row:disabled {\n cursor: default;\n opacity: 0.7;\n }\n\n .family-row .role {\n min-width: 96px;\n font-size: 10px;\n color: ", ";\n }\n\n .family-row.current .role {\n color: ", ";\n }\n\n .family-row .name {\n flex: 1;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n\n .family-row .upc {\n font-size: 11px;\n color: ", ";\n }\n\n .editar-juntas {\n align-self: flex-start;\n margin-top: 4px;\n border: 1px solid ", ";\n border-radius: 6px;\n background: none;\n padding: 6px 12px;\n cursor: pointer;\n font-family: ", ";\n font-size: 11px;\n color: ", ";\n }\n }\n"])), function (_ref) {
22
22
  var headerTop = _ref.headerTop;
23
23
  return headerTop;
24
- }, _variables.FontFamily.AvenirNext, _variables.GlobalColors.color_gray, _variables.GlobalColors.rgb_color_pink, _variables.GlobalColors.color_pink, _variables.GlobalColors.rgb_color_pink, _variables.FontFamily.AvenirNext, _variables.GlobalColors.color_pink, _variables.GlobalColors.white, PINK, _variables.FontFamily.Raleway_600, PINK, _variables.FontFamily.Raleway_500, _variables.GlobalColors.gray, _variables.GlobalColors.s2, _variables.FontFamily.Raleway_500, _variables.GlobalColors.gray, _variables.FontFamily.Raleway_500, _variables.GlobalColors.deep_gray, _variables.GlobalColors.s2, PINK, _variables.GlobalColors.gray, _variables.GlobalColors.gray);
24
+ }, _variables.FontFamily.AvenirNext, _variables.GlobalColors.color_gray, _variables.GlobalColors.rgb_color_pink, _variables.GlobalColors.color_pink, _variables.GlobalColors.rgb_color_pink, _variables.FontFamily.AvenirNext, _variables.GlobalColors.color_pink, _variables.GlobalColors.white, PINK, _variables.FontFamily.Raleway_600, PINK, _variables.FontFamily.Raleway_500, _variables.GlobalColors.gray, _variables.GlobalColors.s2, _variables.FontFamily.Raleway_500, _variables.GlobalColors.gray, _variables.FontFamily.Raleway_500, _variables.GlobalColors.deep_gray, _variables.GlobalColors.s2, PINK, _variables.GlobalColors.gray, _variables.GlobalColors.gray, PINK, _variables.FontFamily.Raleway_600, PINK);
25
25
 
26
26
  exports.Container = Container;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "contentoh-components-library",
3
- "version": "21.6.28",
3
+ "version": "21.6.30",
4
4
  "dependencies": {
5
5
  "@aws-amplify/auth": "^4.5.3",
6
6
  "@aws-amplify/datastore": "^3.11.0",
@@ -86,6 +86,8 @@ const ProviderProductEditionView = ({
86
86
  const [loadingVariant, setLoadingVariant] = useState(null);
87
87
  const [pendingPropagation, setPendingPropagation] = useState(null);
88
88
  const [preparandoPropagacion, setPreparandoPropagacion] = useState(false);
89
+ const [preparandoEdicionMultiple, setPreparandoEdicionMultiple] =
90
+ useState(false);
89
91
  const [showRejectModal, setShowRejectModal] = useState(false);
90
92
  const [headerTop, setHeaderTop] = useState(0);
91
93
  const [assig, setAssig] = useState({});
@@ -798,6 +800,70 @@ const ProviderProductEditionView = ({
798
800
  Es un rodeo, y lo es porque el origen del dato está mal puesto. Arreglarlo de
799
801
  raíz —que la ficha lea de la URL— toca todas las plataformas y no cabe aquí.
800
802
  */
803
+ /*
804
+ Abre la edición múltiple con las variantes de la familia ya cargadas.
805
+
806
+ Esa pantalla lee `multipleEditionList` de sessionStorage —así la deja el
807
+ listado al pulsar "editar varios"— y necesita el PRODUCTO COMPLETO de cada
808
+ uno, no solo su id: pinta el UPC, el nombre, parte `categoryName` por "|",
809
+ cuenta `retailersAvailable` y decide columnas según `id_order`. Con un objeto
810
+ reducido revienta al entrar.
811
+
812
+ Por eso se piden a /new-articles, que devuelve justo la forma del listado, y
813
+ se filtran por id y no por UPC: hay 12,024 UPC repetidos entre artículos
814
+ activos y el UPC no identifica un producto.
815
+
816
+ Va SIN el producto padre a propósito, aunque el botón viva en su ficha. En la
817
+ edición múltiple no existe el diálogo de propagación, así que incluirlo
818
+ abriría un camino para cambiar el padre sin decidir si eso baja a los hijos
819
+ —justo la decisión que su propia ficha obliga a tomar—.
820
+ */
821
+ const openMultipleEdition = async () => {
822
+ const ids = (family?.variants ?? []).map((variant) => variant.articleId);
823
+ if (!ids.length) return;
824
+
825
+ setPreparandoEdicionMultiple(true);
826
+ try {
827
+ const res = await axios.get(`${process.env.REACT_APP_NEW_ARTICLES_ENDPOINT}`, {
828
+ params: { listType: "general", filterByArticleId: ids.join(",") },
829
+ headers: { Authorization: token },
830
+ });
831
+
832
+ const { data } = readPayload(res);
833
+ const productos = (data ?? []).filter((item) =>
834
+ ids.includes(Number(item.id_article))
835
+ );
836
+
837
+ if (!productos.length) {
838
+ console.error("openMultipleEdition: sin productos que abrir");
839
+ return;
840
+ }
841
+
842
+ sessionStorage.setItem(
843
+ "multipleEditionList",
844
+ JSON.stringify(
845
+ productos.sort((a, b) => a.id_article - b.id_article)
846
+ )
847
+ );
848
+ window.location.assign("/products/multipleEdition");
849
+ } catch (error) {
850
+ // Se avisa y se queda donde está: navegar con la lista vieja abriría otros
851
+ // productos, y navegar sin lista deja la pantalla rota.
852
+ console.error("openMultipleEdition: ", error);
853
+ dispatch({
854
+ type: "SET_MODAL",
855
+ payload: {
856
+ show: true,
857
+ title: "",
858
+ message: "No se pudieron cargar las variantes para editarlas juntas.",
859
+ image: errorIcon,
860
+ },
861
+ });
862
+ } finally {
863
+ setPreparandoEdicionMultiple(false);
864
+ }
865
+ };
866
+
801
867
  const openVariant = async (articleId) => {
802
868
  setLoadingVariant(articleId);
803
869
  try {
@@ -1700,6 +1766,21 @@ const ProviderProductEditionView = ({
1700
1766
  {family && !family.error && !family.variants?.length && (
1701
1767
  <p className="loading">Este producto no tiene variantes.</p>
1702
1768
  )}
1769
+
1770
+ {/* Editarlas juntas evita abrir seis fichas para llenar lo
1771
+ mismo seis veces, que es el caso real de una familia. */}
1772
+ {family?.variants?.length > 1 && (
1773
+ <button
1774
+ type="button"
1775
+ className="editar-juntas"
1776
+ disabled={preparandoEdicionMultiple}
1777
+ onClick={openMultipleEdition}
1778
+ >
1779
+ {preparandoEdicionMultiple
1780
+ ? "Abriendo…"
1781
+ : `Editar las ${family.variants.length} variantes juntas`}
1782
+ </button>
1783
+ )}
1703
1784
  </div>
1704
1785
  )}
1705
1786
  <FullProductNameHeader
@@ -253,5 +253,18 @@ export const Container = styled.div`
253
253
  font-size: 11px;
254
254
  color: ${GlobalColors.gray};
255
255
  }
256
+
257
+ .editar-juntas {
258
+ align-self: flex-start;
259
+ margin-top: 4px;
260
+ border: 1px solid ${PINK};
261
+ border-radius: 6px;
262
+ background: none;
263
+ padding: 6px 12px;
264
+ cursor: pointer;
265
+ font-family: ${FontFamily.Raleway_600};
266
+ font-size: 11px;
267
+ color: ${PINK};
268
+ }
256
269
  }
257
270
  `;