contentoh-components-library 21.5.99 → 21.6.1

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 (64) hide show
  1. package/dist/components/atoms/GeneralButton/styles.js +1 -1
  2. package/dist/components/atoms/GeneralInput/index.js +249 -54
  3. package/dist/components/atoms/GeneralInput/styles.js +7 -3
  4. package/dist/components/atoms/InputFormatter/index.js +223 -68
  5. package/dist/components/atoms/InputFormatter/styles.js +20 -4
  6. package/dist/components/molecules/StatusAsignationInfo/index.js +11 -1
  7. package/dist/components/molecules/TabsMenu/index.js +13 -1
  8. package/dist/components/molecules/TagAndInput/index.js +364 -24
  9. package/dist/components/molecules/TagAndInput/styles.js +2 -2
  10. package/dist/components/organisms/FullProductNameHeader/index.js +6 -22
  11. package/dist/components/organisms/InputGroup/index.js +22 -18
  12. package/dist/components/pages/ProviderProductEdition/ProviderProductEdition.stories.js +150 -337
  13. package/dist/components/pages/ProviderProductEdition/context/provider-product-edition.context.js +15 -15
  14. package/dist/components/pages/ProviderProductEdition/index.js +393 -352
  15. package/dist/components/pages/ProviderProductEdition/utils.js +1 -0
  16. package/dist/components/pages/RetailerProductEdition/RetailerProductEdition.stories.js +125 -211
  17. package/dist/components/pages/RetailerProductEdition/index.js +1743 -2239
  18. package/dist/components/pages/RetailerProductEdition/styles.js +4 -2
  19. package/dist/components/pages/RetailerProductEdition/utils.js +251 -2
  20. package/dist/contexts/AiProductEdition.js +34 -22
  21. package/package.json +4 -2
  22. package/src/ai/utils/compare-strings.js +45 -0
  23. package/src/assets/images/Icons/arrow.png +0 -0
  24. package/src/assets/images/Icons/cancel.png +0 -0
  25. package/src/assets/images/Icons/ia-icon.png +0 -0
  26. package/src/assets/images/Icons/loading.svg +5 -0
  27. package/src/assets/images/Icons/reload.png +0 -0
  28. package/src/components/atoms/GeneralButton/styles.js +4 -0
  29. package/src/components/atoms/GeneralInput/index.js +241 -60
  30. package/src/components/atoms/GeneralInput/styles.js +81 -0
  31. package/src/components/atoms/InputFormatter/index.js +200 -51
  32. package/src/components/atoms/InputFormatter/styles.js +284 -0
  33. package/src/components/atoms/RetailerSelector/RetailerSelector.stories.js +10 -0
  34. package/src/components/atoms/RetailerSelector/index.js +3 -0
  35. package/src/components/atoms/RetailerSelector/styles.js +0 -0
  36. package/src/components/molecules/StatusAsignationInfo/index.js +9 -1
  37. package/src/components/molecules/TabsMenu/index.js +12 -0
  38. package/src/components/molecules/TagAndInput/index.js +294 -21
  39. package/src/components/molecules/TagAndInput/styles.js +59 -17
  40. package/src/components/organisms/ChangeStatusModal/index.jsx +488 -0
  41. package/src/components/organisms/ChangeStatusModal/styles.js +333 -0
  42. package/src/components/organisms/FullProductNameHeader/index.js +4 -28
  43. package/src/components/organisms/FullTabsMenu/index.js +1 -1
  44. package/src/components/organisms/InputGroup/index.js +12 -4
  45. package/src/components/pages/ProviderProductEdition/ProviderProductEdition.stories.js +174 -202
  46. package/src/components/pages/ProviderProductEdition/context/provider-product-edition.context.jsx +14 -14
  47. package/src/components/pages/ProviderProductEdition/index.js +486 -417
  48. package/src/components/pages/ProviderProductEdition/utils.js +2 -2
  49. package/src/components/pages/RetailerProductEdition/RetailerProductEdition.stories.js +136 -243
  50. package/src/components/pages/RetailerProductEdition/context/provider-product-edition.context.jsx +575 -0
  51. package/src/components/pages/RetailerProductEdition/context/provider-product-edition.reducer.js +62 -0
  52. package/src/components/pages/RetailerProductEdition/context/reducers/active-state.js +344 -0
  53. package/src/components/pages/RetailerProductEdition/context/reducers/inputs.js +155 -0
  54. package/src/components/pages/RetailerProductEdition/context/reducers/product.js +114 -0
  55. package/src/components/pages/RetailerProductEdition/context/reducers/system.js +60 -0
  56. package/src/components/pages/RetailerProductEdition/index.js +1580 -1719
  57. package/src/components/pages/RetailerProductEdition/index_old.js +1979 -0
  58. package/src/components/pages/RetailerProductEdition/stories/Auditor.stories.js +101 -0
  59. package/src/components/pages/RetailerProductEdition/stories/ImageEditor.stories.js +115 -0
  60. package/src/components/pages/RetailerProductEdition/stories/TextEditor.stories.js +174 -0
  61. package/src/components/pages/RetailerProductEdition/styles.js +67 -2
  62. package/src/components/pages/RetailerProductEdition/utils.js +240 -0
  63. package/src/contexts/AiProductEdition.jsx +356 -0
  64. package/src/global-files/statusDictionary.js +103 -0
@@ -69,3 +69,243 @@ 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
+ };
@@ -0,0 +1,356 @@
1
+ import { useContext, useEffect, useState } from "react";
2
+ import { createContext } from "react";
3
+ import axios from "axios";
4
+
5
+ export const AiProductEdition = createContext();
6
+
7
+ export const useAiProductEdition = () => {
8
+ const context = useContext(AiProductEdition);
9
+
10
+ if (!context) return {};
11
+
12
+ return context;
13
+ };
14
+
15
+ export const AiProductEditionProvider = ({
16
+ children,
17
+ isCreatorsEdition = false,
18
+ user = {},
19
+ token = "",
20
+ state
21
+ }) => {
22
+
23
+ const isCreators = isCreatorsEdition;
24
+
25
+ const productSelected = state.product;
26
+ const activeRetailer = state.active_retailer;
27
+ const datasheetInputs = state.datasheets_inputs?.[1];
28
+ const imagesData = state.images_values;
29
+
30
+ const [product, setProduct] = useState(null);
31
+
32
+ const [parsedDatasheet, setParsedDatasheet] = useState([]);
33
+ const [parsedImages, setParsedImages] = useState([]);
34
+
35
+ const [suggestions, setSuggestions] = useState({});
36
+ const [currentSuggestion, setCurrentSuggestion] = useState({});
37
+
38
+ const [isAiAvailable, setIsAiAvailable] = useState(false);
39
+
40
+ const [inputsGeneratedWithAi, setInputsGeneratedWithAi] = useState({});
41
+ const [inputsUsingAi, setInputsUsingAi] = useState({});
42
+
43
+ const AI_MAX_CREDITS = 2;
44
+ const AI_RESET_MS = 24 * 60 * 60 * 1000;
45
+ const RATE_LIMIT_KEY = "ai_generation_limit_data";
46
+
47
+ const checkAndManageRateLimit = ({ articleId, descriptionId, attributeId, type }) => {
48
+ const now = Date.now();
49
+ const storedData = localStorage.getItem(RATE_LIMIT_KEY);
50
+
51
+ let allRateData = storedData ? JSON.parse(storedData) : {};
52
+
53
+ const idPart = descriptionId ?? attributeId;
54
+
55
+ const key = idPart ? `${articleId}_${idPart}_${type}` : `${articleId}`;
56
+
57
+ let keyTimestamps = allRateData[key] || [];
58
+
59
+ keyTimestamps = keyTimestamps.filter(timestamp => (now - timestamp) < AI_RESET_MS);
60
+
61
+ if (keyTimestamps.length >= AI_MAX_CREDITS) {
62
+ allRateData[key] = keyTimestamps;
63
+ localStorage.setItem(RATE_LIMIT_KEY, JSON.stringify(allRateData));
64
+
65
+ return {
66
+ allowed: false,
67
+ message: idPart
68
+ ? "Has alcanzado el límite de intentos para este atributo. Vuelve a intentarlo en 24 horas."
69
+ : "Has alcanzado el límite de intentos para este producto. Vuelve a intentarlo en 24 horas."
70
+ };
71
+ }
72
+
73
+ // Registramos el intento
74
+ keyTimestamps.push(now);
75
+ allRateData[key] = keyTimestamps;
76
+ localStorage.setItem(RATE_LIMIT_KEY, JSON.stringify(allRateData));
77
+
78
+ return { allowed: true };
79
+ };
80
+
81
+ function setCurrentSuggestionValue({
82
+ inputId,
83
+ index,
84
+ value
85
+ }) {
86
+ setCurrentSuggestion(prev => ({
87
+ ...prev,
88
+ [inputId]: {
89
+ index,
90
+ value
91
+ }
92
+ }));
93
+ }
94
+
95
+ function clearCurrentSuggestions() {
96
+ setCurrentSuggestion({});
97
+ }
98
+
99
+ async function regenerateProductSuggestions ({
100
+ inputName,
101
+ currentValue,
102
+ description,
103
+ maxChar,
104
+ type,
105
+
106
+ articleId,
107
+ versionId,
108
+ descriptionId,
109
+ attributeId
110
+ }) {
111
+
112
+ if(!description || !maxChar || !type) return console.log("Error: No se obtuvieron los parametros obligatorios");
113
+
114
+ const newSuggestions = await generateProductSuggestions({
115
+ inputName,
116
+ currentValue,
117
+ description,
118
+ maxChar,
119
+ type,
120
+
121
+ articleId,
122
+ versionId,
123
+ descriptionId,
124
+ attributeId
125
+ });
126
+
127
+ if(newSuggestions?.error) return {
128
+ error: newSuggestions.error
129
+ }
130
+
131
+ if(!Array.isArray(newSuggestions) || newSuggestions.length === 0)
132
+ return console.log("Error: No se obtuvieron nuevas sugerencias");
133
+
134
+ if(!newSuggestions) return console.log("Error: No exiten resultados nuevos");
135
+
136
+ return newSuggestions;
137
+
138
+ }
139
+
140
+ async function generateProductSuggestions ({
141
+ inputName = "",
142
+ currentValue = "",
143
+ description = "",
144
+ maxChar = 100,
145
+ type = 'description',
146
+
147
+ articleId,
148
+ versionId,
149
+ descriptionId,
150
+ attributeId
151
+ }) {
152
+
153
+ try {
154
+
155
+ if(!isAiAvailable) return;
156
+
157
+ const rateLimitStatus = checkAndManageRateLimit({
158
+ articleId,
159
+ descriptionId,
160
+ attributeId,
161
+ type
162
+ });
163
+
164
+ if (!rateLimitStatus.allowed) {
165
+ return {
166
+ error: rateLimitStatus.message,
167
+ isRateLimitInfo: true
168
+ };
169
+ }
170
+
171
+ if(!product)
172
+ throw new Error("El producto no está definido");
173
+
174
+ if(!Array.isArray(parsedDatasheet) || parsedDatasheet.length === 0)
175
+ throw new Error("No es encontró la ficha técnica");
176
+
177
+ if(!Array.isArray(parsedImages) || parsedImages.length === 0)
178
+ throw new Error("No se encontraron imágenes para la cadena seleccionada");
179
+
180
+ const {
181
+ upc,
182
+ productName,
183
+ retailer,
184
+ category
185
+ } = product;
186
+
187
+ const version = state?.product?.version;
188
+
189
+ if (!upc || !description || !productName || !category || !retailer || !articleId || !version || (!descriptionId && !attributeId))
190
+ throw new Error("Faltan parámetros obligatorios para generar sugerencias de IA");
191
+
192
+ const payload = {
193
+ upc,
194
+ attributeTitle: inputName,
195
+ attributeDescription: description,
196
+ productName,
197
+ currentValue,
198
+ categoryName: category,
199
+ retailerName: retailer,
200
+ datasheet: parsedDatasheet,
201
+ images: parsedImages,
202
+ maxChar: maxChar,
203
+
204
+ articleId,
205
+ retailerId: activeRetailer?.id_retailer,
206
+ versionId: version,
207
+ descriptionId,
208
+ attributeId
209
+ }
210
+
211
+ const { data } = await axios.post(process.env.REACT_APP_GENERATE_AI_ATTRIBUTES, payload, {
212
+ headers: {
213
+ Authorization: token
214
+ }
215
+ });
216
+
217
+ const errorsRaw = JSON.parse(data?.body)?.error;
218
+
219
+ const errorMessage = errorsRaw ? JSON.parse(errorsRaw)?.error?.message : null;
220
+
221
+ if(errorMessage) throw new Error(errorMessage ?? 'Error desconocido')
222
+
223
+ const results = JSON.parse(data?.body)?.data ?? [];
224
+
225
+ if(!results)
226
+ throw new Error("No se encontraron resultados");
227
+
228
+ return results;
229
+
230
+ } catch (error) {
231
+ console.log("Error generating AI suggestions:", error);
232
+ return {
233
+ error: error?.message ?? "Error generating AI suggestions"
234
+ }
235
+ }
236
+
237
+ }
238
+
239
+ // Verificamos si los servicios de ficha técnica e imágenes estan completos
240
+ useEffect(() => {
241
+
242
+ if (!productSelected || !isCreators) return;
243
+
244
+ const {
245
+ name: productName,
246
+ upc: upc,
247
+ categoryRetailer
248
+ } = productSelected;
249
+
250
+ if(!Array.isArray(categoryRetailer)) return console.log("Error: categoryRetailer no es un array");
251
+
252
+ const currentCategory = categoryRetailer.find(retailer => retailer?.id_retailer === activeRetailer?.id_retailer);
253
+
254
+ if(!currentCategory) return console.log("Error: No se encontro la categoría");
255
+
256
+ const {
257
+ retailer,
258
+ category
259
+ } = currentCategory;
260
+
261
+ //Checamos si el servicio de ficha técnica e imagenes esta completo
262
+
263
+ const currentRetailerPercentages = productSelected?.percentages?.find(retailer => retailer?.id_retailer === activeRetailer?.id_retailer);
264
+
265
+ if(!currentRetailerPercentages) return console.log("Error: No hay porcentajes disponibles");
266
+
267
+ const {
268
+ required: datasheetRequiredPercent,
269
+ } = currentRetailerPercentages?.datasheet;
270
+
271
+ const {
272
+ required: imagesRequiredPercent,
273
+ } = currentRetailerPercentages?.images;
274
+
275
+ const aiServiceAvailable = (datasheetRequiredPercent >= 100) && (imagesRequiredPercent >= 100) && [1,4,6,7].some(allowed => allowed = user?.id_role);
276
+
277
+ setIsAiAvailable(aiServiceAvailable);
278
+
279
+ setProduct({
280
+ upc,
281
+ productName,
282
+ retailer,
283
+ category,
284
+ });
285
+
286
+ }, [productSelected]);
287
+
288
+ // Inicializamos la ficha técnica con el objetivo de posteriormente pasarlo a la generación con IA
289
+ useEffect(() => {
290
+
291
+ if (!datasheetInputs || !isCreators) return;
292
+
293
+ const datasheetToArray = Object.values(datasheetInputs);
294
+
295
+ const normalizedDatasheet = datasheetToArray.map(attribute => ({
296
+ description: attribute?.description,
297
+ name: attribute?.name,
298
+ type: attribute?.type,
299
+ value: attribute?.value
300
+ }));
301
+
302
+ setParsedDatasheet(normalizedDatasheet);
303
+
304
+ }, [datasheetInputs]);
305
+
306
+ // Inicializamos las imágenes con el objetivo de posteriormente pasarlo a la generación con IA
307
+ useEffect(() => {
308
+
309
+ if(!isCreators) return;
310
+
311
+ const currentRetailerImageInputs = imagesData?.inputsByRetailer?.[0]?.filter(input => input?.id_retailer === activeRetailer?.id_retailer);
312
+
313
+ if(!Array.isArray(currentRetailerImageInputs) || currentRetailerImageInputs.length === 0) return console.log('No existen imágenes para la cadena seleccionada')
314
+
315
+ const allProductImages = imagesData?.values;
316
+
317
+ if(!Array.isArray(allProductImages) || allProductImages.length === 0) return console.log("No existen imágenes para el producto");
318
+
319
+ //Obtenemos las imágenes para el retailer seleccionado
320
+ const currentParsedImages = allProductImages.filter(image => {
321
+
322
+ const imageId = image?.image_id;
323
+ const foundedImage = currentRetailerImageInputs.some(retailerImage => retailerImage?.id_image === imageId);
324
+
325
+ return foundedImage;
326
+ });
327
+
328
+ setParsedImages(currentParsedImages);
329
+
330
+ }, [imagesData]);
331
+
332
+ return (
333
+ <AiProductEdition.Provider
334
+ value={{
335
+ isCreators: isCreators,
336
+ suggestions,
337
+ currentSuggestion,
338
+ isAiAvailable,
339
+ inputsGeneratedWithAi,
340
+ inputsUsingAi,
341
+
342
+ setInputsUsingAi,
343
+ setInputsGeneratedWithAi,
344
+ setSuggestions,
345
+ setCurrentSuggestionValue,
346
+ generateProductSuggestions,
347
+ regenerateProductSuggestions,
348
+ clearCurrentSuggestions,
349
+
350
+ }}
351
+ >
352
+ { children }
353
+ </AiProductEdition.Provider>
354
+ )
355
+
356
+ }
@@ -0,0 +1,103 @@
1
+ const STATUS_DICTIONARY = {
2
+ // R: {
3
+ // status: "R",
4
+ // name: "Recepción",
5
+ // weight: 1
6
+ // },
7
+ PA: {
8
+ status: "PA",
9
+ name: "Por Asignar",
10
+ weight: 2
11
+ },
12
+ AS: {
13
+ status: "AS",
14
+ name: "Asignado",
15
+ weight: 3
16
+ },
17
+ // CA: {
18
+ // status: "CA",
19
+ // name: "Capturando",
20
+ // weight: 4
21
+ // },
22
+ // IE: {
23
+ // status: "IE",
24
+ // name: "Información Enviada",
25
+ // weight: 5
26
+ // },
27
+ RCA: {
28
+ status: "RCA",
29
+ name: "Rechazado Cadena",
30
+ weight: 6
31
+ },
32
+ RP: {
33
+ status: "RP",
34
+ name: "Rechazado Proveedor",
35
+ weight: 7
36
+ },
37
+ RA: {
38
+ status: "RA",
39
+ name: "Rechazado Auditor",
40
+ weight: 8
41
+ },
42
+ RC: {
43
+ status: "RC",
44
+ name: "Rechazo Coordinador",
45
+ weight: 9
46
+ },
47
+ AC: {
48
+ status: "AC",
49
+ name: "Aprobado Coordinador",
50
+ weight: 10
51
+ },
52
+ AA: {
53
+ status: "AA",
54
+ name: "Aprobado Auditor",
55
+ weight: 11
56
+ },
57
+ AP: {
58
+ status: "AP",
59
+ name: "Aprobado Proveedor",
60
+ weight: 12
61
+ },
62
+ ACA: {
63
+ status: "ACA",
64
+ name: "Aprobado Cadena",
65
+ weight: 13
66
+ },
67
+ Ex: {
68
+ status: "Ex",
69
+ name: "Exportado",
70
+ weight: 14
71
+ },
72
+ // RAC: {
73
+ // status: "RAC",
74
+ // name: "Rechazo de Auditoría Content-oh!",
75
+ // weight: 15
76
+ // },
77
+ // SAC: {
78
+ // status: "SAC",
79
+ // name: "Solicitud de Auditoría Content-oh!",
80
+ // weight: 16
81
+ // },
82
+ // AAC: {
83
+ // status: "AAC",
84
+ // name: "Aprobado Auditoría Content-oh!",
85
+ // weight: 17
86
+ // },
87
+ // FAP: {
88
+ // status: "FAP",
89
+ // name: "Finalización de Auditoría por Proveedor",
90
+ // weight: 18
91
+ // },
92
+
93
+ //El status NS necesita ser el mayor de todos
94
+ NS: {
95
+ status: "NS",
96
+ name: "No Solicitado",
97
+ weight: 100
98
+ },
99
+ };
100
+
101
+ module.exports = {
102
+ STATUS_DICTIONARY
103
+ }