contentoh-components-library 21.6.32 → 21.6.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ai/prompts/attribute.prompt.js +28 -0
- package/dist/ai/prompts/description.prompt.js +33 -0
- package/dist/ai/schemas/attribute.schema.js +35 -0
- package/dist/ai/schemas/description.schema.js +27 -0
- package/dist/components/atoms/InheritanceTag/InheritanceTag.stories.js +5 -5
- package/dist/components/atoms/InheritanceTag/index.js +6 -6
- package/dist/components/organisms/InputGroup/index.js +12 -1
- package/dist/components/organisms/LinkVariantsModal/index.js +269 -356
- package/dist/components/organisms/LinkVariantsModal/styles.js +14 -5
- package/dist/components/organisms/PropagateChangesModal/index.js +12 -13
- package/dist/components/pages/ProviderProductEdition/context/provider-product-edition.context.js +5 -5
- package/dist/components/pages/ProviderProductEdition/context/reducers/inputs.js +5 -2
- package/dist/components/pages/ProviderProductEdition/index.js +76 -33
- package/dist/components/pages/RetailerProductEdition/context/provider-product-edition.context.js +5 -5
- package/dist/components/pages/RetailerProductEdition/context/reducers/inputs.js +5 -2
- package/dist/components/pages/RetailerProductEdition/index.js +75 -35
- package/package.json +1 -1
- package/src/components/atoms/InheritanceTag/InheritanceTag.stories.js +3 -3
- package/src/components/atoms/InheritanceTag/index.js +6 -6
- package/src/components/organisms/InputGroup/index.js +12 -0
- package/src/components/organisms/LinkVariantsModal/index.js +260 -287
- package/src/components/organisms/LinkVariantsModal/styles.js +65 -32
- package/src/components/organisms/PropagateChangesModal/index.js +19 -17
- package/src/components/pages/ProviderProductEdition/context/provider-product-edition.context.jsx +4 -4
- package/src/components/pages/ProviderProductEdition/context/reducers/inputs.js +13 -1
- package/src/components/pages/ProviderProductEdition/index.js +48 -20
- package/src/components/pages/RetailerProductEdition/context/provider-product-edition.context.jsx +4 -4
- package/src/components/pages/RetailerProductEdition/context/reducers/inputs.js +13 -1
- package/src/components/pages/RetailerProductEdition/index.js +48 -20
|
@@ -25,8 +25,6 @@ var _axios = _interopRequireDefault(require("axios"));
|
|
|
25
25
|
|
|
26
26
|
var _api = require("./api");
|
|
27
27
|
|
|
28
|
-
var _SingleSelect = require("../../molecules/SingleSelect");
|
|
29
|
-
|
|
30
28
|
var _helper = require("../../../_utils/helper");
|
|
31
29
|
|
|
32
30
|
var _styles = require("./styles");
|
|
@@ -34,7 +32,7 @@ var _styles = require("./styles");
|
|
|
34
32
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
35
33
|
|
|
36
34
|
/*
|
|
37
|
-
Modal para ligar productos como padre/
|
|
35
|
+
Modal para ligar productos como padre/hijo.
|
|
38
36
|
|
|
39
37
|
props (* requerido):
|
|
40
38
|
- *articleId: producto desde el que se liga (el que está en edición)
|
|
@@ -44,18 +42,28 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
44
42
|
- *onClose: cerrar sin cambios
|
|
45
43
|
- onLinked: se llama con la respuesta del backend cuando la liga tuvo éxito
|
|
46
44
|
|
|
47
|
-
Los dos modos son los de POST /variants/link:
|
|
48
|
-
|
|
49
|
-
|
|
45
|
+
Los dos modos son los de POST /variants/link, y NO son simétricos:
|
|
46
|
+
|
|
47
|
+
parent → este producto pasa a ser hijo del que se elija.
|
|
48
|
+
No baja nada del padre. La única pregunta es si los atributos de
|
|
49
|
+
este producto se planchan sobre el padre (`pushChildToParent`) o
|
|
50
|
+
si solo se crea el vínculo.
|
|
51
|
+
|
|
52
|
+
children → los elegidos pasan a ser hijos de este producto.
|
|
53
|
+
Aquí sí baja del padre al hijo, con la selección de `inherit`.
|
|
50
54
|
|
|
51
|
-
|
|
55
|
+
La asimetría no es un descuido: al modo `parent` se llega desde un producto ya
|
|
56
|
+
capturado al que se le crea un padre para encabezar la familia. Bajarle encima
|
|
57
|
+
lo del padre borraría justo el trabajo desde el que se está ligando.
|
|
52
58
|
*/
|
|
53
59
|
// El backend devuelve códigos estables justamente para no mandar textos de UI
|
|
54
60
|
// desde el servidor. La traducción a lenguaje humano vive aquí.
|
|
55
61
|
var ERROR_TEXT = {
|
|
56
|
-
VARIANT_SELF_LINK: "Un producto no puede ser
|
|
57
|
-
|
|
58
|
-
|
|
62
|
+
VARIANT_SELF_LINK: "Un producto no puede ser hijo de sí mismo.",
|
|
63
|
+
// Se dice el hecho concreto y no la regla que hay detrás: "las familias son de
|
|
64
|
+
// un solo nivel" obliga al usuario a entender el modelo para leer el error.
|
|
65
|
+
VARIANT_PARENT_IS_CHILD: "Ese producto ya tiene un padre. Desvincúlalo primero.",
|
|
66
|
+
VARIANT_CHILD_IS_PARENT: "Ese producto ya tiene hijos, así que no se le puede asignar un padre.",
|
|
59
67
|
VARIANT_ALREADY_LINKED: "Ese producto ya pertenece a otra familia. Desvincúlalo primero.",
|
|
60
68
|
VARIANT_NOT_OWNED_BY_USER: "Ese producto está fuera de tu alcance.",
|
|
61
69
|
VARIANT_CROSS_COMPANY: "Ese producto pertenece a otra compañía.",
|
|
@@ -74,6 +82,8 @@ var readError = function readError(error) {
|
|
|
74
82
|
};
|
|
75
83
|
|
|
76
84
|
var LinkVariantsModal = function LinkVariantsModal(_ref) {
|
|
85
|
+
var _candidates$find$vari, _candidates$find2;
|
|
86
|
+
|
|
77
87
|
var articleId = _ref.articleId,
|
|
78
88
|
articleName = _ref.articleName,
|
|
79
89
|
articleUpc = _ref.articleUpc,
|
|
@@ -81,8 +91,6 @@ var LinkVariantsModal = function LinkVariantsModal(_ref) {
|
|
|
81
91
|
token = _ref.token,
|
|
82
92
|
_ref$endpoint = _ref.endpoint,
|
|
83
93
|
endpoint = _ref$endpoint === void 0 ? process.env.REACT_APP_VARIANTS_ENDPOINT : _ref$endpoint,
|
|
84
|
-
_ref$filtersEndpoint = _ref.filtersEndpoint,
|
|
85
|
-
filtersEndpoint = _ref$filtersEndpoint === void 0 ? process.env.REACT_APP_CREATE_PRODUCTS_FILTERS : _ref$filtersEndpoint,
|
|
86
94
|
onClose = _ref.onClose,
|
|
87
95
|
onLinked = _ref.onLinked;
|
|
88
96
|
|
|
@@ -136,7 +144,7 @@ var LinkVariantsModal = function LinkVariantsModal(_ref) {
|
|
|
136
144
|
loadingMore = _useState20[0],
|
|
137
145
|
setLoadingMore = _useState20[1]; // Lo que el padre ofrece en cada dimensión, y lo que el usuario eligió de
|
|
138
146
|
// cada una. Se guardan por separado porque se eligen por separado: heredar
|
|
139
|
-
// todos los atributos no dice nada sobre qué fotos quiere
|
|
147
|
+
// todos los atributos no dice nada sobre qué fotos quiere el hijo.
|
|
140
148
|
|
|
141
149
|
|
|
142
150
|
var _useState21 = (0, _react.useState)({
|
|
@@ -188,22 +196,33 @@ var LinkVariantsModal = function LinkVariantsModal(_ref) {
|
|
|
188
196
|
// decisión, no un valor por omisión. Marcado de entrada se ligaban todos igual
|
|
189
197
|
// sin que nadie lo hubiera elegido.
|
|
190
198
|
|
|
199
|
+
/*
|
|
200
|
+
Modo `parent`: la unica decision de la pantalla.
|
|
201
|
+
null = sin decidir, true = planchar los atributos del hijo sobre el padre,
|
|
202
|
+
false = solo vincular sin mover nada. No hay una tercera opcion: bajar del
|
|
203
|
+
padre al hijo es la otra direccion y vive en el modo children.
|
|
204
|
+
*/
|
|
205
|
+
|
|
191
206
|
|
|
192
|
-
var _useState29 = (0, _react.useState)(
|
|
207
|
+
var _useState29 = (0, _react.useState)(null),
|
|
193
208
|
_useState30 = (0, _slicedToArray2.default)(_useState29, 2),
|
|
194
|
-
|
|
195
|
-
|
|
209
|
+
pushToParent = _useState30[0],
|
|
210
|
+
setPushToParent = _useState30[1];
|
|
196
211
|
|
|
197
|
-
var _useState31 = (0, _react.useState)(
|
|
212
|
+
var _useState31 = (0, _react.useState)(false),
|
|
198
213
|
_useState32 = (0, _slicedToArray2.default)(_useState31, 2),
|
|
199
|
-
|
|
200
|
-
|
|
214
|
+
applyToAll = _useState32[0],
|
|
215
|
+
setApplyToAll = _useState32[1];
|
|
201
216
|
|
|
202
|
-
var _useState33 = (0, _react.useState)(
|
|
217
|
+
var _useState33 = (0, _react.useState)(null),
|
|
203
218
|
_useState34 = (0, _slicedToArray2.default)(_useState33, 2),
|
|
204
|
-
|
|
205
|
-
|
|
219
|
+
activeChild = _useState34[0],
|
|
220
|
+
setActiveChild = _useState34[1];
|
|
206
221
|
|
|
222
|
+
var _useState35 = (0, _react.useState)({}),
|
|
223
|
+
_useState36 = (0, _slicedToArray2.default)(_useState35, 2),
|
|
224
|
+
perChild = _useState36[0],
|
|
225
|
+
setPerChild = _useState36[1];
|
|
207
226
|
/*
|
|
208
227
|
Imágenes que la base lista pero cuyo archivo no está en S3.
|
|
209
228
|
Pasa: hay filas de rel_article_image con un src válido que apunta a un objeto
|
|
@@ -215,57 +234,20 @@ var LinkVariantsModal = function LinkVariantsModal(_ref) {
|
|
|
215
234
|
*/
|
|
216
235
|
|
|
217
236
|
|
|
218
|
-
var _useState35 = (0, _react.useState)([]),
|
|
219
|
-
_useState36 = (0, _slicedToArray2.default)(_useState35, 2),
|
|
220
|
-
brokenImages = _useState36[0],
|
|
221
|
-
setBrokenImages = _useState36[1];
|
|
222
|
-
|
|
223
237
|
var _useState37 = (0, _react.useState)([]),
|
|
224
238
|
_useState38 = (0, _slicedToArray2.default)(_useState37, 2),
|
|
225
|
-
|
|
226
|
-
|
|
239
|
+
brokenImages = _useState38[0],
|
|
240
|
+
setBrokenImages = _useState38[1];
|
|
227
241
|
|
|
228
|
-
var _useState39 = (0, _react.useState)(
|
|
242
|
+
var _useState39 = (0, _react.useState)(false),
|
|
229
243
|
_useState40 = (0, _slicedToArray2.default)(_useState39, 2),
|
|
230
|
-
|
|
231
|
-
|
|
244
|
+
loading = _useState40[0],
|
|
245
|
+
setLoading = _useState40[1];
|
|
232
246
|
|
|
233
|
-
var _useState41 = (0, _react.useState)(
|
|
247
|
+
var _useState41 = (0, _react.useState)(null),
|
|
234
248
|
_useState42 = (0, _slicedToArray2.default)(_useState41, 2),
|
|
235
|
-
|
|
236
|
-
|
|
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
|
|
242
|
-
// departamento. Es la misma cascada que usa el alta de productos, y se sirve
|
|
243
|
-
// del mismo endpoint para no acabar con dos árboles de categorías distintos.
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
var _useState45 = (0, _react.useState)({
|
|
247
|
-
retailers: [],
|
|
248
|
-
departments: [],
|
|
249
|
-
categories: []
|
|
250
|
-
}),
|
|
251
|
-
_useState46 = (0, _slicedToArray2.default)(_useState45, 2),
|
|
252
|
-
filters = _useState46[0],
|
|
253
|
-
setFilters = _useState46[1];
|
|
254
|
-
|
|
255
|
-
var _useState47 = (0, _react.useState)(false),
|
|
256
|
-
_useState48 = (0, _slicedToArray2.default)(_useState47, 2),
|
|
257
|
-
loadingFilters = _useState48[0],
|
|
258
|
-
setLoadingFilters = _useState48[1];
|
|
259
|
-
|
|
260
|
-
var _useState49 = (0, _react.useState)(false),
|
|
261
|
-
_useState50 = (0, _slicedToArray2.default)(_useState49, 2),
|
|
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
|
+
error = _useState42[0],
|
|
250
|
+
setError = _useState42[1];
|
|
269
251
|
|
|
270
252
|
var request = (0, _react.useCallback)( /*#__PURE__*/function () {
|
|
271
253
|
var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(action, body) {
|
|
@@ -312,6 +294,7 @@ var LinkVariantsModal = function LinkVariantsModal(_ref) {
|
|
|
312
294
|
setTotal(0);
|
|
313
295
|
setHasMore(false);
|
|
314
296
|
setError(null);
|
|
297
|
+
setPushToParent(null);
|
|
315
298
|
setStep("search");
|
|
316
299
|
}, [mode]);
|
|
317
300
|
|
|
@@ -444,16 +427,26 @@ var LinkVariantsModal = function LinkVariantsModal(_ref) {
|
|
|
444
427
|
while (1) {
|
|
445
428
|
switch (_context4.prev = _context4.next) {
|
|
446
429
|
case 0:
|
|
430
|
+
if (!(mode === "parent")) {
|
|
431
|
+
_context4.next = 4;
|
|
432
|
+
break;
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
setPushToParent(null);
|
|
436
|
+
setStep("inherit");
|
|
437
|
+
return _context4.abrupt("return");
|
|
438
|
+
|
|
439
|
+
case 4:
|
|
447
440
|
setLoading(true);
|
|
448
441
|
setError(null);
|
|
449
|
-
_context4.prev =
|
|
450
|
-
_context4.next =
|
|
442
|
+
_context4.prev = 6;
|
|
443
|
+
_context4.next = 9;
|
|
451
444
|
return request("attributes", {
|
|
452
445
|
parentArticleId: parentArticleId,
|
|
453
446
|
retailerId: activeRetailerId
|
|
454
447
|
});
|
|
455
448
|
|
|
456
|
-
case
|
|
449
|
+
case 9:
|
|
457
450
|
data = _context4.sent;
|
|
458
451
|
listas = {
|
|
459
452
|
attributes: data.attributes || [],
|
|
@@ -475,31 +468,30 @@ var LinkVariantsModal = function LinkVariantsModal(_ref) {
|
|
|
475
468
|
attributes: null,
|
|
476
469
|
images: null
|
|
477
470
|
});
|
|
478
|
-
setExtraRetailers([]);
|
|
479
471
|
setBrokenImages([]);
|
|
480
472
|
setPerChild({});
|
|
481
473
|
setApplyToAll(false);
|
|
482
474
|
setActiveChild(mode === "children" ? selected[0] : null);
|
|
483
475
|
setStep("inherit");
|
|
484
|
-
_context4.next =
|
|
476
|
+
_context4.next = 25;
|
|
485
477
|
break;
|
|
486
478
|
|
|
487
|
-
case 19:
|
|
488
|
-
_context4.prev = 19;
|
|
489
|
-
_context4.t0 = _context4["catch"](2);
|
|
490
|
-
setError(readError(_context4.t0));
|
|
491
|
-
|
|
492
479
|
case 22:
|
|
493
480
|
_context4.prev = 22;
|
|
494
|
-
|
|
495
|
-
|
|
481
|
+
_context4.t0 = _context4["catch"](6);
|
|
482
|
+
setError(readError(_context4.t0));
|
|
496
483
|
|
|
497
484
|
case 25:
|
|
485
|
+
_context4.prev = 25;
|
|
486
|
+
setLoading(false);
|
|
487
|
+
return _context4.finish(25);
|
|
488
|
+
|
|
489
|
+
case 28:
|
|
498
490
|
case "end":
|
|
499
491
|
return _context4.stop();
|
|
500
492
|
}
|
|
501
493
|
}
|
|
502
|
-
}, _callee4, null, [[
|
|
494
|
+
}, _callee4, null, [[6, 22, 25, 28]]);
|
|
503
495
|
}));
|
|
504
496
|
|
|
505
497
|
return function goToInheritance() {
|
|
@@ -534,165 +526,14 @@ var LinkVariantsModal = function LinkVariantsModal(_ref) {
|
|
|
534
526
|
return (0, _objectSpread7.default)((0, _objectSpread7.default)({}, current), {}, (0, _defineProperty2.default)({}, dimension, modo === "all" ? ids : []));
|
|
535
527
|
});
|
|
536
528
|
};
|
|
537
|
-
|
|
538
|
-
var loadFilters = (0, _react.useCallback)( /*#__PURE__*/function () {
|
|
539
|
-
var _ref6 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5(retailer, department) {
|
|
540
|
-
var _readPayload$data, _readPayload, res, lista;
|
|
541
|
-
|
|
542
|
-
return _regenerator.default.wrap(function _callee5$(_context5) {
|
|
543
|
-
while (1) {
|
|
544
|
-
switch (_context5.prev = _context5.next) {
|
|
545
|
-
case 0:
|
|
546
|
-
setLoadingFilters(true);
|
|
547
|
-
_context5.prev = 1;
|
|
548
|
-
_context5.next = 4;
|
|
549
|
-
return _axios.default.get("".concat(filtersEndpoint, "?retailerSelected=").concat(retailer !== null && retailer !== void 0 ? retailer : "", "&departmentSelected=").concat(department !== null && department !== void 0 ? department : ""), {
|
|
550
|
-
headers: {
|
|
551
|
-
Authorization: token
|
|
552
|
-
}
|
|
553
|
-
});
|
|
554
|
-
|
|
555
|
-
case 4:
|
|
556
|
-
res = _context5.sent;
|
|
557
|
-
// readPayload YA devuelve el cuerpo parseado. Volver a buscar `body`
|
|
558
|
-
// dentro dejaba la lista siempre vacía, y por eso el selector de cadenas
|
|
559
|
-
// no mostraba nada.
|
|
560
|
-
lista = (_readPayload$data = (_readPayload = (0, _api.readPayload)(res)) === null || _readPayload === void 0 ? void 0 : _readPayload.data) !== null && _readPayload$data !== void 0 ? _readPayload$data : [];
|
|
561
|
-
setFilters(function (current) {
|
|
562
|
-
if (!retailer) {
|
|
563
|
-
return (0, _objectSpread7.default)((0, _objectSpread7.default)({}, current), {}, {
|
|
564
|
-
retailers: lista.map(function (item) {
|
|
565
|
-
return {
|
|
566
|
-
value: item.id,
|
|
567
|
-
label: item.name
|
|
568
|
-
};
|
|
569
|
-
})
|
|
570
|
-
});
|
|
571
|
-
}
|
|
572
|
-
|
|
573
|
-
if (!department) {
|
|
574
|
-
return (0, _objectSpread7.default)((0, _objectSpread7.default)({}, current), {}, {
|
|
575
|
-
departments: lista.map(function (item) {
|
|
576
|
-
return {
|
|
577
|
-
value: item.category,
|
|
578
|
-
label: item.category
|
|
579
|
-
};
|
|
580
|
-
}),
|
|
581
|
-
categories: []
|
|
582
|
-
});
|
|
583
|
-
} // El tercer nivel no viene como {id, name} sino como
|
|
584
|
-
// {category_id, subcategory}: con el mapeo de los otros dos, la
|
|
585
|
-
// categoría salía en la lista pero sin texto. Mismo criterio que usa
|
|
586
|
-
// el alta de productos, incluido el separador legible.
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
return (0, _objectSpread7.default)((0, _objectSpread7.default)({}, current), {}, {
|
|
590
|
-
categories: lista.map(function (item) {
|
|
591
|
-
var _item$subcategory;
|
|
592
|
-
|
|
593
|
-
return {
|
|
594
|
-
value: item.category_id,
|
|
595
|
-
label: ((_item$subcategory = item.subcategory) !== null && _item$subcategory !== void 0 ? _item$subcategory : "").replace("|", " > ")
|
|
596
|
-
};
|
|
597
|
-
})
|
|
598
|
-
});
|
|
599
|
-
});
|
|
600
|
-
_context5.next = 12;
|
|
601
|
-
break;
|
|
602
|
-
|
|
603
|
-
case 9:
|
|
604
|
-
_context5.prev = 9;
|
|
605
|
-
_context5.t0 = _context5["catch"](1);
|
|
606
|
-
console.error("linkVariants/filters: ", _context5.t0);
|
|
607
|
-
|
|
608
|
-
case 12:
|
|
609
|
-
_context5.prev = 12;
|
|
610
|
-
setLoadingFilters(false);
|
|
611
|
-
return _context5.finish(12);
|
|
612
|
-
|
|
613
|
-
case 15:
|
|
614
|
-
case "end":
|
|
615
|
-
return _context5.stop();
|
|
616
|
-
}
|
|
617
|
-
}
|
|
618
|
-
}, _callee5, null, [[1, 9, 12, 15]]);
|
|
619
|
-
}));
|
|
620
|
-
|
|
621
|
-
return function (_x4, _x5) {
|
|
622
|
-
return _ref6.apply(this, arguments);
|
|
623
|
-
};
|
|
624
|
-
}(), [filtersEndpoint, token]); // Las cadenas del catálogo se piden al entrar al paso de herencia, no al abrir
|
|
625
|
-
// el modal: quien solo busca y cancela no llega a necesitarlas.
|
|
626
|
-
|
|
627
|
-
(0, _react.useEffect)(function () {
|
|
628
|
-
if (step === "inherit" && !filters.retailers.length) {
|
|
629
|
-
loadFilters(null, null);
|
|
630
|
-
}
|
|
631
|
-
}, [step, filters.retailers.length, loadFilters]);
|
|
632
|
-
/*
|
|
633
|
-
Quita una cadena agregada a mano. Solo esas: las del padre se desmarcan con
|
|
634
|
-
su casilla, pero siguen existiendo y volverán a aparecer.
|
|
635
|
-
*/
|
|
636
|
-
|
|
637
|
-
var removeExtraRetailer = function removeExtraRetailer(clave) {
|
|
638
|
-
setExtraRetailers(function (current) {
|
|
639
|
-
return current.filter(function (item) {
|
|
640
|
-
return item.clave !== clave;
|
|
641
|
-
});
|
|
642
|
-
});
|
|
643
|
-
setChosen(function (current) {
|
|
644
|
-
return (0, _objectSpread7.default)((0, _objectSpread7.default)({}, current), {}, {
|
|
645
|
-
categoryRetailers: current.categoryRetailers.filter(function (item) {
|
|
646
|
-
return item !== clave;
|
|
647
|
-
})
|
|
648
|
-
});
|
|
649
|
-
});
|
|
650
|
-
};
|
|
651
|
-
|
|
652
|
-
var addRetailer = function addRetailer() {
|
|
653
|
-
var retailerId = Number(newRetailer);
|
|
654
|
-
var categoryId = Number(newCategory);
|
|
655
|
-
if (!retailerId || !categoryId) return;
|
|
656
|
-
var clave = "".concat(retailerId, "-").concat(categoryId);
|
|
657
|
-
var yaEsta = offered.categoryRetailers.some(function (item) {
|
|
658
|
-
return "".concat(item.retailerId, "-").concat(item.categoryId) === clave;
|
|
659
|
-
}) || extraRetailers.some(function (item) {
|
|
660
|
-
return item.clave === clave;
|
|
661
|
-
});
|
|
662
|
-
if (yaEsta) return;
|
|
663
|
-
var retailer = filters.retailers.find(function (item) {
|
|
664
|
-
return Number(item.value) === retailerId;
|
|
665
|
-
});
|
|
666
|
-
var category = filters.categories.find(function (item) {
|
|
667
|
-
return Number(item.value) === categoryId;
|
|
668
|
-
});
|
|
669
|
-
setExtraRetailers(function (current) {
|
|
670
|
-
var _retailer$label, _category$label;
|
|
671
|
-
|
|
672
|
-
return [].concat((0, _toConsumableArray2.default)(current), [{
|
|
673
|
-
clave: clave,
|
|
674
|
-
retailerId: retailerId,
|
|
675
|
-
categoryId: categoryId,
|
|
676
|
-
retailerName: (_retailer$label = retailer === null || retailer === void 0 ? void 0 : retailer.label) !== null && _retailer$label !== void 0 ? _retailer$label : "Cadena ".concat(retailerId),
|
|
677
|
-
categoryName: (_category$label = category === null || category === void 0 ? void 0 : category.label) !== null && _category$label !== void 0 ? _category$label : "Categor\xEDa ".concat(categoryId)
|
|
678
|
-
}]);
|
|
679
|
-
});
|
|
680
|
-
setChosen(function (current) {
|
|
681
|
-
return (0, _objectSpread7.default)((0, _objectSpread7.default)({}, current), {}, {
|
|
682
|
-
categoryRetailers: [].concat((0, _toConsumableArray2.default)(current.categoryRetailers), [clave])
|
|
683
|
-
});
|
|
684
|
-
});
|
|
685
|
-
setNewRetailer("");
|
|
686
|
-
setNewDepartment("");
|
|
687
|
-
setNewCategory("");
|
|
688
|
-
};
|
|
689
529
|
/*
|
|
690
530
|
Convierte una selección de pantalla en el bloque `inherit` de la API.
|
|
691
531
|
Con el modo en "todos" se manda la palabra y no la lista que se pintó: si
|
|
692
532
|
entre la carga del modal y el guardado alguien agregó un valor al padre,
|
|
693
533
|
"todos" sigue significando todos. La lista sería una foto ya vieja.
|
|
694
|
-
Las parejas cadena+categoría viajan como objetos
|
|
695
|
-
|
|
534
|
+
Las parejas cadena+categoría viajan como objetos y no como ids porque el
|
|
535
|
+
backend las da de alta en el hijo por (cadena, categoría); todas salen de las
|
|
536
|
+
que ya tiene el padre, que son las únicas que se pueden heredar.
|
|
696
537
|
*/
|
|
697
538
|
// Las que de verdad se pueden heredar: la base puede listar filas cuyo archivo
|
|
698
539
|
// ya no existe, y esas no cuentan ni para la lista ni para el "todas".
|
|
@@ -703,24 +544,22 @@ var LinkVariantsModal = function LinkVariantsModal(_ref) {
|
|
|
703
544
|
});
|
|
704
545
|
|
|
705
546
|
var buildInherit = function buildInherit(seleccion) {
|
|
706
|
-
var
|
|
707
|
-
|
|
708
|
-
var parejas = [].concat((0, _toConsumableArray2.default)(offered.categoryRetailers.map(function (item) {
|
|
547
|
+
var parejas = offered.categoryRetailers.map(function (item) {
|
|
709
548
|
return {
|
|
710
549
|
clave: "".concat(item.retailerId, "-").concat(item.categoryId),
|
|
711
550
|
retailerId: item.retailerId,
|
|
712
551
|
categoryId: item.categoryId
|
|
713
552
|
};
|
|
714
|
-
})
|
|
553
|
+
});
|
|
715
554
|
return {
|
|
716
555
|
attributes: seleccion.modes.attributes === "all" ? "all-filled" : seleccion.chosen.attributes,
|
|
717
556
|
descriptions: seleccion.modes.descriptions === "all" ? "all" : seleccion.chosen.descriptions,
|
|
718
557
|
images: seleccion.modes.images === "all" ? "all" : seleccion.chosen.images,
|
|
719
558
|
categoryRetailers: parejas.filter(function (par) {
|
|
720
559
|
return seleccion.chosen.categoryRetailers.includes(par.clave);
|
|
721
|
-
}).map(function (
|
|
722
|
-
var retailerId =
|
|
723
|
-
categoryId =
|
|
560
|
+
}).map(function (_ref6) {
|
|
561
|
+
var retailerId = _ref6.retailerId,
|
|
562
|
+
categoryId = _ref6.categoryId;
|
|
724
563
|
return {
|
|
725
564
|
retailerId: retailerId,
|
|
726
565
|
categoryId: categoryId
|
|
@@ -742,8 +581,7 @@ var LinkVariantsModal = function LinkVariantsModal(_ref) {
|
|
|
742
581
|
descriptions: [],
|
|
743
582
|
images: [],
|
|
744
583
|
categoryRetailers: []
|
|
745
|
-
}
|
|
746
|
-
extraRetailers: []
|
|
584
|
+
}
|
|
747
585
|
};
|
|
748
586
|
};
|
|
749
587
|
/*
|
|
@@ -753,35 +591,32 @@ var LinkVariantsModal = function LinkVariantsModal(_ref) {
|
|
|
753
591
|
|
|
754
592
|
|
|
755
593
|
var switchChild = function switchChild(id) {
|
|
756
|
-
var _perChild$id
|
|
594
|
+
var _perChild$id;
|
|
757
595
|
|
|
758
596
|
setPerChild(function (current) {
|
|
759
597
|
return (0, _objectSpread7.default)((0, _objectSpread7.default)({}, current), {}, (0, _defineProperty2.default)({}, activeChild, {
|
|
760
598
|
modes: modes,
|
|
761
|
-
chosen: chosen
|
|
762
|
-
extraRetailers: extraRetailers
|
|
599
|
+
chosen: chosen
|
|
763
600
|
}));
|
|
764
601
|
});
|
|
765
602
|
var guardado = (_perChild$id = perChild[id]) !== null && _perChild$id !== void 0 ? _perChild$id : seleccionVacia();
|
|
766
603
|
setModes(guardado.modes);
|
|
767
604
|
setChosen(guardado.chosen);
|
|
768
|
-
setExtraRetailers((_guardado$extraRetail = guardado.extraRetailers) !== null && _guardado$extraRetail !== void 0 ? _guardado$extraRetail : []);
|
|
769
605
|
setActiveChild(id);
|
|
770
606
|
};
|
|
771
607
|
|
|
772
608
|
var submit = /*#__PURE__*/function () {
|
|
773
|
-
var
|
|
609
|
+
var _ref7 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5() {
|
|
774
610
|
var inherit, inheritByChild, body, data;
|
|
775
|
-
return _regenerator.default.wrap(function
|
|
611
|
+
return _regenerator.default.wrap(function _callee5$(_context5) {
|
|
776
612
|
while (1) {
|
|
777
|
-
switch (
|
|
613
|
+
switch (_context5.prev = _context5.next) {
|
|
778
614
|
case 0:
|
|
779
615
|
setLoading(true);
|
|
780
616
|
setError(null);
|
|
781
617
|
inherit = buildInherit({
|
|
782
618
|
modes: modes,
|
|
783
|
-
chosen: chosen
|
|
784
|
-
extraRetailers: extraRetailers
|
|
619
|
+
chosen: chosen
|
|
785
620
|
}); // Con las pestañas abiertas cada producto manda la suya. La selección de la
|
|
786
621
|
// pestaña a la vista todavía no está en perChild, así que se agrega aquí: si
|
|
787
622
|
// no, lo último que tocó el usuario se perdería al guardar.
|
|
@@ -789,8 +624,7 @@ var LinkVariantsModal = function LinkVariantsModal(_ref) {
|
|
|
789
624
|
inheritByChild = !applyToAll && mode === "children" ? selected.reduce(function (acc, id) {
|
|
790
625
|
var guardado = id === activeChild ? {
|
|
791
626
|
modes: modes,
|
|
792
|
-
chosen: chosen
|
|
793
|
-
extraRetailers: extraRetailers
|
|
627
|
+
chosen: chosen
|
|
794
628
|
} : perChild[id];
|
|
795
629
|
if (guardado) acc[id] = buildInherit(guardado);
|
|
796
630
|
return acc;
|
|
@@ -799,7 +633,7 @@ var LinkVariantsModal = function LinkVariantsModal(_ref) {
|
|
|
799
633
|
mode: mode,
|
|
800
634
|
articleId: articleId,
|
|
801
635
|
parentArticleId: selected[0],
|
|
802
|
-
|
|
636
|
+
pushChildToParent: pushToParent === true
|
|
803
637
|
} : (0, _objectSpread7.default)({
|
|
804
638
|
mode: mode,
|
|
805
639
|
parentArticleId: articleId,
|
|
@@ -808,43 +642,43 @@ var LinkVariantsModal = function LinkVariantsModal(_ref) {
|
|
|
808
642
|
}, inheritByChild ? {
|
|
809
643
|
inheritByChild: inheritByChild
|
|
810
644
|
} : {});
|
|
811
|
-
|
|
812
|
-
|
|
645
|
+
_context5.prev = 5;
|
|
646
|
+
_context5.next = 8;
|
|
813
647
|
return request("link", body);
|
|
814
648
|
|
|
815
649
|
case 8:
|
|
816
|
-
data =
|
|
650
|
+
data = _context5.sent;
|
|
817
651
|
// El modo importa para quien escucha: en `children` este producto GANA
|
|
818
|
-
//
|
|
652
|
+
// hijos; en `parent` pasa a SER uno. Son efectos opuestos sobre la
|
|
819
653
|
// misma ficha, así que quien refresque el estado necesita distinguirlos.
|
|
820
654
|
onLinked === null || onLinked === void 0 ? void 0 : onLinked((0, _objectSpread7.default)((0, _objectSpread7.default)({}, data), {}, {
|
|
821
655
|
mode: mode,
|
|
822
656
|
parentArticleId: mode === "parent" ? selected[0] : articleId
|
|
823
657
|
}));
|
|
824
658
|
onClose === null || onClose === void 0 ? void 0 : onClose();
|
|
825
|
-
|
|
659
|
+
_context5.next = 16;
|
|
826
660
|
break;
|
|
827
661
|
|
|
828
662
|
case 13:
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
setError(readError(
|
|
663
|
+
_context5.prev = 13;
|
|
664
|
+
_context5.t0 = _context5["catch"](5);
|
|
665
|
+
setError(readError(_context5.t0));
|
|
832
666
|
|
|
833
667
|
case 16:
|
|
834
|
-
|
|
668
|
+
_context5.prev = 16;
|
|
835
669
|
setLoading(false);
|
|
836
|
-
return
|
|
670
|
+
return _context5.finish(16);
|
|
837
671
|
|
|
838
672
|
case 19:
|
|
839
673
|
case "end":
|
|
840
|
-
return
|
|
674
|
+
return _context5.stop();
|
|
841
675
|
}
|
|
842
676
|
}
|
|
843
|
-
},
|
|
677
|
+
}, _callee5, null, [[5, 13, 16, 19]]);
|
|
844
678
|
}));
|
|
845
679
|
|
|
846
680
|
return function submit() {
|
|
847
|
-
return
|
|
681
|
+
return _ref7.apply(this, arguments);
|
|
848
682
|
};
|
|
849
683
|
}(); // Una dimensión está decidida si el usuario eligió un modo, o si el padre no
|
|
850
684
|
// ofrece nada en ella —no se puede pedir que decida sobre una lista vacía—.
|
|
@@ -854,7 +688,7 @@ var LinkVariantsModal = function LinkVariantsModal(_ref) {
|
|
|
854
688
|
if (modes[dimension] !== null) return true;
|
|
855
689
|
|
|
856
690
|
if (dimension === "categoryRetailers") {
|
|
857
|
-
return offered.categoryRetailers.length === 0
|
|
691
|
+
return offered.categoryRetailers.length === 0;
|
|
858
692
|
} // Una imagen cuyo archivo no existe no es algo sobre lo que se pueda decidir.
|
|
859
693
|
|
|
860
694
|
|
|
@@ -868,36 +702,59 @@ var LinkVariantsModal = function LinkVariantsModal(_ref) {
|
|
|
868
702
|
var decididoPara = function decididoPara(id) {
|
|
869
703
|
var guardado = id === activeChild ? {
|
|
870
704
|
modes: modes,
|
|
871
|
-
chosen: chosen
|
|
872
|
-
extraRetailers: extraRetailers
|
|
705
|
+
chosen: chosen
|
|
873
706
|
} : perChild[id];
|
|
874
707
|
if (!guardado) return false;
|
|
875
708
|
return DIMENSIONES.every(function (dimension) {
|
|
876
709
|
if (guardado.modes[dimension] !== null) return true;
|
|
877
710
|
|
|
878
711
|
if (dimension === "categoryRetailers") {
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
return offered.categoryRetailers.length === 0 && ((_guardado$extraRetail2 = guardado.extraRetailers) !== null && _guardado$extraRetail2 !== void 0 ? _guardado$extraRetail2 : []).length === 0;
|
|
712
|
+
return offered.categoryRetailers.length === 0;
|
|
882
713
|
}
|
|
883
714
|
|
|
884
715
|
return dimension === "images" ? imagenesUtiles.length === 0 : offered[dimension].length === 0;
|
|
885
716
|
});
|
|
886
717
|
};
|
|
887
718
|
|
|
888
|
-
var todoDecidido = step === "inherit" && (
|
|
889
|
-
var faltantes = [["categoryRetailers", "cadenas"], ["descriptions", "descripciones"], ["attributes", "atributos"], ["images", "imágenes"]].filter(function (
|
|
890
|
-
var
|
|
891
|
-
clave =
|
|
719
|
+
var todoDecidido = step === "inherit" && (mode === "parent" ? pushToParent !== null : applyToAll ? DIMENSIONES.every(decidida) : selected.every(decididoPara));
|
|
720
|
+
var faltantes = [["categoryRetailers", "cadenas"], ["descriptions", "descripciones"], ["attributes", "atributos"], ["images", "imágenes"]].filter(function (_ref8) {
|
|
721
|
+
var _ref9 = (0, _slicedToArray2.default)(_ref8, 1),
|
|
722
|
+
clave = _ref9[0];
|
|
892
723
|
|
|
893
724
|
return !decidida(clave);
|
|
894
|
-
}).map(function (
|
|
895
|
-
var
|
|
896
|
-
nombre =
|
|
725
|
+
}).map(function (_ref10) {
|
|
726
|
+
var _ref11 = (0, _slicedToArray2.default)(_ref10, 2),
|
|
727
|
+
nombre = _ref11[1];
|
|
897
728
|
|
|
898
729
|
return nombre;
|
|
899
730
|
});
|
|
900
|
-
var selectionLabel = mode === "parent" ? "Se elige un solo producto padre." : "".concat(selected.length, " producto(s) pasar\xE1n a ser
|
|
731
|
+
var selectionLabel = mode === "parent" ? "Se elige un solo producto padre." : "".concat(selected.length, " producto(s) pasar\xE1n a ser hijos de este.");
|
|
732
|
+
/*
|
|
733
|
+
Quién es el padre y quién el hijo.
|
|
734
|
+
Es la pregunta que el modal no contestaba: la dirección la fija el modo, que
|
|
735
|
+
se eligió en la pantalla anterior y ya no está a la vista, así que al llegar
|
|
736
|
+
aquí no había forma de saber si lo que se marca baja o sube. En modo `parent`
|
|
737
|
+
el producto abierto es el que RECIBE, que es justo lo contrario de lo que
|
|
738
|
+
sugiere tenerlo en el título del modal.
|
|
739
|
+
*/
|
|
740
|
+
|
|
741
|
+
var nombreDe = function nombreDe(id) {
|
|
742
|
+
var _candidates$find;
|
|
743
|
+
|
|
744
|
+
return ((_candidates$find = candidates.find(function (item) {
|
|
745
|
+
return item.articleId === id;
|
|
746
|
+
})) === null || _candidates$find === void 0 ? void 0 : _candidates$find.name) || "Producto ".concat(id);
|
|
747
|
+
};
|
|
748
|
+
|
|
749
|
+
var esteEsPadre = mode === "children"; // Cuántos hijos tiene ya el padre elegido. Es informativo: sale del mismo
|
|
750
|
+
// candidato que se pintó en la búsqueda, sin una llamada extra.
|
|
751
|
+
|
|
752
|
+
var hijosDelPadre = mode === "parent" && selected.length ? (_candidates$find$vari = (_candidates$find2 = candidates.find(function (item) {
|
|
753
|
+
return item.articleId === selected[0];
|
|
754
|
+
})) === null || _candidates$find2 === void 0 ? void 0 : _candidates$find2.variantsCount) !== null && _candidates$find$vari !== void 0 ? _candidates$find$vari : 0 : 0;
|
|
755
|
+
var nombreEsteProducto = articleName || "Producto ".concat(articleId);
|
|
756
|
+
var nombrePadre = esteEsPadre ? nombreEsteProducto : selected.length ? nombreDe(selected[0]) : "—";
|
|
757
|
+
var nombreHijo = !esteEsPadre ? nombreEsteProducto : selected.length === 1 ? nombreDe(selected[0]) : "".concat(selected.length, " productos elegidos");
|
|
901
758
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_styles.Overlay, {
|
|
902
759
|
onClick: onClose,
|
|
903
760
|
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_styles.Panel, {
|
|
@@ -925,14 +782,14 @@ var LinkVariantsModal = function LinkVariantsModal(_ref) {
|
|
|
925
782
|
onClick: function onClick() {
|
|
926
783
|
return setMode("parent");
|
|
927
784
|
},
|
|
928
|
-
children: "
|
|
785
|
+
children: "Relacionar padre a este producto"
|
|
929
786
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("button", {
|
|
930
787
|
type: "button",
|
|
931
788
|
className: mode === "children" ? "active" : "",
|
|
932
789
|
onClick: function onClick() {
|
|
933
790
|
return setMode("children");
|
|
934
791
|
},
|
|
935
|
-
children: "
|
|
792
|
+
children: "Relacionar hijos a este producto"
|
|
936
793
|
})]
|
|
937
794
|
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_styles.Body, {
|
|
938
795
|
children: [error && /*#__PURE__*/(0, _jsxRuntime.jsx)(_styles.Message, {
|
|
@@ -976,7 +833,7 @@ var LinkVariantsModal = function LinkVariantsModal(_ref) {
|
|
|
976
833
|
})]
|
|
977
834
|
}), candidate.variantsCount > 0 && /*#__PURE__*/(0, _jsxRuntime.jsxs)("span", {
|
|
978
835
|
className: "count",
|
|
979
|
-
children: [candidate.variantsCount, "
|
|
836
|
+
children: [candidate.variantsCount, " hijo", candidate.variantsCount === 1 ? "" : "s"]
|
|
980
837
|
})]
|
|
981
838
|
})
|
|
982
839
|
}, candidate.articleId);
|
|
@@ -991,8 +848,119 @@ var LinkVariantsModal = function LinkVariantsModal(_ref) {
|
|
|
991
848
|
children: loadingMore ? "Cargando…" : "Cargar más"
|
|
992
849
|
})]
|
|
993
850
|
})]
|
|
994
|
-
}), step === "inherit" && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
995
|
-
children: [
|
|
851
|
+
}), step === "inherit" && mode === "parent" && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
852
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_styles.Direction, {
|
|
853
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
854
|
+
className: "lado",
|
|
855
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
856
|
+
className: "rol",
|
|
857
|
+
children: "Producto hijo"
|
|
858
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("strong", {
|
|
859
|
+
title: nombreEsteProducto,
|
|
860
|
+
children: nombreEsteProducto
|
|
861
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
862
|
+
className: "actual",
|
|
863
|
+
children: "el que tienes abierto"
|
|
864
|
+
})]
|
|
865
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
866
|
+
className: "flecha",
|
|
867
|
+
"aria-hidden": "true",
|
|
868
|
+
children: "\u2192"
|
|
869
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
870
|
+
className: "lado",
|
|
871
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
872
|
+
className: "rol",
|
|
873
|
+
children: "Producto padre"
|
|
874
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("strong", {
|
|
875
|
+
title: nombrePadre,
|
|
876
|
+
children: nombrePadre
|
|
877
|
+
})]
|
|
878
|
+
})]
|
|
879
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_styles.Message, {
|
|
880
|
+
children: ["Aqu\xED ", /*#__PURE__*/(0, _jsxRuntime.jsx)("strong", {
|
|
881
|
+
children: "no baja nada del padre"
|
|
882
|
+
}), ": \xAB", nombreEsteProducto, "\xBB conserva todo lo que ya tiene capturado. Lo \xFAnico que se decide es si esos valores", " ", /*#__PURE__*/(0, _jsxRuntime.jsx)("strong", {
|
|
883
|
+
children: "suben al padre"
|
|
884
|
+
}), "."]
|
|
885
|
+
}), hijosDelPadre > 0 && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_styles.Message, {
|
|
886
|
+
className: "aviso",
|
|
887
|
+
children: ["\xAB", nombrePadre, "\xBB ya tiene ", /*#__PURE__*/(0, _jsxRuntime.jsx)("strong", {
|
|
888
|
+
children: hijosDelPadre
|
|
889
|
+
}), " ", hijosDelPadre === 1 ? "hijo" : "hijos", ". Si planchas, cambias los valores desde los que ellos heredan. Lo que ya tengan capturado no se toca."]
|
|
890
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_styles.Block, {
|
|
891
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("h3", {
|
|
892
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
893
|
+
className: "paso",
|
|
894
|
+
children: "1"
|
|
895
|
+
}), " \xBFQu\xE9 hacemos con los atributos?"]
|
|
896
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_styles.Choices, {
|
|
897
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("label", {
|
|
898
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("input", {
|
|
899
|
+
type: "radio",
|
|
900
|
+
name: "push-to-parent",
|
|
901
|
+
checked: pushToParent === true,
|
|
902
|
+
onChange: function onChange() {
|
|
903
|
+
return setPushToParent(true);
|
|
904
|
+
}
|
|
905
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)("span", {
|
|
906
|
+
children: ["Planchar los de este producto sobre el padre", /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
907
|
+
className: "hint",
|
|
908
|
+
children: "El padre se queda con estos valores y pasan a contar como heredados. El UPC y el SKU nunca suben."
|
|
909
|
+
})]
|
|
910
|
+
})]
|
|
911
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)("label", {
|
|
912
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("input", {
|
|
913
|
+
type: "radio",
|
|
914
|
+
name: "push-to-parent",
|
|
915
|
+
checked: pushToParent === false,
|
|
916
|
+
onChange: function onChange() {
|
|
917
|
+
return setPushToParent(false);
|
|
918
|
+
}
|
|
919
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)("span", {
|
|
920
|
+
children: ["Solo vincular, sin mover nada", /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
921
|
+
className: "hint",
|
|
922
|
+
children: "Se crea el parentesco y ya. Ni el padre ni este producto cambian de valor."
|
|
923
|
+
})]
|
|
924
|
+
})]
|
|
925
|
+
})]
|
|
926
|
+
})]
|
|
927
|
+
})]
|
|
928
|
+
}), step === "inherit" && mode === "children" && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
929
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_styles.Direction, {
|
|
930
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
931
|
+
className: "lado",
|
|
932
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
933
|
+
className: "rol",
|
|
934
|
+
children: "Producto padre"
|
|
935
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("strong", {
|
|
936
|
+
title: nombrePadre,
|
|
937
|
+
children: nombrePadre
|
|
938
|
+
}), esteEsPadre && /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
939
|
+
className: "actual",
|
|
940
|
+
children: "el que tienes abierto"
|
|
941
|
+
})]
|
|
942
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
943
|
+
className: "flecha",
|
|
944
|
+
"aria-hidden": "true",
|
|
945
|
+
children: "\u2192"
|
|
946
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
947
|
+
className: "lado",
|
|
948
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
949
|
+
className: "rol",
|
|
950
|
+
children: esteEsPadre && selected.length > 1 ? "".concat(selected.length, " productos hijo") : "Producto hijo"
|
|
951
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("strong", {
|
|
952
|
+
title: nombreHijo,
|
|
953
|
+
children: nombreHijo
|
|
954
|
+
}), !esteEsPadre && /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
955
|
+
className: "actual",
|
|
956
|
+
children: "el que tienes abierto"
|
|
957
|
+
})]
|
|
958
|
+
})]
|
|
959
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_styles.Message, {
|
|
960
|
+
children: ["Todo lo que marques abajo ", /*#__PURE__*/(0, _jsxRuntime.jsx)("strong", {
|
|
961
|
+
children: "baja del padre al hijo"
|
|
962
|
+
}), ". Nada sube en el otro sentido:", " ", esteEsPadre ? "este producto no cambia." : "\xAB".concat(nombrePadre, "\xBB no cambia.")]
|
|
963
|
+
}), mode === "children" && selected.length > 1 && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
996
964
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("label", {
|
|
997
965
|
className: "apply-all",
|
|
998
966
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("input", {
|
|
@@ -1064,23 +1032,18 @@ var LinkVariantsModal = function LinkVariantsModal(_ref) {
|
|
|
1064
1032
|
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)("span", {
|
|
1065
1033
|
children: ["Elegir cu\xE1les", /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
1066
1034
|
className: "hint",
|
|
1067
|
-
children: "
|
|
1035
|
+
children: "Solo se puede heredar de las que ya tiene el padre."
|
|
1068
1036
|
})]
|
|
1069
1037
|
})]
|
|
1070
1038
|
})]
|
|
1071
1039
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_styles.List, {
|
|
1072
|
-
children:
|
|
1040
|
+
children: offered.categoryRetailers.map(function (item) {
|
|
1073
1041
|
return (0, _objectSpread7.default)((0, _objectSpread7.default)({}, item), {}, {
|
|
1074
|
-
clave: "".concat(item.retailerId, "-").concat(item.categoryId)
|
|
1075
|
-
delPadre: true
|
|
1042
|
+
clave: "".concat(item.retailerId, "-").concat(item.categoryId)
|
|
1076
1043
|
});
|
|
1077
|
-
})
|
|
1078
|
-
return (0,
|
|
1079
|
-
|
|
1080
|
-
});
|
|
1081
|
-
}))).map(function (item) {
|
|
1082
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("li", {
|
|
1083
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("label", {
|
|
1044
|
+
}).map(function (item) {
|
|
1045
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)("li", {
|
|
1046
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("label", {
|
|
1084
1047
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("input", {
|
|
1085
1048
|
type: "checkbox",
|
|
1086
1049
|
disabled: modes.categoryRetailers === "all",
|
|
@@ -1093,64 +1056,14 @@ var LinkVariantsModal = function LinkVariantsModal(_ref) {
|
|
|
1093
1056
|
src: (0, _helper.getRetailerPicture)(item.retailerId, 24, 24),
|
|
1094
1057
|
alt: ""
|
|
1095
1058
|
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)("span", {
|
|
1096
|
-
children: [item.retailerName, /*#__PURE__*/(0, _jsxRuntime.
|
|
1059
|
+
children: [item.retailerName, /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
1097
1060
|
className: "meta",
|
|
1098
|
-
children:
|
|
1061
|
+
children: item.categoryName || "Sin categoría"
|
|
1099
1062
|
})]
|
|
1100
1063
|
})]
|
|
1101
|
-
})
|
|
1102
|
-
type: "button",
|
|
1103
|
-
className: "quitar",
|
|
1104
|
-
title: "Quitar esta cadena",
|
|
1105
|
-
"aria-label": "Quitar ".concat(item.retailerName),
|
|
1106
|
-
onClick: function onClick() {
|
|
1107
|
-
return removeExtraRetailer(item.clave);
|
|
1108
|
-
},
|
|
1109
|
-
children: "\xD7"
|
|
1110
|
-
})]
|
|
1064
|
+
})
|
|
1111
1065
|
}, item.clave);
|
|
1112
1066
|
})
|
|
1113
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_styles.AddRetailer, {
|
|
1114
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_SingleSelect.SingleSelect, {
|
|
1115
|
-
id: "link-variants-retailer",
|
|
1116
|
-
placeholder: "Agregar otra cadena\u2026",
|
|
1117
|
-
options: filters.retailers,
|
|
1118
|
-
value: newRetailer,
|
|
1119
|
-
loading: loadingFilters && !filters.retailers.length,
|
|
1120
|
-
onChange: function onChange(valor) {
|
|
1121
|
-
setNewRetailer(valor !== null && valor !== void 0 ? valor : "");
|
|
1122
|
-
setNewDepartment("");
|
|
1123
|
-
setNewCategory("");
|
|
1124
|
-
if (valor) loadFilters(valor, null);
|
|
1125
|
-
}
|
|
1126
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_SingleSelect.SingleSelect, {
|
|
1127
|
-
id: "link-variants-department",
|
|
1128
|
-
placeholder: "Departamento\u2026",
|
|
1129
|
-
options: filters.departments,
|
|
1130
|
-
value: newDepartment,
|
|
1131
|
-
disabled: !newRetailer,
|
|
1132
|
-
loading: loadingFilters && !!newRetailer,
|
|
1133
|
-
onChange: function onChange(valor) {
|
|
1134
|
-
setNewDepartment(valor !== null && valor !== void 0 ? valor : "");
|
|
1135
|
-
setNewCategory("");
|
|
1136
|
-
if (valor) loadFilters(newRetailer, valor);
|
|
1137
|
-
}
|
|
1138
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_SingleSelect.SingleSelect, {
|
|
1139
|
-
id: "link-variants-category",
|
|
1140
|
-
placeholder: "Categor\xEDa\u2026",
|
|
1141
|
-
options: filters.categories,
|
|
1142
|
-
value: newCategory,
|
|
1143
|
-
disabled: !newDepartment,
|
|
1144
|
-
loading: loadingFilters && !!newDepartment,
|
|
1145
|
-
onChange: function onChange(valor) {
|
|
1146
|
-
return setNewCategory(valor !== null && valor !== void 0 ? valor : "");
|
|
1147
|
-
}
|
|
1148
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("button", {
|
|
1149
|
-
type: "button",
|
|
1150
|
-
onClick: addRetailer,
|
|
1151
|
-
disabled: !newRetailer || !newCategory || loadingFilters,
|
|
1152
|
-
children: "Agregar"
|
|
1153
|
-
})]
|
|
1154
1067
|
})]
|
|
1155
1068
|
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_styles.Block, {
|
|
1156
1069
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("h3", {
|
|
@@ -1187,7 +1100,7 @@ var LinkVariantsModal = function LinkVariantsModal(_ref) {
|
|
|
1187
1100
|
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)("span", {
|
|
1188
1101
|
children: ["Elegir cu\xE1les", /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
1189
1102
|
className: "hint",
|
|
1190
|
-
children: "Lo que no elijas conserva el valor que ya tiene
|
|
1103
|
+
children: "Lo que no elijas conserva el valor que ya tiene el hijo."
|
|
1191
1104
|
})]
|
|
1192
1105
|
})]
|
|
1193
1106
|
})]
|
|
@@ -1254,7 +1167,7 @@ var LinkVariantsModal = function LinkVariantsModal(_ref) {
|
|
|
1254
1167
|
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)("span", {
|
|
1255
1168
|
children: ["Elegir cu\xE1les", /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
1256
1169
|
className: "hint",
|
|
1257
|
-
children: "Lo que no elijas conserva el valor que ya tiene
|
|
1170
|
+
children: "Lo que no elijas conserva el valor que ya tiene el hijo."
|
|
1258
1171
|
})]
|
|
1259
1172
|
})]
|
|
1260
1173
|
})]
|
|
@@ -1325,7 +1238,7 @@ var LinkVariantsModal = function LinkVariantsModal(_ref) {
|
|
|
1325
1238
|
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)("span", {
|
|
1326
1239
|
children: ["Elegir cu\xE1les", /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
1327
1240
|
className: "hint",
|
|
1328
|
-
children: "\xDAtil cuando
|
|
1241
|
+
children: "\xDAtil cuando el hijo cambia de color o de empaque."
|
|
1329
1242
|
})]
|
|
1330
1243
|
})]
|
|
1331
1244
|
})]
|
|
@@ -1355,7 +1268,7 @@ var LinkVariantsModal = function LinkVariantsModal(_ref) {
|
|
|
1355
1268
|
})
|
|
1356
1269
|
})]
|
|
1357
1270
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_styles.Message, {
|
|
1358
|
-
children: "Lo que elijas heredar reemplaza el valor actual
|
|
1271
|
+
children: "Lo que elijas heredar reemplaza el valor actual del hijo, incluso si alguien lo hab\xEDa capturado a mano."
|
|
1359
1272
|
})]
|
|
1360
1273
|
})]
|
|
1361
1274
|
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_styles.Footer, {
|
|
@@ -1367,7 +1280,7 @@ var LinkVariantsModal = function LinkVariantsModal(_ref) {
|
|
|
1367
1280
|
falta, no repetir que falta "1 producto". */
|
|
1368
1281
|
!applyToAll && mode === "children" && selected.length > 1 ? "Faltan ".concat(selected.filter(function (id) {
|
|
1369
1282
|
return !decididoPara(id);
|
|
1370
|
-
}).length, " producto(s) por revisar.") : "Falta decidir: ".concat(faltantes.join(", "), ".")
|
|
1283
|
+
}).length, " producto(s) por revisar.") : mode === "parent" ? "Elige si los atributos suben al padre o no." : "Falta decidir: ".concat(faltantes.join(", "), ".")
|
|
1371
1284
|
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
1372
1285
|
className: "actions",
|
|
1373
1286
|
children: [step === "inherit" && /*#__PURE__*/(0, _jsxRuntime.jsx)("button", {
|