contentoh-components-library 21.5.97 → 21.5.99

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 (63) hide show
  1. package/dist/components/atoms/GeneralButton/styles.js +1 -1
  2. package/dist/components/atoms/GeneralInput/index.js +54 -249
  3. package/dist/components/atoms/GeneralInput/styles.js +3 -7
  4. package/dist/components/atoms/InputFormatter/index.js +68 -223
  5. package/dist/components/atoms/InputFormatter/styles.js +4 -20
  6. package/dist/components/molecules/StatusAsignationInfo/index.js +1 -11
  7. package/dist/components/molecules/TabsMenu/index.js +1 -13
  8. package/dist/components/molecules/TagAndInput/index.js +24 -364
  9. package/dist/components/molecules/TagAndInput/styles.js +2 -2
  10. package/dist/components/organisms/FullProductNameHeader/index.js +22 -6
  11. package/dist/components/organisms/InputGroup/index.js +18 -22
  12. package/dist/components/pages/ProviderProductEdition/ProviderProductEdition.stories.js +337 -150
  13. package/dist/components/pages/ProviderProductEdition/context/provider-product-edition.context.js +15 -15
  14. package/dist/components/pages/ProviderProductEdition/index.js +376 -412
  15. package/dist/components/pages/ProviderProductEdition/utils.js +0 -1
  16. package/dist/components/pages/RetailerProductEdition/RetailerProductEdition.stories.js +211 -125
  17. package/dist/components/pages/RetailerProductEdition/index.js +2236 -1738
  18. package/dist/components/pages/RetailerProductEdition/styles.js +2 -4
  19. package/dist/components/pages/RetailerProductEdition/utils.js +2 -251
  20. package/package.json +2 -4
  21. package/src/components/atoms/GeneralButton/styles.js +0 -4
  22. package/src/components/atoms/GeneralInput/index.js +60 -241
  23. package/src/components/atoms/GeneralInput/styles.js +0 -81
  24. package/src/components/atoms/InputFormatter/index.js +51 -200
  25. package/src/components/atoms/InputFormatter/styles.js +0 -284
  26. package/src/components/molecules/StatusAsignationInfo/index.js +1 -9
  27. package/src/components/molecules/TabsMenu/index.js +0 -12
  28. package/src/components/molecules/TagAndInput/index.js +21 -294
  29. package/src/components/molecules/TagAndInput/styles.js +17 -59
  30. package/src/components/organisms/FullProductNameHeader/index.js +28 -4
  31. package/src/components/organisms/FullTabsMenu/index.js +1 -1
  32. package/src/components/organisms/InputGroup/index.js +4 -12
  33. package/src/components/pages/ProviderProductEdition/ProviderProductEdition.stories.js +202 -174
  34. package/src/components/pages/ProviderProductEdition/context/provider-product-edition.context.jsx +14 -14
  35. package/src/components/pages/ProviderProductEdition/index.js +420 -494
  36. package/src/components/pages/ProviderProductEdition/utils.js +2 -2
  37. package/src/components/pages/RetailerProductEdition/RetailerProductEdition.stories.js +243 -136
  38. package/src/components/pages/RetailerProductEdition/index.js +1717 -1563
  39. package/src/components/pages/RetailerProductEdition/styles.js +2 -67
  40. package/src/components/pages/RetailerProductEdition/utils.js +0 -240
  41. package/src/ai/utils/compare-strings.js +0 -45
  42. package/src/assets/images/Icons/arrow.png +0 -0
  43. package/src/assets/images/Icons/cancel.png +0 -0
  44. package/src/assets/images/Icons/ia-icon.png +0 -0
  45. package/src/assets/images/Icons/loading.svg +0 -5
  46. package/src/assets/images/Icons/reload.png +0 -0
  47. package/src/components/atoms/RetailerSelector/RetailerSelector.stories.js +0 -10
  48. package/src/components/atoms/RetailerSelector/index.js +0 -3
  49. package/src/components/atoms/RetailerSelector/styles.js +0 -0
  50. package/src/components/organisms/ChangeStatusModal/index.jsx +0 -488
  51. package/src/components/organisms/ChangeStatusModal/styles.js +0 -333
  52. package/src/components/pages/RetailerProductEdition/context/provider-product-edition.context.jsx +0 -575
  53. package/src/components/pages/RetailerProductEdition/context/provider-product-edition.reducer.js +0 -62
  54. package/src/components/pages/RetailerProductEdition/context/reducers/active-state.js +0 -344
  55. package/src/components/pages/RetailerProductEdition/context/reducers/inputs.js +0 -155
  56. package/src/components/pages/RetailerProductEdition/context/reducers/product.js +0 -114
  57. package/src/components/pages/RetailerProductEdition/context/reducers/system.js +0 -60
  58. package/src/components/pages/RetailerProductEdition/index_old.js +0 -1979
  59. package/src/components/pages/RetailerProductEdition/stories/Auditor.stories.js +0 -101
  60. package/src/components/pages/RetailerProductEdition/stories/ImageEditor.stories.js +0 -115
  61. package/src/components/pages/RetailerProductEdition/stories/TextEditor.stories.js +0 -174
  62. package/src/contexts/AiProductEdition.jsx +0 -347
  63. package/src/global-files/statusDictionary.js +0 -103
@@ -1,5 +1,4 @@
1
1
  import styled from "styled-components";
2
- import { FontFamily, GlobalColors } from "../../../global-files/variables";
3
2
 
4
3
  export const Container = styled.div`
5
4
  display: flex;
@@ -21,8 +20,7 @@ export const Container = styled.div`
21
20
  }
22
21
 
23
22
  .product-information {
24
- width: 100%;
25
- height: 100%;
23
+ width: calc(100% - 341px);
26
24
  display: flex;
27
25
  flex-direction: column;
28
26
 
@@ -48,12 +46,6 @@ export const Container = styled.div`
48
46
  padding: 10px;
49
47
  padding-left: 0;
50
48
 
51
- .action-buttons{
52
- display: flex;
53
- flex-direction: column;
54
- gap: 1rem;
55
- }
56
-
57
49
  .commentary {
58
50
  display: flex;
59
51
  align-items: flex-end;
@@ -95,23 +87,6 @@ export const Container = styled.div`
95
87
  .feedback-box {
96
88
  display: flex;
97
89
  }
98
-
99
- .required-inputs-message {
100
- font-family: ${FontFamily.AvenirNext};
101
- font-size: 13px;
102
- color: ${GlobalColors.color_gray};
103
- padding: 10px;
104
- display: flex;
105
- align-items: center;
106
-
107
- p + * {
108
- margin-top: 10px;
109
- }
110
-
111
- button {
112
- min-width: fit-content;
113
- }
114
- }
115
90
  }
116
91
  }
117
92
  #modal-message-box {
@@ -120,50 +95,10 @@ export const Container = styled.div`
120
95
  }
121
96
  .container {
122
97
  width: 100%;
123
- height: 90%;
98
+ height: 100%;
124
99
  .dropzone {
125
100
  height: 100%;
126
101
  width: 100%;
127
- position: relative;
128
- transition: all 0.5s ease;
129
-
130
- &.drag-active {
131
- background-color: rgba(${GlobalColors.rgb_color_pink}, 0.05);
132
- border: 2px dashed ${GlobalColors.color_pink};
133
- border-radius: 8px;
134
-
135
- aside {
136
- opacity: 0.3;
137
- pointer-events: none;
138
- }
139
- }
140
-
141
- .drag-overlay {
142
- position: absolute;
143
- top: 0;
144
- left: 0;
145
- right: 0;
146
- bottom: 0;
147
- display: flex;
148
- align-items: center;
149
- justify-content: center;
150
- background-color: rgba(${GlobalColors.rgb_color_pink}, 0.1);
151
- border-radius: 8px;
152
- pointer-events: none;
153
- z-index: 10;
154
-
155
- p {
156
- font-family: ${FontFamily.AvenirNext};
157
- font-size: 24px;
158
- font-weight: 600;
159
- color: ${GlobalColors.color_pink};
160
- text-align: center;
161
- padding: 20px;
162
- background-color: ${GlobalColors.white};
163
- border-radius: 8px;
164
- box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
165
- }
166
- }
167
102
  }
168
103
  }
169
104
  `;
@@ -69,243 +69,3 @@ export const sendMessage = async (data) => {
69
69
  paramsHeader
70
70
  );
71
71
  };
72
-
73
- export const normalizeProduct = (product) => {
74
- // Handle case where product might be wrapped in a product property
75
- const productData = product.product || product;
76
- const article = productData.article || {};
77
-
78
- const categoryRetailer =
79
- productData.categoryRetailer || article.categoryRetailer;
80
-
81
- const categoryRetailerNormalized = categoryRetailer
82
- ? categoryRetailer.map((rel) => ({
83
- id_retailer: rel.id_retailer || rel.retailer_id,
84
- retailer: rel.retailer_name || rel.retailerName,
85
- name: rel.retailer_name || rel.retailerName,
86
- id_category: rel.id_category,
87
- category: rel.category_name || rel.categoryName,
88
- image: `https://content-management-images.s3.amazonaws.com/retailers/${
89
- rel.id_retailer || rel.retailer_id
90
- }.png`,
91
- }))
92
- : null;
93
-
94
- // extraer los retailer_id de statusByRetailer donde task_group_id no sea nulo
95
- const retailersIdsInOrder = productData.statusByRetailer
96
- ? productData.statusByRetailer.map((status) => status.retailer_id)
97
- : [];
98
-
99
- const categoryRetailerInOrder = categoryRetailerNormalized.filter((rel) =>
100
- retailersIdsInOrder.includes(rel.id_retailer)
101
- );
102
-
103
- return {
104
- id_article: productData.id_article || article.id_article || 0,
105
- upc: productData.upc || article.upc || null,
106
- sku: productData.sku || article.sku || null,
107
- name: productData.name || article.name || null,
108
- timestamp: productData.timestamp || article.timestamp || null,
109
- id_user: productData.id_user || article.id_user || null,
110
- categoryName: productData.category || article.category || null,
111
- id_category: productData.id_category || article.id_category || null,
112
- retailersAvailable: productData.retailersAvailable || null,
113
- categoryRetailer: categoryRetailerNormalized || null,
114
- percentages: productData.percentages || null,
115
- summary: productData.summary || null,
116
- version: productData.version || 0,
117
- id_order: productData.orderId || 0,
118
- status: productData.status || null,
119
- datasheet_status: productData.datasheet_status || null,
120
- description_status: productData.description_status || null,
121
- images_status: productData.images_status || null,
122
- brand: productData.brand || null,
123
- services: productData.services || null,
124
- country: article.country || null,
125
- id_company: article.company_id || null,
126
- company: article.company_name || null,
127
- id_datasheet_especialist: article.id_datasheet_especialist || 0,
128
- id_datasheet_facilitator: article.id_datasheet_facilitator || null,
129
- id_description_especialist: article.id_description_especialist || 0,
130
- id_description_facilitator: article.id_description_facilitator || null,
131
- id_images_especialist: article.id_images_especialist || 0,
132
- id_images_facilitator: article.id_images_facilitator || null,
133
- id_auditor: article.id_auditor || 0,
134
- statusByRetailer: productData.statusByRetailer || null,
135
- categoryRetailerInOrder: categoryRetailerInOrder || null,
136
- };
137
- };
138
-
139
- const TAB_TO_CONCEPT = {
140
- Descripción: "description",
141
- "Ficha técnica": "datasheet",
142
- Imágenes: "images",
143
- };
144
-
145
- const CONCEPT_TO_TAB = {
146
- description: "Descripción",
147
- datasheet: "Ficha técnica",
148
- images: "Imágenes",
149
- };
150
-
151
- export const getConceptByTab = (tab) => TAB_TO_CONCEPT[tab];
152
-
153
- export const translateConcept = (concept) => CONCEPT_TO_TAB[concept];
154
-
155
- export const getStatusArrayByRole = (idRole) => {
156
- switch (idRole) {
157
- case 7:
158
- case 8:
159
- return ["PA", "AS", "CA", "RC", "RA", "RP", "RCA"];
160
- case 4:
161
- case 5:
162
- return ["RC", "AC", "AA", "AP", "ACA"];
163
- case 6:
164
- return ["RP", "RCA", "AC", "RA"];
165
- default:
166
- return [];
167
- }
168
- };
169
-
170
- export const getConceptsByRole = (idRole) => {
171
- switch (idRole) {
172
- case 4:
173
- return ["description", "datasheet"];
174
- case 5:
175
- return ["images"];
176
- default:
177
- return ["description", "datasheet", "images"];
178
- }
179
- };
180
-
181
- export const buildCollaboratorAssignations = (product, users) => ({
182
- Descripción: {
183
- assignations: [
184
- {
185
- collaboratorType: "especialist",
186
- id: product.id_description_especialist,
187
- },
188
- {
189
- collaboratorType: "facilitator",
190
- id: product.id_description_facilitator,
191
- },
192
- ],
193
- collaborators: {
194
- especialist: users[0] || [],
195
- facilitator: users[2] || [],
196
- },
197
- },
198
- "Ficha técnica": {
199
- assignations: [
200
- {
201
- collaboratorType: "especialist",
202
- id: product.id_datasheet_especialist,
203
- },
204
- {
205
- collaboratorType: "facilitator",
206
- id: product.id_datasheet_facilitator,
207
- },
208
- ],
209
- collaborators: {
210
- especialist: users[0] || [],
211
- facilitator: users[2] || [],
212
- },
213
- },
214
- Imágenes: {
215
- assignations: [
216
- {
217
- collaboratorType: "especialist",
218
- id: product.id_images_especialist,
219
- },
220
- {
221
- collaboratorType: "facilitator",
222
- id: product.id_images_facilitator,
223
- },
224
- ],
225
- collaborators: {
226
- especialist: users[1] || [],
227
- facilitator: users[3] || [],
228
- },
229
- },
230
- });
231
-
232
- export const calculateRequiredNull = (services, servicesData, activeRetailerId) => {
233
- const result = {
234
- "Ficha técnica": 0,
235
- Descripción: 0,
236
- Imágenes: 0,
237
- };
238
-
239
- const isServiceRequested = (retailerId, concept) =>
240
- servicesData?.some(
241
- (srv) => srv.id_retailer === retailerId && srv.service === concept
242
- );
243
-
244
- // Ficha técnica: contar inputs requeridos sin valor
245
- const datasheetInputs = services[0]?.inputs || {};
246
- const datasheetsByRetailer = Object.values(services[0]).filter(
247
- (item) => item?.retailer?.id === activeRetailerId
248
- );
249
-
250
- datasheetsByRetailer.forEach((datasheet) => {
251
- if (!isServiceRequested(datasheet.retailer?.id, "datasheet")) return;
252
-
253
- Object.values(datasheet.data || {}).forEach((dataGroup) => {
254
- dataGroup.inputs?.forEach((inputId) => {
255
- const input = datasheetInputs[inputId];
256
- if (
257
- input?.required &&
258
- input?.id_retailer === activeRetailerId &&
259
- !input?.value
260
- ) {
261
- result["Ficha técnica"]++;
262
- }
263
- });
264
- });
265
- });
266
-
267
- // Descripción: contar inputs requeridos sin valor
268
- const htmlTagsRegex = /(<\/?p>)|(<\/?strong>)|(<br>)/gm;
269
- const descriptions = services[1]?.filter(
270
- (desc) => desc.id === activeRetailerId
271
- );
272
-
273
- descriptions?.forEach((description) => {
274
- if (!isServiceRequested(description.id, "description")) return;
275
-
276
- description.inputs?.forEach((input) => {
277
- const valueClean = input.value?.replace(htmlTagsRegex, "") || "";
278
- if (input.required && !valueClean) {
279
- result["Descripción"]++;
280
- }
281
- });
282
- });
283
-
284
- // Imágenes: contar imágenes requeridas sin valor
285
- const retailerMandatories = services[2]?.retailerMandatories?.flat() || [];
286
- const requestedRetailers = retailerMandatories.filter((rm) =>
287
- servicesData?.some((srv) => srv.id_retailer === rm.id_retailer)
288
- );
289
-
290
- const requiredImageIds = new Set(
291
- requestedRetailers
292
- .filter((rm) =>
293
- services[2]?.inputs?.some(
294
- (input) => input.id === rm.id_image && input.required === 1
295
- )
296
- )
297
- .map((rm) => rm.id_image)
298
- );
299
-
300
- const existingImageIds = new Set(
301
- services[2]?.values?.map((img) => img.image_id) || []
302
- );
303
-
304
- requiredImageIds.forEach((imageId) => {
305
- if (!existingImageIds.has(imageId)) {
306
- result["Imágenes"]++;
307
- }
308
- });
309
-
310
- return result;
311
- };
@@ -1,45 +0,0 @@
1
-
2
- //Calcula el porcentaje de similitud entre la descripción generada por IA y la versión editada por el usuario.
3
-
4
- export function getTextSimilarityPercentage(originalText, candidateText) {
5
-
6
- if(!originalText || !candidateText) return;
7
-
8
- const normalize = (text) => {
9
- return text
10
- .trim()
11
- .toLowerCase()
12
- .replace(/\s+/g, ' ');
13
- };
14
-
15
- const source = normalize(originalText);
16
- const target = normalize(candidateText);
17
-
18
- if (source === target) return 100;
19
- if (source.length === 0 || target.length === 0) return 0;
20
-
21
- const sourceLength = source.length;
22
- const targetLength = target.length;
23
- const distanceMatrix = Array(targetLength + 1).fill(null).map(() => []);
24
-
25
- for (let i = 0; i <= sourceLength; i++) distanceMatrix[0][i] = i;
26
- for (let j = 0; j <= targetLength; j++) distanceMatrix[j][0] = j;
27
-
28
- for (let j = 1; j <= targetLength; j++) {
29
- for (let i = 1; i <= sourceLength; i++) {
30
- const substitutionCost = (source[i - 1] === target[j - 1]) ? 0 : 1;
31
-
32
- distanceMatrix[j][i] = Math.min(
33
- distanceMatrix[j - 1][i] + 1,
34
- distanceMatrix[j][i - 1] + 1,
35
- distanceMatrix[j - 1][i - 1] + substitutionCost
36
- );
37
- }
38
- }
39
-
40
- const editDistance = distanceMatrix[targetLength][sourceLength];
41
- const maxLength = Math.max(sourceLength, targetLength);
42
- const similarityScore = 1 - (editDistance / maxLength);
43
-
44
- return similarityScore * 100;
45
- }
Binary file
Binary file
Binary file
@@ -1,5 +0,0 @@
1
- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" preserveAspectRatio="xMidYMid" width="283" height="283" style="shape-rendering: auto; display: block; background: transparent;" xmlns:xlink="http://www.w3.org/1999/xlink"><g><g>
2
- <path stroke-width="10" stroke="#e13aa7" fill="none" d="M50 27A23 23 0 1 0 69.9785248320784 38.604450626054636"></path>
3
- <path fill="#e13aa7" d="M49 15L49 39L61 27L49 15"></path>
4
- <animateTransform keyTimes="0;1" values="0 50 50;360 50 50" dur="0.9803921568627451s" repeatCount="indefinite" type="rotate" attributeName="transform"></animateTransform>
5
- </g><g></g></g><!-- [ldio] generated by https://loading.io --></svg>
Binary file
@@ -1,10 +0,0 @@
1
- import { RetailerSelector } from ".";
2
-
3
- export default {
4
- component: RetailerSelector,
5
- parameters: {
6
- layout: "centered",
7
- },
8
- };
9
-
10
- export const Default = {};
@@ -1,3 +0,0 @@
1
- export const RetailerSelector = () => {
2
- return <div>RetailerSelector Component</div>;
3
- };
File without changes