contentoh-components-library 21.5.78 → 21.5.81
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ai/utils/compare-strings.js +43 -0
- package/dist/components/atoms/GeneralInput/index.js +64 -36
- package/dist/components/atoms/GeneralInput/styles.js +1 -1
- package/dist/components/atoms/InputFormatter/index.js +45 -21
- package/dist/components/atoms/InputFormatter/styles.js +1 -1
- package/dist/components/molecules/StatusAsignationInfo/index.js +11 -1
- package/dist/components/molecules/TagAndInput/index.js +110 -29
- package/dist/components/molecules/TagAndInput/styles.js +2 -2
- package/dist/components/organisms/InputGroup/index.js +22 -18
- package/dist/components/pages/RetailerProductEdition/RetailerProductEdition.stories.js +92 -785
- package/dist/components/pages/RetailerProductEdition/context/provider-product-edition.context.js +59 -260
- package/dist/components/pages/RetailerProductEdition/context/reducers/product.js +3 -41
- package/dist/components/pages/RetailerProductEdition/index.js +191 -123
- package/dist/contexts/AiProductEdition.js +179 -155
- package/package.json +1 -1
- package/src/ai/utils/compare-strings.js +43 -0
- package/src/components/atoms/GeneralInput/index.js +63 -42
- package/src/components/atoms/GeneralInput/styles.js +7 -0
- package/src/components/atoms/InputFormatter/index.js +51 -23
- package/src/components/atoms/InputFormatter/styles.js +62 -10
- package/src/components/molecules/StatusAsignationInfo/index.js +9 -1
- package/src/components/molecules/TagAndInput/index.js +113 -28
- package/src/components/molecules/TagAndInput/styles.js +48 -17
- package/src/components/organisms/FullTabsMenu/index.js +1 -1
- package/src/components/organisms/InputGroup/index.js +4 -0
- package/src/components/pages/RetailerProductEdition/RetailerProductEdition.stories.js +111 -832
- package/src/components/pages/RetailerProductEdition/context/provider-product-edition.context.jsx +3 -221
- package/src/components/pages/RetailerProductEdition/context/reducers/product.js +3 -43
- package/src/components/pages/RetailerProductEdition/index.js +17 -15
- package/src/contexts/AiProductEdition.jsx +138 -96
- package/src/ai/prompts/attribute.prompt.js +0 -46
- package/src/ai/prompts/description.prompt.js +0 -52
- package/src/ai/schemas/attribute.schema.js +0 -23
- package/src/ai/schemas/description.schema.js +0 -19
|
@@ -9,6 +9,7 @@ import { SliderToolTip } from "../../atoms/SliderToolTip";
|
|
|
9
9
|
import { Tooltip } from "../../atoms/Tooltip";
|
|
10
10
|
|
|
11
11
|
import { useAiProductEdition } from "../../../contexts/AiProductEdition";
|
|
12
|
+
import AiGenerationIcon from "../../../assets/images/Icons/ia-icon.png";
|
|
12
13
|
|
|
13
14
|
|
|
14
15
|
export const TagAndInput = ({
|
|
@@ -30,6 +31,7 @@ export const TagAndInput = ({
|
|
|
30
31
|
inputRows,
|
|
31
32
|
maxChar,
|
|
32
33
|
required,
|
|
34
|
+
aiGenerated,
|
|
33
35
|
optionList,
|
|
34
36
|
description,
|
|
35
37
|
inputOnChange,
|
|
@@ -54,7 +56,12 @@ export const TagAndInput = ({
|
|
|
54
56
|
suggestions,
|
|
55
57
|
setSuggestions,
|
|
56
58
|
currentSuggestion,
|
|
57
|
-
setCurrentSuggestionValue
|
|
59
|
+
setCurrentSuggestionValue,
|
|
60
|
+
isAiAvailable,
|
|
61
|
+
inputsGeneratedWithAi,
|
|
62
|
+
setInputsGeneratedWithAi,
|
|
63
|
+
inputsUsingAi,
|
|
64
|
+
setInputsUsingAi
|
|
58
65
|
} = useAiProductEdition();
|
|
59
66
|
|
|
60
67
|
const isBenefitInput = label?.toLowerCase().includes("beneficios");
|
|
@@ -62,12 +69,13 @@ export const TagAndInput = ({
|
|
|
62
69
|
const [isAiGenerationLoading, setIsAiGenerationLoading] = useState(false);
|
|
63
70
|
const [isAiActive, setIsAiActive] = useState(false);
|
|
64
71
|
const [isAiRegenerationLoading, setIsAiRegenerationLoading] = useState(false);
|
|
72
|
+
const [isAiGenerated, setIsAiGenerated] = useState(false);
|
|
65
73
|
|
|
66
74
|
async function handlerAiGeneration({
|
|
67
75
|
type
|
|
68
76
|
}) {
|
|
69
77
|
|
|
70
|
-
if(isAiGenerationLoading) return;
|
|
78
|
+
if(isAiGenerationLoading || !isAiAvailable) return;
|
|
71
79
|
|
|
72
80
|
if(isAiActive) {
|
|
73
81
|
setIsAiActive(false);
|
|
@@ -87,7 +95,12 @@ export const TagAndInput = ({
|
|
|
87
95
|
currentValue: value,
|
|
88
96
|
description: description,
|
|
89
97
|
maxChar: maxChar ?? 99,
|
|
90
|
-
type: type
|
|
98
|
+
type: type,
|
|
99
|
+
// Informacion del producto
|
|
100
|
+
articleId: articleId,
|
|
101
|
+
versionId: version,
|
|
102
|
+
descriptionId: !isBenefitInput ? inputId : null,
|
|
103
|
+
attributeId: isBenefitInput ? inputId : null
|
|
91
104
|
});
|
|
92
105
|
|
|
93
106
|
if(!aiSuggestions && aiSuggestions.length === 0) {
|
|
@@ -118,14 +131,24 @@ export const TagAndInput = ({
|
|
|
118
131
|
const currentSuggestions = suggestions?.[inputId];
|
|
119
132
|
|
|
120
133
|
const aiSuggestions = await regenerateProductSuggestions({
|
|
121
|
-
inputId,
|
|
122
134
|
inputName: label,
|
|
123
135
|
currentValue: value,
|
|
124
|
-
description,
|
|
125
|
-
maxChar,
|
|
126
|
-
type
|
|
136
|
+
description: description,
|
|
137
|
+
maxChar: maxChar ?? 99,
|
|
138
|
+
type: type,
|
|
139
|
+
//Información del producto
|
|
140
|
+
articleId,
|
|
141
|
+
versionId: version,
|
|
142
|
+
descriptionId: !isBenefitInput ? inputId : null,
|
|
143
|
+
attributeId: isBenefitInput ? inputId : null
|
|
127
144
|
});
|
|
128
145
|
|
|
146
|
+
if(!aiSuggestions && aiSuggestions.length === 0) {
|
|
147
|
+
console.log("Error: No se recibieron sugerencias de IA");
|
|
148
|
+
setIsAiRegenerationLoading(false);
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
|
|
129
152
|
setSuggestions(prev => ({
|
|
130
153
|
...prev,
|
|
131
154
|
[inputId]: [
|
|
@@ -205,10 +228,60 @@ export const TagAndInput = ({
|
|
|
205
228
|
);
|
|
206
229
|
}
|
|
207
230
|
}, []);
|
|
231
|
+
|
|
208
232
|
useEffect(() => {
|
|
209
233
|
onChange && onChange(boxOnboardingList);
|
|
210
234
|
}, [boxOnboardingList]);
|
|
211
235
|
|
|
236
|
+
useEffect(() => {
|
|
237
|
+
|
|
238
|
+
if(Array.isArray(updatedDescriptions)) {
|
|
239
|
+
|
|
240
|
+
const currentDescriptionUpdate = updatedDescriptions.find(
|
|
241
|
+
description => description?.attributeId === inputId
|
|
242
|
+
);
|
|
243
|
+
|
|
244
|
+
const calculatedIsAiGenerated = currentDescriptionUpdate
|
|
245
|
+
? !!currentDescriptionUpdate.aiSuggestionAccepted
|
|
246
|
+
: aiGenerated;
|
|
247
|
+
|
|
248
|
+
setInputsGeneratedWithAi(prev => ({
|
|
249
|
+
...prev,
|
|
250
|
+
[`${inputId}-${inputType}-${version}`]: {
|
|
251
|
+
inputType,
|
|
252
|
+
inputId,
|
|
253
|
+
version,
|
|
254
|
+
isAiGenerated: calculatedIsAiGenerated,
|
|
255
|
+
label
|
|
256
|
+
}
|
|
257
|
+
}))
|
|
258
|
+
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
if(Array.isArray(updatedDatasheets) && updatedDatasheets.length > 0) {
|
|
262
|
+
console.log({isAiGenerated, updatedDatasheets});
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
}, [updatedDescriptions, updatedDatasheets, aiGenerated, inputId]);
|
|
266
|
+
|
|
267
|
+
|
|
268
|
+
useEffect(() => {
|
|
269
|
+
|
|
270
|
+
setIsAiGenerated(!!inputsGeneratedWithAi[`${inputId}-${inputType}-${version}`]?.isAiGenerated);
|
|
271
|
+
|
|
272
|
+
}, [inputsGeneratedWithAi]);
|
|
273
|
+
|
|
274
|
+
useEffect(() => {
|
|
275
|
+
|
|
276
|
+
setInputsUsingAi(prev => ({
|
|
277
|
+
...prev,
|
|
278
|
+
[`${inputId}-${inputType}-${version}`]: {
|
|
279
|
+
using: isAiActive
|
|
280
|
+
}
|
|
281
|
+
}))
|
|
282
|
+
|
|
283
|
+
}, [isAiActive])
|
|
284
|
+
|
|
212
285
|
return (
|
|
213
286
|
<Container
|
|
214
287
|
inputType={inputType}
|
|
@@ -217,28 +290,38 @@ export const TagAndInput = ({
|
|
|
217
290
|
>
|
|
218
291
|
{label?.length && (
|
|
219
292
|
<div className="title-container">
|
|
220
|
-
<
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
{description && (
|
|
226
|
-
<Tooltip
|
|
227
|
-
componentTooltip={
|
|
228
|
-
<>
|
|
229
|
-
<p>{description}</p>
|
|
230
|
-
</>
|
|
231
|
-
}
|
|
232
|
-
children={
|
|
233
|
-
<img
|
|
234
|
-
src={InfoIcon}
|
|
235
|
-
alt="info icon"
|
|
236
|
-
className={'icon_information'}
|
|
237
|
-
/>
|
|
238
|
-
}
|
|
239
|
-
classNameTooltip={"container-tooltip"}
|
|
293
|
+
<div className="titles">
|
|
294
|
+
<ScreenHeader
|
|
295
|
+
text={label}
|
|
296
|
+
headerType={"input-name-header"}
|
|
297
|
+
color={color}
|
|
240
298
|
/>
|
|
241
|
-
|
|
299
|
+
{description && (
|
|
300
|
+
<Tooltip
|
|
301
|
+
componentTooltip={
|
|
302
|
+
<>
|
|
303
|
+
<p>{description}</p>
|
|
304
|
+
</>
|
|
305
|
+
}
|
|
306
|
+
children={
|
|
307
|
+
<img
|
|
308
|
+
src={InfoIcon}
|
|
309
|
+
alt="info icon"
|
|
310
|
+
className={'icon_information'}
|
|
311
|
+
/>
|
|
312
|
+
}
|
|
313
|
+
classNameTooltip={"container-tooltip"}
|
|
314
|
+
/>
|
|
315
|
+
)}
|
|
316
|
+
</div>
|
|
317
|
+
{
|
|
318
|
+
isCreators && isAiGenerated ? (
|
|
319
|
+
<div className="ai-generated">
|
|
320
|
+
<img src={AiGenerationIcon} />
|
|
321
|
+
<p>Atributo generado con IA</p>
|
|
322
|
+
</div>
|
|
323
|
+
) : null
|
|
324
|
+
}
|
|
242
325
|
</div>
|
|
243
326
|
)}
|
|
244
327
|
<GeneralInput
|
|
@@ -272,6 +355,8 @@ export const TagAndInput = ({
|
|
|
272
355
|
isAiRegenerationLoading={isAiRegenerationLoading}
|
|
273
356
|
isAiActive={isAiActive}
|
|
274
357
|
setIsAiActive={setIsAiActive}
|
|
358
|
+
isAiAvailable={isAiAvailable}
|
|
359
|
+
aiGenerated={aiGenerated}
|
|
275
360
|
// aiSuggestions={aiSuggestions}
|
|
276
361
|
handlerAiGeneration={handlerAiGeneration}
|
|
277
362
|
handlerRegenerateSuggestions={handlerRegenerateSuggestions}
|
|
@@ -7,26 +7,55 @@ export const Container = styled.div`
|
|
|
7
7
|
|
|
8
8
|
display: flex;
|
|
9
9
|
align-items: center;
|
|
10
|
-
|
|
10
|
+
justify-content: space-between;
|
|
11
11
|
|
|
12
|
-
.
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
font-family: ${FontFamily.Raleway};
|
|
13
|
+
|
|
14
|
+
.titles{
|
|
15
|
+
display: flex;
|
|
16
|
+
gap: .5rem;
|
|
17
|
+
align-items: center;
|
|
16
18
|
}
|
|
17
19
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
20
|
+
.icon_information{
|
|
21
|
+
width: 1.35rem;
|
|
22
|
+
height: 1.35rem;
|
|
23
|
+
filter: brightness(.35);
|
|
24
|
+
margin-top: 10px;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.tooltip {
|
|
28
|
+
display: none;
|
|
29
|
+
position: absolute;
|
|
30
|
+
background-color: ${GlobalColors.white};
|
|
31
|
+
color: ${({ color }) => (color ? color : GlobalColors.s5)};
|
|
32
|
+
font-size: 14px;
|
|
33
|
+
line-height: 19px;
|
|
34
|
+
left: 0;
|
|
35
|
+
top: 0;
|
|
36
|
+
height: fit-content;
|
|
37
|
+
transition: display 2s;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.ai-generated{
|
|
41
|
+
|
|
42
|
+
display: flex;
|
|
43
|
+
align-items: items-center;
|
|
44
|
+
gap: .5rem;
|
|
45
|
+
font-size: 11px;
|
|
46
|
+
background-color: rgba(224, 57, 167, 0.025);
|
|
47
|
+
border: 1px solid rgba(224, 57, 167, 0.1);
|
|
48
|
+
padding: .25rem .5rem;
|
|
49
|
+
border-radius: 5px;
|
|
50
|
+
margin-left: 0.5rem;
|
|
51
|
+
margin-top: 7px;
|
|
52
|
+
cursor: default;
|
|
53
|
+
|
|
54
|
+
> img {
|
|
55
|
+
width: 0.75rem;
|
|
56
|
+
height: 0.75rem;
|
|
57
|
+
}
|
|
58
|
+
|
|
30
59
|
}
|
|
31
60
|
|
|
32
61
|
&:hover {
|
|
@@ -34,6 +63,8 @@ export const Container = styled.div`
|
|
|
34
63
|
display: block;
|
|
35
64
|
}
|
|
36
65
|
}
|
|
66
|
+
|
|
67
|
+
|
|
37
68
|
}
|
|
38
69
|
|
|
39
70
|
& > :first-child {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Container } from "./styles";
|
|
2
2
|
import { TabsMenu } from "../../molecules/TabsMenu/index";
|
|
3
3
|
import { StatusAsignationInfo } from "../../molecules/StatusAsignationInfo/index";
|
|
4
|
-
import { useState } from "react";
|
|
4
|
+
import { useEffect, useState } from "react";
|
|
5
5
|
|
|
6
6
|
export const FullTabsMenu = ({
|
|
7
7
|
tabsSections,
|
|
@@ -219,6 +219,7 @@ export const InputGroup = ({
|
|
|
219
219
|
inputPlaceHolder={input?.placeholder}
|
|
220
220
|
articleId={articleId}
|
|
221
221
|
isRequired={dataInputs[input]?.required}
|
|
222
|
+
aiGenerated={dataInputs[input]?.ai_generated}
|
|
222
223
|
updatedDatasheets={updatedDatasheets}
|
|
223
224
|
setUpdatedDatasheets={setUpdatedDatasheets}
|
|
224
225
|
maxChar={
|
|
@@ -277,6 +278,7 @@ export const InputGroup = ({
|
|
|
277
278
|
: input?.value
|
|
278
279
|
}
|
|
279
280
|
isRequired={input.required}
|
|
281
|
+
aiGenerated={input?.ai_generated}
|
|
280
282
|
disabled={input.id===44186||input.id===44187?false:input?.isApproved}
|
|
281
283
|
maxChar={input.max_chars}
|
|
282
284
|
inputPlaceHolder={input?.placeholder}
|
|
@@ -352,6 +354,7 @@ export const InputGroup = ({
|
|
|
352
354
|
inputPlaceHolder={input?.placeholder}
|
|
353
355
|
articleId={articleId}
|
|
354
356
|
isRequired={dataInputs[input]?.required}
|
|
357
|
+
aiGenerated={dataInputs[input]?.ai_generated}
|
|
355
358
|
updatedDatasheets={updatedDatasheets}
|
|
356
359
|
setUpdatedDatasheets={setUpdatedDatasheets}
|
|
357
360
|
maxChar={
|
|
@@ -413,6 +416,7 @@ export const InputGroup = ({
|
|
|
413
416
|
: input?.value
|
|
414
417
|
}
|
|
415
418
|
isRequired={input.required}
|
|
419
|
+
aiGenerated={input?.ai_generated}
|
|
416
420
|
maxChar={input.max_chars}
|
|
417
421
|
inputPlaceHolder={input?.placeholder}
|
|
418
422
|
updatedDescriptions={updatedDescriptions}
|