contentoh-components-library 21.6.24 → 21.6.26

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.
@@ -25,6 +25,8 @@ var _axios = _interopRequireDefault(require("axios"));
25
25
 
26
26
  var _api = require("./api");
27
27
 
28
+ var _SingleSelect = require("../../molecules/SingleSelect");
29
+
28
30
  var _helper = require("../../../_utils/helper");
29
31
 
30
32
  var _styles = require("./styles");
@@ -182,9 +184,12 @@ var LinkVariantsModal = function LinkVariantsModal(_ref) {
182
184
  cuatro decisiones por producto. Al desmarcarlo aparecen las pestañas y cada
183
185
  producto guarda su propia selección en `perChild`.
184
186
  */
187
+ // Desmarcado a propósito: aplicar la misma herencia a varios productos es una
188
+ // decisión, no un valor por omisión. Marcado de entrada se ligaban todos igual
189
+ // sin que nadie lo hubiera elegido.
185
190
 
186
191
 
187
- var _useState29 = (0, _react.useState)(true),
192
+ var _useState29 = (0, _react.useState)(false),
188
193
  _useState30 = (0, _slicedToArray2.default)(_useState29, 2),
189
194
  applyToAll = _useState30[0],
190
195
  setApplyToAll = _useState30[1];
@@ -199,53 +204,68 @@ var LinkVariantsModal = function LinkVariantsModal(_ref) {
199
204
  perChild = _useState34[0],
200
205
  setPerChild = _useState34[1]; // Cadenas que el padre NO tiene y el usuario decidió agregar a la variante.
201
206
 
207
+ /*
208
+ Imágenes que la base lista pero cuyo archivo no está en S3.
209
+ Pasa: hay filas de rel_article_image con un src válido que apunta a un objeto
210
+ que ya no existe —comprobado, CloudFront responde 404—. Sin esto el paso 4
211
+ muestra una tarjeta rota, con el texto alternativo donde debería ir la foto, y
212
+ deja marcar para heredar algo que no se puede heredar.
213
+ No se puede saber desde el servidor sin ir a S3 por cada imagen, así que se
214
+ detecta al fallar la carga y se descuenta de la lista y del conteo.
215
+ */
216
+
202
217
 
203
218
  var _useState35 = (0, _react.useState)([]),
204
219
  _useState36 = (0, _slicedToArray2.default)(_useState35, 2),
205
- extraRetailers = _useState36[0],
206
- setExtraRetailers = _useState36[1];
220
+ brokenImages = _useState36[0],
221
+ setBrokenImages = _useState36[1];
207
222
 
208
- var _useState37 = (0, _react.useState)(""),
223
+ var _useState37 = (0, _react.useState)([]),
209
224
  _useState38 = (0, _slicedToArray2.default)(_useState37, 2),
210
- newRetailer = _useState38[0],
211
- setNewRetailer = _useState38[1];
225
+ extraRetailers = _useState38[0],
226
+ setExtraRetailers = _useState38[1];
212
227
 
213
228
  var _useState39 = (0, _react.useState)(""),
214
229
  _useState40 = (0, _slicedToArray2.default)(_useState39, 2),
215
- newDepartment = _useState40[0],
216
- setNewDepartment = _useState40[1];
230
+ newRetailer = _useState40[0],
231
+ setNewRetailer = _useState40[1];
217
232
 
218
233
  var _useState41 = (0, _react.useState)(""),
219
234
  _useState42 = (0, _slicedToArray2.default)(_useState41, 2),
220
- newCategory = _useState42[0],
221
- setNewCategory = _useState42[1]; // Las categorías no son una lista plana: dependen de la cadena y del
235
+ newDepartment = _useState42[0],
236
+ setNewDepartment = _useState42[1];
237
+
238
+ var _useState43 = (0, _react.useState)(""),
239
+ _useState44 = (0, _slicedToArray2.default)(_useState43, 2),
240
+ newCategory = _useState44[0],
241
+ setNewCategory = _useState44[1]; // Las categorías no son una lista plana: dependen de la cadena y del
222
242
  // departamento. Es la misma cascada que usa el alta de productos, y se sirve
223
243
  // del mismo endpoint para no acabar con dos árboles de categorías distintos.
224
244
 
225
245
 
226
- var _useState43 = (0, _react.useState)({
246
+ var _useState45 = (0, _react.useState)({
227
247
  retailers: [],
228
248
  departments: [],
229
249
  categories: []
230
250
  }),
231
- _useState44 = (0, _slicedToArray2.default)(_useState43, 2),
232
- filters = _useState44[0],
233
- setFilters = _useState44[1];
234
-
235
- var _useState45 = (0, _react.useState)(false),
236
251
  _useState46 = (0, _slicedToArray2.default)(_useState45, 2),
237
- loadingFilters = _useState46[0],
238
- setLoadingFilters = _useState46[1];
252
+ filters = _useState46[0],
253
+ setFilters = _useState46[1];
239
254
 
240
255
  var _useState47 = (0, _react.useState)(false),
241
256
  _useState48 = (0, _slicedToArray2.default)(_useState47, 2),
242
- loading = _useState48[0],
243
- setLoading = _useState48[1];
257
+ loadingFilters = _useState48[0],
258
+ setLoadingFilters = _useState48[1];
244
259
 
245
- var _useState49 = (0, _react.useState)(null),
260
+ var _useState49 = (0, _react.useState)(false),
246
261
  _useState50 = (0, _slicedToArray2.default)(_useState49, 2),
247
- error = _useState50[0],
248
- setError = _useState50[1];
262
+ loading = _useState50[0],
263
+ setLoading = _useState50[1];
264
+
265
+ var _useState51 = (0, _react.useState)(null),
266
+ _useState52 = (0, _slicedToArray2.default)(_useState51, 2),
267
+ error = _useState52[0],
268
+ setError = _useState52[1];
249
269
 
250
270
  var request = (0, _react.useCallback)( /*#__PURE__*/function () {
251
271
  var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(action, body) {
@@ -456,29 +476,30 @@ var LinkVariantsModal = function LinkVariantsModal(_ref) {
456
476
  images: null
457
477
  });
458
478
  setExtraRetailers([]);
479
+ setBrokenImages([]);
459
480
  setPerChild({});
460
- setApplyToAll(true);
481
+ setApplyToAll(false);
461
482
  setActiveChild(mode === "children" ? selected[0] : null);
462
483
  setStep("inherit");
463
- _context4.next = 21;
484
+ _context4.next = 22;
464
485
  break;
465
486
 
466
- case 18:
467
- _context4.prev = 18;
487
+ case 19:
488
+ _context4.prev = 19;
468
489
  _context4.t0 = _context4["catch"](2);
469
490
  setError(readError(_context4.t0));
470
491
 
471
- case 21:
472
- _context4.prev = 21;
492
+ case 22:
493
+ _context4.prev = 22;
473
494
  setLoading(false);
474
- return _context4.finish(21);
495
+ return _context4.finish(22);
475
496
 
476
- case 24:
497
+ case 25:
477
498
  case "end":
478
499
  return _context4.stop();
479
500
  }
480
501
  }
481
- }, _callee4, null, [[2, 18, 21, 24]]);
502
+ }, _callee4, null, [[2, 19, 22, 25]]);
482
503
  }));
483
504
 
484
505
  return function goToInheritance() {
@@ -506,7 +527,7 @@ var LinkVariantsModal = function LinkVariantsModal(_ref) {
506
527
 
507
528
  var loadFilters = (0, _react.useCallback)( /*#__PURE__*/function () {
508
529
  var _ref6 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5(retailer, department) {
509
- var _data, _ref7, res, _readPayload, body, lista;
530
+ var _readPayload$data, _readPayload, res, lista;
510
531
 
511
532
  return _regenerator.default.wrap(function _callee5$(_context5) {
512
533
  while (1) {
@@ -523,8 +544,10 @@ var LinkVariantsModal = function LinkVariantsModal(_ref) {
523
544
 
524
545
  case 4:
525
546
  res = _context5.sent;
526
- _readPayload = (0, _api.readPayload)(res), body = _readPayload.body;
527
- lista = (_data = (_ref7 = body ? JSON.parse(body) : res.data) === null || _ref7 === void 0 ? void 0 : _ref7.data) !== null && _data !== void 0 ? _data : [];
547
+ // readPayload YA devuelve el cuerpo parseado. Volver a buscar `body`
548
+ // dentro dejaba la lista siempre vacía, y por eso el selector de cadenas
549
+ // no mostraba nada.
550
+ lista = (_readPayload$data = (_readPayload = (0, _api.readPayload)(res)) === null || _readPayload === void 0 ? void 0 : _readPayload.data) !== null && _readPayload$data !== void 0 ? _readPayload$data : [];
528
551
  setFilters(function (current) {
529
552
  if (!retailer) {
530
553
  return (0, _objectSpread6.default)((0, _objectSpread6.default)({}, current), {}, {
@@ -547,36 +570,42 @@ var LinkVariantsModal = function LinkVariantsModal(_ref) {
547
570
  }),
548
571
  categories: []
549
572
  });
550
- }
573
+ } // El tercer nivel no viene como {id, name} sino como
574
+ // {category_id, subcategory}: con el mapeo de los otros dos, la
575
+ // categoría salía en la lista pero sin texto. Mismo criterio que usa
576
+ // el alta de productos, incluido el separador legible.
577
+
551
578
 
552
579
  return (0, _objectSpread6.default)((0, _objectSpread6.default)({}, current), {}, {
553
580
  categories: lista.map(function (item) {
581
+ var _item$subcategory;
582
+
554
583
  return {
555
- value: item.id,
556
- label: item.name
584
+ value: item.category_id,
585
+ label: ((_item$subcategory = item.subcategory) !== null && _item$subcategory !== void 0 ? _item$subcategory : "").replace("|", " > ")
557
586
  };
558
587
  })
559
588
  });
560
589
  });
561
- _context5.next = 13;
590
+ _context5.next = 12;
562
591
  break;
563
592
 
564
- case 10:
565
- _context5.prev = 10;
593
+ case 9:
594
+ _context5.prev = 9;
566
595
  _context5.t0 = _context5["catch"](1);
567
596
  console.error("linkVariants/filters: ", _context5.t0);
568
597
 
569
- case 13:
570
- _context5.prev = 13;
598
+ case 12:
599
+ _context5.prev = 12;
571
600
  setLoadingFilters(false);
572
- return _context5.finish(13);
601
+ return _context5.finish(12);
573
602
 
574
- case 16:
603
+ case 15:
575
604
  case "end":
576
605
  return _context5.stop();
577
606
  }
578
607
  }
579
- }, _callee5, null, [[1, 10, 13, 16]]);
608
+ }, _callee5, null, [[1, 9, 12, 15]]);
580
609
  }));
581
610
 
582
611
  return function (_x4, _x5) {
@@ -636,7 +665,13 @@ var LinkVariantsModal = function LinkVariantsModal(_ref) {
636
665
  Las parejas cadena+categoría viajan como objetos, no como ids, porque pueden
637
666
  ser cadenas que el padre no tiene: ahí no hay nada que heredar, se asigna.
638
667
  */
668
+ // Las que de verdad se pueden heredar: la base puede listar filas cuyo archivo
669
+ // ya no existe, y esas no cuentan ni para la lista ni para el "todas".
670
+
639
671
 
672
+ var imagenesUtiles = offered.images.filter(function (image) {
673
+ return !brokenImages.includes(image.id);
674
+ });
640
675
 
641
676
  var buildInherit = function buildInherit(seleccion) {
642
677
  var _seleccion$extraRetai;
@@ -654,9 +689,9 @@ var LinkVariantsModal = function LinkVariantsModal(_ref) {
654
689
  images: seleccion.modes.images === "all" ? "all" : seleccion.chosen.images,
655
690
  categoryRetailers: parejas.filter(function (par) {
656
691
  return seleccion.chosen.categoryRetailers.includes(par.clave);
657
- }).map(function (_ref8) {
658
- var retailerId = _ref8.retailerId,
659
- categoryId = _ref8.categoryId;
692
+ }).map(function (_ref7) {
693
+ var retailerId = _ref7.retailerId,
694
+ categoryId = _ref7.categoryId;
660
695
  return {
661
696
  retailerId: retailerId,
662
697
  categoryId: categoryId
@@ -706,7 +741,7 @@ var LinkVariantsModal = function LinkVariantsModal(_ref) {
706
741
  };
707
742
 
708
743
  var submit = /*#__PURE__*/function () {
709
- var _ref9 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6() {
744
+ var _ref8 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6() {
710
745
  var inherit, inheritByChild, body, data;
711
746
  return _regenerator.default.wrap(function _callee6$(_context6) {
712
747
  while (1) {
@@ -780,14 +815,21 @@ var LinkVariantsModal = function LinkVariantsModal(_ref) {
780
815
  }));
781
816
 
782
817
  return function submit() {
783
- return _ref9.apply(this, arguments);
818
+ return _ref8.apply(this, arguments);
784
819
  };
785
820
  }(); // Una dimensión está decidida si el usuario eligió un modo, o si el padre no
786
821
  // ofrece nada en ella —no se puede pedir que decida sobre una lista vacía—.
787
822
 
788
823
 
789
824
  var decidida = function decidida(dimension) {
790
- return modes[dimension] !== null || (dimension === "categoryRetailers" ? offered.categoryRetailers.length === 0 && extraRetailers.length === 0 : offered[dimension].length === 0);
825
+ if (modes[dimension] !== null) return true;
826
+
827
+ if (dimension === "categoryRetailers") {
828
+ return offered.categoryRetailers.length === 0 && extraRetailers.length === 0;
829
+ } // Una imagen cuyo archivo no existe no es algo sobre lo que se pueda decidir.
830
+
831
+
832
+ return dimension === "images" ? imagenesUtiles.length === 0 : offered[dimension].length === 0;
791
833
  };
792
834
 
793
835
  var DIMENSIONES = ["categoryRetailers", "descriptions", "attributes", "images"]; // Con pestañas, que la que estoy viendo esté completa no basta: ligar escribe
@@ -802,22 +844,27 @@ var LinkVariantsModal = function LinkVariantsModal(_ref) {
802
844
  } : perChild[id];
803
845
  if (!guardado) return false;
804
846
  return DIMENSIONES.every(function (dimension) {
805
- var _guardado$extraRetail2;
806
-
807
847
  if (guardado.modes[dimension] !== null) return true;
808
- return dimension === "categoryRetailers" ? offered.categoryRetailers.length === 0 && ((_guardado$extraRetail2 = guardado.extraRetailers) !== null && _guardado$extraRetail2 !== void 0 ? _guardado$extraRetail2 : []).length === 0 : offered[dimension].length === 0;
848
+
849
+ if (dimension === "categoryRetailers") {
850
+ var _guardado$extraRetail2;
851
+
852
+ return offered.categoryRetailers.length === 0 && ((_guardado$extraRetail2 = guardado.extraRetailers) !== null && _guardado$extraRetail2 !== void 0 ? _guardado$extraRetail2 : []).length === 0;
853
+ }
854
+
855
+ return dimension === "images" ? imagenesUtiles.length === 0 : offered[dimension].length === 0;
809
856
  });
810
857
  };
811
858
 
812
859
  var todoDecidido = step === "inherit" && (applyToAll || mode !== "children" ? DIMENSIONES.every(decidida) : selected.every(decididoPara));
813
- var faltantes = [["categoryRetailers", "cadenas"], ["descriptions", "descripciones"], ["attributes", "atributos"], ["images", "imágenes"]].filter(function (_ref10) {
814
- var _ref11 = (0, _slicedToArray2.default)(_ref10, 1),
815
- clave = _ref11[0];
860
+ var faltantes = [["categoryRetailers", "cadenas"], ["descriptions", "descripciones"], ["attributes", "atributos"], ["images", "imágenes"]].filter(function (_ref9) {
861
+ var _ref10 = (0, _slicedToArray2.default)(_ref9, 1),
862
+ clave = _ref10[0];
816
863
 
817
864
  return !decidida(clave);
818
- }).map(function (_ref12) {
819
- var _ref13 = (0, _slicedToArray2.default)(_ref12, 2),
820
- nombre = _ref13[1];
865
+ }).map(function (_ref11) {
866
+ var _ref12 = (0, _slicedToArray2.default)(_ref11, 2),
867
+ nombre = _ref12[1];
821
868
 
822
869
  return nombre;
823
870
  });
@@ -964,6 +1011,7 @@ var LinkVariantsModal = function LinkVariantsModal(_ref) {
964
1011
  children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("label", {
965
1012
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("input", {
966
1013
  type: "radio",
1014
+ name: "categoryRetailers-".concat(activeChild !== null && activeChild !== void 0 ? activeChild : "todos"),
967
1015
  checked: modes.categoryRetailers === "all",
968
1016
  onChange: function onChange() {
969
1017
  return chooseMode("categoryRetailers", "all", offered.categoryRetailers.map(function (item) {
@@ -979,6 +1027,7 @@ var LinkVariantsModal = function LinkVariantsModal(_ref) {
979
1027
  }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("label", {
980
1028
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("input", {
981
1029
  type: "radio",
1030
+ name: "categoryRetailers-".concat(activeChild !== null && activeChild !== void 0 ? activeChild : "todos"),
982
1031
  checked: modes.categoryRetailers === "some",
983
1032
  onChange: function onChange() {
984
1033
  return chooseMode("categoryRetailers", "some", []);
@@ -1024,62 +1073,45 @@ var LinkVariantsModal = function LinkVariantsModal(_ref) {
1024
1073
  }, item.clave);
1025
1074
  })
1026
1075
  }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_styles.AddRetailer, {
1027
- children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("select", {
1076
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_SingleSelect.SingleSelect, {
1077
+ id: "link-variants-retailer",
1078
+ placeholder: "Agregar otra cadena\u2026",
1079
+ options: filters.retailers,
1028
1080
  value: newRetailer,
1029
- onChange: function onChange(event) {
1030
- var valor = event.target.value;
1031
- setNewRetailer(valor);
1081
+ loading: loadingFilters && !filters.retailers.length,
1082
+ onChange: function onChange(valor) {
1083
+ setNewRetailer(valor !== null && valor !== void 0 ? valor : "");
1032
1084
  setNewDepartment("");
1033
1085
  setNewCategory("");
1034
1086
  if (valor) loadFilters(valor, null);
1035
- },
1036
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("option", {
1037
- value: "",
1038
- children: "Agregar otra cadena\u2026"
1039
- }), filters.retailers.map(function (item) {
1040
- return /*#__PURE__*/(0, _jsxRuntime.jsx)("option", {
1041
- value: item.value,
1042
- children: item.label
1043
- }, item.value);
1044
- })]
1045
- }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("select", {
1087
+ }
1088
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_SingleSelect.SingleSelect, {
1089
+ id: "link-variants-department",
1090
+ placeholder: "Departamento\u2026",
1091
+ options: filters.departments,
1046
1092
  value: newDepartment,
1047
- disabled: !newRetailer || !filters.departments.length,
1048
- onChange: function onChange(event) {
1049
- var valor = event.target.value;
1050
- setNewDepartment(valor);
1093
+ disabled: !newRetailer,
1094
+ loading: loadingFilters && !!newRetailer,
1095
+ onChange: function onChange(valor) {
1096
+ setNewDepartment(valor !== null && valor !== void 0 ? valor : "");
1051
1097
  setNewCategory("");
1052
1098
  if (valor) loadFilters(newRetailer, valor);
1053
- },
1054
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("option", {
1055
- value: "",
1056
- children: "Departamento\u2026"
1057
- }), filters.departments.map(function (item) {
1058
- return /*#__PURE__*/(0, _jsxRuntime.jsx)("option", {
1059
- value: item.value,
1060
- children: item.label
1061
- }, item.value);
1062
- })]
1063
- }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("select", {
1099
+ }
1100
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_SingleSelect.SingleSelect, {
1101
+ id: "link-variants-category",
1102
+ placeholder: "Categor\xEDa\u2026",
1103
+ options: filters.categories,
1064
1104
  value: newCategory,
1065
- disabled: !newDepartment || !filters.categories.length,
1066
- onChange: function onChange(event) {
1067
- return setNewCategory(event.target.value);
1068
- },
1069
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("option", {
1070
- value: "",
1071
- children: "Categor\xEDa\u2026"
1072
- }), filters.categories.map(function (item) {
1073
- return /*#__PURE__*/(0, _jsxRuntime.jsx)("option", {
1074
- value: item.value,
1075
- children: item.label
1076
- }, item.value);
1077
- })]
1105
+ disabled: !newDepartment,
1106
+ loading: loadingFilters && !!newDepartment,
1107
+ onChange: function onChange(valor) {
1108
+ return setNewCategory(valor !== null && valor !== void 0 ? valor : "");
1109
+ }
1078
1110
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)("button", {
1079
1111
  type: "button",
1080
1112
  onClick: addRetailer,
1081
1113
  disabled: !newRetailer || !newCategory || loadingFilters,
1082
- children: loadingFilters ? "…" : "Agregar"
1114
+ children: "Agregar"
1083
1115
  })]
1084
1116
  })]
1085
1117
  }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_styles.Block, {
@@ -1093,6 +1125,7 @@ var LinkVariantsModal = function LinkVariantsModal(_ref) {
1093
1125
  children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("label", {
1094
1126
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("input", {
1095
1127
  type: "radio",
1128
+ name: "descriptions-".concat(activeChild !== null && activeChild !== void 0 ? activeChild : "todos"),
1096
1129
  checked: modes.descriptions === "all",
1097
1130
  onChange: function onChange() {
1098
1131
  return chooseMode("descriptions", "all", offered.descriptions.map(function (item) {
@@ -1108,6 +1141,7 @@ var LinkVariantsModal = function LinkVariantsModal(_ref) {
1108
1141
  }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("label", {
1109
1142
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("input", {
1110
1143
  type: "radio",
1144
+ name: "descriptions-".concat(activeChild !== null && activeChild !== void 0 ? activeChild : "todos"),
1111
1145
  checked: modes.descriptions === "some",
1112
1146
  onChange: function onChange() {
1113
1147
  return chooseMode("descriptions", "some", []);
@@ -1158,6 +1192,7 @@ var LinkVariantsModal = function LinkVariantsModal(_ref) {
1158
1192
  children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("label", {
1159
1193
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("input", {
1160
1194
  type: "radio",
1195
+ name: "attributes-".concat(activeChild !== null && activeChild !== void 0 ? activeChild : "todos"),
1161
1196
  checked: modes.attributes === "all",
1162
1197
  onChange: function onChange() {
1163
1198
  return chooseMode("attributes", "all", offered.attributes.map(function (item) {
@@ -1173,6 +1208,7 @@ var LinkVariantsModal = function LinkVariantsModal(_ref) {
1173
1208
  }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("label", {
1174
1209
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("input", {
1175
1210
  type: "radio",
1211
+ name: "attributes-".concat(activeChild !== null && activeChild !== void 0 ? activeChild : "todos"),
1176
1212
  checked: modes.attributes === "some",
1177
1213
  onChange: function onChange() {
1178
1214
  return chooseMode("attributes", "some", []);
@@ -1217,65 +1253,68 @@ var LinkVariantsModal = function LinkVariantsModal(_ref) {
1217
1253
  }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_styles.Message, {
1218
1254
  children: "El producto padre no tiene atributos con valor que heredar."
1219
1255
  })]
1220
- }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_styles.Block, {
1256
+ }), imagenesUtiles.length > 0 && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_styles.Block, {
1221
1257
  children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("h3", {
1222
1258
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
1223
1259
  className: "paso",
1224
1260
  children: "4"
1225
1261
  }), " Im\xE1genes"]
1226
- }), offered.images.length ? /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
1227
- children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_styles.Choices, {
1228
- children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("label", {
1229
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("input", {
1230
- type: "radio",
1231
- checked: modes.images === "all",
1232
- onChange: function onChange() {
1233
- return chooseMode("images", "all", offered.images.map(function (item) {
1234
- return item.id;
1235
- }));
1236
- }
1237
- }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("span", {
1238
- children: ["Todas", /*#__PURE__*/(0, _jsxRuntime.jsxs)("span", {
1239
- className: "hint",
1240
- children: [offered.images.length, " imagen(es) en el padre."]
1241
- })]
1262
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_styles.Choices, {
1263
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("label", {
1264
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("input", {
1265
+ type: "radio",
1266
+ name: "images-".concat(activeChild !== null && activeChild !== void 0 ? activeChild : "todos"),
1267
+ checked: modes.images === "all",
1268
+ onChange: function onChange() {
1269
+ return chooseMode("images", "all", imagenesUtiles.map(function (item) {
1270
+ return item.id;
1271
+ }));
1272
+ }
1273
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("span", {
1274
+ children: ["Todas", /*#__PURE__*/(0, _jsxRuntime.jsxs)("span", {
1275
+ className: "hint",
1276
+ children: [imagenesUtiles.length, " imagen(es) en el padre."]
1242
1277
  })]
1243
- }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("label", {
1278
+ })]
1279
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("label", {
1280
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("input", {
1281
+ type: "radio",
1282
+ name: "images-".concat(activeChild !== null && activeChild !== void 0 ? activeChild : "todos"),
1283
+ checked: modes.images === "some",
1284
+ onChange: function onChange() {
1285
+ return chooseMode("images", "some", []);
1286
+ }
1287
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("span", {
1288
+ children: ["Elegir cu\xE1les", /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
1289
+ className: "hint",
1290
+ children: "\xDAtil cuando la variante cambia de color o de empaque."
1291
+ })]
1292
+ })]
1293
+ })]
1294
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_styles.ImageGrid, {
1295
+ children: imagenesUtiles.map(function (image) {
1296
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)("label", {
1297
+ className: [chosen.images.includes(image.id) ? "picked" : "", modes.images === "all" ? "locked" : ""].filter(Boolean).join(" "),
1244
1298
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("input", {
1245
- type: "radio",
1246
- checked: modes.images === "some",
1299
+ type: "checkbox",
1300
+ disabled: modes.images === "all",
1301
+ checked: chosen.images.includes(image.id),
1247
1302
  onChange: function onChange() {
1248
- return chooseMode("images", "some", []);
1303
+ return toggleChoice("images", image.id);
1249
1304
  }
1250
- }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("span", {
1251
- children: ["Elegir cu\xE1les", /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
1252
- className: "hint",
1253
- children: "\xDAtil cuando la variante cambia de color o de empaque."
1254
- })]
1305
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("img", {
1306
+ src: (0, _helper.getProductImage)(image.src),
1307
+ alt: "",
1308
+ onError: function onError() {
1309
+ return setBrokenImages(function (current) {
1310
+ return current.includes(image.id) ? current : [].concat((0, _toConsumableArray2.default)(current), [image.id]);
1311
+ });
1312
+ }
1313
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
1314
+ children: image.imageType || "Sin tipo de toma"
1255
1315
  })]
1256
- })]
1257
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_styles.ImageGrid, {
1258
- children: offered.images.map(function (image) {
1259
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)("label", {
1260
- className: [chosen.images.includes(image.id) ? "picked" : "", modes.images === "all" ? "locked" : ""].filter(Boolean).join(" "),
1261
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("input", {
1262
- type: "checkbox",
1263
- disabled: modes.images === "all",
1264
- checked: chosen.images.includes(image.id),
1265
- onChange: function onChange() {
1266
- return toggleChoice("images", image.id);
1267
- }
1268
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)("img", {
1269
- src: (0, _helper.getProductImage)(image.src),
1270
- alt: image.imageType || "Imagen del producto"
1271
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
1272
- children: image.imageType || "Sin tipo de toma"
1273
- })]
1274
- }, image.id);
1275
- })
1276
- })]
1277
- }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_styles.Message, {
1278
- children: "El producto padre no tiene im\xE1genes que heredar."
1316
+ }, image.id);
1317
+ })
1279
1318
  })]
1280
1319
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_styles.Message, {
1281
1320
  children: "Lo que elijas heredar reemplaza el valor actual de la variante, incluso si alguien lo hab\xEDa capturado a mano."