contentoh-components-library 21.5.91 → 21.5.93

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 (66) hide show
  1. package/dist/components/atoms/GeneralButton/styles.js +1 -1
  2. package/dist/components/atoms/GeneralInput/index.js +54 -245
  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 +12 -13
  8. package/dist/components/molecules/TagAndInput/index.js +24 -361
  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/index.js +47 -34
  13. package/dist/components/pages/ProviderProductEdition/utils.js +0 -1
  14. package/dist/components/pages/RetailerProductEdition/RetailerProductEdition.stories.js +196 -179
  15. package/dist/components/pages/RetailerProductEdition/context/provider-product-edition.context.js +260 -59
  16. package/dist/components/pages/RetailerProductEdition/context/reducers/product.js +38 -50
  17. package/dist/components/pages/RetailerProductEdition/index.js +2234 -1715
  18. package/dist/components/pages/RetailerProductEdition/styles.js +2 -4
  19. package/dist/components/pages/RetailerProductEdition/utils.js +2 -251
  20. package/dist/contexts/AiProductEdition.js +157 -234
  21. package/package.json +2 -4
  22. package/src/components/atoms/GeneralButton/styles.js +0 -4
  23. package/src/components/atoms/GeneralInput/index.js +60 -237
  24. package/src/components/atoms/GeneralInput/styles.js +0 -81
  25. package/src/components/atoms/InputFormatter/index.js +51 -200
  26. package/src/components/atoms/InputFormatter/styles.js +0 -284
  27. package/src/components/molecules/StatusAsignationInfo/index.js +1 -9
  28. package/src/components/molecules/TabsMenu/index.js +11 -12
  29. package/src/components/molecules/TagAndInput/index.js +21 -286
  30. package/src/components/molecules/TagAndInput/styles.js +17 -59
  31. package/src/components/organisms/FullProductNameHeader/index.js +28 -4
  32. package/src/components/organisms/FullTabsMenu/index.js +1 -1
  33. package/src/components/organisms/InputGroup/index.js +4 -12
  34. package/src/components/pages/ProviderProductEdition/index.js +69 -51
  35. package/src/components/pages/ProviderProductEdition/utils.js +2 -2
  36. package/src/components/pages/RetailerProductEdition/RetailerProductEdition.stories.js +224 -201
  37. package/src/components/pages/RetailerProductEdition/index.js +1718 -1546
  38. package/src/components/pages/RetailerProductEdition/styles.js +2 -67
  39. package/src/components/pages/RetailerProductEdition/utils.js +0 -240
  40. package/dist/ai/utils/compare-strings.js +0 -45
  41. package/dist/components/organisms/ChangeStatusModal/index.js +0 -531
  42. package/dist/components/organisms/ChangeStatusModal/styles.js +0 -85
  43. package/dist/global-files/statusDictionary.js +0 -103
  44. package/src/ai/utils/compare-strings.js +0 -45
  45. package/src/assets/images/Icons/arrow.png +0 -0
  46. package/src/assets/images/Icons/cancel.png +0 -0
  47. package/src/assets/images/Icons/ia-icon.png +0 -0
  48. package/src/assets/images/Icons/loading.svg +0 -5
  49. package/src/assets/images/Icons/reload.png +0 -0
  50. package/src/components/atoms/RetailerSelector/RetailerSelector.stories.js +0 -10
  51. package/src/components/atoms/RetailerSelector/index.js +0 -3
  52. package/src/components/atoms/RetailerSelector/styles.js +0 -0
  53. package/src/components/organisms/ChangeStatusModal/index.jsx +0 -488
  54. package/src/components/organisms/ChangeStatusModal/styles.js +0 -333
  55. package/src/components/pages/RetailerProductEdition/context/provider-product-edition.context.jsx +0 -575
  56. package/src/components/pages/RetailerProductEdition/context/provider-product-edition.reducer.js +0 -62
  57. package/src/components/pages/RetailerProductEdition/context/reducers/active-state.js +0 -344
  58. package/src/components/pages/RetailerProductEdition/context/reducers/inputs.js +0 -155
  59. package/src/components/pages/RetailerProductEdition/context/reducers/product.js +0 -114
  60. package/src/components/pages/RetailerProductEdition/context/reducers/system.js +0 -60
  61. package/src/components/pages/RetailerProductEdition/index_old.js +0 -1979
  62. package/src/components/pages/RetailerProductEdition/stories/Auditor.stories.js +0 -101
  63. package/src/components/pages/RetailerProductEdition/stories/ImageEditor.stories.js +0 -115
  64. package/src/components/pages/RetailerProductEdition/stories/TextEditor.stories.js +0 -174
  65. package/src/contexts/AiProductEdition.jsx +0 -344
  66. package/src/global-files/statusDictionary.js +0 -103
@@ -42,7 +42,6 @@ import errorIcon from "../../../assets/images/genericModal/errorModal.svg";
42
42
  import warningIcon from "../../../assets/images/genericModal/genericModalWarning.svg";
43
43
 
44
44
  import { Container } from "./styles";
45
- import { AiProductEditionProvider } from "../../../contexts/AiProductEdition";
46
45
 
47
46
  const ProviderProductEditionView = ({
48
47
  tabsSections,
@@ -149,13 +148,30 @@ const ProviderProductEditionView = ({
149
148
 
150
149
  const productNormalized = normalizeProduct(product);
151
150
 
151
+ console.log({ productNormalized });
152
+
152
153
  dispatch({
153
154
  type: "SET_PRODUCT",
154
155
  payload: productNormalized,
155
156
  });
156
157
  dispatch({
157
158
  type: "SET_ACTIVE_RETAILER",
158
- payload: productNormalized.categoryRetailer[0],
159
+ payload: productNormalized.categoryRetailerInOrder[0],
160
+ });
161
+ const firstRetailerStatus =
162
+ productNormalized.statusByRetailer[
163
+ productNormalized.categoryRetailerInOrder[0].id_retailer
164
+ ];
165
+ const initialTab = firstRetailerStatus.description
166
+ ? "Descripción"
167
+ : firstRetailerStatus.datasheet
168
+ ? "Ficha técnica"
169
+ : firstRetailerStatus.images
170
+ ? "Imágenes"
171
+ : "Imágenes";
172
+ dispatch({
173
+ type: "SET_ACTIVE_TAB",
174
+ payload: initialTab,
159
175
  });
160
176
  } catch (error) {
161
177
  console.log("Error setting product data: ", error);
@@ -200,7 +216,7 @@ const ProviderProductEditionView = ({
200
216
  id_category,
201
217
  version,
202
218
  token,
203
- id_retailer
219
+ id_retailer,
204
220
  ),
205
221
  getPercentage({ data, headers }),
206
222
  getServicesData({
@@ -247,7 +263,7 @@ const ProviderProductEditionView = ({
247
263
  dispatch({
248
264
  type: "SET_ACTIVE_PERCENTAGES",
249
265
  payload: percentages.find(
250
- ({ id_retailer: rId }) => rId === id_retailer
266
+ ({ id_retailer: rId }) => rId === id_retailer,
251
267
  ),
252
268
  });
253
269
  } catch (error) {
@@ -267,46 +283,51 @@ const ProviderProductEditionView = ({
267
283
  console.log("Actualizar inputs del retailer activo");
268
284
  const updateInputsActiveRetailer = () => {
269
285
  if (!state.services) return;
286
+ if (state.services.datasheets) {
287
+ const retailerDatasheets =
288
+ state.services.datasheets[state.active_retailer.id_retailer];
270
289
 
271
- const retailerDatasheets =
272
- state.services.datasheets[state.active_retailer.id_retailer];
273
-
274
- const datasheetsActiveRetailer = {
275
- ...retailerDatasheets,
276
- data: Object.values(retailerDatasheets.data),
277
- };
290
+ const datasheetsActiveRetailer = {
291
+ ...retailerDatasheets,
292
+ data: Object.values(retailerDatasheets.data),
293
+ };
278
294
 
279
- const descriptionsActiveRetailer = state.services.descriptions.filter(
280
- (item) => item.id === state.active_retailer.id_retailer
281
- );
295
+ dispatch({
296
+ type: "SET_DATASHEETS_INPUTS",
297
+ payload: [datasheetsActiveRetailer, state.services.datasheets.inputs],
298
+ });
299
+ }
282
300
 
283
- const filteredValues = state.services.images.values.filter((value) => {
284
- return state.services.images.inputsByRetailer.some((retailerInput) =>
285
- retailerInput.some(
286
- (input) =>
287
- input.id_retailer === state.active_retailer.id_retailer &&
288
- input.id_image === value.image_id
289
- )
301
+ if (state.services.descriptions) {
302
+ const descriptionsActiveRetailer = state.services.descriptions.filter(
303
+ (item) => item.id === state.active_retailer.id_retailer,
290
304
  );
291
- });
292
305
 
293
- dispatch({
294
- type: "SET_DATASHEETS_INPUTS",
295
- payload: [datasheetsActiveRetailer, state.services.datasheets.inputs],
296
- });
306
+ dispatch({
307
+ type: "SET_DESCRIPTIONS_INPUTS",
308
+ payload: descriptionsActiveRetailer,
309
+ });
310
+ }
297
311
 
298
- dispatch({
299
- type: "SET_DESCRIPTIONS_INPUTS",
300
- payload: descriptionsActiveRetailer,
301
- });
312
+ if (state.services.images) {
313
+ const filteredValues = state.services.images.values.filter((value) => {
314
+ return state.services.images.inputsByRetailer.some((retailerInput) =>
315
+ retailerInput.some(
316
+ (input) =>
317
+ input.id_retailer === state.active_retailer.id_retailer &&
318
+ input.id_image === value.image_id,
319
+ ),
320
+ );
321
+ });
302
322
 
303
- dispatch({
304
- type: "SET_IMAGES_VALUES",
305
- payload: {
306
- ...state.services.images,
307
- values: filteredValues,
308
- },
309
- });
323
+ dispatch({
324
+ type: "SET_IMAGES_VALUES",
325
+ payload: {
326
+ ...state.services.images,
327
+ values: filteredValues,
328
+ },
329
+ });
330
+ }
310
331
  };
311
332
 
312
333
  updateInputsActiveRetailer();
@@ -378,7 +399,7 @@ const ProviderProductEditionView = ({
378
399
  name: e?.name,
379
400
  required: e?.required,
380
401
  active: state.images_values?.values?.some(
381
- (value) => value?.image_id === e?.id
402
+ (value) => value?.image_id === e?.id,
382
403
  ),
383
404
  }));
384
405
  const imageType = state.images_values?.imageType?.map((e) => ({
@@ -389,7 +410,7 @@ const ProviderProductEditionView = ({
389
410
  (e) => ({
390
411
  value: e?.id,
391
412
  name: e?.name,
392
- })
413
+ }),
393
414
  );
394
415
 
395
416
  return state.images_values?.values?.map((image, index) => (
@@ -644,7 +665,7 @@ const ProviderProductEditionView = ({
644
665
  headers: {
645
666
  Authorization: token,
646
667
  },
647
- }
668
+ },
648
669
  );
649
670
 
650
671
  const newStatuses = JSON.parse(res.data.body);
@@ -892,7 +913,7 @@ const ProviderProductEditionView = ({
892
913
  headers: {
893
914
  Authorization: token,
894
915
  },
895
- })
916
+ }),
896
917
  );
897
918
  });
898
919
 
@@ -937,7 +958,7 @@ const ProviderProductEditionView = ({
937
958
  ArticleId: updatedProduct.id_article,
938
959
  idCategory: updatedProduct.id_category,
939
960
  product: updatedProduct,
940
- })
961
+ }),
941
962
  );
942
963
 
943
964
  // Mostrar modal de éxito
@@ -1004,6 +1025,7 @@ const ProviderProductEditionView = ({
1004
1025
 
1005
1026
  return (
1006
1027
  <Container headerTop={headerTop}>
1028
+ {/* <button onClick={() => console.log(state)}>log</button> */}
1007
1029
  {showVersionSelector && (
1008
1030
  <VersionSelector
1009
1031
  modalId={"version-selector"}
@@ -1099,7 +1121,7 @@ const ProviderProductEditionView = ({
1099
1121
  size={12}
1100
1122
  onClick={async () => {
1101
1123
  const elements = document.querySelectorAll(
1102
- "#modal-message-box .ql-container .ql-editor > p"
1124
+ "#modal-message-box .ql-container .ql-editor > p",
1103
1125
  );
1104
1126
 
1105
1127
  if (!elements || elements.length === 0) {
@@ -1114,7 +1136,7 @@ const ProviderProductEditionView = ({
1114
1136
 
1115
1137
  if (isMessageEmpty) {
1116
1138
  const container = document.querySelector(
1117
- ".container-customComponent"
1139
+ ".container-customComponent",
1118
1140
  );
1119
1141
  const existingAlert = container.querySelector(".alert-error");
1120
1142
 
@@ -1146,7 +1168,7 @@ const ProviderProductEditionView = ({
1146
1168
  .join("")
1147
1169
  .replace(/<br\s*\/?>/gi, "\n");
1148
1170
 
1149
- await createComment(fullMessage, token);
1171
+ await createComment(fullMessage);
1150
1172
 
1151
1173
  rejectAll
1152
1174
  ? handleOnEvaluateAll("R")
@@ -1309,7 +1331,7 @@ const ProviderProductEditionView = ({
1309
1331
  handleOnUpdateApprovedInputs // No se usa?
1310
1332
  }
1311
1333
  />
1312
- )
1334
+ ),
1313
1335
  )}
1314
1336
  </>
1315
1337
  ) : (
@@ -1413,11 +1435,7 @@ const ProviderProductEditionView = ({
1413
1435
  export const ProviderProductEdition = (props) => {
1414
1436
  return (
1415
1437
  <ProviderProductEditionProvider>
1416
- <AiProductEditionProvider
1417
- isCreatorsEdition={false}
1418
- >
1419
- <ProviderProductEditionView {...props} />
1420
- </AiProductEditionProvider>
1438
+ <ProviderProductEditionView {...props} />
1421
1439
  </ProviderProductEditionProvider>
1422
1440
  );
1423
1441
  };
@@ -9,7 +9,6 @@ export const normalizeProduct = (product) => {
9
9
  ? categoryRetailer.map((rel) => ({
10
10
  id_retailer: rel.id_retailer || rel.retailer_id,
11
11
  retailer: rel.retailer_name || rel.retailerName,
12
- name: rel.retailer_name || rel.retailerName,
13
12
  id_category: rel.id_category,
14
13
  category: rel.category_name || rel.categoryName,
15
14
  image: `https://content-management-images.s3.amazonaws.com/retailers/${
@@ -54,7 +53,8 @@ export const normalizeProduct = (product) => {
54
53
  id_datasheet_especialist: article.id_datasheet_especialist || 0,
55
54
  id_datasheet_facilitator: article.id_datasheet_facilitator || null,
56
55
  id_description_especialist: article.id_description_especialist || 0,
57
- id_description_facilitator: article.id_description_facilitator || null,
56
+ id_description_facilitator:
57
+ article.id_description_facilitator || null,
58
58
  id_images_especialist: article.id_images_especialist || 0,
59
59
  id_images_facilitator: article.id_images_facilitator || null,
60
60
  id_auditor: article.id_auditor || 0,