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
@@ -0,0 +1,575 @@
1
+ import { createContext, useContext, useReducer } from "react";
2
+ import PropTypes from "prop-types";
3
+ import {
4
+ initialState,
5
+ productEditionReducer,
6
+ ACTIONS,
7
+ } from "./provider-product-edition.reducer";
8
+ import AWS from "aws-sdk";
9
+ import axios from "axios";
10
+ import { v4 as uuidv4 } from "uuid";
11
+
12
+ import successIcon from "../../../../assets/images/genericModal/genericModalCheck.svg";
13
+ import errorIcon from "../../../../assets/images/genericModal/errorModal.svg";
14
+ import { getConceptByTab } from "../utils";
15
+
16
+ const S3_BUCKET = process.env.REACT_APP_IMAGES_BUCKET;
17
+ const REGION = "us-east-1";
18
+
19
+ AWS.config.update({
20
+ accessKeyId: process.env.REACT_APP_KUTS3,
21
+ secretAccessKey: process.env.REACT_APP_AKUTS3,
22
+ });
23
+
24
+ const myBucket = new AWS.S3({
25
+ params: { Bucket: S3_BUCKET },
26
+ region: REGION,
27
+ });
28
+
29
+ // Create context
30
+ const ProductEditionContext = createContext();
31
+
32
+ // Provider component
33
+ export const ProviderProductEditionProvider = ({ children }) => {
34
+ const [state, dispatch] = useReducer(productEditionReducer, initialState);
35
+
36
+ const saveDescriptions = async (token) => {
37
+ if (state.updated_descriptions_inputs.length === 0) return;
38
+
39
+ dispatch({ type: "SET_SAVING", payload: true });
40
+
41
+ const dataObject = {
42
+ articleId: state.product?.id_article,
43
+ articleData: state.updated_descriptions_inputs,
44
+ };
45
+
46
+ // console.log({dataObject});
47
+
48
+ if (state.product?.id_order) {
49
+ dataObject.orderId = state.product?.id_order;
50
+ }
51
+
52
+ try {
53
+ const res = await axios.put(
54
+ process.env.REACT_APP_ARTICLE_DATA_ENDPOINT,
55
+ dataObject,
56
+ {
57
+ params: {
58
+ description: true,
59
+ version: state.product.version,
60
+ },
61
+ headers: {
62
+ Authorization: token,
63
+ },
64
+ },
65
+ );
66
+
67
+ if (
68
+ res.data.statusCode === 200 &&
69
+ JSON.parse(res.data.body).message.toLowerCase() === "ok"
70
+ ) {
71
+ // Limpiar las descripciones actualizadas
72
+ dispatch({
73
+ type: "SET_UPDATED_DESCRIPTIONS_INPUTS",
74
+ payload: [],
75
+ });
76
+ dispatch({
77
+ type: "UPDATE_DESCRIPTIONS_INPUTS",
78
+ payload: state.updated_descriptions_inputs,
79
+ });
80
+
81
+ // Contar cuántos campos requeridos que antes estaban vacíos ahora tienen valor
82
+ const inputs = state.descriptions_inputs[0].inputs;
83
+ let filledRequiredCount = 0;
84
+
85
+ state.updated_descriptions_inputs.forEach((updatedInput) => {
86
+ const originalInput = inputs.find(
87
+ (input) => input.id === updatedInput.attributeId,
88
+ );
89
+ // Si es requerido, antes no tenía valor, y ahora sí tiene valor
90
+ if (
91
+ originalInput?.required &&
92
+ !originalInput.value &&
93
+ updatedInput.value &&
94
+ updatedInput.value.trim() !== ""
95
+ ) {
96
+ filledRequiredCount += 1;
97
+ }
98
+ });
99
+
100
+ dispatch({
101
+ type: "SET_MISSING_REQUIRED_FIELDS",
102
+ payload: {
103
+ ...state.missing_required_fields,
104
+ Descripción:
105
+ state.missing_required_fields["Descripción"] -
106
+ filledRequiredCount,
107
+ },
108
+ });
109
+
110
+ // Mostrar modal de éxito
111
+ dispatch({
112
+ type: "SET_MODAL",
113
+ payload: {
114
+ show: true,
115
+ title: "",
116
+ message: "Descripciones guardadas con éxito",
117
+ image: successIcon,
118
+ },
119
+ });
120
+ }
121
+ } catch (error) {
122
+ console.log("Error saving descriptions:", error);
123
+ // Mostrar modal de error
124
+ dispatch({
125
+ type: "SET_MODAL",
126
+ payload: {
127
+ show: true,
128
+ title: "Error",
129
+ message:
130
+ "Hubo un error al guardar las descripciones. Por favor, intenta nuevamente.",
131
+ image: errorIcon,
132
+ },
133
+ });
134
+ } finally {
135
+ dispatch({ type: "SET_SAVING", payload: false });
136
+ }
137
+ };
138
+
139
+ const saveDatasheets = async (token) => {
140
+ if (state.updated_datasheets_inputs.length === 0) return;
141
+ dispatch({ type: "SET_SAVING", payload: true });
142
+
143
+ const dataObject = {
144
+ articleId: state.product?.id_article,
145
+ articleData: state.updated_datasheets_inputs,
146
+ };
147
+
148
+ if (state.product?.id_order) {
149
+ dataObject.orderId = state.product?.id_order;
150
+ }
151
+
152
+ try {
153
+ const res = await axios.put(
154
+ process.env.REACT_APP_ARTICLE_DATA_ENDPOINT,
155
+ dataObject,
156
+ {
157
+ headers: {
158
+ Authorization: token,
159
+ },
160
+ params: {
161
+ datasheet: true,
162
+ version: state.product.version,
163
+ },
164
+ },
165
+ );
166
+
167
+ if (
168
+ res.data.statusCode === 200 &&
169
+ JSON.parse(res.data.body).message.toLowerCase() === "ok"
170
+ ) {
171
+ // Limpiar las fichas técnicas actualizadas
172
+ dispatch({
173
+ type: "SET_UPDATED_DATASHEETS_INPUTS",
174
+ payload: [],
175
+ });
176
+ dispatch({
177
+ type: "UPDATE_DATASHEETS_INPUTS",
178
+ payload: state.updated_datasheets_inputs,
179
+ });
180
+
181
+ // Contar cuántos campos requeridos que antes estaban vacíos ahora tienen valor
182
+ const datasheetInputs = state.datasheets_inputs[1];
183
+ const retailerId = state.active_retailer?.id_retailer;
184
+ let filledRequiredCount = 0;
185
+
186
+ state.updated_datasheets_inputs.forEach((updatedInput) => {
187
+ const key = `${updatedInput.attributeId}_${retailerId}`;
188
+ const originalInput = datasheetInputs[key];
189
+ // Si es requerido, antes no tenía valor, y ahora sí tiene valor
190
+ if (
191
+ originalInput?.required &&
192
+ !originalInput.value &&
193
+ updatedInput.value &&
194
+ String(updatedInput.value).trim() !== ""
195
+ ) {
196
+ filledRequiredCount += 1;
197
+ }
198
+ });
199
+
200
+ dispatch({
201
+ type: "SET_MISSING_REQUIRED_FIELDS",
202
+ payload: {
203
+ ...state.missing_required_fields,
204
+ "Ficha técnica":
205
+ state.missing_required_fields["Ficha técnica"] -
206
+ filledRequiredCount,
207
+ },
208
+ });
209
+
210
+ // Mostrar modal de éxito
211
+ dispatch({
212
+ type: "SET_MODAL",
213
+ payload: {
214
+ show: true,
215
+ title: "",
216
+ message: "Ficha técnica guardada con éxito",
217
+ image: successIcon,
218
+ },
219
+ });
220
+ }
221
+ } catch (error) {
222
+ console.log(error);
223
+ dispatch({
224
+ type: "SET_ERRORS",
225
+ payload: [...state.errors, error],
226
+ });
227
+ } finally {
228
+ dispatch({ type: "SET_SAVING", payload: false });
229
+ }
230
+ };
231
+
232
+ const updateImages = async (token) => {
233
+ if (state.updated_images_values.length === 0) return;
234
+ const updatedImages = state.updated_images_values;
235
+
236
+ const attrForImgs = state.images_values?.attrForImgs || {};
237
+ const generalAttrs = attrForImgs.general || [];
238
+ const retailerKey = Object.keys(attrForImgs).find(
239
+ (key) => key !== "general",
240
+ );
241
+ const retailerAttrs = retailerKey ? attrForImgs[retailerKey] : [];
242
+
243
+ const mergedAttrs = retailerAttrs.map((retailerAttr) => {
244
+ const generalAttr = generalAttrs.find((g) => g.id === retailerAttr.id);
245
+ if (generalAttr && generalAttr.value !== retailerAttr.value) {
246
+ return { ...retailerAttr, value: generalAttr.value };
247
+ }
248
+ return retailerAttr;
249
+ });
250
+
251
+ const data = {
252
+ articleId: state.product?.id_article,
253
+ attrReqImgs: mergedAttrs.map((e) => ({
254
+ attrId: e.id,
255
+ value: e.value ?? "",
256
+ })),
257
+ articleData: state.images_values.values.filter((e) => !e.id),
258
+ updateImages: state.images_values.values.filter((e) => e.id),
259
+ };
260
+
261
+ if (state.product?.orderId) data["orderId"] = state.product?.orderId;
262
+
263
+ const valid =
264
+ data?.articleData?.every((e) => e?.image_id) &&
265
+ data?.updateImages?.every((e) => e?.image_id);
266
+
267
+ // console.log({ data });
268
+
269
+ if (valid) {
270
+ dispatch({ type: "SET_SAVING", payload: true });
271
+
272
+ data.articleData = data.articleData.map((e) => ({
273
+ ...e,
274
+ uuid: uuidv4(),
275
+ isApproved: true,
276
+ }));
277
+
278
+ data.updateImages = data.updateImages.map((image) => ({
279
+ ...image,
280
+ isApproved: true,
281
+ }));
282
+
283
+ try {
284
+ const promiseArray = data.articleData.map((e) => {
285
+ const file = Buffer.from(
286
+ e.src.replace(/^data:image\/\w+;base64,/, ""),
287
+ "base64",
288
+ );
289
+ const params = {
290
+ ACL: "public-read",
291
+ Body: file,
292
+ Bucket: S3_BUCKET,
293
+ Key: `id-${data.articleId}/${state.product.version}/${e?.image_id}-${e?.uuid}.${e?.ext}`,
294
+ };
295
+ return myBucket.putObject(params).promise();
296
+ });
297
+
298
+ await Promise.all(promiseArray);
299
+
300
+ // Eliminar el buffer base64 antes de enviar al endpoint para evitar error 413
301
+ data.articleData = data.articleData.map(({ src, ...rest }) => rest);
302
+ data.updateImages = data.updateImages.map(({ src, ...rest }) => rest);
303
+
304
+ const res = await axios.put(
305
+ process.env.REACT_APP_ARTICLE_DATA_ENDPOINT,
306
+ data,
307
+ {
308
+ params: {
309
+ image: true,
310
+ version: state.product.version,
311
+ },
312
+ headers: {
313
+ Authorization: token,
314
+ },
315
+ },
316
+ );
317
+
318
+ if (res.data.statusCode === 200) {
319
+ // Limpiar las imágenes actualizadas
320
+ dispatch({
321
+ type: "SET_UPDATED_IMAGES_VALUES",
322
+ payload: [],
323
+ });
324
+ // Mostrar modal de éxito
325
+ dispatch({
326
+ type: "SET_MODAL",
327
+ payload: {
328
+ show: true,
329
+ title: "",
330
+ message: "Imágenes guardadas con éxito",
331
+ image: successIcon,
332
+ },
333
+ });
334
+ }
335
+ } catch (error) {
336
+ console.log(error);
337
+ dispatch({
338
+ type: "SET_ERRORS",
339
+ payload: [...state.errors, error],
340
+ });
341
+ dispatch({
342
+ type: "SET_MODAL",
343
+ payload: {
344
+ show: true,
345
+ title: "Error",
346
+ message: "Hubo un error al actualizar las imágenes",
347
+ image: errorIcon,
348
+ },
349
+ });
350
+ } finally {
351
+ dispatch({ type: "SET_SAVING", payload: false });
352
+ }
353
+ } else {
354
+ dispatch({
355
+ type: "SET_MODAL",
356
+ payload: {
357
+ show: true,
358
+ title: "Campos incompletos o duplicados",
359
+ message:
360
+ "Completa los campos que solicita cada una de la imágenes o hay imágenes con el mismo tipo de toma. Recuerda hay campos obligatorios y no podras avanzar si no estan completos.",
361
+ image: warningIcon,
362
+ },
363
+ });
364
+ }
365
+ };
366
+
367
+ const saveImageAttrs = async (token) => {
368
+ if (state.updated_attr_for_imgs.length === 0) return;
369
+
370
+ dispatch({ type: "SET_SAVING", payload: true });
371
+
372
+ const activeImage = state.images_values.values[state.current_image];
373
+
374
+ const attrForImgs = state.images_values?.attrForImgs?.general ?? [];
375
+
376
+ const data = {
377
+ articleId: state.product?.id_article,
378
+ attrReqImgs: attrForImgs.map((e) => ({
379
+ attrId: e.id,
380
+ value: e.value ?? "-",
381
+ })),
382
+ articleData: [],
383
+ updateImages: activeImage ? [activeImage] : [],
384
+ };
385
+
386
+ if (state.product?.orderId || state.product?.id_order) {
387
+ data.orderId = state.product?.orderId || state.product?.id_order;
388
+ }
389
+
390
+ try {
391
+ const res = await axios.put(
392
+ process.env.REACT_APP_ARTICLE_DATA_ENDPOINT,
393
+ data,
394
+ {
395
+ params: {
396
+ image: true,
397
+ version: state.product.version,
398
+ },
399
+ headers: {
400
+ Authorization: token,
401
+ },
402
+ },
403
+ );
404
+
405
+ if (res.data.statusCode === 200) {
406
+ dispatch({
407
+ type: "SET_UPDATED_ATTR_FOR_IMGS",
408
+ payload: [],
409
+ });
410
+
411
+ dispatch({
412
+ type: "SET_MODAL",
413
+ payload: {
414
+ show: true,
415
+ title: "",
416
+ message: "Atributos de imagen guardados con éxito",
417
+ image: successIcon,
418
+ },
419
+ });
420
+ }
421
+ } catch (error) {
422
+ console.log(error);
423
+ dispatch({
424
+ type: "SET_ERRORS",
425
+ payload: [...state.errors, error],
426
+ });
427
+ dispatch({
428
+ type: "SET_MODAL",
429
+ payload: {
430
+ show: true,
431
+ title: "Error",
432
+ message: "Hubo un error al guardar los atributos de imagen",
433
+ image: errorIcon,
434
+ },
435
+ });
436
+ } finally {
437
+ dispatch({ type: "SET_SAVING", payload: false });
438
+ }
439
+ };
440
+
441
+ const handleOnDownloadImages = () => {
442
+ const upc = state.product?.upc || state.product?.article?.upc;
443
+ state.selected_images.length > 0
444
+ ? state.selected_images.forEach((e) => {
445
+ if (e.id) {
446
+ saveAs(
447
+ `https://${process.env.REACT_APP_IMAGES_BUCKET}.s3.amazonaws.com/${e.srcDB}`,
448
+ `${upc}_${e.name}.${e.ext}`,
449
+ );
450
+ }
451
+ })
452
+ : state.images_values?.values?.forEach((e) => {
453
+ if (e.id) {
454
+ saveAs(
455
+ `https://${process.env.REACT_APP_IMAGES_BUCKET}.s3.amazonaws.com/${e.srcDB}`,
456
+ `${upc}_${e.name}.${e.ext}`,
457
+ );
458
+ }
459
+ });
460
+ };
461
+
462
+ const deleteImages = async (token) => {
463
+ dispatch({ type: "SET_SAVING", payload: true });
464
+
465
+ // Filtrar las imágenes que ya existen en el backend (tienen id)
466
+ const imgsInBack = state.selected_images.filter((img) => img.id);
467
+
468
+ // Hacer el request al backend si hay imágenes que eliminar
469
+ if (imgsInBack.length > 0) {
470
+ const data = {
471
+ articleId: state.product?.id_article,
472
+ deleteImages: imgsInBack,
473
+ };
474
+
475
+ try {
476
+ await axios.put(process.env.REACT_APP_ARTICLE_DATA_ENDPOINT, data, {
477
+ params: {
478
+ image: true,
479
+ version: state.product.version,
480
+ },
481
+ headers: {
482
+ Authorization: token,
483
+ },
484
+ });
485
+
486
+ // Mostrar modal de éxito
487
+ dispatch({
488
+ type: "SET_MODAL",
489
+ payload: {
490
+ show: true,
491
+ title: "",
492
+ message: "Imágenes eliminadas con éxito",
493
+ image: successIcon,
494
+ },
495
+ });
496
+ } catch (err) {
497
+ console.log(err);
498
+ dispatch({
499
+ type: "SET_MODAL",
500
+ payload: {
501
+ show: true,
502
+ title: "Error",
503
+ message: "Hubo un error al eliminar las imágenes",
504
+ image: errorIcon,
505
+ },
506
+ });
507
+ return;
508
+ } finally {
509
+ dispatch({ type: "SET_SAVING", payload: false });
510
+ }
511
+ }
512
+
513
+ // Actualizar el estado eliminando las imágenes seleccionadas
514
+ dispatch({
515
+ type: "DELETE_IMAGES",
516
+ payload: { selectedImages: state.selected_images },
517
+ });
518
+
519
+ dispatch({ type: "SET_SAVING", payload: false });
520
+ };
521
+
522
+ const createComment = async (body, token) => {
523
+ const concept = getConceptByTab(state.active_tab);
524
+ const data = {
525
+ articleId: state.product?.id_article,
526
+ orderId: state.product?.orderId || state.product?.id_order,
527
+ message: body,
528
+ concept: concept,
529
+ version: state.product.version,
530
+ };
531
+ try {
532
+ await axios.post(`${process.env.REACT_APP_COMMENTS_ENDPOINT}`, data, {
533
+ headers: {
534
+ Authorization: token,
535
+ },
536
+ });
537
+ } catch (error) {
538
+ console.log("Error creating comment:", error);
539
+ }
540
+ };
541
+
542
+ const value = {
543
+ state,
544
+ dispatch,
545
+ saveDatasheets,
546
+ saveDescriptions,
547
+ updateImages,
548
+ saveImageAttrs,
549
+ deleteImages,
550
+ handleOnDownloadImages,
551
+ createComment,
552
+ };
553
+ return (
554
+ <ProductEditionContext.Provider value={value}>
555
+ {children}
556
+ </ProductEditionContext.Provider>
557
+ );
558
+ };
559
+
560
+ ProviderProductEditionProvider.propTypes = {
561
+ children: PropTypes.node.isRequired,
562
+ };
563
+
564
+ // Custom hook to use the context
565
+ export const useProviderProductEdition = () => {
566
+ const context = useContext(ProductEditionContext);
567
+
568
+ if (!context) {
569
+ throw new Error(
570
+ "useProviderProductEdition must be used within a ProviderProductEditionProvider",
571
+ );
572
+ }
573
+
574
+ return context;
575
+ };
@@ -0,0 +1,62 @@
1
+ import {
2
+ SYSTEM_ACTIONS,
3
+ systemInitialState,
4
+ systemReducer,
5
+ } from "./reducers/system";
6
+ import {
7
+ PRODUCT_ACTIONS,
8
+ productInitialState,
9
+ productReducer,
10
+ } from "./reducers/product";
11
+ import {
12
+ INPUTS_ACTIONS,
13
+ inputsInitialState,
14
+ inputsReducer,
15
+ } from "./reducers/inputs";
16
+ import {
17
+ ACTIVE_STATE_ACTIONS,
18
+ activeStateInitialState,
19
+ activeStateReducer,
20
+ } from "./reducers/active-state";
21
+
22
+ // Initial state
23
+ export const initialState = {
24
+ ...systemInitialState,
25
+ ...productInitialState,
26
+ ...inputsInitialState,
27
+ ...activeStateInitialState,
28
+ };
29
+
30
+ // Action types
31
+ export const ACTIONS = {
32
+ ...SYSTEM_ACTIONS,
33
+ ...PRODUCT_ACTIONS,
34
+ ...INPUTS_ACTIONS,
35
+ ...ACTIVE_STATE_ACTIONS,
36
+ };
37
+
38
+ // Reducer function
39
+ export const productEditionReducer = (state, action) => {
40
+ // Delegar las acciones a sus respectivos reducers
41
+ const systemResult = systemReducer(state, action, initialState);
42
+ if (systemResult !== null) {
43
+ return systemResult;
44
+ }
45
+
46
+ const productResult = productReducer(state, action);
47
+ if (productResult !== null) {
48
+ return productResult;
49
+ }
50
+
51
+ const inputsResult = inputsReducer(state, action);
52
+ if (inputsResult !== null) {
53
+ return inputsResult;
54
+ }
55
+
56
+ const activeStateResult = activeStateReducer(state, action);
57
+ if (activeStateResult !== null) {
58
+ return activeStateResult;
59
+ }
60
+
61
+ return state;
62
+ };