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
package/.env.test CHANGED
@@ -72,4 +72,5 @@ SKIP_PREFLIGHT_CHECK=true
72
72
 
73
73
  REACT_APP_ID_AWS=7o2hp8msfl
74
74
  REACT_APP_ENVIRONMENT=test
75
- REACT_APP_REGION=us-east-1
75
+ REACT_APP_REGION=us-east-1
76
+ REACT_APP_VARIANTS_ENDPOINT=https://7o2hp8msfl.execute-api.us-east-1.amazonaws.com/test/variants
@@ -23,6 +23,8 @@ var _styles = require("./styles");
23
23
 
24
24
  var _index = require("../../atoms/ScreenHeader/index");
25
25
 
26
+ var _InheritanceTag = require("../../atoms/InheritanceTag");
27
+
26
28
  var _index2 = require("../../atoms/GeneralInput/index");
27
29
 
28
30
  var _react = require("react");
@@ -74,7 +76,11 @@ var TagAndInput = function TagAndInput(_ref) {
74
76
  onChange = _ref.onChange,
75
77
  dataInputs = _ref.dataInputs,
76
78
  inputGroup = _ref.inputGroup,
77
- boxOnboardingData = _ref.boxOnboardingData;
79
+ boxOnboardingData = _ref.boxOnboardingData,
80
+ isVariant = _ref.isVariant,
81
+ isOverridden = _ref.isOverridden,
82
+ parentUpc = _ref.parentUpc,
83
+ onRestoreInheritance = _ref.onRestoreInheritance;
78
84
 
79
85
  var _useState = (0, _react.useState)(boxOnboardingData || []),
80
86
  _useState2 = (0, _slicedToArray2.default)(_useState, 2),
@@ -421,6 +427,13 @@ var TagAndInput = function TagAndInput(_ref) {
421
427
  text: label,
422
428
  headerType: "input-name-header",
423
429
  color: color
430
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_InheritanceTag.InheritanceTag, {
431
+ isVariant: isVariant,
432
+ isOverridden: isOverridden,
433
+ parentUpc: parentUpc,
434
+ onRestore: onRestoreInheritance ? function () {
435
+ return onRestoreInheritance(inputId);
436
+ } : undefined
424
437
  }), description && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Tooltip.Tooltip, {
425
438
  componentTooltip: /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
426
439
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)("p", {
@@ -58,7 +58,9 @@ var InputGroup = function InputGroup(_ref) {
58
58
  groupData = _ref$groupData === void 0 ? [] : _ref$groupData,
59
59
  setUpdatedBoxData = _ref.setUpdatedBoxData,
60
60
  activeRetailer = _ref.activeRetailer,
61
- updateApprovedInputs = _ref.updateApprovedInputs;
61
+ updateApprovedInputs = _ref.updateApprovedInputs,
62
+ variant = _ref.variant,
63
+ onRestoreInheritance = _ref.onRestoreInheritance;
62
64
 
63
65
  var InputReviewSection = function InputReviewSection(_ref2) {
64
66
  var inputId = _ref2.inputId,
@@ -183,7 +185,7 @@ var InputGroup = function InputGroup(_ref) {
183
185
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
184
186
  className: "inputs-container",
185
187
  children: inputGroup === null || inputGroup === void 0 ? void 0 : (_inputGroup$inputs = inputGroup.inputs) === null || _inputGroup$inputs === void 0 ? void 0 : _inputGroup$inputs.map(function (input, index) {
186
- var _dataInputs$input, _dataInputs$input2, _dataInputs$input3, _dataInputs$input4, _dataInputs$input5, _dataInputs$input6, _dataInputs$input7, _dataInputs$input8, _dataInputs$input9, _dataInputs$input10, _dataInputs$input11, _dataInputs$input12, _dataInputs$input13, _dataInputs$input14, _dataInputs$input15, _dataInputs$input16, _auditInputs$input, _dataInputs$input17, _dataInputs$input18, _dataInputs$input19, _dataInputs$input20, _dataInputs$input21, _dataInputs$input22, _dataInputs$input23, _auditInputGroup$inpu, _auditInputGroup$inpu2;
188
+ var _dataInputs$input, _dataInputs$input2, _dataInputs$input3, _dataInputs$input4, _dataInputs$input5, _dataInputs$input6, _dataInputs$input7, _dataInputs$input8, _dataInputs$input9, _dataInputs$input10, _dataInputs$input11, _dataInputs$input12, _dataInputs$input13, _dataInputs$input14, _dataInputs$input15, _dataInputs$input16, _auditInputs$input, _dataInputs$input17, _dataInputs$input18, _dataInputs$input19, _dataInputs$input20, _dataInputs$input21, _dataInputs$input22, _dataInputs$input23, _dataInputs$input24, _variant$parent, _auditInputGroup$inpu, _auditInputGroup$inpu2;
187
189
 
188
190
  return activeSection === "Ficha técnica" ? /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
189
191
  className: ((_dataInputs$input = dataInputs[input]) === null || _dataInputs$input === void 0 ? void 0 : _dataInputs$input.id) === 6700 || ((_dataInputs$input2 = dataInputs[input]) === null || _dataInputs$input2 === void 0 ? void 0 : _dataInputs$input2.id) === 6701 ? "inputs-validation-onboarding" : "inputs-validation",
@@ -213,6 +215,10 @@ var InputGroup = function InputGroup(_ref) {
213
215
  optionList: (_dataInputs$input22 = dataInputs[input]) === null || _dataInputs$input22 === void 0 ? void 0 : _dataInputs$input22.option_list,
214
216
  description: (_dataInputs$input23 = dataInputs[input]) === null || _dataInputs$input23 === void 0 ? void 0 : _dataInputs$input23.description,
215
217
  showTooltip: true,
218
+ isVariant: variant === null || variant === void 0 ? void 0 : variant.isVariant,
219
+ isOverridden: (_dataInputs$input24 = dataInputs[input]) === null || _dataInputs$input24 === void 0 ? void 0 : _dataInputs$input24.isOverridden,
220
+ parentUpc: variant === null || variant === void 0 ? void 0 : (_variant$parent = variant.parent) === null || _variant$parent === void 0 ? void 0 : _variant$parent.upc,
221
+ onRestoreInheritance: onRestoreInheritance,
216
222
  auditClass: compare && !isEquals(dataInputs[input].value, auditInputs[input].value) ? "audit-class" : ""
217
223
  }, index + "-" + ((_dataInputs$input10 = dataInputs[input]) === null || _dataInputs$input10 === void 0 ? void 0 : _dataInputs$input10.value) + "-" + ((_dataInputs$input11 = dataInputs[input]) === null || _dataInputs$input11 === void 0 ? void 0 : _dataInputs$input11.id) + "-" + compare)]
218
224
  }) : /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
@@ -255,35 +261,35 @@ var InputGroup = function InputGroup(_ref) {
255
261
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
256
262
  className: "inputs-container",
257
263
  children: inputGroup === null || inputGroup === void 0 ? void 0 : (_inputGroup$inputs2 = inputGroup.inputs) === null || _inputGroup$inputs2 === void 0 ? void 0 : _inputGroup$inputs2.map(function (input, index) {
258
- var _dataInputs$input24, _dataInputs$input25, _dataInputs$input26, _dataInputs$input27, _dataInputs$input28, _dataInputs$input29, _dataInputs$input30, _dataInputs$input31, _dataInputs$input32, _auditInputs$input2, _dataInputs$input33, _dataInputs$input34, _dataInputs$input35, _dataInputs$input36, _dataInputs$input37, _dataInputs$input38, _dataInputs$input39, _dataInputs$input40, _dataInputs$input41, _dataInputs$input42, _dataInputs$input43, _auditInputGroup$inpu3, _auditInputGroup$inpu4;
264
+ var _dataInputs$input25, _dataInputs$input26, _dataInputs$input27, _dataInputs$input28, _dataInputs$input29, _dataInputs$input30, _dataInputs$input31, _dataInputs$input32, _dataInputs$input33, _auditInputs$input2, _dataInputs$input34, _dataInputs$input35, _dataInputs$input36, _dataInputs$input37, _dataInputs$input38, _dataInputs$input39, _dataInputs$input40, _dataInputs$input41, _dataInputs$input42, _dataInputs$input43, _dataInputs$input44, _auditInputGroup$inpu3, _auditInputGroup$inpu4;
259
265
 
260
266
  return activeSection === "Ficha técnica" ? /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
261
267
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_TagAndInput.TagAndInput, {
262
268
  //disabled={input === 40001}
263
- disabled: (_dataInputs$input26 = dataInputs[input]) === null || _dataInputs$input26 === void 0 ? void 0 : _dataInputs$input26.isApproved,
264
- inputId: (_dataInputs$input27 = dataInputs[input]) === null || _dataInputs$input27 === void 0 ? void 0 : _dataInputs$input27.id,
269
+ disabled: (_dataInputs$input27 = dataInputs[input]) === null || _dataInputs$input27 === void 0 ? void 0 : _dataInputs$input27.isApproved,
270
+ inputId: (_dataInputs$input28 = dataInputs[input]) === null || _dataInputs$input28 === void 0 ? void 0 : _dataInputs$input28.id,
265
271
  version: version,
266
- inputType: inputTypeValue((_dataInputs$input28 = dataInputs[input]) === null || _dataInputs$input28 === void 0 ? void 0 : _dataInputs$input28.type),
267
- label: ((_dataInputs$input29 = dataInputs[input]) === null || _dataInputs$input29 === void 0 ? void 0 : _dataInputs$input29.name) + ((_dataInputs$input30 = dataInputs[input]) !== null && _dataInputs$input30 !== void 0 && _dataInputs$input30.required ? "*" : ""),
268
- value: (_dataInputs$input31 = dataInputs[input]) !== null && _dataInputs$input31 !== void 0 && _dataInputs$input31.box ? Object.values((_dataInputs$input32 = dataInputs[input]) === null || _dataInputs$input32 === void 0 ? void 0 : _dataInputs$input32.box)[0] : compare ? (_auditInputs$input2 = auditInputs[input]) === null || _auditInputs$input2 === void 0 ? void 0 : _auditInputs$input2.value : (_dataInputs$input33 = dataInputs[input]) === null || _dataInputs$input33 === void 0 ? void 0 : _dataInputs$input33.value,
272
+ inputType: inputTypeValue((_dataInputs$input29 = dataInputs[input]) === null || _dataInputs$input29 === void 0 ? void 0 : _dataInputs$input29.type),
273
+ label: ((_dataInputs$input30 = dataInputs[input]) === null || _dataInputs$input30 === void 0 ? void 0 : _dataInputs$input30.name) + ((_dataInputs$input31 = dataInputs[input]) !== null && _dataInputs$input31 !== void 0 && _dataInputs$input31.required ? "*" : ""),
274
+ value: (_dataInputs$input32 = dataInputs[input]) !== null && _dataInputs$input32 !== void 0 && _dataInputs$input32.box ? Object.values((_dataInputs$input33 = dataInputs[input]) === null || _dataInputs$input33 === void 0 ? void 0 : _dataInputs$input33.box)[0] : compare ? (_auditInputs$input2 = auditInputs[input]) === null || _auditInputs$input2 === void 0 ? void 0 : _auditInputs$input2.value : (_dataInputs$input34 = dataInputs[input]) === null || _dataInputs$input34 === void 0 ? void 0 : _dataInputs$input34.value,
269
275
  inputPlaceHolder: input === null || input === void 0 ? void 0 : input.placeholder,
270
276
  articleId: articleId,
271
- isRequired: (_dataInputs$input34 = dataInputs[input]) === null || _dataInputs$input34 === void 0 ? void 0 : _dataInputs$input34.required,
272
- aiGenerated: (_dataInputs$input35 = dataInputs[input]) === null || _dataInputs$input35 === void 0 ? void 0 : _dataInputs$input35.ai_generated,
277
+ isRequired: (_dataInputs$input35 = dataInputs[input]) === null || _dataInputs$input35 === void 0 ? void 0 : _dataInputs$input35.required,
278
+ aiGenerated: (_dataInputs$input36 = dataInputs[input]) === null || _dataInputs$input36 === void 0 ? void 0 : _dataInputs$input36.ai_generated,
273
279
  updatedDatasheets: updatedDatasheets,
274
280
  setUpdatedDatasheets: setUpdatedDatasheets,
275
- maxChar: (_dataInputs$input36 = dataInputs[input]) !== null && _dataInputs$input36 !== void 0 && _dataInputs$input36.max_chars ? (_dataInputs$input37 = dataInputs[input]) === null || _dataInputs$input37 === void 0 ? void 0 : _dataInputs$input37.max_chars : 999,
276
- optionList: (_dataInputs$input38 = dataInputs[input]) === null || _dataInputs$input38 === void 0 ? void 0 : _dataInputs$input38.option_list,
277
- description: (_dataInputs$input39 = dataInputs[input]) === null || _dataInputs$input39 === void 0 ? void 0 : _dataInputs$input39.description,
281
+ maxChar: (_dataInputs$input37 = dataInputs[input]) !== null && _dataInputs$input37 !== void 0 && _dataInputs$input37.max_chars ? (_dataInputs$input38 = dataInputs[input]) === null || _dataInputs$input38 === void 0 ? void 0 : _dataInputs$input38.max_chars : 999,
282
+ optionList: (_dataInputs$input39 = dataInputs[input]) === null || _dataInputs$input39 === void 0 ? void 0 : _dataInputs$input39.option_list,
283
+ description: (_dataInputs$input40 = dataInputs[input]) === null || _dataInputs$input40 === void 0 ? void 0 : _dataInputs$input40.description,
278
284
  showTooltip: true,
279
285
  inputGroup: inputGroup,
280
286
  dataInputs: dataInputs,
281
287
  onChange: setUpdatedBoxData,
282
288
  auditClass: compare && !isEquals(dataInputs[input].value, auditInputs[input].value) ? "audit-class" : ""
283
- }, index + "-" + ((_dataInputs$input24 = dataInputs[input]) === null || _dataInputs$input24 === void 0 ? void 0 : _dataInputs$input24.value) + "-" + ((_dataInputs$input25 = dataInputs[input]) === null || _dataInputs$input25 === void 0 ? void 0 : _dataInputs$input25.id) + "-" + compare), ((_dataInputs$input40 = dataInputs[input]) === null || _dataInputs$input40 === void 0 ? void 0 : _dataInputs$input40.isApproved) === false && /*#__PURE__*/(0, _jsxRuntime.jsx)(InputReviewSection, {
284
- inputId: (_dataInputs$input41 = dataInputs[input]) === null || _dataInputs$input41 === void 0 ? void 0 : _dataInputs$input41.id,
285
- isApproved: (_dataInputs$input42 = dataInputs[input]) === null || _dataInputs$input42 === void 0 ? void 0 : _dataInputs$input42.isApproved,
286
- comment: (_dataInputs$input43 = dataInputs[input]) === null || _dataInputs$input43 === void 0 ? void 0 : _dataInputs$input43.comment,
289
+ }, index + "-" + ((_dataInputs$input25 = dataInputs[input]) === null || _dataInputs$input25 === void 0 ? void 0 : _dataInputs$input25.value) + "-" + ((_dataInputs$input26 = dataInputs[input]) === null || _dataInputs$input26 === void 0 ? void 0 : _dataInputs$input26.id) + "-" + compare), ((_dataInputs$input41 = dataInputs[input]) === null || _dataInputs$input41 === void 0 ? void 0 : _dataInputs$input41.isApproved) === false && /*#__PURE__*/(0, _jsxRuntime.jsx)(InputReviewSection, {
290
+ inputId: (_dataInputs$input42 = dataInputs[input]) === null || _dataInputs$input42 === void 0 ? void 0 : _dataInputs$input42.id,
291
+ isApproved: (_dataInputs$input43 = dataInputs[input]) === null || _dataInputs$input43 === void 0 ? void 0 : _dataInputs$input43.isApproved,
292
+ comment: (_dataInputs$input44 = dataInputs[input]) === null || _dataInputs$input44 === void 0 ? void 0 : _dataInputs$input44.comment,
287
293
  handleImgClick: handleImgClick,
288
294
  changeImageBtn: changeImageBtn,
289
295
  showDivState: showDivStates,
@@ -0,0 +1,102 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.unwrap = exports.readPayload = exports.ApiError = void 0;
9
+
10
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/createClass"));
11
+
12
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/classCallCheck"));
13
+
14
+ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/inherits"));
15
+
16
+ var _createSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/createSuper"));
17
+
18
+ var _wrapNativeSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/wrapNativeSuper"));
19
+
20
+ var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/typeof"));
21
+
22
+ /*
23
+ Las lambdas de este API están declaradas con `integration: lambda`, no con
24
+ lambda-proxy. Eso tiene dos consecuencias que se pagan caras si se ignoran:
25
+
26
+ 1. La respuesta llega ENVUELTA: axios entrega { statusCode, headers, body },
27
+ con `body` en texto. Leer `res.data.candidates` da undefined.
28
+ 2. El HTTP siempre es 200, incluso cuando la lambda respondió 400 o 500. Un
29
+ try/catch alrededor de axios NUNCA se dispara por un error de negocio: el
30
+ error viaja dentro del cuerpo y hay que mirar `statusCode` a mano.
31
+
32
+ El repo ya vive con esto —provider-product-edition.context.jsx hace
33
+ JSON.parse(res.data.body)— pero sin un lugar común cada llamada nueva vuelve a
34
+ tropezar. Esto lo centraliza.
35
+ */
36
+ var unwrap = function unwrap(res) {
37
+ var _res$status;
38
+
39
+ var payload = res === null || res === void 0 ? void 0 : res.data;
40
+ var envuelto = payload && (0, _typeof2.default)(payload) === "object" && "statusCode" in payload && "body" in payload;
41
+ if (!envuelto) return {
42
+ status: (_res$status = res === null || res === void 0 ? void 0 : res.status) !== null && _res$status !== void 0 ? _res$status : 200,
43
+ body: payload
44
+ };
45
+ var body = typeof payload.body === "string" ? safeParse(payload.body) : payload.body;
46
+ return {
47
+ status: Number(payload.statusCode),
48
+ body: body
49
+ };
50
+ };
51
+
52
+ exports.unwrap = unwrap;
53
+
54
+ var safeParse = function safeParse(text) {
55
+ try {
56
+ return JSON.parse(text);
57
+ } catch (error) {
58
+ return {
59
+ message: text
60
+ };
61
+ }
62
+ };
63
+ /*
64
+ Error de negocio con el código estable que manda el backend
65
+ (VARIANT_CROSS_COMPANY, VARIANT_ALREADY_LINKED, ...). Se lanza para que el
66
+ llamador use un try/catch normal, aunque el transporte haya dicho 200.
67
+ */
68
+
69
+
70
+ var ApiError = /*#__PURE__*/function (_Error) {
71
+ (0, _inherits2.default)(ApiError, _Error);
72
+
73
+ var _super = (0, _createSuper2.default)(ApiError);
74
+
75
+ function ApiError(code, message) {
76
+ var _this;
77
+
78
+ (0, _classCallCheck2.default)(this, ApiError);
79
+ _this = _super.call(this, message);
80
+ _this.name = "ApiError";
81
+ _this.code = code;
82
+ return _this;
83
+ }
84
+
85
+ return (0, _createClass2.default)(ApiError);
86
+ }( /*#__PURE__*/(0, _wrapNativeSuper2.default)(Error));
87
+
88
+ exports.ApiError = ApiError;
89
+
90
+ var readPayload = function readPayload(res) {
91
+ var _unwrap = unwrap(res),
92
+ status = _unwrap.status,
93
+ body = _unwrap.body;
94
+
95
+ if (status >= 400) {
96
+ throw new ApiError(body === null || body === void 0 ? void 0 : body.code, (body === null || body === void 0 ? void 0 : body.message) || "La operación falló.");
97
+ }
98
+
99
+ return body !== null && body !== void 0 ? body : {};
100
+ };
101
+
102
+ exports.readPayload = readPayload;