contentoh-components-library 21.5.94 → 21.5.95

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 (70) hide show
  1. package/dist/ai/utils/compare-strings.js +45 -0
  2. package/dist/components/atoms/GeneralButton/styles.js +1 -1
  3. package/dist/components/atoms/GeneralInput/index.js +245 -54
  4. package/dist/components/atoms/GeneralInput/styles.js +7 -3
  5. package/dist/components/atoms/InputFormatter/index.js +223 -68
  6. package/dist/components/atoms/InputFormatter/styles.js +20 -4
  7. package/dist/components/molecules/StatusAsignationInfo/index.js +11 -1
  8. package/dist/components/molecules/TabsMenu/index.js +13 -12
  9. package/dist/components/molecules/TagAndInput/index.js +361 -24
  10. package/dist/components/molecules/TagAndInput/styles.js +2 -2
  11. package/dist/components/organisms/ChangeStatusModal/index.js +531 -0
  12. package/dist/components/organisms/ChangeStatusModal/styles.js +85 -0
  13. package/dist/components/organisms/FullProductNameHeader/index.js +6 -22
  14. package/dist/components/organisms/InputGroup/index.js +22 -18
  15. package/dist/components/pages/ProviderProductEdition/ProviderProductEdition.stories.js +150 -337
  16. package/dist/components/pages/ProviderProductEdition/context/provider-product-edition.context.js +15 -15
  17. package/dist/components/pages/ProviderProductEdition/index.js +413 -396
  18. package/dist/components/pages/ProviderProductEdition/utils.js +1 -0
  19. package/dist/components/pages/RetailerProductEdition/RetailerProductEdition.stories.js +179 -196
  20. package/dist/components/pages/RetailerProductEdition/context/provider-product-edition.context.js +59 -260
  21. package/dist/components/pages/RetailerProductEdition/context/reducers/product.js +50 -38
  22. package/dist/components/pages/RetailerProductEdition/index.js +1719 -2237
  23. package/dist/components/pages/RetailerProductEdition/styles.js +4 -2
  24. package/dist/components/pages/RetailerProductEdition/utils.js +251 -2
  25. package/dist/contexts/AiProductEdition.js +230 -158
  26. package/dist/global-files/statusDictionary.js +103 -0
  27. package/package.json +4 -2
  28. package/src/ai/utils/compare-strings.js +45 -0
  29. package/src/assets/images/Icons/arrow.png +0 -0
  30. package/src/assets/images/Icons/cancel.png +0 -0
  31. package/src/assets/images/Icons/ia-icon.png +0 -0
  32. package/src/assets/images/Icons/loading.svg +5 -0
  33. package/src/assets/images/Icons/reload.png +0 -0
  34. package/src/components/atoms/GeneralButton/styles.js +4 -0
  35. package/src/components/atoms/GeneralInput/index.js +237 -60
  36. package/src/components/atoms/GeneralInput/styles.js +81 -0
  37. package/src/components/atoms/InputFormatter/index.js +200 -51
  38. package/src/components/atoms/InputFormatter/styles.js +284 -0
  39. package/src/components/atoms/RetailerSelector/RetailerSelector.stories.js +10 -0
  40. package/src/components/atoms/RetailerSelector/index.js +3 -0
  41. package/src/components/atoms/RetailerSelector/styles.js +0 -0
  42. package/src/components/molecules/StatusAsignationInfo/index.js +9 -1
  43. package/src/components/molecules/TabsMenu/index.js +12 -11
  44. package/src/components/molecules/TagAndInput/index.js +286 -21
  45. package/src/components/molecules/TagAndInput/styles.js +59 -17
  46. package/src/components/organisms/ChangeStatusModal/index.jsx +488 -0
  47. package/src/components/organisms/ChangeStatusModal/styles.js +333 -0
  48. package/src/components/organisms/FullProductNameHeader/index.js +4 -28
  49. package/src/components/organisms/FullTabsMenu/index.js +1 -1
  50. package/src/components/organisms/InputGroup/index.js +12 -4
  51. package/src/components/pages/ProviderProductEdition/ProviderProductEdition.stories.js +174 -202
  52. package/src/components/pages/ProviderProductEdition/context/provider-product-edition.context.jsx +14 -14
  53. package/src/components/pages/ProviderProductEdition/index.js +496 -475
  54. package/src/components/pages/ProviderProductEdition/utils.js +2 -2
  55. package/src/components/pages/RetailerProductEdition/RetailerProductEdition.stories.js +201 -224
  56. package/src/components/pages/RetailerProductEdition/context/provider-product-edition.context.jsx +575 -0
  57. package/src/components/pages/RetailerProductEdition/context/provider-product-edition.reducer.js +62 -0
  58. package/src/components/pages/RetailerProductEdition/context/reducers/active-state.js +344 -0
  59. package/src/components/pages/RetailerProductEdition/context/reducers/inputs.js +155 -0
  60. package/src/components/pages/RetailerProductEdition/context/reducers/product.js +114 -0
  61. package/src/components/pages/RetailerProductEdition/context/reducers/system.js +60 -0
  62. package/src/components/pages/RetailerProductEdition/index.js +1545 -1718
  63. package/src/components/pages/RetailerProductEdition/index_old.js +1979 -0
  64. package/src/components/pages/RetailerProductEdition/stories/Auditor.stories.js +101 -0
  65. package/src/components/pages/RetailerProductEdition/stories/ImageEditor.stories.js +115 -0
  66. package/src/components/pages/RetailerProductEdition/stories/TextEditor.stories.js +174 -0
  67. package/src/components/pages/RetailerProductEdition/styles.js +67 -2
  68. package/src/components/pages/RetailerProductEdition/utils.js +240 -0
  69. package/src/contexts/AiProductEdition.jsx +339 -0
  70. package/src/global-files/statusDictionary.js +103 -0
@@ -17,9 +17,25 @@ var _react = require("react");
17
17
 
18
18
  var _styles = require("./styles");
19
19
 
20
+ var _iaIcon = _interopRequireDefault(require("../../../assets/images/Icons/ia-icon.png"));
21
+
22
+ var _arrow = _interopRequireDefault(require("../../../assets/images/Icons/arrow.png"));
23
+
24
+ var _loading = _interopRequireDefault(require("../../../assets/images/Icons/loading.svg"));
25
+
26
+ var _cancel = _interopRequireDefault(require("../../../assets/images/Icons/cancel.png"));
27
+
28
+ var _reload = _interopRequireDefault(require("../../../assets/images/Icons/reload.png"));
29
+
30
+ var _AiProductEdition = require("../../../contexts/AiProductEdition");
31
+
32
+ var _compareStrings = require("../../../ai/utils/compare-strings");
33
+
20
34
  var _jsxRuntime = require("react/jsx-runtime");
21
35
 
22
36
  var InputFormatter = function InputFormatter(_ref) {
37
+ var _currentSuggestion$in, _currentSuggestion$in2, _currentSuggestion$in3, _suggestions$inputId, _currentSuggestion$in4, _suggestions$inputId2;
38
+
23
39
  var _ref$mainValue = _ref.mainValue,
24
40
  mainValue = _ref$mainValue === void 0 ? "" : _ref$mainValue,
25
41
  inputId = _ref.inputId,
@@ -28,35 +44,69 @@ var InputFormatter = function InputFormatter(_ref) {
28
44
  setUpdatedDescriptions = _ref.setUpdatedDescriptions,
29
45
  isRequired = _ref.isRequired,
30
46
  maxChar = _ref.maxChar,
31
- disabled = _ref.disabled;
47
+ disabled = _ref.disabled,
48
+ _ref$hasAiGeneration = _ref.hasAiGeneration,
49
+ hasAiGeneration = _ref$hasAiGeneration === void 0 ? false : _ref$hasAiGeneration,
50
+ _ref$isAiGenerationLo = _ref.isAiGenerationLoading,
51
+ isAiGenerationLoading = _ref$isAiGenerationLo === void 0 ? false : _ref$isAiGenerationLo,
52
+ _ref$isAiRegeneration = _ref.isAiRegenerationLoading,
53
+ isAiRegenerationLoading = _ref$isAiRegeneration === void 0 ? false : _ref$isAiRegeneration,
54
+ _ref$isAiActive = _ref.isAiActive,
55
+ isAiActive = _ref$isAiActive === void 0 ? false : _ref$isAiActive,
56
+ _ref$isAiAvailable = _ref.isAiAvailable,
57
+ isAiAvailable = _ref$isAiAvailable === void 0 ? false : _ref$isAiAvailable,
58
+ _ref$aiGenerated = _ref.aiGenerated,
59
+ aiGenerated = _ref$aiGenerated === void 0 ? false : _ref$aiGenerated,
60
+ _ref$setIsAiActive = _ref.setIsAiActive,
61
+ setIsAiActive = _ref$setIsAiActive === void 0 ? function () {} : _ref$setIsAiActive,
62
+ _ref$handlerAiGenerat = _ref.handlerAiGeneration,
63
+ handlerAiGeneration = _ref$handlerAiGenerat === void 0 ? function () {} : _ref$handlerAiGenerat,
64
+ _ref$handlerRegenerat = _ref.handlerRegenerateSuggestions,
65
+ handlerRegenerateSuggestions = _ref$handlerRegenerat === void 0 ? function () {} : _ref$handlerRegenerat,
66
+ _ref$handleChangeSugg = _ref.handleChangeSuggestion,
67
+ handleChangeSuggestion = _ref$handleChangeSugg === void 0 ? function () {} : _ref$handleChangeSugg;
32
68
 
33
- var _useState = (0, _react.useState)(mainValue),
69
+ var _useAiProductEdition = (0, _AiProductEdition.useAiProductEdition)(),
70
+ suggestions = _useAiProductEdition.suggestions,
71
+ currentSuggestion = _useAiProductEdition.currentSuggestion;
72
+
73
+ var _useState = (0, _react.useState)(false),
34
74
  _useState2 = (0, _slicedToArray2.default)(_useState, 2),
35
- inputValue = _useState2[0],
36
- setInputValue = _useState2[1];
75
+ aiSuggestionAccepted = _useState2[0],
76
+ setAiSuggestionAccepted = _useState2[1];
37
77
 
38
- var _useState3 = (0, _react.useState)(false),
78
+ var _useState3 = (0, _react.useState)(mainValue),
39
79
  _useState4 = (0, _slicedToArray2.default)(_useState3, 2),
40
- selection = _useState4[0],
41
- setSelection = _useState4[1];
80
+ valueAccepted = _useState4[0],
81
+ setValueAccepted = _useState4[1];
42
82
 
43
- var _useState5 = (0, _react.useState)({
44
- left: 0,
45
- top: 0
46
- }),
83
+ var _useState5 = (0, _react.useState)(mainValue),
47
84
  _useState6 = (0, _slicedToArray2.default)(_useState5, 2),
48
- position = _useState6[0],
49
- setPosition = _useState6[1];
85
+ inputValue = _useState6[0],
86
+ setInputValue = _useState6[1];
50
87
 
51
- var _useState7 = (0, _react.useState)(0),
88
+ var _useState7 = (0, _react.useState)(false),
52
89
  _useState8 = (0, _slicedToArray2.default)(_useState7, 2),
53
- charsCounter = _useState8[0],
54
- setCharsCounter = _useState8[1];
90
+ selection = _useState8[0],
91
+ setSelection = _useState8[1];
55
92
 
56
- var _useState9 = (0, _react.useState)({}),
93
+ var _useState9 = (0, _react.useState)({
94
+ left: 0,
95
+ top: 0
96
+ }),
57
97
  _useState10 = (0, _slicedToArray2.default)(_useState9, 2),
58
- quillState = _useState10[0],
59
- setQuillState = _useState10[1];
98
+ position = _useState10[0],
99
+ setPosition = _useState10[1];
100
+
101
+ var _useState11 = (0, _react.useState)(0),
102
+ _useState12 = (0, _slicedToArray2.default)(_useState11, 2),
103
+ charsCounter = _useState12[0],
104
+ setCharsCounter = _useState12[1];
105
+
106
+ var _useState13 = (0, _react.useState)({}),
107
+ _useState14 = (0, _slicedToArray2.default)(_useState13, 2),
108
+ quillState = _useState14[0],
109
+ setQuillState = _useState14[1];
60
110
 
61
111
  var maxLength = maxChar ? maxChar : 999;
62
112
 
@@ -97,37 +147,50 @@ var InputFormatter = function InputFormatter(_ref) {
97
147
 
98
148
  setCharsCounter(h.getLength() - 1);
99
149
  value = valueFormater(value);
150
+ updateParentDescriptions(value, aiSuggestionAccepted);
151
+ };
100
152
 
101
- if (updatedDescriptions) {
102
- var idInput = inputId;
103
- var dataSave = updatedDescriptions === null || updatedDescriptions === void 0 ? void 0 : updatedDescriptions.slice();
153
+ var updateParentDescriptions = function updateParentDescriptions(finalValue, isAiAccepted) {
154
+ if (!updatedDescriptions) return;
155
+ var idInput = inputId;
156
+ var dataSave = updatedDescriptions === null || updatedDescriptions === void 0 ? void 0 : updatedDescriptions.slice();
157
+ var similarity = (0, _compareStrings.getTextSimilarityPercentage)(valueAccepted, inputValue);
158
+ var generatedWithAi = isAiAccepted || aiGenerated && similarity >= 50;
104
159
 
105
- if ((dataSave === null || dataSave === void 0 ? void 0 : dataSave.length) > 0) {
106
- var index = dataSave.findIndex(function (e) {
107
- return e.attributeId === idInput;
108
- });
160
+ if ((dataSave === null || dataSave === void 0 ? void 0 : dataSave.length) > 0) {
161
+ var index = dataSave.findIndex(function (e) {
162
+ return e.attributeId === idInput;
163
+ });
109
164
 
110
- if (index !== -1) {
111
- if (value !== mainValue) dataSave[index].value = value;else dataSave.splice(index, 1);
165
+ if (index !== -1) {
166
+ if (finalValue !== mainValue) {
167
+ dataSave[index].value = finalValue;
168
+ dataSave[index].aiSuggestionAccepted = generatedWithAi;
112
169
  } else {
113
- dataSave.push({
114
- articleId: articleId,
115
- attributeId: idInput,
116
- value: value
117
- });
170
+ dataSave.splice(index, 1);
118
171
  }
119
172
  } else {
120
- if (value !== mainValue) {
173
+ if (finalValue !== mainValue) {
121
174
  dataSave.push({
122
175
  articleId: articleId,
123
176
  attributeId: idInput,
124
- value: value
177
+ value: finalValue,
178
+ aiSuggestionAccepted: generatedWithAi
125
179
  });
126
180
  }
127
181
  }
128
-
129
- setUpdatedDescriptions(dataSave);
182
+ } else {
183
+ if (finalValue !== mainValue) {
184
+ dataSave.push({
185
+ articleId: articleId,
186
+ attributeId: idInput,
187
+ value: finalValue,
188
+ aiSuggestionAccepted: generatedWithAi
189
+ });
190
+ }
130
191
  }
192
+
193
+ setUpdatedDescriptions(dataSave);
131
194
  };
132
195
 
133
196
  var getSelection = function getSelection(range, a, b) {
@@ -142,43 +205,135 @@ var InputFormatter = function InputFormatter(_ref) {
142
205
  });
143
206
  setSelection((selected === null || selected === void 0 ? void 0 : selected.length) > 0);
144
207
  }
208
+ }; //AI Generation
209
+
210
+
211
+ var handleAcceptSuggestion = function handleAcceptSuggestion(suggestionValue) {
212
+ if (!suggestionValue) return;
213
+ setInputValue(suggestionValue);
214
+ setValueAccepted(suggestionValue);
215
+ setAiSuggestionAccepted(true);
216
+ setIsAiActive(false); // Formateamos el valor sugerido igual que en el onChange
217
+
218
+ var formattedSuggestion = valueFormater(suggestionValue); // Disparamos la actualización enviando "true" directamente
219
+
220
+ updateParentDescriptions(formattedSuggestion, true);
145
221
  };
146
222
 
223
+ (0, _react.useEffect)(function () {
224
+ // Comprueba cuando la función de IA se cierra y no se acepto una sugerencia
225
+ // Devuelve el valor inicial
226
+ if (!isAiActive && !aiSuggestionAccepted) return setInputValue(valueAccepted);
227
+ }, [suggestions, isAiActive]);
228
+ (0, _react.useEffect)(function () {
229
+ if (!isAiActive) return; // Comprueba si la sugerencia fue aceptada
230
+
231
+ setAiSuggestionAccepted(false);
232
+ }, [isAiActive]); //End Ai Generation
233
+
147
234
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_styles.Container, {
148
235
  isRequired: isRequired && (inputValue.replace(/<.*?>/gm, "").length === 0 || !inputValue),
149
236
  selection: selection,
150
237
  position: position,
151
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactQuill.default, {
152
- id: inputId + "",
153
- ref: function ref(el) {
154
- return setQuill(el);
155
- },
156
- defaultValue: getValue(inputValue),
157
- readOnly: disabled,
158
- modules: {
159
- toolbar: ["bold"]
160
- },
161
- onKeyPress: function onKeyPress(e) {
162
- if (charsCounter >= maxLength && e.key !== "Backspace") {
163
- e.preventDefault();
164
- }
165
- },
166
- onKeyDown: function onKeyDown(e) {
167
- var keysArray = ["Backspace", "Meta", "ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown"];
168
-
169
- if (charsCounter >= maxLength && keysArray.every(function (key) {
170
- return e.key !== key;
171
- })) {
172
- e.preventDefault();
173
- }
174
- },
175
- onChange: function onChange(valueInput, user, range, h) {
176
- return _onChange(valueInput, h);
177
- },
178
- onChangeSelection: getSelection
179
- }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("p", {
180
- className: "description-limit",
181
- children: [charsCounter, "/", maxLength]
238
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_styles.InputContainer, {
239
+ className: hasAiGeneration ? "ai-generation" : "",
240
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactQuill.default, {
241
+ id: inputId + "",
242
+ ref: function ref(el) {
243
+ return setQuill(el);
244
+ },
245
+ value: isAiActive ? currentSuggestion === null || currentSuggestion === void 0 ? void 0 : (_currentSuggestion$in = currentSuggestion[inputId]) === null || _currentSuggestion$in === void 0 ? void 0 : _currentSuggestion$in.value : getValue(inputValue),
246
+ readOnly: isAiActive || disabled,
247
+ modules: {
248
+ toolbar: false
249
+ },
250
+ onKeyPress: function onKeyPress(e) {
251
+ if (charsCounter >= maxLength && e.key !== "Backspace") {
252
+ e.preventDefault();
253
+ }
254
+ },
255
+ onKeyDown: function onKeyDown(e) {
256
+ var keysArray = ["Backspace", "Meta", "ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown"];
257
+
258
+ if (charsCounter >= maxLength && keysArray.every(function (key) {
259
+ return e.key !== key;
260
+ })) {
261
+ e.preventDefault();
262
+ }
263
+ },
264
+ onChange: function onChange(valueInput, user, range, h) {
265
+ return _onChange(valueInput, h);
266
+ },
267
+ onChangeSelection: getSelection,
268
+ className: "quill ".concat(hasAiGeneration && "has-ai", " ").concat(isAiActive && "ai-generation")
269
+ }), hasAiGeneration && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
270
+ className: "icon_container ".concat(isAiActive ? "ai-active" : '', " ").concat(isAiAvailable ? "ai-available" : ''),
271
+ title: !isAiAvailable ? 'Debes de completar ficha técnica e imágenes para desbloquear la generación con IA' : '',
272
+ onClick: handlerAiGeneration,
273
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)("img", {
274
+ className: isAiGenerationLoading ? "loading" : "",
275
+ src: isAiGenerationLoading ? _loading.default : isAiActive ? _cancel.default : _iaIcon.default
276
+ })
277
+ })]
278
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_styles.BottomContainer, {
279
+ className: isAiActive ? "with-ai" : "",
280
+ children: [isAiActive && /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
281
+ className: "ai-options",
282
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_styles.OptionsContainer, {
283
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
284
+ className: "arrow ".concat((currentSuggestion === null || currentSuggestion === void 0 ? void 0 : (_currentSuggestion$in2 = currentSuggestion[inputId]) === null || _currentSuggestion$in2 === void 0 ? void 0 : _currentSuggestion$in2.index) === 0 && "disabled"),
285
+ onClick: function onClick() {
286
+ handleChangeSuggestion({
287
+ action: "prev"
288
+ });
289
+ },
290
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)("img", {
291
+ src: _arrow.default,
292
+ alt: ""
293
+ })
294
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("p", {
295
+ children: [(currentSuggestion === null || currentSuggestion === void 0 ? void 0 : (_currentSuggestion$in3 = currentSuggestion[inputId]) === null || _currentSuggestion$in3 === void 0 ? void 0 : _currentSuggestion$in3.index) + 1 || 1, "/", suggestions === null || suggestions === void 0 ? void 0 : (_suggestions$inputId = suggestions[inputId]) === null || _suggestions$inputId === void 0 ? void 0 : _suggestions$inputId.length]
296
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
297
+ className: "arrow right ".concat((currentSuggestion === null || currentSuggestion === void 0 ? void 0 : (_currentSuggestion$in4 = currentSuggestion[inputId]) === null || _currentSuggestion$in4 === void 0 ? void 0 : _currentSuggestion$in4.index) === (suggestions === null || suggestions === void 0 ? void 0 : (_suggestions$inputId2 = suggestions[inputId]) === null || _suggestions$inputId2 === void 0 ? void 0 : _suggestions$inputId2.length) - 1 && "disabled"),
298
+ onClick: function onClick() {},
299
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)("img", {
300
+ onClick: function onClick() {
301
+ handleChangeSuggestion({
302
+ action: "next"
303
+ });
304
+ },
305
+ src: _arrow.default,
306
+ alt: "ai icon"
307
+ })
308
+ })]
309
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_styles.ButtonsContainer, {
310
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
311
+ className: "reload-suggestions ".concat(isAiRegenerationLoading && "loading"),
312
+ onClick: function onClick() {
313
+ handlerRegenerateSuggestions({
314
+ type: "description"
315
+ });
316
+ },
317
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)("img", {
318
+ className: "",
319
+ src: isAiRegenerationLoading ? _loading.default : _reload.default
320
+ })
321
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
322
+ className: "accept-suggestion",
323
+ onClick: function onClick() {
324
+ var _currentSuggestion$in5;
325
+
326
+ handleAcceptSuggestion(currentSuggestion === null || currentSuggestion === void 0 ? void 0 : (_currentSuggestion$in5 = currentSuggestion[inputId]) === null || _currentSuggestion$in5 === void 0 ? void 0 : _currentSuggestion$in5.value);
327
+ },
328
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)("p", {
329
+ children: "Aceptar sugerencia"
330
+ })
331
+ })]
332
+ })]
333
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("p", {
334
+ className: "description-limit",
335
+ children: [charsCounter, "/", maxLength]
336
+ })]
182
337
  })]
183
338
  });
184
339
  };
@@ -5,7 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
- exports.Container = void 0;
8
+ exports.OptionsContainer = exports.InputContainer = exports.Container = exports.ButtonsContainer = exports.BottomContainer = void 0;
9
9
 
10
10
  var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/taggedTemplateLiteral"));
11
11
 
@@ -13,9 +13,9 @@ var _styledComponents = _interopRequireDefault(require("styled-components"));
13
13
 
14
14
  var _variables = require("../../../global-files/variables");
15
15
 
16
- var _templateObject;
16
+ var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5;
17
17
 
18
- var Container = _styledComponents.default.div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n .quill {\n background-color: ", ";\n border: 1px solid\n ", ";\n position: relative;\n border-radius: 5px;\n\n .ql-toolbar {\n background-color: ", ";\n position: absolute;\n z-index: 10;\n border: 1px solid ", ";\n width: 45px;\n height: 45px;\n border-radius: 4px;\n visibility: ", ";\n top: ", "px;\n left: ", "px;\n }\n\n .ql-container {\n border: none;\n font-family: ", ";\n color: ", ";\n strong {\n font-family: ", ";\n }\n\n .ql-editor{\n padding: 8px 10px;\n }\n }\n }\n .description-limit {\n font-size: 12px;\n font-family: ", ";\n color: ", ";\n text-align: right;\n margin-top: 5px;\n }\n"])), _variables.GlobalColors.white, function (_ref) {
18
+ var Container = _styledComponents.default.div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n .quill {\n background-color: ", ";\n border: 1px solid\n ", ";\n position: relative;\n border-radius: 5px;\n\n &.has-ai {\n .ql-container {\n padding-right: 2.5rem;\n }\n }\n\n &.ai-generation {\n\n .ql-container {\n border: 1px solid #3F8AED;\n border-radius: 5px;\n background-color: rgba(59, 147, 224, 0.05);\n margin: 5px;\n margin-right: 2.5rem;\n }\n\n }\n\n .ql-toolbar {\n background-color: ", ";\n position: absolute;\n z-index: 10;\n border: 1px solid ", ";\n width: 45px;\n height: 45px;\n border-radius: 4px;\n visibility: ", ";\n top: ", "px;\n left: ", "px;\n }\n\n .ql-container {\n border: none;\n font-family: ", ";\n color: ", ";\n strong {\n font-family: ", ";\n }\n\n .ql-editor{\n padding: 8px 10px;\n }\n }\n }\n .description-limit {\n font-size: 12px;\n font-family: ", ";\n color: ", ";\n text-align: right;\n margin-top: 5px;\n }\n"])), _variables.GlobalColors.white, function (_ref) {
19
19
  var focus = _ref.focus,
20
20
  isRequired = _ref.isRequired;
21
21
  return focus ? _variables.GlobalColors.magenta_s2 : isRequired ? "red" : _variables.GlobalColors.gray_light;
@@ -30,4 +30,20 @@ var Container = _styledComponents.default.div(_templateObject || (_templateObjec
30
30
  return position.left;
31
31
  }, _variables.FontFamily.AvenirNext, _variables.GlobalColors.deep_gray, _variables.FontFamily.Raleway_900, _variables.FontFamily.AvenirNext, _variables.GlobalColors.deep_gray);
32
32
 
33
- exports.Container = Container;
33
+ exports.Container = Container;
34
+
35
+ var InputContainer = _styledComponents.default.div(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n\n &.ai-generation {\n\n position: relative;\n\n > input[type=text] {\n padding-right: 2.5rem;\n }\n\n > input[type=text].ia-input {\n background-color: rgba(59, 147, 224, 0.05);\n border: 1px solid #3F8AED;\n }\n\n .icon_container {\n position: absolute;\n right: 10px;\n top: 7px;\n width: 22.5px;\n height: 22.5px;\n padding: 4px;\n\n cursor: not-allowed;\n\n border-radius: 50%;\n overflow: hidden;\n display: flex;\n align-items: center;\n justify-content: center;\n z-index: 1;\n\n &::before {\n content: '';\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n\n background: gray;\n background-size: 200% 200%;\n\n animation: ai-shimmer 3s ease-in-out infinite alternate;\n z-index: -1;\n }\n\n &.ai-available {\n cursor: pointer;\n }\n\n &.ai-available::before{\n background: linear-gradient(\n 120deg,\n #4285F4 20%,\n #33A3C8 50%,\n #4285F4 80%\n );\n background-size: 200% 200%;\n }\n\n &.ai-available::after {\n content: \"\";\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n opacity: 0.75;\n\n background: linear-gradient(\n 135deg,\n rgba(255, 255, 255, 0) 0%,\n rgba(255, 255, 255, 0) 40%,\n rgba(255, 255, 255, 0.8) 50%,\n rgba(255, 255, 255, 0) 60%,\n rgba(255, 255, 255, 0) 100%\n );\n\n transform: scale(2) translate(-100%, -100%);\n z-index: 3;\n\n animation: ai-glint 3s infinite ease-in-out;\n }\n\n &.ai-available img.loading ~ ::after {\n animation: none;\n display: none;\n }\n\n &.ai-active::after {\n animation: none;\n display: none;\n }\n\n img {\n width: 100%;\n height: 100%;\n object-fit: contain;\n position: relative;\n z-index: 2;\n filter: invert(1) grayscale(1) brightness(2);\n }\n\n img.loading {\n width: 22.5px;\n height: 22.5px;\n }\n\n &.ai-active::before {\n background: oklch(57.7% 0.245 27.325);\n }\n\n\n }\n }\n\n @keyframes ai-shimmer {\n 0% {\n background-position: 0% 50%;\n }\n 100% {\n background-position: 100% 50%;\n }\n }\n\n @keyframes ai-glint {\n 0% {\n transform: scale(2) translate(-100%, -100%);\n }\n 70%, 100% {\n transform: scale(2) translate(100%, 100%);\n }\n }\n\n"])));
36
+
37
+ exports.InputContainer = InputContainer;
38
+
39
+ var BottomContainer = _styledComponents.default.div(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2.default)(["\n\n display: flex;\n align-items: center;\n padding-top: 5px;\n justify-content: flex-end;\n\n &.with-ai {\n justify-content: space-between;\n }\n\n > div.ai-options {\n display: flex;\n align-items: center;\n gap: 0.25rem;\n }\n\n"])));
40
+
41
+ exports.BottomContainer = BottomContainer;
42
+
43
+ var OptionsContainer = _styledComponents.default.div(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2.default)(["\n\n display: flex;\n align-items: center;\n gap: 0.25rem;\n user-select: none;\n\n p {\n font-size: 12px;\n font-family: ", ";\n color: ", ";\n padding-top: 2px;\n }\n\n .arrow {\n width: 20px;\n height: 20px;\n cursor: pointer;\n padding: 2px;\n\n border-radius: 5px;\n overflow: hidden;\n display: flex;\n align-items: center;\n justify-content: center;\n\n &.disabled {\n opacity: 0.5;\n filter: grayscale(1);\n cursor: not-allowed;\n }\n\n :hover {\n background-color: rgba(59, 147, 224, 0.1);\n }\n\n &.right {\n transform: rotate(180deg);\n }\n\n img {\n width: 100%;\n height: 100%;\n object-fit: contain;\n }\n\n }\n\n"])), _variables.FontFamily.AvenirNext, _variables.GlobalColors.deep_gray);
44
+
45
+ exports.OptionsContainer = OptionsContainer;
46
+
47
+ var ButtonsContainer = _styledComponents.default.div(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2.default)(["\n\n display: flex;\n align-items: center;\n gap: 0.5rem;\n\n .reload-suggestions {\n\n width: 20px;\n height: 20px;\n display: flex;\n align-items: center;\n justify-content: center;\n border-radius: 5px;\n padding: 4px;\n cursor: pointer;\n\n &.loading {\n\n filter: grayscale(1);\n opacity: 0.75;\n cursor: not-allowed;\n\n > img {\n width: 20px;\n height: 20px;\n }\n\n }\n\n :hover {\n background-color: rgba(59, 147, 224, 0.1);\n }\n\n > img {\n width: 100%;\n height: 100%;\n object-fit: contain;\n }\n\n }\n\n .accept-suggestion {\n\n text-align: center;\n padding: 4px 5px;\n cursor: pointer;\n background-color: rgba(59, 147, 224, 0.05);\n\n border-radius: 5px;\n\n :hover {\n background-color: rgba(59, 147, 224, 0.1);\n }\n\n > p {\n font-size: 11px;\n }\n }\n\n"])));
48
+
49
+ exports.ButtonsContainer = ButtonsContainer;
@@ -39,6 +39,8 @@ var _FinancedCompanies = require("./FinancedCompanies");
39
39
 
40
40
  var _variables = require("../../../global-files/variables");
41
41
 
42
+ var _AiProductEdition = require("../../../contexts/AiProductEdition");
43
+
42
44
  var _jsxRuntime = require("react/jsx-runtime");
43
45
 
44
46
  var StatusAsignationInfo = function StatusAsignationInfo(_ref) {
@@ -81,6 +83,9 @@ var StatusAsignationInfo = function StatusAsignationInfo(_ref) {
81
83
 
82
84
  var isFinanced = _FinancedCompanies.FinancedCompanies.includes(user === null || user === void 0 ? void 0 : user.id_company);
83
85
 
86
+ var _useAiProductEdition = (0, _AiProductEdition.useAiProductEdition)(),
87
+ inputsUsingAi = _useAiProductEdition.inputsUsingAi;
88
+
84
89
  var closeAsignations = function closeAsignations(e) {
85
90
  if (!e.target.closest("#default-id") && showAsignationPanel) {
86
91
  document.removeEventListener("click", closeAsignations, false);
@@ -126,7 +131,12 @@ var StatusAsignationInfo = function StatusAsignationInfo(_ref) {
126
131
  ovalForm: true
127
132
  }), showSaveButton && !isFinanced && /*#__PURE__*/(0, _jsxRuntime.jsx)(_GeneralButton.Button, {
128
133
  buttonType: "circular-button save-button",
129
- onClick: onClickSave
134
+ onClick: function onClick() {
135
+ if (Object.values(inputsUsingAi).some(function (input) {
136
+ return !!(input !== null && input !== void 0 && input.using);
137
+ })) return console.warn("Para guardar se debe de dejar de usar la generación con IA");
138
+ onClickSave();
139
+ }
130
140
  }), imagesSection && /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
131
141
  className: "images-buttons",
132
142
  children: [showSaveButton && /*#__PURE__*/(0, _jsxRuntime.jsx)(_GeneralButton.Button, {
@@ -40,17 +40,6 @@ var TabsMenu = function TabsMenu(_ref) {
40
40
  sections = _useState2[0],
41
41
  setSections = _useState2[1];
42
42
 
43
- (0, _react.useEffect)(function () {
44
- if (!activeTab) return;
45
- setSections(function (prev) {
46
- var updated = {};
47
- Object.keys(prev).forEach(function (key) {
48
- updated[key] = key === activeTab;
49
- });
50
- return updated;
51
- });
52
- }, [activeTab]);
53
-
54
43
  var _useState3 = (0, _react.useState)(false),
55
44
  _useState4 = (0, _slicedToArray2.default)(_useState3, 2),
56
45
  modal = _useState4[0],
@@ -69,7 +58,19 @@ var TabsMenu = function TabsMenu(_ref) {
69
58
  var _useState9 = (0, _react.useState)(),
70
59
  _useState10 = (0, _slicedToArray2.default)(_useState9, 2),
71
60
  objeto = _useState10[0],
72
- setObjeto = _useState10[1];
61
+ setObjeto = _useState10[1]; // Sincronizar sections cuando activeTab cambia desde el exterior
62
+
63
+
64
+ (0, _react.useEffect)(function () {
65
+ if (activeTab && Object.keys(tabsSections).length > 0) {
66
+ var tempArray = {};
67
+ Object.keys(tabsSections).forEach(function (section) {
68
+ tempArray[section] = section === activeTab;
69
+ });
70
+ setSections(tempArray);
71
+ setImagesSection(activeTab === "Imágenes");
72
+ }
73
+ }, [activeTab, tabsSections]);
73
74
 
74
75
  var activeSection = function activeSection(key) {
75
76
  var array = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};