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.
Files changed (29) hide show
  1. package/dist/ai/prompts/attribute.prompt.js +28 -0
  2. package/dist/ai/prompts/description.prompt.js +33 -0
  3. package/dist/ai/schemas/attribute.schema.js +35 -0
  4. package/dist/ai/schemas/description.schema.js +27 -0
  5. package/dist/components/atoms/InheritanceTag/InheritanceTag.stories.js +5 -5
  6. package/dist/components/atoms/InheritanceTag/index.js +6 -6
  7. package/dist/components/organisms/InputGroup/index.js +12 -1
  8. package/dist/components/organisms/LinkVariantsModal/index.js +269 -356
  9. package/dist/components/organisms/LinkVariantsModal/styles.js +14 -5
  10. package/dist/components/organisms/PropagateChangesModal/index.js +12 -13
  11. package/dist/components/pages/ProviderProductEdition/context/provider-product-edition.context.js +5 -5
  12. package/dist/components/pages/ProviderProductEdition/context/reducers/inputs.js +5 -2
  13. package/dist/components/pages/ProviderProductEdition/index.js +76 -33
  14. package/dist/components/pages/RetailerProductEdition/context/provider-product-edition.context.js +5 -5
  15. package/dist/components/pages/RetailerProductEdition/context/reducers/inputs.js +5 -2
  16. package/dist/components/pages/RetailerProductEdition/index.js +75 -35
  17. package/package.json +1 -1
  18. package/src/components/atoms/InheritanceTag/InheritanceTag.stories.js +3 -3
  19. package/src/components/atoms/InheritanceTag/index.js +6 -6
  20. package/src/components/organisms/InputGroup/index.js +12 -0
  21. package/src/components/organisms/LinkVariantsModal/index.js +260 -287
  22. package/src/components/organisms/LinkVariantsModal/styles.js +65 -32
  23. package/src/components/organisms/PropagateChangesModal/index.js +19 -17
  24. package/src/components/pages/ProviderProductEdition/context/provider-product-edition.context.jsx +4 -4
  25. package/src/components/pages/ProviderProductEdition/context/reducers/inputs.js +13 -1
  26. package/src/components/pages/ProviderProductEdition/index.js +48 -20
  27. package/src/components/pages/RetailerProductEdition/context/provider-product-edition.context.jsx +4 -4
  28. package/src/components/pages/RetailerProductEdition/context/reducers/inputs.js +13 -1
  29. package/src/components/pages/RetailerProductEdition/index.js +48 -20
@@ -234,7 +234,7 @@ function _regenerateVideoThumbnails() {
234
234
  }
235
235
 
236
236
  var RetailerProductEditionView = function RetailerProductEditionView(_ref) {
237
- var _state$product10, _family$variants, _state$product11, _state$errors, _family$variants2, _state$product14, _state$product15, _state$product16, _state$active_retaile5, _location$state, _location$state2, _state$active_retaile6, _state$active_retaile7, _state$images_values$2, _state$images_values10, _state$images_values11, _state$product17, _state$active_retaile8, _family$variants3, _family$variants4, _state$active_percent, _state$active_percent2, _state$active_percent3, _state$active_retaile9, _state$active_retaile10, _state$active_retaile11, _state$product18, _state$product19, _state$product20, _state$datasheets_inp, _state$datasheets_inp2, _state$product21, _state$images_values12, _state$comment;
237
+ var _state$product10, _family$variants, _state$product11, _state$errors, _family$variants2, _state$product14, _state$product15, _state$product16, _state$active_retaile5, _location$state, _location$state2, _state$active_retaile6, _state$active_retaile7, _state$images_values$2, _state$images_values10, _state$images_values11, _state$product17, _state$active_retaile8, _family$variants3, _family$variants4, _state$active_percent, _state$active_percent2, _state$active_percent3, _state$active_retaile9, _state$active_retaile10, _state$active_retaile11, _state$product18, _state$services2, _state$services2$data, _state$product19, _state$product20, _state$datasheets_inp, _state$datasheets_inp2, _state$product21, _state$images_values12, _state$comment;
238
238
 
239
239
  var tabsSections = _ref.tabsSections,
240
240
  _ref$productSelected = _ref.productSelected,
@@ -310,7 +310,7 @@ var RetailerProductEditionView = function RetailerProductEditionView(_ref) {
310
310
  var _useState19 = (0, _react.useState)(false),
311
311
  _useState20 = (0, _slicedToArray2.default)(_useState19, 2),
312
312
  rejectAll = _useState20[0],
313
- setRejectAll = _useState20[1]; // Variantes: mismo comportamiento que la ficha de la aplicación de clientes.
313
+ setRejectAll = _useState20[1]; // Padre/hijo: mismo comportamiento que la ficha de la aplicación de clientes.
314
314
 
315
315
 
316
316
  var _useState21 = (0, _react.useState)(false),
@@ -1128,7 +1128,7 @@ var RetailerProductEditionView = function RetailerProductEditionView(_ref) {
1128
1128
  }
1129
1129
  };
1130
1130
  /*
1131
- Trae la familia: las variantes del producto, o sus hermanas si el abierto es
1131
+ Trae la familia: los hijos del producto, o sus hermanos si el abierto es
1132
1132
  una de ellas. Se pide al abrir la sección y no al montar la pantalla: la
1133
1133
  mayoría de los productos no son familia.
1134
1134
  */
@@ -1215,19 +1215,19 @@ var RetailerProductEditionView = function RetailerProductEditionView(_ref) {
1215
1215
  loadFamily(true); // eslint-disable-next-line react-hooks/exhaustive-deps
1216
1216
  }, [(_state$product10 = state.product) === null || _state$product10 === void 0 ? void 0 : _state$product10.id_article]); // El conteo sale de la familia recién consultada, no del producto.
1217
1217
 
1218
- var variantesDelProducto = family !== null && family !== void 0 && family.error ? 0 : ((_family$variants = family === null || family === void 0 ? void 0 : family.variants) !== null && _family$variants !== void 0 ? _family$variants : []).filter(function (v) {
1218
+ var hijosDelProducto = family !== null && family !== void 0 && family.error ? 0 : ((_family$variants = family === null || family === void 0 ? void 0 : family.variants) !== null && _family$variants !== void 0 ? _family$variants : []).filter(function (v) {
1219
1219
  return !v.isCurrent;
1220
1220
  }).length;
1221
- var esVarianteDeOtro = family !== null && family !== void 0 && family.error ? !!((_state$product11 = state.product) !== null && _state$product11 !== void 0 && _state$product11.parentArticleId) : !!(family !== null && family !== void 0 && family.parent);
1221
+ var esHijoDeOtro = family !== null && family !== void 0 && family.error ? !!((_state$product11 = state.product) !== null && _state$product11 !== void 0 && _state$product11.parentArticleId) : !!(family !== null && family !== void 0 && family.parent);
1222
1222
  /*
1223
- En Creators la lista de familia es INFORMATIVA: no se salta a otra variante.
1223
+ En Creators la lista de familia es INFORMATIVA: no se salta a otro producto.
1224
1224
  Saltar exige precargar el producto destino, y el endpoint que hace eso en la
1225
1225
  aplicación de clientes —read-articles-v2— filtra por la compañía del usuario:
1226
1226
  `AND a.company_id = <la del usuario>`. El equipo interno pertenece a ContentOh
1227
1227
  y trabaja productos de sus clientes, así que ahí no devuelve nada.
1228
1228
  Navegar sin precargar sería peor que no ofrecerlo: esta pantalla lee el
1229
1229
  producto de sessionStorage, así que cambiaría la URL y seguiría mostrando el
1230
- producto anterior, dando a entender que se cambió de variante cuando no.
1230
+ producto anterior, dando a entender que se cambió de producto cuando no.
1231
1231
  Para habilitarlo hace falta una forma de traer un producto por id sin filtro
1232
1232
  de compañía, respetando el alcance del perfil interno (§5.1 del contrato).
1233
1233
  */
@@ -1264,38 +1264,73 @@ var RetailerProductEditionView = function RetailerProductEditionView(_ref) {
1264
1264
  el endpoint: recargar la ficha se llevaría lo que haya sin guardar.
1265
1265
  */
1266
1266
 
1267
+ /*
1268
+ `kind` distingue de qué pestaña salió el chip. Las descripciones viven en
1269
+ `rel_article_description` y la ficha técnica en `article_data`: el endpoint
1270
+ recibe una lista o la otra.
1271
+ */
1272
+
1267
1273
 
1268
1274
  var handleOnRestoreInheritance = /*#__PURE__*/function () {
1269
1275
  var _ref9 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6(attributeId) {
1270
1276
  var _state$product13;
1271
1277
 
1272
- var res, data;
1278
+ var kind,
1279
+ esDescripcion,
1280
+ res,
1281
+ data,
1282
+ _args6 = arguments;
1273
1283
  return _regenerator.default.wrap(function _callee6$(_context6) {
1274
1284
  while (1) {
1275
1285
  switch (_context6.prev = _context6.next) {
1276
1286
  case 0:
1287
+ kind = _args6.length > 1 && _args6[1] !== undefined ? _args6[1] : "attribute";
1288
+
1277
1289
  if (!(!attributeId || !((_state$product13 = state.product) !== null && _state$product13 !== void 0 && _state$product13.id_article))) {
1278
- _context6.next = 2;
1290
+ _context6.next = 3;
1279
1291
  break;
1280
1292
  }
1281
1293
 
1282
1294
  return _context6.abrupt("return");
1283
1295
 
1284
- case 2:
1285
- _context6.prev = 2;
1286
- _context6.next = 5;
1287
- return _axios.default.post("".concat(process.env.REACT_APP_VARIANTS_ENDPOINT, "/restore"), {
1288
- articleId: state.product.id_article,
1296
+ case 3:
1297
+ esDescripcion = kind === "description";
1298
+ _context6.prev = 4;
1299
+ _context6.next = 7;
1300
+ return _axios.default.post("".concat(process.env.REACT_APP_VARIANTS_ENDPOINT, "/restore"), (0, _objectSpread5.default)({
1301
+ articleId: state.product.id_article
1302
+ }, esDescripcion ? {
1303
+ descriptions: [Number(attributeId)]
1304
+ } : {
1289
1305
  attributes: [Number(attributeId)]
1290
- }, {
1306
+ }), {
1291
1307
  headers: {
1292
1308
  Authorization: token
1293
1309
  }
1294
1310
  });
1295
1311
 
1296
- case 5:
1312
+ case 7:
1297
1313
  res = _context6.sent;
1298
1314
  data = (0, _api.readPayload)(res);
1315
+
1316
+ if (!esDescripcion) {
1317
+ _context6.next = 12;
1318
+ break;
1319
+ }
1320
+
1321
+ dispatch({
1322
+ type: "UPDATE_DESCRIPTIONS_INPUTS",
1323
+ payload: (data.descriptionValues || []).map(function (item) {
1324
+ return {
1325
+ attributeId: item.id_description,
1326
+ value: item.value,
1327
+ isOverridden: 0
1328
+ };
1329
+ })
1330
+ });
1331
+ return _context6.abrupt("return");
1332
+
1333
+ case 12:
1299
1334
  dispatch({
1300
1335
  type: "UPDATE_DATASHEETS_INPUTS",
1301
1336
  payload: (data.values || []).map(function (item) {
@@ -1306,20 +1341,20 @@ var RetailerProductEditionView = function RetailerProductEditionView(_ref) {
1306
1341
  };
1307
1342
  })
1308
1343
  });
1309
- _context6.next = 13;
1344
+ _context6.next = 18;
1310
1345
  break;
1311
1346
 
1312
- case 10:
1313
- _context6.prev = 10;
1314
- _context6.t0 = _context6["catch"](2);
1347
+ case 15:
1348
+ _context6.prev = 15;
1349
+ _context6.t0 = _context6["catch"](4);
1315
1350
  console.error("restoreInheritance: ", _context6.t0);
1316
1351
 
1317
- case 13:
1352
+ case 18:
1318
1353
  case "end":
1319
1354
  return _context6.stop();
1320
1355
  }
1321
1356
  }
1322
- }, _callee6, null, [[2, 10]]);
1357
+ }, _callee6, null, [[4, 15]]);
1323
1358
  }));
1324
1359
 
1325
1360
  return function handleOnRestoreInheritance(_x3) {
@@ -1376,10 +1411,10 @@ var RetailerProductEditionView = function RetailerProductEditionView(_ref) {
1376
1411
  return _context7.abrupt("break", 21);
1377
1412
 
1378
1413
  case 8:
1379
- // Guardar un padre con variantes abre la decisión de propagar. Sin este
1380
- // paso el cambio se queda solo en el padre y las variantes se van
1414
+ // Guardar un padre con hijos abre la decisión de propagar. Sin este
1415
+ // paso el cambio se queda solo en el padre y los hijos se van
1381
1416
  // separando de él sin que nadie lo note.
1382
- esPadre = variantesDelProducto > 0;
1417
+ esPadre = hijosDelProducto > 0;
1383
1418
  cambios = cambiosDeFichaTecnica();
1384
1419
 
1385
1420
  if (!(esPadre && cambios.length > 0)) {
@@ -2537,7 +2572,7 @@ var RetailerProductEditionView = function RetailerProductEditionView(_ref) {
2537
2572
  })]
2538
2573
  }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
2539
2574
  className: "product-information",
2540
- children: [!esVarianteDeOtro && /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
2575
+ children: [!esHijoDeOtro && /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
2541
2576
  className: "variants-actions",
2542
2577
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("button", {
2543
2578
  type: "button",
@@ -2546,7 +2581,7 @@ var RetailerProductEditionView = function RetailerProductEditionView(_ref) {
2546
2581
  return setShowLinkVariants(true);
2547
2582
  },
2548
2583
  children: "Ligar productos"
2549
- }), variantesDelProducto > 0 && /*#__PURE__*/(0, _jsxRuntime.jsxs)("button", {
2584
+ }), hijosDelProducto > 0 && /*#__PURE__*/(0, _jsxRuntime.jsxs)("button", {
2550
2585
  type: "button",
2551
2586
  className: "variants-count",
2552
2587
  "aria-expanded": showFamily,
@@ -2556,12 +2591,12 @@ var RetailerProductEditionView = function RetailerProductEditionView(_ref) {
2556
2591
  });
2557
2592
  loadFamily();
2558
2593
  },
2559
- children: [variantesDelProducto, " variante", variantesDelProducto === 1 ? "" : "s", /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
2594
+ children: [hijosDelProducto, " hijo", hijosDelProducto === 1 ? "" : "s", /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
2560
2595
  "aria-hidden": "true",
2561
2596
  children: showFamily ? " ▴" : " ▾"
2562
2597
  })]
2563
2598
  })]
2564
- }), esVarianteDeOtro && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
2599
+ }), esHijoDeOtro && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
2565
2600
  className: "variants-actions",
2566
2601
  children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("button", {
2567
2602
  type: "button",
@@ -2573,7 +2608,7 @@ var RetailerProductEditionView = function RetailerProductEditionView(_ref) {
2573
2608
  });
2574
2609
  loadFamily();
2575
2610
  },
2576
- children: ["Variante de otro producto", /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
2611
+ children: ["Hijo de otro producto", /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
2577
2612
  "aria-hidden": "true",
2578
2613
  children: showFamily ? " ▴" : " ▾"
2579
2614
  })]
@@ -2603,7 +2638,7 @@ var RetailerProductEditionView = function RetailerProductEditionView(_ref) {
2603
2638
  className: "family-row".concat(variant.isCurrent ? " current" : ""),
2604
2639
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
2605
2640
  className: "role",
2606
- children: variant.isCurrent ? "Estás aquí" : "Variante"
2641
+ children: variant.isCurrent ? "Estás aquí" : "Hijo"
2607
2642
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
2608
2643
  className: "name",
2609
2644
  children: variant.name
@@ -2614,7 +2649,7 @@ var RetailerProductEditionView = function RetailerProductEditionView(_ref) {
2614
2649
  }, variant.articleId);
2615
2650
  }), family && !family.error && !((_family$variants4 = family.variants) !== null && _family$variants4 !== void 0 && _family$variants4.length) && /*#__PURE__*/(0, _jsxRuntime.jsx)("p", {
2616
2651
  className: "loading",
2617
- children: "Este producto no tiene variantes."
2652
+ children: "Este producto no tiene hijos."
2618
2653
  })]
2619
2654
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_FullProductNameHeader.FullProductNameHeader // states
2620
2655
  , {
@@ -2677,7 +2712,12 @@ var RetailerProductEditionView = function RetailerProductEditionView(_ref) {
2677
2712
  children: [state.active_tab === "Descripción" && (((_state$product18 = state.product) === null || _state$product18 === void 0 ? void 0 : _state$product18.description_status) !== "NS" ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_InputGroup.InputGroup, {
2678
2713
  activeSection: state.active_tab,
2679
2714
  inputGroup: state.descriptions_inputs[0],
2680
- updatedDescriptions: state.updated_descriptions_inputs,
2715
+ updatedDescriptions: state.updated_descriptions_inputs
2716
+ /* El parentesco es del producto, no del servicio: los
2717
+ dos endpoints lo devuelven igual. */
2718
+ ,
2719
+ variant: (_state$services2 = state.services) === null || _state$services2 === void 0 ? void 0 : (_state$services2$data = _state$services2.datasheets) === null || _state$services2$data === void 0 ? void 0 : _state$services2$data.variant,
2720
+ onRestoreInheritance: handleOnRestoreInheritance,
2681
2721
  articleId: (_state$product19 = state.product) === null || _state$product19 === void 0 ? void 0 : _state$product19.id_article,
2682
2722
  version: state.product.version,
2683
2723
  auditInputGroup: auditDescriptions[0],
@@ -2689,7 +2729,7 @@ var RetailerProductEditionView = function RetailerProductEditionView(_ref) {
2689
2729
  headerType: "input-name-header"
2690
2730
  })), state.active_tab === "Ficha técnica" && (((_state$product20 = state.product) === null || _state$product20 === void 0 ? void 0 : _state$product20.datasheet_status) !== "NS" ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
2691
2731
  children: (_state$datasheets_inp = state.datasheets_inputs[0]) === null || _state$datasheets_inp === void 0 ? void 0 : (_state$datasheets_inp2 = _state$datasheets_inp.data) === null || _state$datasheets_inp2 === void 0 ? void 0 : _state$datasheets_inp2.map(function (dataGroup, index) {
2692
- var _state$services2, _state$services2$data;
2732
+ var _state$services3, _state$services3$data;
2693
2733
 
2694
2734
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_InputGroup.InputGroup, {
2695
2735
  articleId: state.product.id_article,
@@ -2697,7 +2737,7 @@ var RetailerProductEditionView = function RetailerProductEditionView(_ref) {
2697
2737
  activeSection: state.active_tab,
2698
2738
  inputGroup: dataGroup,
2699
2739
  dataInputs: state.datasheets_inputs[1],
2700
- variant: (_state$services2 = state.services) === null || _state$services2 === void 0 ? void 0 : (_state$services2$data = _state$services2.datasheets) === null || _state$services2$data === void 0 ? void 0 : _state$services2$data.variant,
2740
+ variant: (_state$services3 = state.services) === null || _state$services3 === void 0 ? void 0 : (_state$services3$data = _state$services3.datasheets) === null || _state$services3$data === void 0 ? void 0 : _state$services3$data.variant,
2701
2741
  onRestoreInheritance: handleOnRestoreInheritance,
2702
2742
  auditInputs: auditDatasheets[1],
2703
2743
  updatedDatasheets: state.updated_datasheets_inputs,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "contentoh-components-library",
3
- "version": "21.6.32",
3
+ "version": "21.6.33",
4
4
  "dependencies": {
5
5
  "@aws-amplify/auth": "^4.5.3",
6
6
  "@aws-amplify/datastore": "^3.11.0",
@@ -31,9 +31,9 @@ PropioSinAccion.args = {
31
31
  isOverridden: true,
32
32
  };
33
33
 
34
- // En un producto que no es variante no se pinta nada.
35
- export const NoEsVariante = Template.bind({});
36
- NoEsVariante.args = {
34
+ // En un producto que no es hijo de nadie no se pinta nada.
35
+ export const NoEsHijo = Template.bind({});
36
+ NoEsHijo.args = {
37
37
  isVariant: false,
38
38
  isOverridden: true,
39
39
  };
@@ -1,9 +1,9 @@
1
1
  import { Container } from "./styles";
2
2
 
3
3
  /**
4
- * Marca si el valor de un atributo viene del producto padre o es propio de la
5
- * variante. Solo tiene sentido dentro de una variante: en un producto sin padre
6
- * no se pinta nada, porque no hay de quién heredar.
4
+ * Marca si el valor de un atributo viene del producto padre o es propio del
5
+ * hijo. Solo tiene sentido dentro de un producto hijo: en uno sin padre no se
6
+ * pinta nada, porque no hay de quién heredar.
7
7
  *
8
8
  * El estado "propio" es el que carga información —ese campo se separó del padre—
9
9
  * así que es el que lleva acento y el que ofrece la acción de volver a heredar.
@@ -11,8 +11,8 @@ import { Container } from "./styles";
11
11
  * la ficha entera se volvería ruido.
12
12
  *
13
13
  * Un campo VACÍO no lleva marca: no heredó nada y tampoco tiene valor propio, así
14
- * que llamarlo "Heredado" es falso además de ruidoso. Sin esto la ficha de una
15
- * variante sale con el chip repetido en cada campo, incluidos los obligatorios en
14
+ * que llamarlo "Heredado" es falso además de ruidoso. Sin esto la ficha de un
15
+ * hijo sale con el chip repetido en cada campo, incluidos los obligatorios en
16
16
  * rojo que están sin capturar, y la marca deja de distinguir nada.
17
17
  *
18
18
  * Tampoco la lleva un atributo NO heredable. El UPC y el SKU son la identidad del
@@ -41,7 +41,7 @@ export const InheritanceTag = ({
41
41
  className="tag-label"
42
42
  title={
43
43
  isOverridden
44
- ? "Valor propio de esta variante. La propagación del producto padre no lo modifica."
44
+ ? "Valor propio de este producto hijo. La propagación del padre no lo modifica."
45
45
  : `Valor heredado${parentUpc ? ` del producto ${parentUpc}` : " del producto padre"}.`
46
46
  }
47
47
  >
@@ -296,6 +296,18 @@ export const InputGroup = ({
296
296
  dinamicHeight={dinamicHeight}
297
297
  description={input?.description}
298
298
  showTooltip={true}
299
+ isVariant={variant?.isVariant}
300
+ isOverridden={input?.isOverridden}
301
+ inheritable={input?.inheritable}
302
+ parentUpc={variant?.parent?.upc}
303
+ /* Las descripciones viven en otra tabla que la ficha
304
+ técnica, así que restore necesita saber cuál de las dos
305
+ listas está recibiendo. */
306
+ onRestoreInheritance={
307
+ onRestoreInheritance
308
+ ? (id) => onRestoreInheritance(id, "description")
309
+ : undefined
310
+ }
299
311
  auditClass={
300
312
  compare &&
301
313
  !isEquals(