contentoh-components-library 21.6.18 → 21.6.20

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 (28) hide show
  1. package/.env.test +2 -1
  2. package/dist/components/molecules/TagAndInput/index.js +14 -1
  3. package/dist/components/organisms/InputGroup/index.js +23 -17
  4. package/dist/components/organisms/LinkVariantsModal/api.js +102 -0
  5. package/dist/components/organisms/LinkVariantsModal/index.js +617 -0
  6. package/dist/components/organisms/LinkVariantsModal/styles.js +60 -0
  7. package/dist/components/pages/ProductEditionv2/index.js +3 -0
  8. package/dist/components/pages/ProviderProductEdition/context/reducers/inputs.js +8 -2
  9. package/dist/components/pages/ProviderProductEdition/index.js +201 -91
  10. package/dist/components/pages/ProviderProductEdition/styles.js +2 -2
  11. package/dist/components/pages/ProviderProductEdition/utils.js +8 -0
  12. package/dist/index.js +25 -12
  13. package/package.json +1 -1
  14. package/src/components/molecules/TagAndInput/index.js +15 -0
  15. package/src/components/organisms/InputGroup/index.js +6 -0
  16. package/src/components/organisms/LinkVariantsModal/api.js +61 -0
  17. package/src/components/organisms/LinkVariantsModal/index.js +474 -0
  18. package/src/components/organisms/LinkVariantsModal/styles.js +264 -0
  19. package/src/components/pages/ProductEditionv2/index.js +1 -0
  20. package/src/components/pages/ProviderProductEdition/context/reducers/inputs.js +21 -13
  21. package/src/components/pages/ProviderProductEdition/index.js +77 -0
  22. package/src/components/pages/ProviderProductEdition/styles.js +23 -0
  23. package/src/components/pages/ProviderProductEdition/utils.js +8 -0
  24. package/src/index.js +1 -0
  25. package/dist/ai/prompts/attribute.prompt.js +0 -28
  26. package/dist/ai/prompts/description.prompt.js +0 -33
  27. package/dist/ai/schemas/attribute.schema.js +0 -35
  28. package/dist/ai/schemas/description.schema.js +0 -27
@@ -15,9 +15,9 @@ var _variables = require("../../../global-files/variables");
15
15
 
16
16
  var _templateObject;
17
17
 
18
- var Container = _styledComponents.default.div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n display: flex;\n flex-direction: column;\n height: 100%;\n flex: 1;\n overflow: auto;\n\n .data-container {\n display: flex;\n flex: 0%;\n height: calc(100% - ", "px);\n .image-data-panel {\n width: 340px;\n\n & + * {\n margin-left: 10px;\n }\n }\n\n .product-information {\n width: 100%;\n height: 100%;\n display: flex;\n flex-direction: column;\n\n .services-information-container {\n height: 100%;\n overflow: auto;\n }\n\n .image-services {\n aside {\n display: grid;\n grid-template-columns: repeat(auto-fill, 179px);\n column-gap: 15px;\n row-gap: 15px;\n padding: 20px;\n }\n }\n\n .commentary-box {\n display: flex;\n justify-content: space-between;\n align-items: flex-end;\n padding: 10px;\n padding-left: 0;\n\n .commentary {\n display: flex;\n align-items: flex-end;\n\n .input-container {\n width: 500px;\n\n .quill {\n height: 100px;\n }\n\n & + * {\n margin-left: 5px;\n }\n }\n\n .buttons-box {\n display: flex;\n width: 210px;\n flex-wrap: wrap;\n\n .general-transparent-button {\n & + * {\n margin-top: 5px;\n }\n }\n\n .general-transparent-button,\n .general-green-button,\n .general-button-disabled {\n width: fit-content;\n min-width: 201px;\n height: 40px;\n }\n }\n }\n }\n\n .feedback-box {\n display: flex;\n }\n\n .required-inputs-message {\n font-family: ", ";\n font-size: 13px;\n color: ", ";\n padding: 10px;\n display: flex;\n align-items: center;\n\n p + * {\n margin-top: 10px;\n }\n\n button {\n min-width: fit-content;\n }\n }\n }\n }\n #modal-message-box {\n width: 400px;\n height: 100px;\n }\n .container {\n width: 100%;\n height: 90%;\n .dropzone {\n height: 100%;\n width: 100%;\n position: relative;\n transition: all 0.5s ease;\n\n &.drag-active {\n background-color: rgba(", ", 0.05);\n border: 2px dashed ", ";\n border-radius: 8px;\n\n aside {\n opacity: 0.3;\n pointer-events: none;\n }\n }\n\n .drag-overlay {\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n display: flex;\n align-items: center;\n justify-content: center;\n background-color: rgba(", ", 0.1);\n border-radius: 8px;\n pointer-events: none;\n z-index: 10;\n\n p {\n font-family: ", ";\n font-size: 24px;\n font-weight: 600;\n color: ", ";\n text-align: center;\n padding: 20px;\n background-color: ", ";\n border-radius: 8px;\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);\n }\n }\n }\n }\n"])), function (_ref) {
18
+ var Container = _styledComponents.default.div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n display: flex;\n flex-direction: column;\n height: 100%;\n flex: 1;\n overflow: auto;\n\n .data-container {\n display: flex;\n flex: 0%;\n height: calc(100% - ", "px);\n .image-data-panel {\n width: 340px;\n\n & + * {\n margin-left: 10px;\n }\n }\n\n .product-information {\n width: 100%;\n height: 100%;\n display: flex;\n flex-direction: column;\n\n .services-information-container {\n height: 100%;\n overflow: auto;\n }\n\n .image-services {\n aside {\n display: grid;\n grid-template-columns: repeat(auto-fill, 179px);\n column-gap: 15px;\n row-gap: 15px;\n padding: 20px;\n }\n }\n\n .commentary-box {\n display: flex;\n justify-content: space-between;\n align-items: flex-end;\n padding: 10px;\n padding-left: 0;\n\n .commentary {\n display: flex;\n align-items: flex-end;\n\n .input-container {\n width: 500px;\n\n .quill {\n height: 100px;\n }\n\n & + * {\n margin-left: 5px;\n }\n }\n\n .buttons-box {\n display: flex;\n width: 210px;\n flex-wrap: wrap;\n\n .general-transparent-button {\n & + * {\n margin-top: 5px;\n }\n }\n\n .general-transparent-button,\n .general-green-button,\n .general-button-disabled {\n width: fit-content;\n min-width: 201px;\n height: 40px;\n }\n }\n }\n }\n\n .feedback-box {\n display: flex;\n }\n\n .required-inputs-message {\n font-family: ", ";\n font-size: 13px;\n color: ", ";\n padding: 10px;\n display: flex;\n align-items: center;\n\n p + * {\n margin-top: 10px;\n }\n\n button {\n min-width: fit-content;\n }\n }\n }\n }\n #modal-message-box {\n width: 400px;\n height: 100px;\n }\n .container {\n width: 100%;\n height: 90%;\n .dropzone {\n height: 100%;\n width: 100%;\n position: relative;\n transition: all 0.5s ease;\n\n &.drag-active {\n background-color: rgba(", ", 0.05);\n border: 2px dashed ", ";\n border-radius: 8px;\n\n aside {\n opacity: 0.3;\n pointer-events: none;\n }\n }\n\n .drag-overlay {\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n display: flex;\n align-items: center;\n justify-content: center;\n background-color: rgba(", ", 0.1);\n border-radius: 8px;\n pointer-events: none;\n z-index: 10;\n\n p {\n font-family: ", ";\n font-size: 24px;\n font-weight: 600;\n color: ", ";\n text-align: center;\n padding: 20px;\n background-color: ", ";\n border-radius: 8px;\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);\n }\n }\n }\n }\n .variants-actions {\n display: flex;\n align-items: center;\n gap: 10px;\n margin-bottom: 8px;\n\n .link-variants {\n border: 1px solid ", ";\n border-radius: 6px;\n background: none;\n padding: 6px 12px;\n font-family: ", ";\n font-size: 11px;\n color: ", ";\n cursor: pointer;\n }\n\n .variants-count {\n font-family: ", ";\n font-size: 11px;\n color: ", ";\n }\n }\n"])), function (_ref) {
19
19
  var headerTop = _ref.headerTop;
20
20
  return headerTop;
21
- }, _variables.FontFamily.AvenirNext, _variables.GlobalColors.color_gray, _variables.GlobalColors.rgb_color_pink, _variables.GlobalColors.color_pink, _variables.GlobalColors.rgb_color_pink, _variables.FontFamily.AvenirNext, _variables.GlobalColors.color_pink, _variables.GlobalColors.white);
21
+ }, _variables.FontFamily.AvenirNext, _variables.GlobalColors.color_gray, _variables.GlobalColors.rgb_color_pink, _variables.GlobalColors.color_pink, _variables.GlobalColors.rgb_color_pink, _variables.FontFamily.AvenirNext, _variables.GlobalColors.color_pink, _variables.GlobalColors.white, _variables.GlobalColors.original_magenta, _variables.FontFamily.Raleway_600, _variables.GlobalColors.original_magenta, _variables.FontFamily.Raleway_500, _variables.GlobalColors.gray);
22
22
 
23
23
  exports.Container = Container;
@@ -8,6 +8,8 @@ exports.normalizeProduct = exports.getConceptByTab = void 0;
8
8
  var _statusDictionary = require("../../../global-files/statusDictionary");
9
9
 
10
10
  var normalizeProduct = function normalizeProduct(product) {
11
+ var _ref, _productData$parentAr, _ref2, _productData$parent, _ref3, _productData$variants;
12
+
11
13
  // Handle case where product might be wrapped in a product property
12
14
  var productData = product.product || product;
13
15
  var article = productData.article || {};
@@ -43,6 +45,12 @@ var normalizeProduct = function normalizeProduct(product) {
43
45
  percentages: productData.percentages || null,
44
46
  summary: productData.summary || null,
45
47
  version: productData.version || 0,
48
+ // Parentesco. read-articles-v2 ya lo devuelve; sin arrastrarlo hasta aquí la
49
+ // pantalla de edición no puede saber si el producto pertenece a una familia.
50
+ // Ojo con `?? null` en vez de `|| null`: variantsCount 0 es un dato válido.
51
+ parentArticleId: (_ref = (_productData$parentAr = productData.parentArticleId) !== null && _productData$parentAr !== void 0 ? _productData$parentAr : article.parentArticleId) !== null && _ref !== void 0 ? _ref : null,
52
+ parent: (_ref2 = (_productData$parent = productData.parent) !== null && _productData$parent !== void 0 ? _productData$parent : article.parent) !== null && _ref2 !== void 0 ? _ref2 : null,
53
+ variantsCount: (_ref3 = (_productData$variants = productData.variantsCount) !== null && _productData$variants !== void 0 ? _productData$variants : article.variantsCount) !== null && _ref3 !== void 0 ? _ref3 : 0,
46
54
  // from tasks
47
55
  id_order: productData.orderId || null,
48
56
  status: productData.statusByRetailer ? (0, _statusDictionary.getMinorStatusFromRetailerMap)(productData.statusByRetailer) : productData.status || null,
package/dist/index.js CHANGED
@@ -1083,7 +1083,7 @@ Object.keys(_index82).forEach(function (key) {
1083
1083
  });
1084
1084
  });
1085
1085
 
1086
- var _index83 = require("./components/organisms/ProductImageModal/index");
1086
+ var _index83 = require("./components/organisms/LinkVariantsModal/index");
1087
1087
 
1088
1088
  Object.keys(_index83).forEach(function (key) {
1089
1089
  if (key === "default" || key === "__esModule") return;
@@ -1096,7 +1096,7 @@ Object.keys(_index83).forEach(function (key) {
1096
1096
  });
1097
1097
  });
1098
1098
 
1099
- var _index84 = require("./components/organisms/Chat/index");
1099
+ var _index84 = require("./components/organisms/ProductImageModal/index");
1100
1100
 
1101
1101
  Object.keys(_index84).forEach(function (key) {
1102
1102
  if (key === "default" || key === "__esModule") return;
@@ -1109,7 +1109,7 @@ Object.keys(_index84).forEach(function (key) {
1109
1109
  });
1110
1110
  });
1111
1111
 
1112
- var _index85 = require("./components/organisms/Modal/index");
1112
+ var _index85 = require("./components/organisms/Chat/index");
1113
1113
 
1114
1114
  Object.keys(_index85).forEach(function (key) {
1115
1115
  if (key === "default" || key === "__esModule") return;
@@ -1122,7 +1122,7 @@ Object.keys(_index85).forEach(function (key) {
1122
1122
  });
1123
1123
  });
1124
1124
 
1125
- var _index86 = require("./components/organisms/OrderDetail/index");
1125
+ var _index86 = require("./components/organisms/Modal/index");
1126
1126
 
1127
1127
  Object.keys(_index86).forEach(function (key) {
1128
1128
  if (key === "default" || key === "__esModule") return;
@@ -1135,6 +1135,19 @@ Object.keys(_index86).forEach(function (key) {
1135
1135
  });
1136
1136
  });
1137
1137
 
1138
+ var _index87 = require("./components/organisms/OrderDetail/index");
1139
+
1140
+ Object.keys(_index87).forEach(function (key) {
1141
+ if (key === "default" || key === "__esModule") return;
1142
+ if (key in exports && exports[key] === _index87[key]) return;
1143
+ Object.defineProperty(exports, key, {
1144
+ enumerable: true,
1145
+ get: function get() {
1146
+ return _index87[key];
1147
+ }
1148
+ });
1149
+ });
1150
+
1138
1151
  var _RangeCalendar = require("./components/organisms/RangeCalendar");
1139
1152
 
1140
1153
  Object.keys(_RangeCalendar).forEach(function (key) {
@@ -1161,28 +1174,28 @@ Object.keys(_TableResizable).forEach(function (key) {
1161
1174
  });
1162
1175
  });
1163
1176
 
1164
- var _index87 = require("./components/organisms/SideModal/index");
1177
+ var _index88 = require("./components/organisms/SideModal/index");
1165
1178
 
1166
- Object.keys(_index87).forEach(function (key) {
1179
+ Object.keys(_index88).forEach(function (key) {
1167
1180
  if (key === "default" || key === "__esModule") return;
1168
- if (key in exports && exports[key] === _index87[key]) return;
1181
+ if (key in exports && exports[key] === _index88[key]) return;
1169
1182
  Object.defineProperty(exports, key, {
1170
1183
  enumerable: true,
1171
1184
  get: function get() {
1172
- return _index87[key];
1185
+ return _index88[key];
1173
1186
  }
1174
1187
  });
1175
1188
  });
1176
1189
 
1177
- var _index88 = require("./components/organisms/GridProducts/index");
1190
+ var _index89 = require("./components/organisms/GridProducts/index");
1178
1191
 
1179
- Object.keys(_index88).forEach(function (key) {
1192
+ Object.keys(_index89).forEach(function (key) {
1180
1193
  if (key === "default" || key === "__esModule") return;
1181
- if (key in exports && exports[key] === _index88[key]) return;
1194
+ if (key in exports && exports[key] === _index89[key]) return;
1182
1195
  Object.defineProperty(exports, key, {
1183
1196
  enumerable: true,
1184
1197
  get: function get() {
1185
- return _index88[key];
1198
+ return _index89[key];
1186
1199
  }
1187
1200
  });
1188
1201
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "contentoh-components-library",
3
- "version": "21.6.18",
3
+ "version": "21.6.20",
4
4
  "dependencies": {
5
5
  "@aws-amplify/auth": "^4.5.3",
6
6
  "@aws-amplify/datastore": "^3.11.0",
@@ -1,5 +1,6 @@
1
1
  import { Container } from "./styles";
2
2
  import { ScreenHeader } from "../../atoms/ScreenHeader/index";
3
+ import { InheritanceTag } from "../../atoms/InheritanceTag";
3
4
  import { GeneralInput } from "../../atoms/GeneralInput/index";
4
5
  import { useState, useEffect } from "react";
5
6
  import acceptIcon from "../../../assets/images/generalButton/acceptIcon.svg";
@@ -44,6 +45,10 @@ export const TagAndInput = ({
44
45
  dataInputs,
45
46
  inputGroup,
46
47
  boxOnboardingData,
48
+ isVariant,
49
+ isOverridden,
50
+ parentUpc,
51
+ onRestoreInheritance,
47
52
  }) => {
48
53
  const [boxOnboardingList, setBoxOnboardingList] = useState(
49
54
  boxOnboardingData || []
@@ -323,6 +328,16 @@ export const TagAndInput = ({
323
328
  headerType={"input-name-header"}
324
329
  color={color}
325
330
  />
331
+ <InheritanceTag
332
+ isVariant={isVariant}
333
+ isOverridden={isOverridden}
334
+ parentUpc={parentUpc}
335
+ onRestore={
336
+ onRestoreInheritance
337
+ ? () => onRestoreInheritance(inputId)
338
+ : undefined
339
+ }
340
+ />
326
341
  {description && (
327
342
  <Tooltip
328
343
  componentTooltip={
@@ -27,6 +27,8 @@ export const InputGroup = ({
27
27
  setUpdatedBoxData,
28
28
  activeRetailer,
29
29
  updateApprovedInputs,
30
+ variant,
31
+ onRestoreInheritance,
30
32
  }) => {
31
33
  const InputReviewSection = ({
32
34
  inputId,
@@ -230,6 +232,10 @@ export const InputGroup = ({
230
232
  optionList={dataInputs[input]?.option_list}
231
233
  description={dataInputs[input]?.description}
232
234
  showTooltip={true}
235
+ isVariant={variant?.isVariant}
236
+ isOverridden={dataInputs[input]?.isOverridden}
237
+ parentUpc={variant?.parent?.upc}
238
+ onRestoreInheritance={onRestoreInheritance}
233
239
  auditClass={
234
240
  compare &&
235
241
  !isEquals(
@@ -0,0 +1,61 @@
1
+ /*
2
+ Las lambdas de este API están declaradas con `integration: lambda`, no con
3
+ lambda-proxy. Eso tiene dos consecuencias que se pagan caras si se ignoran:
4
+
5
+ 1. La respuesta llega ENVUELTA: axios entrega { statusCode, headers, body },
6
+ con `body` en texto. Leer `res.data.candidates` da undefined.
7
+ 2. El HTTP siempre es 200, incluso cuando la lambda respondió 400 o 500. Un
8
+ try/catch alrededor de axios NUNCA se dispara por un error de negocio: el
9
+ error viaja dentro del cuerpo y hay que mirar `statusCode` a mano.
10
+
11
+ El repo ya vive con esto —provider-product-edition.context.jsx hace
12
+ JSON.parse(res.data.body)— pero sin un lugar común cada llamada nueva vuelve a
13
+ tropezar. Esto lo centraliza.
14
+ */
15
+
16
+ export const unwrap = (res) => {
17
+ const payload = res?.data;
18
+
19
+ const envuelto = payload
20
+ && typeof payload === "object"
21
+ && "statusCode" in payload
22
+ && "body" in payload;
23
+
24
+ if (!envuelto) return { status: res?.status ?? 200, body: payload };
25
+
26
+ const body =
27
+ typeof payload.body === "string" ? safeParse(payload.body) : payload.body;
28
+
29
+ return { status: Number(payload.statusCode), body };
30
+ };
31
+
32
+ const safeParse = (text) => {
33
+ try {
34
+ return JSON.parse(text);
35
+ } catch (error) {
36
+ return { message: text };
37
+ }
38
+ };
39
+
40
+ /*
41
+ Error de negocio con el código estable que manda el backend
42
+ (VARIANT_CROSS_COMPANY, VARIANT_ALREADY_LINKED, ...). Se lanza para que el
43
+ llamador use un try/catch normal, aunque el transporte haya dicho 200.
44
+ */
45
+ export class ApiError extends Error {
46
+ constructor(code, message) {
47
+ super(message);
48
+ this.name = "ApiError";
49
+ this.code = code;
50
+ }
51
+ }
52
+
53
+ export const readPayload = (res) => {
54
+ const { status, body } = unwrap(res);
55
+
56
+ if (status >= 400) {
57
+ throw new ApiError(body?.code, body?.message || "La operación falló.");
58
+ }
59
+
60
+ return body ?? {};
61
+ };