contentoh-components-library 21.6.23 → 21.6.25

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.
@@ -11,7 +11,7 @@ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"))
11
11
 
12
12
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/defineProperty"));
13
13
 
14
- var _objectSpread4 = _interopRequireDefault(require("@babel/runtime/helpers/esm/objectSpread2"));
14
+ var _objectSpread6 = _interopRequireDefault(require("@babel/runtime/helpers/esm/objectSpread2"));
15
15
 
16
16
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/toConsumableArray"));
17
17
 
@@ -25,6 +25,8 @@ var _axios = _interopRequireDefault(require("axios"));
25
25
 
26
26
  var _api = require("./api");
27
27
 
28
+ var _helper = require("../../../_utils/helper");
29
+
28
30
  var _styles = require("./styles");
29
31
 
30
32
  var _jsxRuntime = require("react/jsx-runtime");
@@ -74,11 +76,11 @@ var LinkVariantsModal = function LinkVariantsModal(_ref) {
74
76
  articleName = _ref.articleName,
75
77
  articleUpc = _ref.articleUpc,
76
78
  activeRetailerId = _ref.activeRetailerId,
77
- retailersAvailable = _ref.retailersAvailable,
78
- categoriesAvailable = _ref.categoriesAvailable,
79
79
  token = _ref.token,
80
80
  _ref$endpoint = _ref.endpoint,
81
81
  endpoint = _ref$endpoint === void 0 ? process.env.REACT_APP_VARIANTS_ENDPOINT : _ref$endpoint,
82
+ _ref$filtersEndpoint = _ref.filtersEndpoint,
83
+ filtersEndpoint = _ref$filtersEndpoint === void 0 ? process.env.REACT_APP_CREATE_PRODUCTS_FILTERS : _ref$filtersEndpoint,
82
84
  onClose = _ref.onClose,
83
85
  onLinked = _ref.onLinked;
84
86
 
@@ -115,71 +117,153 @@ var LinkVariantsModal = function LinkVariantsModal(_ref) {
115
117
  var _useState13 = (0, _react.useState)([]),
116
118
  _useState14 = (0, _slicedToArray2.default)(_useState13, 2),
117
119
  selected = _useState14[0],
118
- setSelected = _useState14[1]; // Lo que el padre ofrece en cada dimensión, y lo que el usuario eligió de
120
+ setSelected = _useState14[1];
121
+
122
+ var _useState15 = (0, _react.useState)(0),
123
+ _useState16 = (0, _slicedToArray2.default)(_useState15, 2),
124
+ total = _useState16[0],
125
+ setTotal = _useState16[1];
126
+
127
+ var _useState17 = (0, _react.useState)(false),
128
+ _useState18 = (0, _slicedToArray2.default)(_useState17, 2),
129
+ hasMore = _useState18[0],
130
+ setHasMore = _useState18[1];
131
+
132
+ var _useState19 = (0, _react.useState)(false),
133
+ _useState20 = (0, _slicedToArray2.default)(_useState19, 2),
134
+ loadingMore = _useState20[0],
135
+ setLoadingMore = _useState20[1]; // Lo que el padre ofrece en cada dimensión, y lo que el usuario eligió de
119
136
  // cada una. Se guardan por separado porque se eligen por separado: heredar
120
137
  // todos los atributos no dice nada sobre qué fotos quiere la variante.
121
138
 
122
139
 
123
- var _useState15 = (0, _react.useState)({
140
+ var _useState21 = (0, _react.useState)({
124
141
  attributes: [],
125
142
  descriptions: [],
126
143
  images: [],
127
144
  categoryRetailers: []
128
145
  }),
129
- _useState16 = (0, _slicedToArray2.default)(_useState15, 2),
130
- offered = _useState16[0],
131
- setOffered = _useState16[1];
146
+ _useState22 = (0, _slicedToArray2.default)(_useState21, 2),
147
+ offered = _useState22[0],
148
+ setOffered = _useState22[1];
132
149
 
133
- var _useState17 = (0, _react.useState)({
150
+ var _useState23 = (0, _react.useState)({
134
151
  attributes: [],
135
152
  descriptions: [],
136
153
  images: [],
137
154
  categoryRetailers: []
138
155
  }),
139
- _useState18 = (0, _slicedToArray2.default)(_useState17, 2),
140
- chosen = _useState18[0],
141
- setChosen = _useState18[1];
142
-
143
- var _useState19 = (0, _react.useState)(null),
144
- _useState20 = (0, _slicedToArray2.default)(_useState19, 2),
145
- nameScope = _useState20[0],
146
- setNameScope = _useState20[1];
147
-
148
- var _useState21 = (0, _react.useState)("all-filled"),
149
- _useState22 = (0, _slicedToArray2.default)(_useState21, 2),
150
- inheritMode = _useState22[0],
151
- setInheritMode = _useState22[1];
152
-
153
- var _useState23 = (0, _react.useState)("attributes"),
154
156
  _useState24 = (0, _slicedToArray2.default)(_useState23, 2),
155
- openSection = _useState24[0],
156
- setOpenSection = _useState24[1]; // Cadenas que el padre NO tiene y el usuario decidió agregar a la variante.
157
+ chosen = _useState24[0],
158
+ setChosen = _useState24[1];
157
159
 
158
-
159
- var _useState25 = (0, _react.useState)([]),
160
+ var _useState25 = (0, _react.useState)(null),
160
161
  _useState26 = (0, _slicedToArray2.default)(_useState25, 2),
161
- extraRetailers = _useState26[0],
162
- setExtraRetailers = _useState26[1];
163
-
164
- var _useState27 = (0, _react.useState)(""),
162
+ nameScope = _useState26[0],
163
+ setNameScope = _useState26[1]; // Un modo por dimensión, y ninguno decidido de entrada: el usuario tiene que
164
+ // pasar por las cuatro antes de poder ligar. Preseleccionar "todo" hacía que
165
+ // se pudiera ligar sin haber mirado nada, que es justo lo que hay que evitar
166
+ // en una operación que sobrescribe valores capturados.
167
+
168
+
169
+ var _useState27 = (0, _react.useState)({
170
+ categoryRetailers: null,
171
+ descriptions: null,
172
+ attributes: null,
173
+ images: null
174
+ }),
165
175
  _useState28 = (0, _slicedToArray2.default)(_useState27, 2),
166
- newRetailer = _useState28[0],
167
- setNewRetailer = _useState28[1];
168
-
169
- var _useState29 = (0, _react.useState)(""),
176
+ modes = _useState28[0],
177
+ setModes = _useState28[1];
178
+ /*
179
+ Al ligar varios productos, la herencia puede ser la misma para todos o
180
+ distinta para cada uno.
181
+ Por defecto es la misma: es lo que se quiere casi siempre y evita repetir
182
+ cuatro decisiones por producto. Al desmarcarlo aparecen las pestañas y cada
183
+ producto guarda su propia selección en `perChild`.
184
+ */
185
+ // Desmarcado a propósito: aplicar la misma herencia a varios productos es una
186
+ // decisión, no un valor por omisión. Marcado de entrada se ligaban todos igual
187
+ // sin que nadie lo hubiera elegido.
188
+
189
+
190
+ var _useState29 = (0, _react.useState)(false),
170
191
  _useState30 = (0, _slicedToArray2.default)(_useState29, 2),
171
- newCategory = _useState30[0],
172
- setNewCategory = _useState30[1];
192
+ applyToAll = _useState30[0],
193
+ setApplyToAll = _useState30[1];
173
194
 
174
- var _useState31 = (0, _react.useState)(false),
195
+ var _useState31 = (0, _react.useState)(null),
175
196
  _useState32 = (0, _slicedToArray2.default)(_useState31, 2),
176
- loading = _useState32[0],
177
- setLoading = _useState32[1];
197
+ activeChild = _useState32[0],
198
+ setActiveChild = _useState32[1];
178
199
 
179
- var _useState33 = (0, _react.useState)(null),
200
+ var _useState33 = (0, _react.useState)({}),
180
201
  _useState34 = (0, _slicedToArray2.default)(_useState33, 2),
181
- error = _useState34[0],
182
- setError = _useState34[1];
202
+ perChild = _useState34[0],
203
+ setPerChild = _useState34[1]; // Cadenas que el padre NO tiene y el usuario decidió agregar a la variante.
204
+
205
+ /*
206
+ Imágenes que la base lista pero cuyo archivo no está en S3.
207
+ Pasa: hay filas de rel_article_image con un src válido que apunta a un objeto
208
+ que ya no existe —comprobado, CloudFront responde 404—. Sin esto el paso 4
209
+ muestra una tarjeta rota, con el texto alternativo donde debería ir la foto, y
210
+ deja marcar para heredar algo que no se puede heredar.
211
+ No se puede saber desde el servidor sin ir a S3 por cada imagen, así que se
212
+ detecta al fallar la carga y se descuenta de la lista y del conteo.
213
+ */
214
+
215
+
216
+ var _useState35 = (0, _react.useState)([]),
217
+ _useState36 = (0, _slicedToArray2.default)(_useState35, 2),
218
+ brokenImages = _useState36[0],
219
+ setBrokenImages = _useState36[1];
220
+
221
+ var _useState37 = (0, _react.useState)([]),
222
+ _useState38 = (0, _slicedToArray2.default)(_useState37, 2),
223
+ extraRetailers = _useState38[0],
224
+ setExtraRetailers = _useState38[1];
225
+
226
+ var _useState39 = (0, _react.useState)(""),
227
+ _useState40 = (0, _slicedToArray2.default)(_useState39, 2),
228
+ newRetailer = _useState40[0],
229
+ setNewRetailer = _useState40[1];
230
+
231
+ var _useState41 = (0, _react.useState)(""),
232
+ _useState42 = (0, _slicedToArray2.default)(_useState41, 2),
233
+ newDepartment = _useState42[0],
234
+ setNewDepartment = _useState42[1];
235
+
236
+ var _useState43 = (0, _react.useState)(""),
237
+ _useState44 = (0, _slicedToArray2.default)(_useState43, 2),
238
+ newCategory = _useState44[0],
239
+ setNewCategory = _useState44[1]; // Las categorías no son una lista plana: dependen de la cadena y del
240
+ // departamento. Es la misma cascada que usa el alta de productos, y se sirve
241
+ // del mismo endpoint para no acabar con dos árboles de categorías distintos.
242
+
243
+
244
+ var _useState45 = (0, _react.useState)({
245
+ retailers: [],
246
+ departments: [],
247
+ categories: []
248
+ }),
249
+ _useState46 = (0, _slicedToArray2.default)(_useState45, 2),
250
+ filters = _useState46[0],
251
+ setFilters = _useState46[1];
252
+
253
+ var _useState47 = (0, _react.useState)(false),
254
+ _useState48 = (0, _slicedToArray2.default)(_useState47, 2),
255
+ loadingFilters = _useState48[0],
256
+ setLoadingFilters = _useState48[1];
257
+
258
+ var _useState49 = (0, _react.useState)(false),
259
+ _useState50 = (0, _slicedToArray2.default)(_useState49, 2),
260
+ loading = _useState50[0],
261
+ setLoading = _useState50[1];
262
+
263
+ var _useState51 = (0, _react.useState)(null),
264
+ _useState52 = (0, _slicedToArray2.default)(_useState51, 2),
265
+ error = _useState52[0],
266
+ setError = _useState52[1];
183
267
 
184
268
  var request = (0, _react.useCallback)( /*#__PURE__*/function () {
185
269
  var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(action, body) {
@@ -223,13 +307,16 @@ var LinkVariantsModal = function LinkVariantsModal(_ref) {
223
307
  setSelected([]);
224
308
  setRejected(null);
225
309
  setSearched(false);
310
+ setTotal(0);
311
+ setHasMore(false);
226
312
  setError(null);
227
313
  setStep("search");
228
314
  }, [mode]);
229
315
 
230
316
  var search = /*#__PURE__*/function () {
231
317
  var _ref3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(event) {
232
- var data;
318
+ var _data$total, data;
319
+
233
320
  return _regenerator.default.wrap(function _callee2$(_context2) {
234
321
  while (1) {
235
322
  switch (_context2.prev = _context2.next) {
@@ -249,32 +336,94 @@ var LinkVariantsModal = function LinkVariantsModal(_ref) {
249
336
  data = _context2.sent;
250
337
  setCandidates(data.candidates || []);
251
338
  setRejected(data.rejected || null);
339
+ setTotal((_data$total = data.total) !== null && _data$total !== void 0 ? _data$total : (data.candidates || []).length);
340
+ setHasMore(!!data.hasMore);
252
341
  setSearched(true);
253
- _context2.next = 15;
342
+ _context2.next = 17;
254
343
  break;
255
344
 
256
- case 12:
257
- _context2.prev = 12;
345
+ case 14:
346
+ _context2.prev = 14;
258
347
  _context2.t0 = _context2["catch"](3);
259
348
  setError(readError(_context2.t0));
260
349
 
261
- case 15:
262
- _context2.prev = 15;
350
+ case 17:
351
+ _context2.prev = 17;
263
352
  setLoading(false);
264
- return _context2.finish(15);
353
+ return _context2.finish(17);
265
354
 
266
- case 18:
355
+ case 20:
267
356
  case "end":
268
357
  return _context2.stop();
269
358
  }
270
359
  }
271
- }, _callee2, null, [[3, 12, 15, 18]]);
360
+ }, _callee2, null, [[3, 14, 17, 20]]);
272
361
  }));
273
362
 
274
363
  return function search(_x3) {
275
364
  return _ref3.apply(this, arguments);
276
365
  };
277
366
  }();
367
+ /*
368
+ Trae la siguiente página y la agrega a la lista.
369
+ Se acumula en vez de reemplazar porque la selección vive en esta pantalla: si
370
+ la página 2 borrara la 1, lo marcado antes desaparecería de la vista sin
371
+ dejar de estar seleccionado, y el usuario acabaría ligando productos que ya
372
+ no ve.
373
+ */
374
+
375
+
376
+ var loadMore = /*#__PURE__*/function () {
377
+ var _ref4 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
378
+ var _data$total2, data;
379
+
380
+ return _regenerator.default.wrap(function _callee3$(_context3) {
381
+ while (1) {
382
+ switch (_context3.prev = _context3.next) {
383
+ case 0:
384
+ setLoadingMore(true);
385
+ setError(null);
386
+ _context3.prev = 2;
387
+ _context3.next = 5;
388
+ return request("search", {
389
+ mode: mode,
390
+ articleId: articleId,
391
+ query: query.trim(),
392
+ offset: candidates.length
393
+ });
394
+
395
+ case 5:
396
+ data = _context3.sent;
397
+ setCandidates(function (current) {
398
+ return [].concat((0, _toConsumableArray2.default)(current), (0, _toConsumableArray2.default)(data.candidates || []));
399
+ });
400
+ setTotal((_data$total2 = data.total) !== null && _data$total2 !== void 0 ? _data$total2 : total);
401
+ setHasMore(!!data.hasMore);
402
+ _context3.next = 14;
403
+ break;
404
+
405
+ case 11:
406
+ _context3.prev = 11;
407
+ _context3.t0 = _context3["catch"](2);
408
+ setError(readError(_context3.t0));
409
+
410
+ case 14:
411
+ _context3.prev = 14;
412
+ setLoadingMore(false);
413
+ return _context3.finish(14);
414
+
415
+ case 17:
416
+ case "end":
417
+ return _context3.stop();
418
+ }
419
+ }
420
+ }, _callee3, null, [[2, 11, 14, 17]]);
421
+ }));
422
+
423
+ return function loadMore() {
424
+ return _ref4.apply(this, arguments);
425
+ };
426
+ }();
278
427
 
279
428
  var toggle = function toggle(id) {
280
429
  setSelected(function (current) {
@@ -286,24 +435,24 @@ var LinkVariantsModal = function LinkVariantsModal(_ref) {
286
435
  };
287
436
 
288
437
  var goToInheritance = /*#__PURE__*/function () {
289
- var _ref4 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
438
+ var _ref5 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4() {
290
439
  var _data$nameScope, data, listas;
291
440
 
292
- return _regenerator.default.wrap(function _callee3$(_context3) {
441
+ return _regenerator.default.wrap(function _callee4$(_context4) {
293
442
  while (1) {
294
- switch (_context3.prev = _context3.next) {
443
+ switch (_context4.prev = _context4.next) {
295
444
  case 0:
296
445
  setLoading(true);
297
446
  setError(null);
298
- _context3.prev = 2;
299
- _context3.next = 5;
447
+ _context4.prev = 2;
448
+ _context4.next = 5;
300
449
  return request("attributes", {
301
450
  parentArticleId: parentArticleId,
302
451
  retailerId: activeRetailerId
303
452
  });
304
453
 
305
454
  case 5:
306
- data = _context3.sent;
455
+ data = _context4.sent;
307
456
  listas = {
308
457
  attributes: data.attributes || [],
309
458
  descriptions: data.descriptions || [],
@@ -311,66 +460,158 @@ var LinkVariantsModal = function LinkVariantsModal(_ref) {
311
460
  categoryRetailers: data.categoryRetailers || []
312
461
  };
313
462
  setOffered(listas);
314
- setNameScope((_data$nameScope = data.nameScope) !== null && _data$nameScope !== void 0 ? _data$nameScope : null); // Todo preseleccionado: heredar es el caso normal, y quitar lo que sobra
315
- // es menos trabajo que marcar de cero lo que casi siempre se quiere.
316
-
463
+ setNameScope((_data$nameScope = data.nameScope) !== null && _data$nameScope !== void 0 ? _data$nameScope : null);
317
464
  setChosen({
318
- attributes: listas.attributes.map(function (item) {
319
- return item.id;
320
- }),
321
- descriptions: listas.descriptions.map(function (item) {
322
- return item.id;
323
- }),
324
- images: listas.images.map(function (item) {
325
- return item.id;
326
- }),
327
- categoryRetailers: listas.categoryRetailers.map(function (item) {
328
- return "".concat(item.retailerId, "-").concat(item.categoryId);
329
- })
465
+ attributes: [],
466
+ descriptions: [],
467
+ images: [],
468
+ categoryRetailers: []
469
+ });
470
+ setModes({
471
+ categoryRetailers: null,
472
+ descriptions: null,
473
+ attributes: null,
474
+ images: null
330
475
  });
331
476
  setExtraRetailers([]);
477
+ setBrokenImages([]);
478
+ setPerChild({});
479
+ setApplyToAll(false);
480
+ setActiveChild(mode === "children" ? selected[0] : null);
332
481
  setStep("inherit");
333
- _context3.next = 17;
482
+ _context4.next = 22;
334
483
  break;
335
484
 
336
- case 14:
337
- _context3.prev = 14;
338
- _context3.t0 = _context3["catch"](2);
339
- setError(readError(_context3.t0));
485
+ case 19:
486
+ _context4.prev = 19;
487
+ _context4.t0 = _context4["catch"](2);
488
+ setError(readError(_context4.t0));
340
489
 
341
- case 17:
342
- _context3.prev = 17;
490
+ case 22:
491
+ _context4.prev = 22;
343
492
  setLoading(false);
344
- return _context3.finish(17);
493
+ return _context4.finish(22);
345
494
 
346
- case 20:
495
+ case 25:
347
496
  case "end":
348
- return _context3.stop();
497
+ return _context4.stop();
349
498
  }
350
499
  }
351
- }, _callee3, null, [[2, 14, 17, 20]]);
500
+ }, _callee4, null, [[2, 19, 22, 25]]);
352
501
  }));
353
502
 
354
503
  return function goToInheritance() {
355
- return _ref4.apply(this, arguments);
504
+ return _ref5.apply(this, arguments);
356
505
  };
357
506
  }();
358
507
 
359
508
  var toggleChoice = function toggleChoice(dimension, id) {
360
509
  setChosen(function (current) {
361
510
  var lista = current[dimension];
362
- return (0, _objectSpread4.default)((0, _objectSpread4.default)({}, current), {}, (0, _defineProperty2.default)({}, dimension, lista.includes(id) ? lista.filter(function (item) {
511
+ return (0, _objectSpread6.default)((0, _objectSpread6.default)({}, current), {}, (0, _defineProperty2.default)({}, dimension, lista.includes(id) ? lista.filter(function (item) {
363
512
  return item !== id;
364
513
  }) : [].concat((0, _toConsumableArray2.default)(lista), [id])));
365
514
  });
366
515
  };
367
516
 
368
- var toggleAll = function toggleAll(dimension, ids) {
517
+ var chooseMode = function chooseMode(dimension, modo, ids) {
518
+ setModes(function (current) {
519
+ return (0, _objectSpread6.default)((0, _objectSpread6.default)({}, current), {}, (0, _defineProperty2.default)({}, dimension, modo));
520
+ });
369
521
  setChosen(function (current) {
370
- return (0, _objectSpread4.default)((0, _objectSpread4.default)({}, current), {}, (0, _defineProperty2.default)({}, dimension, current[dimension].length === ids.length ? [] : ids));
522
+ return (0, _objectSpread6.default)((0, _objectSpread6.default)({}, current), {}, (0, _defineProperty2.default)({}, dimension, modo === "all" ? ids : []));
371
523
  });
372
524
  };
373
525
 
526
+ var loadFilters = (0, _react.useCallback)( /*#__PURE__*/function () {
527
+ var _ref6 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5(retailer, department) {
528
+ var _readPayload$data, _readPayload, res, lista;
529
+
530
+ return _regenerator.default.wrap(function _callee5$(_context5) {
531
+ while (1) {
532
+ switch (_context5.prev = _context5.next) {
533
+ case 0:
534
+ setLoadingFilters(true);
535
+ _context5.prev = 1;
536
+ _context5.next = 4;
537
+ return _axios.default.get("".concat(filtersEndpoint, "?retailerSelected=").concat(retailer !== null && retailer !== void 0 ? retailer : "", "&departmentSelected=").concat(department !== null && department !== void 0 ? department : ""), {
538
+ headers: {
539
+ Authorization: token
540
+ }
541
+ });
542
+
543
+ case 4:
544
+ res = _context5.sent;
545
+ // readPayload YA devuelve el cuerpo parseado. Volver a buscar `body`
546
+ // dentro dejaba la lista siempre vacía, y por eso el selector de cadenas
547
+ // no mostraba nada.
548
+ lista = (_readPayload$data = (_readPayload = (0, _api.readPayload)(res)) === null || _readPayload === void 0 ? void 0 : _readPayload.data) !== null && _readPayload$data !== void 0 ? _readPayload$data : [];
549
+ setFilters(function (current) {
550
+ if (!retailer) {
551
+ return (0, _objectSpread6.default)((0, _objectSpread6.default)({}, current), {}, {
552
+ retailers: lista.map(function (item) {
553
+ return {
554
+ value: item.id,
555
+ label: item.name
556
+ };
557
+ })
558
+ });
559
+ }
560
+
561
+ if (!department) {
562
+ return (0, _objectSpread6.default)((0, _objectSpread6.default)({}, current), {}, {
563
+ departments: lista.map(function (item) {
564
+ return {
565
+ value: item.category,
566
+ label: item.category
567
+ };
568
+ }),
569
+ categories: []
570
+ });
571
+ }
572
+
573
+ return (0, _objectSpread6.default)((0, _objectSpread6.default)({}, current), {}, {
574
+ categories: lista.map(function (item) {
575
+ return {
576
+ value: item.id,
577
+ label: item.name
578
+ };
579
+ })
580
+ });
581
+ });
582
+ _context5.next = 12;
583
+ break;
584
+
585
+ case 9:
586
+ _context5.prev = 9;
587
+ _context5.t0 = _context5["catch"](1);
588
+ console.error("linkVariants/filters: ", _context5.t0);
589
+
590
+ case 12:
591
+ _context5.prev = 12;
592
+ setLoadingFilters(false);
593
+ return _context5.finish(12);
594
+
595
+ case 15:
596
+ case "end":
597
+ return _context5.stop();
598
+ }
599
+ }
600
+ }, _callee5, null, [[1, 9, 12, 15]]);
601
+ }));
602
+
603
+ return function (_x4, _x5) {
604
+ return _ref6.apply(this, arguments);
605
+ };
606
+ }(), [filtersEndpoint, token]); // Las cadenas del catálogo se piden al entrar al paso de herencia, no al abrir
607
+ // el modal: quien solo busca y cancela no llega a necesitarlas.
608
+
609
+ (0, _react.useEffect)(function () {
610
+ if (step === "inherit" && !filters.retailers.length) {
611
+ loadFilters(null, null);
612
+ }
613
+ }, [step, filters.retailers.length, loadFilters]);
614
+
374
615
  var addRetailer = function addRetailer() {
375
616
  var retailerId = Number(newRetailer);
376
617
  var categoryId = Number(newCategory);
@@ -382,120 +623,243 @@ var LinkVariantsModal = function LinkVariantsModal(_ref) {
382
623
  return item.clave === clave;
383
624
  });
384
625
  if (yaEsta) return;
385
- var retailer = (retailersAvailable || []).find(function (item) {
386
- var _item$id;
387
-
388
- return Number((_item$id = item.id) !== null && _item$id !== void 0 ? _item$id : item.value) === retailerId;
626
+ var retailer = filters.retailers.find(function (item) {
627
+ return Number(item.value) === retailerId;
389
628
  });
390
- var category = (categoriesAvailable || []).find(function (item) {
391
- var _item$id2;
392
-
393
- return Number((_item$id2 = item.id) !== null && _item$id2 !== void 0 ? _item$id2 : item.value) === categoryId;
629
+ var category = filters.categories.find(function (item) {
630
+ return Number(item.value) === categoryId;
394
631
  });
395
632
  setExtraRetailers(function (current) {
396
- var _ref5, _retailer$name, _ref6, _category$name;
633
+ var _retailer$label, _category$label;
397
634
 
398
635
  return [].concat((0, _toConsumableArray2.default)(current), [{
399
636
  clave: clave,
400
637
  retailerId: retailerId,
401
638
  categoryId: categoryId,
402
- retailerName: (_ref5 = (_retailer$name = retailer === null || retailer === void 0 ? void 0 : retailer.name) !== null && _retailer$name !== void 0 ? _retailer$name : retailer === null || retailer === void 0 ? void 0 : retailer.label) !== null && _ref5 !== void 0 ? _ref5 : "Cadena ".concat(retailerId),
403
- categoryName: (_ref6 = (_category$name = category === null || category === void 0 ? void 0 : category.name) !== null && _category$name !== void 0 ? _category$name : category === null || category === void 0 ? void 0 : category.label) !== null && _ref6 !== void 0 ? _ref6 : "Categor\xEDa ".concat(categoryId)
639
+ retailerName: (_retailer$label = retailer === null || retailer === void 0 ? void 0 : retailer.label) !== null && _retailer$label !== void 0 ? _retailer$label : "Cadena ".concat(retailerId),
640
+ categoryName: (_category$label = category === null || category === void 0 ? void 0 : category.label) !== null && _category$label !== void 0 ? _category$label : "Categor\xEDa ".concat(categoryId)
404
641
  }]);
405
642
  });
406
643
  setChosen(function (current) {
407
- return (0, _objectSpread4.default)((0, _objectSpread4.default)({}, current), {}, {
644
+ return (0, _objectSpread6.default)((0, _objectSpread6.default)({}, current), {}, {
408
645
  categoryRetailers: [].concat((0, _toConsumableArray2.default)(current.categoryRetailers), [clave])
409
646
  });
410
647
  });
411
648
  setNewRetailer("");
649
+ setNewDepartment("");
412
650
  setNewCategory("");
413
651
  };
652
+ /*
653
+ Convierte una selección de pantalla en el bloque `inherit` de la API.
654
+ Con el modo en "todos" se manda la palabra y no la lista que se pintó: si
655
+ entre la carga del modal y el guardado alguien agregó un valor al padre,
656
+ "todos" sigue significando todos. La lista sería una foto ya vieja.
657
+ Las parejas cadena+categoría viajan como objetos, no como ids, porque pueden
658
+ ser cadenas que el padre no tiene: ahí no hay nada que heredar, se asigna.
659
+ */
660
+ // Las que de verdad se pueden heredar: la base puede listar filas cuyo archivo
661
+ // ya no existe, y esas no cuentan ni para la lista ni para el "todas".
662
+
663
+
664
+ var imagenesUtiles = offered.images.filter(function (image) {
665
+ return !brokenImages.includes(image.id);
666
+ });
667
+
668
+ var buildInherit = function buildInherit(seleccion) {
669
+ var _seleccion$extraRetai;
670
+
671
+ var parejas = [].concat((0, _toConsumableArray2.default)(offered.categoryRetailers.map(function (item) {
672
+ return {
673
+ clave: "".concat(item.retailerId, "-").concat(item.categoryId),
674
+ retailerId: item.retailerId,
675
+ categoryId: item.categoryId
676
+ };
677
+ })), (0, _toConsumableArray2.default)((_seleccion$extraRetai = seleccion.extraRetailers) !== null && _seleccion$extraRetai !== void 0 ? _seleccion$extraRetai : []));
678
+ return {
679
+ attributes: seleccion.modes.attributes === "all" ? "all-filled" : seleccion.chosen.attributes,
680
+ descriptions: seleccion.modes.descriptions === "all" ? "all" : seleccion.chosen.descriptions,
681
+ images: seleccion.modes.images === "all" ? "all" : seleccion.chosen.images,
682
+ categoryRetailers: parejas.filter(function (par) {
683
+ return seleccion.chosen.categoryRetailers.includes(par.clave);
684
+ }).map(function (_ref7) {
685
+ var retailerId = _ref7.retailerId,
686
+ categoryId = _ref7.categoryId;
687
+ return {
688
+ retailerId: retailerId,
689
+ categoryId: categoryId
690
+ };
691
+ })
692
+ };
693
+ };
694
+
695
+ var seleccionVacia = function seleccionVacia() {
696
+ return {
697
+ modes: {
698
+ categoryRetailers: null,
699
+ descriptions: null,
700
+ attributes: null,
701
+ images: null
702
+ },
703
+ chosen: {
704
+ attributes: [],
705
+ descriptions: [],
706
+ images: [],
707
+ categoryRetailers: []
708
+ },
709
+ extraRetailers: []
710
+ };
711
+ };
712
+ /*
713
+ Cambia de pestaña conservando lo elegido en la anterior. Sin esto, moverse
714
+ entre productos borraría el trabajo hecho en cada uno.
715
+ */
716
+
717
+
718
+ var switchChild = function switchChild(id) {
719
+ var _perChild$id, _guardado$extraRetail;
720
+
721
+ setPerChild(function (current) {
722
+ return (0, _objectSpread6.default)((0, _objectSpread6.default)({}, current), {}, (0, _defineProperty2.default)({}, activeChild, {
723
+ modes: modes,
724
+ chosen: chosen,
725
+ extraRetailers: extraRetailers
726
+ }));
727
+ });
728
+ var guardado = (_perChild$id = perChild[id]) !== null && _perChild$id !== void 0 ? _perChild$id : seleccionVacia();
729
+ setModes(guardado.modes);
730
+ setChosen(guardado.chosen);
731
+ setExtraRetailers((_guardado$extraRetail = guardado.extraRetailers) !== null && _guardado$extraRetail !== void 0 ? _guardado$extraRetail : []);
732
+ setActiveChild(id);
733
+ };
414
734
 
415
735
  var submit = /*#__PURE__*/function () {
416
- var _ref7 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4() {
417
- var todasLasParejas, inherit, body, data;
418
- return _regenerator.default.wrap(function _callee4$(_context4) {
736
+ var _ref8 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6() {
737
+ var inherit, inheritByChild, body, data;
738
+ return _regenerator.default.wrap(function _callee6$(_context6) {
419
739
  while (1) {
420
- switch (_context4.prev = _context4.next) {
740
+ switch (_context6.prev = _context6.next) {
421
741
  case 0:
422
742
  setLoading(true);
423
- setError(null); // Las parejas cadena+categoría viajan como objetos, no como ids: pueden ser
424
- // cadenas que el padre no tiene, y ahí no hay nada que "heredar" — se asigna.
425
-
426
- todasLasParejas = [].concat((0, _toConsumableArray2.default)(offered.categoryRetailers.map(function (item) {
427
- return {
428
- clave: "".concat(item.retailerId, "-").concat(item.categoryId),
429
- retailerId: item.retailerId,
430
- categoryId: item.categoryId
431
- };
432
- })), (0, _toConsumableArray2.default)(extraRetailers));
433
- inherit = {
434
- attributes: inheritMode === "all-filled" ? "all-filled" : chosen.attributes,
435
- descriptions: chosen.descriptions,
436
- images: chosen.images,
437
- categoryRetailers: todasLasParejas.filter(function (par) {
438
- return chosen.categoryRetailers.includes(par.clave);
439
- }).map(function (_ref8) {
440
- var retailerId = _ref8.retailerId,
441
- categoryId = _ref8.categoryId;
442
- return {
443
- retailerId: retailerId,
444
- categoryId: categoryId
445
- };
446
- })
447
- };
743
+ setError(null);
744
+ inherit = buildInherit({
745
+ modes: modes,
746
+ chosen: chosen,
747
+ extraRetailers: extraRetailers
748
+ }); // Con las pestañas abiertas cada producto manda la suya. La selección de la
749
+ // pestaña a la vista todavía no está en perChild, así que se agrega aquí: si
750
+ // no, lo último que tocó el usuario se perdería al guardar.
751
+
752
+ inheritByChild = !applyToAll && mode === "children" ? selected.reduce(function (acc, id) {
753
+ var guardado = id === activeChild ? {
754
+ modes: modes,
755
+ chosen: chosen,
756
+ extraRetailers: extraRetailers
757
+ } : perChild[id];
758
+ if (guardado) acc[id] = buildInherit(guardado);
759
+ return acc;
760
+ }, {}) : undefined;
448
761
  body = mode === "parent" ? {
449
762
  mode: mode,
450
763
  articleId: articleId,
451
764
  parentArticleId: selected[0],
452
765
  inherit: inherit
453
- } : {
766
+ } : (0, _objectSpread6.default)({
454
767
  mode: mode,
455
768
  parentArticleId: articleId,
456
769
  childrenArticleIds: selected,
457
770
  inherit: inherit
458
- };
459
- _context4.prev = 5;
460
- _context4.next = 8;
771
+ }, inheritByChild ? {
772
+ inheritByChild: inheritByChild
773
+ } : {});
774
+ _context6.prev = 5;
775
+ _context6.next = 8;
461
776
  return request("link", body);
462
777
 
463
778
  case 8:
464
- data = _context4.sent;
779
+ data = _context6.sent;
465
780
  // El modo importa para quien escucha: en `children` este producto GANA
466
781
  // variantes; en `parent` pasa a SER una. Son efectos opuestos sobre la
467
782
  // misma ficha, así que quien refresque el estado necesita distinguirlos.
468
- onLinked === null || onLinked === void 0 ? void 0 : onLinked((0, _objectSpread4.default)((0, _objectSpread4.default)({}, data), {}, {
783
+ onLinked === null || onLinked === void 0 ? void 0 : onLinked((0, _objectSpread6.default)((0, _objectSpread6.default)({}, data), {}, {
469
784
  mode: mode,
470
785
  parentArticleId: mode === "parent" ? selected[0] : articleId
471
786
  }));
472
787
  onClose === null || onClose === void 0 ? void 0 : onClose();
473
- _context4.next = 16;
788
+ _context6.next = 16;
474
789
  break;
475
790
 
476
791
  case 13:
477
- _context4.prev = 13;
478
- _context4.t0 = _context4["catch"](5);
479
- setError(readError(_context4.t0));
792
+ _context6.prev = 13;
793
+ _context6.t0 = _context6["catch"](5);
794
+ setError(readError(_context6.t0));
480
795
 
481
796
  case 16:
482
- _context4.prev = 16;
797
+ _context6.prev = 16;
483
798
  setLoading(false);
484
- return _context4.finish(16);
799
+ return _context6.finish(16);
485
800
 
486
801
  case 19:
487
802
  case "end":
488
- return _context4.stop();
803
+ return _context6.stop();
489
804
  }
490
805
  }
491
- }, _callee4, null, [[5, 13, 16, 19]]);
806
+ }, _callee6, null, [[5, 13, 16, 19]]);
492
807
  }));
493
808
 
494
809
  return function submit() {
495
- return _ref7.apply(this, arguments);
810
+ return _ref8.apply(this, arguments);
496
811
  };
497
- }();
812
+ }(); // Una dimensión está decidida si el usuario eligió un modo, o si el padre no
813
+ // ofrece nada en ella —no se puede pedir que decida sobre una lista vacía—.
814
+
498
815
 
816
+ var decidida = function decidida(dimension) {
817
+ if (modes[dimension] !== null) return true;
818
+
819
+ if (dimension === "categoryRetailers") {
820
+ return offered.categoryRetailers.length === 0 && extraRetailers.length === 0;
821
+ } // Una imagen cuyo archivo no existe no es algo sobre lo que se pueda decidir.
822
+
823
+
824
+ return dimension === "images" ? imagenesUtiles.length === 0 : offered[dimension].length === 0;
825
+ };
826
+
827
+ var DIMENSIONES = ["categoryRetailers", "descriptions", "attributes", "images"]; // Con pestañas, que la que estoy viendo esté completa no basta: ligar escribe
828
+ // en todos, así que todos tienen que estar decididos. Si no, un producto se
829
+ // ligaría sin heredar nada solo porque nadie abrió su pestaña.
830
+
831
+ var decididoPara = function decididoPara(id) {
832
+ var guardado = id === activeChild ? {
833
+ modes: modes,
834
+ chosen: chosen,
835
+ extraRetailers: extraRetailers
836
+ } : perChild[id];
837
+ if (!guardado) return false;
838
+ return DIMENSIONES.every(function (dimension) {
839
+ if (guardado.modes[dimension] !== null) return true;
840
+
841
+ if (dimension === "categoryRetailers") {
842
+ var _guardado$extraRetail2;
843
+
844
+ return offered.categoryRetailers.length === 0 && ((_guardado$extraRetail2 = guardado.extraRetailers) !== null && _guardado$extraRetail2 !== void 0 ? _guardado$extraRetail2 : []).length === 0;
845
+ }
846
+
847
+ return dimension === "images" ? imagenesUtiles.length === 0 : offered[dimension].length === 0;
848
+ });
849
+ };
850
+
851
+ var todoDecidido = step === "inherit" && (applyToAll || mode !== "children" ? DIMENSIONES.every(decidida) : selected.every(decididoPara));
852
+ var faltantes = [["categoryRetailers", "cadenas"], ["descriptions", "descripciones"], ["attributes", "atributos"], ["images", "imágenes"]].filter(function (_ref9) {
853
+ var _ref10 = (0, _slicedToArray2.default)(_ref9, 1),
854
+ clave = _ref10[0];
855
+
856
+ return !decidida(clave);
857
+ }).map(function (_ref11) {
858
+ var _ref12 = (0, _slicedToArray2.default)(_ref11, 2),
859
+ nombre = _ref12[1];
860
+
861
+ return nombre;
862
+ });
499
863
  var selectionLabel = mode === "parent" ? "Se elige un solo producto padre." : "".concat(selected.length, " producto(s) pasar\xE1n a ser variantes.");
500
864
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_styles.Overlay, {
501
865
  onClick: onClose,
@@ -580,241 +944,390 @@ var LinkVariantsModal = function LinkVariantsModal(_ref) {
580
944
  })
581
945
  }, candidate.articleId);
582
946
  })
947
+ }), searched && candidates.length > 0 && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_styles.Paging, {
948
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("span", {
949
+ children: ["Mostrando ", candidates.length, " de ", total]
950
+ }), hasMore && /*#__PURE__*/(0, _jsxRuntime.jsx)("button", {
951
+ type: "button",
952
+ onClick: loadMore,
953
+ disabled: loadingMore,
954
+ children: loadingMore ? "Cargando…" : "Cargar más"
955
+ })]
583
956
  })]
584
957
  }), step === "inherit" && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
585
- children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_styles.Section, {
586
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("h3", {
587
- children: "Atributos de la ficha t\xE9cnica"
588
- }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("label", {
589
- className: "choice",
590
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("input", {
591
- type: "radio",
592
- checked: inheritMode === "all-filled",
593
- onChange: function onChange() {
594
- return setInheritMode("all-filled");
595
- }
596
- }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("span", {
597
- children: ["Todos los que tienen valor", /*#__PURE__*/(0, _jsxRuntime.jsxs)("span", {
598
- className: "hint",
599
- children: [offered.attributes.length, " atributo(s) con informaci\xF3n en el padre."]
600
- })]
601
- })]
602
- }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("label", {
603
- className: "choice",
958
+ children: [mode === "children" && selected.length > 1 && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
959
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("label", {
960
+ className: "apply-all",
604
961
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("input", {
605
- type: "radio",
606
- checked: inheritMode === "selected",
607
- onChange: function onChange() {
608
- return setInheritMode("selected");
962
+ type: "checkbox",
963
+ checked: applyToAll,
964
+ onChange: function onChange(event) {
965
+ setApplyToAll(event.target.checked);
966
+ if (event.target.checked) setPerChild({});
609
967
  }
610
968
  }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("span", {
611
- children: ["Elegir cu\xE1les", /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
969
+ children: ["Aplicar lo mismo a los ", selected.length, " productos", /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
612
970
  className: "hint",
613
- children: "Lo que no elijas conserva el valor que ya tiene la variante."
971
+ children: "Desm\xE1rcalo si alguno debe heredar algo distinto."
614
972
  })]
615
973
  })]
974
+ }), !applyToAll && /*#__PURE__*/(0, _jsxRuntime.jsx)(_styles.Tabs, {
975
+ children: selected.map(function (id, indice) {
976
+ var producto = candidates.find(function (item) {
977
+ return item.articleId === id;
978
+ });
979
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)("button", {
980
+ type: "button",
981
+ className: id === activeChild ? "active" : "",
982
+ onClick: function onClick() {
983
+ return switchChild(id);
984
+ },
985
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
986
+ className: "orden",
987
+ children: indice + 1
988
+ }), (producto === null || producto === void 0 ? void 0 : producto.name) || "Producto ".concat(id), decididoPara(id) && /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
989
+ className: "listo",
990
+ "aria-label": "listo",
991
+ children: "\u2713"
992
+ })]
993
+ }, id);
994
+ })
616
995
  })]
617
- }), inheritMode === "selected" && activeRetailerId && !nameScope && /*#__PURE__*/(0, _jsxRuntime.jsx)(_styles.Message, {
618
- children: "El producto padre no comparte la cadena que tienes abierta, as\xED que los nombres de abajo son los de otra de sus cadenas."
619
- }), inheritMode === "selected" && /*#__PURE__*/(0, _jsxRuntime.jsx)(_styles.AttributeList, {
620
- children: offered.attributes.map(function (attribute) {
621
- return /*#__PURE__*/(0, _jsxRuntime.jsx)("li", {
622
- children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("label", {
623
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("input", {
624
- type: "checkbox",
625
- checked: chosen.attributes.includes(attribute.id),
626
- onChange: function onChange() {
627
- return toggleChoice("attributes", attribute.id);
628
- }
629
- }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("span", {
630
- children: [attribute.name, attribute.unconfigured && /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
631
- className: "note",
632
- children: "sin configuraci\xF3n en las cadenas del padre"
633
- }), attribute.ambiguousName && /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
634
- className: "note",
635
- children: "se llama distinto en otra cadena"
636
- })]
637
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
638
- className: "value",
639
- title: attribute.value,
640
- children: attribute.value
996
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_styles.Block, {
997
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("h3", {
998
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
999
+ className: "paso",
1000
+ children: "1"
1001
+ }), " Cadenas y categor\xEDas"]
1002
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_styles.Choices, {
1003
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("label", {
1004
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("input", {
1005
+ type: "radio",
1006
+ name: "categoryRetailers-".concat(activeChild !== null && activeChild !== void 0 ? activeChild : "todos"),
1007
+ checked: modes.categoryRetailers === "all",
1008
+ onChange: function onChange() {
1009
+ return chooseMode("categoryRetailers", "all", offered.categoryRetailers.map(function (item) {
1010
+ return "".concat(item.retailerId, "-").concat(item.categoryId);
1011
+ }));
1012
+ }
1013
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("span", {
1014
+ children: ["Todas las del producto padre", /*#__PURE__*/(0, _jsxRuntime.jsxs)("span", {
1015
+ className: "hint",
1016
+ children: [offered.categoryRetailers.length, " cadena(s)."]
1017
+ })]
1018
+ })]
1019
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("label", {
1020
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("input", {
1021
+ type: "radio",
1022
+ name: "categoryRetailers-".concat(activeChild !== null && activeChild !== void 0 ? activeChild : "todos"),
1023
+ checked: modes.categoryRetailers === "some",
1024
+ onChange: function onChange() {
1025
+ return chooseMode("categoryRetailers", "some", []);
1026
+ }
1027
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("span", {
1028
+ children: ["Elegir cu\xE1les", /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
1029
+ className: "hint",
1030
+ children: "Tambi\xE9n puedes agregar una cadena que el padre no tenga."
641
1031
  })]
642
- })
643
- }, attribute.id);
644
- })
645
- }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_styles.Section, {
646
- children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_styles.SectionHead, {
647
- children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("button", {
648
- type: "button",
649
- className: "toggle",
650
- "aria-expanded": openSection === "descriptions",
651
- onClick: function onClick() {
652
- return setOpenSection(openSection === "descriptions" ? null : "descriptions");
653
- },
654
- children: ["Descripciones", /*#__PURE__*/(0, _jsxRuntime.jsxs)("span", {
655
- className: "count",
656
- children: [chosen.descriptions.length, " de", " ", offered.descriptions.length]
657
1032
  })]
658
- }), offered.descriptions.length > 0 && /*#__PURE__*/(0, _jsxRuntime.jsx)("button", {
659
- type: "button",
660
- className: "all",
661
- onClick: function onClick() {
662
- return toggleAll("descriptions", offered.descriptions.map(function (item) {
663
- return item.id;
664
- }));
665
- },
666
- children: chosen.descriptions.length === offered.descriptions.length ? "Ninguna" : "Todas"
667
1033
  })]
668
- }), openSection === "descriptions" && (offered.descriptions.length ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_styles.AttributeList, {
669
- children: offered.descriptions.map(function (item) {
1034
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_styles.List, {
1035
+ children: [].concat((0, _toConsumableArray2.default)(offered.categoryRetailers.map(function (item) {
1036
+ return (0, _objectSpread6.default)((0, _objectSpread6.default)({}, item), {}, {
1037
+ clave: "".concat(item.retailerId, "-").concat(item.categoryId),
1038
+ delPadre: true
1039
+ });
1040
+ })), (0, _toConsumableArray2.default)(extraRetailers.map(function (item) {
1041
+ return (0, _objectSpread6.default)((0, _objectSpread6.default)({}, item), {}, {
1042
+ delPadre: false
1043
+ });
1044
+ }))).map(function (item) {
670
1045
  return /*#__PURE__*/(0, _jsxRuntime.jsx)("li", {
671
1046
  children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("label", {
672
1047
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("input", {
673
1048
  type: "checkbox",
674
- checked: chosen.descriptions.includes(item.id),
1049
+ disabled: modes.categoryRetailers === "all",
1050
+ checked: chosen.categoryRetailers.includes(item.clave),
675
1051
  onChange: function onChange() {
676
- return toggleChoice("descriptions", item.id);
1052
+ return toggleChoice("categoryRetailers", item.clave);
677
1053
  }
678
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
679
- children: item.name
680
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
681
- className: "value",
682
- title: item.value,
683
- children: item.value
1054
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("img", {
1055
+ className: "logo",
1056
+ src: (0, _helper.getRetailerPicture)(item.retailerId, 24, 24),
1057
+ alt: ""
1058
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("span", {
1059
+ children: [item.retailerName, /*#__PURE__*/(0, _jsxRuntime.jsxs)("span", {
1060
+ className: "meta",
1061
+ children: [item.categoryName || "Sin categoría", !item.delPadre && " · no la tiene el padre"]
1062
+ })]
684
1063
  })]
685
1064
  })
686
- }, item.id);
1065
+ }, item.clave);
687
1066
  })
688
- }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_styles.Message, {
689
- children: "El producto padre no tiene descripciones."
690
- }))]
691
- }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_styles.Section, {
692
- children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_styles.SectionHead, {
693
- children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("button", {
694
- type: "button",
695
- className: "toggle",
696
- "aria-expanded": openSection === "images",
697
- onClick: function onClick() {
698
- return setOpenSection(openSection === "images" ? null : "images");
1067
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_styles.AddRetailer, {
1068
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("select", {
1069
+ value: newRetailer,
1070
+ onChange: function onChange(event) {
1071
+ var valor = event.target.value;
1072
+ setNewRetailer(valor);
1073
+ setNewDepartment("");
1074
+ setNewCategory("");
1075
+ if (valor) loadFilters(valor, null);
699
1076
  },
700
- children: ["Im\xE1genes", /*#__PURE__*/(0, _jsxRuntime.jsxs)("span", {
701
- className: "count",
702
- children: [chosen.images.length, " de ", offered.images.length]
1077
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("option", {
1078
+ value: "",
1079
+ children: "Agregar otra cadena\u2026"
1080
+ }), filters.retailers.map(function (item) {
1081
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)("option", {
1082
+ value: item.value,
1083
+ children: item.label
1084
+ }, item.value);
703
1085
  })]
704
- }), offered.images.length > 0 && /*#__PURE__*/(0, _jsxRuntime.jsx)("button", {
705
- type: "button",
706
- className: "all",
707
- onClick: function onClick() {
708
- return toggleAll("images", offered.images.map(function (item) {
709
- return item.id;
710
- }));
1086
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("select", {
1087
+ value: newDepartment,
1088
+ disabled: !newRetailer || !filters.departments.length,
1089
+ onChange: function onChange(event) {
1090
+ var valor = event.target.value;
1091
+ setNewDepartment(valor);
1092
+ setNewCategory("");
1093
+ if (valor) loadFilters(newRetailer, valor);
1094
+ },
1095
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("option", {
1096
+ value: "",
1097
+ children: "Departamento\u2026"
1098
+ }), filters.departments.map(function (item) {
1099
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)("option", {
1100
+ value: item.value,
1101
+ children: item.label
1102
+ }, item.value);
1103
+ })]
1104
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("select", {
1105
+ value: newCategory,
1106
+ disabled: !newDepartment || !filters.categories.length,
1107
+ onChange: function onChange(event) {
1108
+ return setNewCategory(event.target.value);
711
1109
  },
712
- children: chosen.images.length === offered.images.length ? "Ninguna" : "Todas"
1110
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("option", {
1111
+ value: "",
1112
+ children: "Categor\xEDa\u2026"
1113
+ }), filters.categories.map(function (item) {
1114
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)("option", {
1115
+ value: item.value,
1116
+ children: item.label
1117
+ }, item.value);
1118
+ })]
1119
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("button", {
1120
+ type: "button",
1121
+ onClick: addRetailer,
1122
+ disabled: !newRetailer || !newCategory || loadingFilters,
1123
+ children: loadingFilters ? "…" : "Agregar"
713
1124
  })]
714
- }), openSection === "images" && (offered.images.length ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_styles.ImageGrid, {
715
- children: offered.images.map(function (image) {
716
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)("label", {
717
- className: chosen.images.includes(image.id) ? "picked" : "",
1125
+ })]
1126
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_styles.Block, {
1127
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("h3", {
1128
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
1129
+ className: "paso",
1130
+ children: "2"
1131
+ }), " Descripciones"]
1132
+ }), offered.descriptions.length ? /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
1133
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_styles.Choices, {
1134
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("label", {
718
1135
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("input", {
719
- type: "checkbox",
720
- checked: chosen.images.includes(image.id),
1136
+ type: "radio",
1137
+ name: "descriptions-".concat(activeChild !== null && activeChild !== void 0 ? activeChild : "todos"),
1138
+ checked: modes.descriptions === "all",
721
1139
  onChange: function onChange() {
722
- return toggleChoice("images", image.id);
1140
+ return chooseMode("descriptions", "all", offered.descriptions.map(function (item) {
1141
+ return item.id;
1142
+ }));
723
1143
  }
724
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)("img", {
725
- src: image.src,
726
- alt: image.imageType || ""
727
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
728
- children: image.imageType || "Sin tipo"
1144
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("span", {
1145
+ children: ["Todas las que tienen valor", /*#__PURE__*/(0, _jsxRuntime.jsxs)("span", {
1146
+ className: "hint",
1147
+ children: [offered.descriptions.length, " descripci\xF3n(es) con informaci\xF3n en el padre."]
1148
+ })]
729
1149
  })]
730
- }, image.id);
731
- })
1150
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("label", {
1151
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("input", {
1152
+ type: "radio",
1153
+ name: "descriptions-".concat(activeChild !== null && activeChild !== void 0 ? activeChild : "todos"),
1154
+ checked: modes.descriptions === "some",
1155
+ onChange: function onChange() {
1156
+ return chooseMode("descriptions", "some", []);
1157
+ }
1158
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("span", {
1159
+ children: ["Elegir cu\xE1les", /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
1160
+ className: "hint",
1161
+ children: "Lo que no elijas conserva el valor que ya tiene la variante."
1162
+ })]
1163
+ })]
1164
+ })]
1165
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_styles.AttributeList, {
1166
+ children: offered.descriptions.map(function (item) {
1167
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)("li", {
1168
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("label", {
1169
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("input", {
1170
+ type: "checkbox",
1171
+ disabled: modes.descriptions === "all",
1172
+ checked: chosen.descriptions.includes(item.id),
1173
+ onChange: function onChange() {
1174
+ return toggleChoice("descriptions", item.id);
1175
+ }
1176
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("span", {
1177
+ children: [item.name, item.duplicated && /*#__PURE__*/(0, _jsxRuntime.jsxs)("span", {
1178
+ className: "note",
1179
+ children: ["el padre tiene ", item.rows, " versiones de este texto; se copian todas"]
1180
+ })]
1181
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
1182
+ className: "value",
1183
+ title: item.value,
1184
+ children: item.value
1185
+ })]
1186
+ })
1187
+ }, item.id);
1188
+ })
1189
+ })]
732
1190
  }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_styles.Message, {
733
- children: "El producto padre no tiene im\xE1genes."
734
- }))]
735
- }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_styles.Section, {
736
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_styles.SectionHead, {
737
- children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("button", {
738
- type: "button",
739
- className: "toggle",
740
- "aria-expanded": openSection === "retailers",
741
- onClick: function onClick() {
742
- return setOpenSection(openSection === "retailers" ? null : "retailers");
743
- },
744
- children: ["Cadenas y categor\xEDas", /*#__PURE__*/(0, _jsxRuntime.jsxs)("span", {
745
- className: "count",
746
- children: [chosen.categoryRetailers.length, " seleccionada(s)"]
1191
+ children: "El producto padre no tiene descripciones que heredar."
1192
+ })]
1193
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_styles.Block, {
1194
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("h3", {
1195
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
1196
+ className: "paso",
1197
+ children: "3"
1198
+ }), " Atributos de la ficha t\xE9cnica"]
1199
+ }), offered.attributes.length ? /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
1200
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_styles.Choices, {
1201
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("label", {
1202
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("input", {
1203
+ type: "radio",
1204
+ name: "attributes-".concat(activeChild !== null && activeChild !== void 0 ? activeChild : "todos"),
1205
+ checked: modes.attributes === "all",
1206
+ onChange: function onChange() {
1207
+ return chooseMode("attributes", "all", offered.attributes.map(function (item) {
1208
+ return item.id;
1209
+ }));
1210
+ }
1211
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("span", {
1212
+ children: ["Todos los que tienen valor", /*#__PURE__*/(0, _jsxRuntime.jsxs)("span", {
1213
+ className: "hint",
1214
+ children: [offered.attributes.length, " atributo(s) con informaci\xF3n en el padre."]
1215
+ })]
1216
+ })]
1217
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("label", {
1218
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("input", {
1219
+ type: "radio",
1220
+ name: "attributes-".concat(activeChild !== null && activeChild !== void 0 ? activeChild : "todos"),
1221
+ checked: modes.attributes === "some",
1222
+ onChange: function onChange() {
1223
+ return chooseMode("attributes", "some", []);
1224
+ }
1225
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("span", {
1226
+ children: ["Elegir cu\xE1les", /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
1227
+ className: "hint",
1228
+ children: "Lo que no elijas conserva el valor que ya tiene la variante."
1229
+ })]
1230
+ })]
747
1231
  })]
748
- })
749
- }), openSection === "retailers" && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
750
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_styles.List, {
751
- children: [].concat((0, _toConsumableArray2.default)(offered.categoryRetailers.map(function (item) {
752
- return (0, _objectSpread4.default)((0, _objectSpread4.default)({}, item), {}, {
753
- clave: "".concat(item.retailerId, "-").concat(item.categoryId),
754
- delPadre: true
755
- });
756
- })), (0, _toConsumableArray2.default)(extraRetailers.map(function (item) {
757
- return (0, _objectSpread4.default)((0, _objectSpread4.default)({}, item), {}, {
758
- delPadre: false
759
- });
760
- }))).map(function (item) {
1232
+ }), activeRetailerId && !nameScope && /*#__PURE__*/(0, _jsxRuntime.jsx)(_styles.Message, {
1233
+ children: "El producto padre no comparte la cadena que tienes abierta, as\xED que los nombres de abajo son los de otra de sus cadenas."
1234
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_styles.AttributeList, {
1235
+ children: offered.attributes.map(function (attribute) {
761
1236
  return /*#__PURE__*/(0, _jsxRuntime.jsx)("li", {
762
1237
  children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("label", {
763
1238
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("input", {
764
1239
  type: "checkbox",
765
- checked: chosen.categoryRetailers.includes(item.clave),
1240
+ disabled: modes.attributes === "all",
1241
+ checked: chosen.attributes.includes(attribute.id),
766
1242
  onChange: function onChange() {
767
- return toggleChoice("categoryRetailers", item.clave);
1243
+ return toggleChoice("attributes", attribute.id);
768
1244
  }
769
1245
  }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("span", {
770
- children: [item.retailerName, /*#__PURE__*/(0, _jsxRuntime.jsxs)("span", {
771
- className: "meta",
772
- children: [item.categoryName || "Sin categoría", !item.delPadre && " · no la tiene el padre"]
1246
+ children: [attribute.name, attribute.unconfigured && /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
1247
+ className: "note",
1248
+ children: "sin configuraci\xF3n en las cadenas del padre"
1249
+ }), attribute.ambiguousName && /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
1250
+ className: "note",
1251
+ children: "se llama distinto en otra cadena"
773
1252
  })]
1253
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
1254
+ className: "value",
1255
+ title: attribute.value,
1256
+ children: attribute.value
774
1257
  })]
775
1258
  })
776
- }, item.clave);
1259
+ }, attribute.id);
777
1260
  })
778
- }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_styles.AddRetailer, {
779
- children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("select", {
780
- value: newRetailer,
781
- onChange: function onChange(event) {
782
- return setNewRetailer(event.target.value);
783
- },
784
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("option", {
785
- value: "",
786
- children: "Agregar otra cadena\u2026"
787
- }), (retailersAvailable || []).map(function (item) {
788
- var _item$id3, _item$id4, _item$name;
789
-
790
- return /*#__PURE__*/(0, _jsxRuntime.jsx)("option", {
791
- value: (_item$id4 = item.id) !== null && _item$id4 !== void 0 ? _item$id4 : item.value,
792
- children: (_item$name = item.name) !== null && _item$name !== void 0 ? _item$name : item.label
793
- }, (_item$id3 = item.id) !== null && _item$id3 !== void 0 ? _item$id3 : item.value);
1261
+ })]
1262
+ }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_styles.Message, {
1263
+ children: "El producto padre no tiene atributos con valor que heredar."
1264
+ })]
1265
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_styles.Block, {
1266
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("h3", {
1267
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
1268
+ className: "paso",
1269
+ children: "4"
1270
+ }), " Im\xE1genes"]
1271
+ }), imagenesUtiles.length ? /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
1272
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_styles.Choices, {
1273
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("label", {
1274
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("input", {
1275
+ type: "radio",
1276
+ name: "images-".concat(activeChild !== null && activeChild !== void 0 ? activeChild : "todos"),
1277
+ checked: modes.images === "all",
1278
+ onChange: function onChange() {
1279
+ return chooseMode("images", "all", imagenesUtiles.map(function (item) {
1280
+ return item.id;
1281
+ }));
1282
+ }
1283
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("span", {
1284
+ children: ["Todas", /*#__PURE__*/(0, _jsxRuntime.jsxs)("span", {
1285
+ className: "hint",
1286
+ children: [imagenesUtiles.length, " imagen(es) en el padre."]
1287
+ })]
794
1288
  })]
795
- }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("select", {
796
- value: newCategory,
797
- onChange: function onChange(event) {
798
- return setNewCategory(event.target.value);
799
- },
800
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("option", {
801
- value: "",
802
- children: "Categor\xEDa\u2026"
803
- }), (categoriesAvailable || []).map(function (item) {
804
- var _item$id5, _item$id6, _item$name2;
805
-
806
- return /*#__PURE__*/(0, _jsxRuntime.jsx)("option", {
807
- value: (_item$id6 = item.id) !== null && _item$id6 !== void 0 ? _item$id6 : item.value,
808
- children: (_item$name2 = item.name) !== null && _item$name2 !== void 0 ? _item$name2 : item.label
809
- }, (_item$id5 = item.id) !== null && _item$id5 !== void 0 ? _item$id5 : item.value);
1289
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("label", {
1290
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("input", {
1291
+ type: "radio",
1292
+ name: "images-".concat(activeChild !== null && activeChild !== void 0 ? activeChild : "todos"),
1293
+ checked: modes.images === "some",
1294
+ onChange: function onChange() {
1295
+ return chooseMode("images", "some", []);
1296
+ }
1297
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("span", {
1298
+ children: ["Elegir cu\xE1les", /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
1299
+ className: "hint",
1300
+ children: "\xDAtil cuando la variante cambia de color o de empaque."
1301
+ })]
810
1302
  })]
811
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)("button", {
812
- type: "button",
813
- onClick: addRetailer,
814
- disabled: !newRetailer || !newCategory,
815
- children: "Agregar"
816
1303
  })]
1304
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_styles.ImageGrid, {
1305
+ children: imagenesUtiles.map(function (image) {
1306
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)("label", {
1307
+ className: [chosen.images.includes(image.id) ? "picked" : "", modes.images === "all" ? "locked" : ""].filter(Boolean).join(" "),
1308
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("input", {
1309
+ type: "checkbox",
1310
+ disabled: modes.images === "all",
1311
+ checked: chosen.images.includes(image.id),
1312
+ onChange: function onChange() {
1313
+ return toggleChoice("images", image.id);
1314
+ }
1315
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("img", {
1316
+ src: (0, _helper.getProductImage)(image.src),
1317
+ alt: "",
1318
+ onError: function onError() {
1319
+ return setBrokenImages(function (current) {
1320
+ return current.includes(image.id) ? current : [].concat((0, _toConsumableArray2.default)(current), [image.id]);
1321
+ });
1322
+ }
1323
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
1324
+ children: image.imageType || "Sin tipo de toma"
1325
+ })]
1326
+ }, image.id);
1327
+ })
817
1328
  })]
1329
+ }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_styles.Message, {
1330
+ children: "El producto padre no tiene im\xE1genes que heredar."
818
1331
  })]
819
1332
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_styles.Message, {
820
1333
  children: "Lo que elijas heredar reemplaza el valor actual de la variante, incluso si alguien lo hab\xEDa capturado a mano."
@@ -823,7 +1336,9 @@ var LinkVariantsModal = function LinkVariantsModal(_ref) {
823
1336
  }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_styles.Footer, {
824
1337
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
825
1338
  className: "summary",
826
- children: step === "search" ? selectionLabel : "Revisa la herencia antes de ligar."
1339
+ children: step === "search" ? selectionLabel : todoDecidido ? "Todo revisado. Puedes ligar." : !applyToAll && mode === "children" ? "Faltan ".concat(selected.filter(function (id) {
1340
+ return !decididoPara(id);
1341
+ }).length, " producto(s) por revisar.") : "Falta decidir: ".concat(faltantes.join(", "), ".")
827
1342
  }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
828
1343
  className: "actions",
829
1344
  children: [step === "inherit" && /*#__PURE__*/(0, _jsxRuntime.jsx)("button", {
@@ -850,10 +1365,7 @@ var LinkVariantsModal = function LinkVariantsModal(_ref) {
850
1365
  type: "button",
851
1366
  className: "primary",
852
1367
  onClick: submit,
853
- disabled: loading || // Solo estorba cuando hay algo que elegir y no se eligió nada.
854
- // Con el padre sin atributos heredables, ligar sigue siendo
855
- // válido: se heredan imágenes, descripciones y cadenas.
856
- inheritMode === "selected" && offered.attributes.length > 0 && !chosen.attributes.length,
1368
+ disabled: loading || !todoDecidido,
857
1369
  children: loading ? "Ligando…" : "Ligar"
858
1370
  })]
859
1371
  })]