contentoh-components-library 21.5.92 → 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 (70) 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/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 +362 -368
  15. package/dist/components/pages/ProviderProductEdition/utils.js +0 -1
  16. package/dist/components/pages/RetailerProductEdition/RetailerProductEdition.stories.js +196 -179
  17. package/dist/components/pages/RetailerProductEdition/context/provider-product-edition.context.js +260 -59
  18. package/dist/components/pages/RetailerProductEdition/context/reducers/product.js +38 -50
  19. package/dist/components/pages/RetailerProductEdition/index.js +2234 -1716
  20. package/dist/components/pages/RetailerProductEdition/styles.js +2 -4
  21. package/dist/components/pages/RetailerProductEdition/utils.js +2 -251
  22. package/dist/contexts/AiProductEdition.js +158 -230
  23. package/package.json +2 -4
  24. package/src/components/atoms/GeneralButton/styles.js +0 -4
  25. package/src/components/atoms/GeneralInput/index.js +60 -237
  26. package/src/components/atoms/GeneralInput/styles.js +0 -81
  27. package/src/components/atoms/InputFormatter/index.js +51 -200
  28. package/src/components/atoms/InputFormatter/styles.js +0 -284
  29. package/src/components/molecules/StatusAsignationInfo/index.js +1 -9
  30. package/src/components/molecules/TabsMenu/index.js +11 -12
  31. package/src/components/molecules/TagAndInput/index.js +21 -286
  32. package/src/components/molecules/TagAndInput/styles.js +17 -59
  33. package/src/components/organisms/FullProductNameHeader/index.js +28 -4
  34. package/src/components/organisms/FullTabsMenu/index.js +1 -1
  35. package/src/components/organisms/InputGroup/index.js +4 -12
  36. package/src/components/pages/ProviderProductEdition/ProviderProductEdition.stories.js +202 -174
  37. package/src/components/pages/ProviderProductEdition/context/provider-product-edition.context.jsx +14 -14
  38. package/src/components/pages/ProviderProductEdition/index.js +452 -453
  39. package/src/components/pages/ProviderProductEdition/utils.js +2 -2
  40. package/src/components/pages/RetailerProductEdition/RetailerProductEdition.stories.js +224 -201
  41. package/src/components/pages/RetailerProductEdition/index.js +1718 -1547
  42. package/src/components/pages/RetailerProductEdition/styles.js +2 -67
  43. package/src/components/pages/RetailerProductEdition/utils.js +0 -240
  44. package/dist/ai/utils/compare-strings.js +0 -45
  45. package/dist/components/organisms/ChangeStatusModal/index.js +0 -531
  46. package/dist/components/organisms/ChangeStatusModal/styles.js +0 -85
  47. package/dist/global-files/statusDictionary.js +0 -103
  48. package/src/ai/utils/compare-strings.js +0 -45
  49. package/src/assets/images/Icons/arrow.png +0 -0
  50. package/src/assets/images/Icons/cancel.png +0 -0
  51. package/src/assets/images/Icons/ia-icon.png +0 -0
  52. package/src/assets/images/Icons/loading.svg +0 -5
  53. package/src/assets/images/Icons/reload.png +0 -0
  54. package/src/components/atoms/RetailerSelector/RetailerSelector.stories.js +0 -10
  55. package/src/components/atoms/RetailerSelector/index.js +0 -3
  56. package/src/components/atoms/RetailerSelector/styles.js +0 -0
  57. package/src/components/organisms/ChangeStatusModal/index.jsx +0 -488
  58. package/src/components/organisms/ChangeStatusModal/styles.js +0 -333
  59. package/src/components/pages/RetailerProductEdition/context/provider-product-edition.context.jsx +0 -575
  60. package/src/components/pages/RetailerProductEdition/context/provider-product-edition.reducer.js +0 -62
  61. package/src/components/pages/RetailerProductEdition/context/reducers/active-state.js +0 -344
  62. package/src/components/pages/RetailerProductEdition/context/reducers/inputs.js +0 -155
  63. package/src/components/pages/RetailerProductEdition/context/reducers/product.js +0 -114
  64. package/src/components/pages/RetailerProductEdition/context/reducers/system.js +0 -60
  65. package/src/components/pages/RetailerProductEdition/index_old.js +0 -1979
  66. package/src/components/pages/RetailerProductEdition/stories/Auditor.stories.js +0 -101
  67. package/src/components/pages/RetailerProductEdition/stories/ImageEditor.stories.js +0 -115
  68. package/src/components/pages/RetailerProductEdition/stories/TextEditor.stories.js +0 -174
  69. package/src/contexts/AiProductEdition.jsx +0 -339
  70. 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();
@@ -340,23 +361,13 @@ const ProviderProductEditionView = ({
340
361
  // No retailer
341
362
  const hasNoOrder = !state.product.id_order && !state.product.orderId;
342
363
 
343
- console.log({
344
- originTab,
345
- currentStatus,
346
- hasNoOrder
347
- })
348
-
349
- const condition =
350
- (
351
- originTab === "RequestWithoutContentoh" && (
352
- ["R", "CA"].includes(currentStatus) || (currentStatus === "RCA" && hasNoOrder)
353
- )
354
- ) ||
355
- (
356
- ["RequestWithContentoh", "Contentoh"].includes(originTab) && currentStatus === "AA"
357
- )
358
-
359
- return condition;
364
+ return (
365
+ (originTab === "RequestWithoutContentoh" &&
366
+ (["R", "CA"].includes(currentStatus) ||
367
+ (currentStatus === "RCA" && hasNoOrder))) ||
368
+ (["RequestWithContentoh", "Contentoh"].includes(originTab) &&
369
+ currentStatus === "AA")
370
+ );
360
371
  };
361
372
 
362
373
  const canShowSaveButton = (version_status) => {
@@ -388,7 +399,7 @@ const ProviderProductEditionView = ({
388
399
  name: e?.name,
389
400
  required: e?.required,
390
401
  active: state.images_values?.values?.some(
391
- (value) => value?.image_id === e?.id
402
+ (value) => value?.image_id === e?.id,
392
403
  ),
393
404
  }));
394
405
  const imageType = state.images_values?.imageType?.map((e) => ({
@@ -399,7 +410,7 @@ const ProviderProductEditionView = ({
399
410
  (e) => ({
400
411
  value: e?.id,
401
412
  name: e?.name,
402
- })
413
+ }),
403
414
  );
404
415
 
405
416
  return state.images_values?.values?.map((image, index) => (
@@ -640,7 +651,6 @@ const ProviderProductEditionView = ({
640
651
  state.product[sectionStatusKey] || state.product?.version_status;
641
652
 
642
653
  let data = { articleId, orderId, concept, evalStatus };
643
-
644
654
  const retailerId = state.active_retailer?.id_retailer;
645
655
 
646
656
  try {
@@ -655,15 +665,13 @@ const ProviderProductEditionView = ({
655
665
  headers: {
656
666
  Authorization: token,
657
667
  },
658
- }
668
+ },
659
669
  );
660
670
 
661
671
  const newStatuses = JSON.parse(res.data.body);
662
672
  const serviceStatus =
663
673
  newStatuses.newServiceStatus[articleId][`${concept}Status`];
664
674
 
665
- console.log({product: state.product, newStatuses, serviceStatus, servicesData: state.services_data});
666
-
667
675
  // Actualizar el producto con los nuevos estados
668
676
  const updatedProduct = {
669
677
  ...state.product,
@@ -671,17 +679,12 @@ const ProviderProductEditionView = ({
671
679
  ...state.product.statusByRetailer,
672
680
  [retailerId]: {
673
681
  ...state.product.statusByRetailer[retailerId],
674
- [concept]: newStatuses?.newStatus ?? serviceStatus,
682
+ [concept]: serviceStatus,
675
683
  },
676
684
  },
677
685
  };
678
686
 
679
- const updatedServicesData = state.services_data?.map(service => ({
680
- ...service,
681
- status: service?.id_retailer === retailerId && service?.service === concept ? (newStatuses?.newStatus ?? serviceStatus) : service?.status
682
- }));
683
-
684
- // console.log({ updatedProduct });
687
+ console.log({ updatedProduct });
685
688
 
686
689
  dispatch({ type: "SET_PRODUCT", payload: updatedProduct });
687
690
 
@@ -910,7 +913,7 @@ const ProviderProductEditionView = ({
910
913
  headers: {
911
914
  Authorization: token,
912
915
  },
913
- })
916
+ }),
914
917
  );
915
918
  });
916
919
 
@@ -955,7 +958,7 @@ const ProviderProductEditionView = ({
955
958
  ArticleId: updatedProduct.id_article,
956
959
  idCategory: updatedProduct.id_category,
957
960
  product: updatedProduct,
958
- })
961
+ }),
959
962
  );
960
963
 
961
964
  // Mostrar modal de éxito
@@ -1021,422 +1024,418 @@ const ProviderProductEditionView = ({
1021
1024
  if (state.loading || !state.services || !state.product) return <Loading />;
1022
1025
 
1023
1026
  return (
1024
- <AiProductEditionProvider
1025
- isCreatorsEdition={false}
1026
- state={state}
1027
- >
1028
- <Container headerTop={headerTop}>
1029
- {showVersionSelector && (
1030
- <VersionSelector
1031
- modalId={"version-selector"}
1032
- articleId={state.product.id_article}
1033
- setVersion={handleOnChangeProductVersion}
1034
- companyName={company.company_name}
1035
- currentVersion={state.product.version}
1036
- setShowVersionSelector={setShowVersionSelector}
1037
- jwt={token}
1038
- />
1039
- )}
1040
- {showModal && (
1041
- <ProductImageModal
1042
- images={state.images_values}
1043
- setShowModal={setShowModal}
1044
- approveRejectButtons={canShowValidationButtons()}
1045
- sendToFacilitator={handleOnSendEvaluation}
1046
- />
1047
- )}
1048
- {state.modal.show && (
1049
- <GenericModal
1050
- componentsArray={[
1051
- state.modal.image && (
1052
- <img key="1" src={state.modal.image} alt="modal icon" />
1053
- ),
1054
- state.modal.title && (
1055
- <ScreenHeader
1056
- key="2"
1057
- headerType={"retailer-name-header"}
1058
- text={state.modal.title}
1059
- color={"white"}
1060
- />
1061
- ),
1062
- state.modal.message && (
1063
- <ScreenHeader
1064
- key="3"
1065
- headerType={"retailer-name-header"}
1066
- text={state.modal.message}
1067
- color={"white"}
1068
- />
1069
- ),
1070
- state.modal.buttons && (
1071
- <div key="4" style={{ marginTop: "16px" }}>
1072
- {state.modal.buttons.map((button, index) => (
1073
- <Button
1074
- key={index}
1075
- buttonType={button.buttonType}
1076
- label={button.text}
1077
- onClick={button.action}
1078
- />
1079
- ))}
1080
- </div>
1081
- ),
1082
- ].filter(Boolean)}
1083
- onClick={() =>
1084
- dispatch({
1085
- type: "SET_MODAL",
1086
- payload: { show: false, title: "", message: "", image: null },
1087
- })
1088
- }
1089
- />
1090
- )}
1091
- {showRejectModal && (
1092
- <Modal
1093
- title={
1094
- rejectAll
1095
- ? "Agregar mensaje para rechazar todo"
1096
- : "Agregar mensaje de rechazo"
1097
- }
1098
- show={showRejectModal}
1099
- customComponent={
1100
- <TagAndInput
1101
- inputType={"textarea"}
1102
- inputId={"modal-message-box"}
1103
- index={0}
1027
+ <Container headerTop={headerTop}>
1028
+ {/* <button onClick={() => console.log(state)}>log</button> */}
1029
+ {showVersionSelector && (
1030
+ <VersionSelector
1031
+ modalId={"version-selector"}
1032
+ articleId={state.product.id_article}
1033
+ setVersion={handleOnChangeProductVersion}
1034
+ companyName={company.company_name}
1035
+ currentVersion={state.product.version}
1036
+ setShowVersionSelector={setShowVersionSelector}
1037
+ jwt={token}
1038
+ />
1039
+ )}
1040
+ {showModal && (
1041
+ <ProductImageModal
1042
+ images={state.images_values}
1043
+ setShowModal={setShowModal}
1044
+ approveRejectButtons={canShowValidationButtons()}
1045
+ sendToFacilitator={handleOnSendEvaluation}
1046
+ />
1047
+ )}
1048
+ {state.modal.show && (
1049
+ <GenericModal
1050
+ componentsArray={[
1051
+ state.modal.image && (
1052
+ <img key="1" src={state.modal.image} alt="modal icon" />
1053
+ ),
1054
+ state.modal.title && (
1055
+ <ScreenHeader
1056
+ key="2"
1057
+ headerType={"retailer-name-header"}
1058
+ text={state.modal.title}
1104
1059
  color={"white"}
1105
1060
  />
1106
- }
1107
- buttons={[
1108
- <ButtonV2
1109
- key={"btn-Cancelar"}
1110
- type={"white"}
1111
- label={"Cancelar"}
1112
- size={12}
1113
- onClick={() => {
1114
- setShowRejectModal(false);
1115
- }}
1116
- />,
1117
- <ButtonV2
1118
- key={"btn-Aceptar"}
1119
- type={"pink"}
1120
- label={"Aceptar"}
1121
- size={12}
1122
- onClick={async () => {
1123
- const elements = document.querySelectorAll(
1124
- "#modal-message-box .ql-container .ql-editor > p"
1125
- );
1061
+ ),
1062
+ state.modal.message && (
1063
+ <ScreenHeader
1064
+ key="3"
1065
+ headerType={"retailer-name-header"}
1066
+ text={state.modal.message}
1067
+ color={"white"}
1068
+ />
1069
+ ),
1070
+ state.modal.buttons && (
1071
+ <div key="4" style={{ marginTop: "16px" }}>
1072
+ {state.modal.buttons.map((button, index) => (
1073
+ <Button
1074
+ key={index}
1075
+ buttonType={button.buttonType}
1076
+ label={button.text}
1077
+ onClick={button.action}
1078
+ />
1079
+ ))}
1080
+ </div>
1081
+ ),
1082
+ ].filter(Boolean)}
1083
+ onClick={() =>
1084
+ dispatch({
1085
+ type: "SET_MODAL",
1086
+ payload: { show: false, title: "", message: "", image: null },
1087
+ })
1088
+ }
1089
+ />
1090
+ )}
1091
+ {showRejectModal && (
1092
+ <Modal
1093
+ title={
1094
+ rejectAll
1095
+ ? "Agregar mensaje para rechazar todo"
1096
+ : "Agregar mensaje de rechazo"
1097
+ }
1098
+ show={showRejectModal}
1099
+ customComponent={
1100
+ <TagAndInput
1101
+ inputType={"textarea"}
1102
+ inputId={"modal-message-box"}
1103
+ index={0}
1104
+ color={"white"}
1105
+ />
1106
+ }
1107
+ buttons={[
1108
+ <ButtonV2
1109
+ key={"btn-Cancelar"}
1110
+ type={"white"}
1111
+ label={"Cancelar"}
1112
+ size={12}
1113
+ onClick={() => {
1114
+ setShowRejectModal(false);
1115
+ }}
1116
+ />,
1117
+ <ButtonV2
1118
+ key={"btn-Aceptar"}
1119
+ type={"pink"}
1120
+ label={"Aceptar"}
1121
+ size={12}
1122
+ onClick={async () => {
1123
+ const elements = document.querySelectorAll(
1124
+ "#modal-message-box .ql-container .ql-editor > p",
1125
+ );
1126
+
1127
+ if (!elements || elements.length === 0) {
1128
+ console.error("Elemento no encontrado");
1129
+ return;
1130
+ }
1126
1131
 
1127
- if (!elements || elements.length === 0) {
1128
- console.error("Elemento no encontrado");
1129
- return;
1130
- }
1132
+ const isMessageEmpty = Array.from(elements).every((el) => {
1133
+ const body = el.innerHTML;
1134
+ return !body || body.replace(/<.*?\/?>/gm, "").trim() === "";
1135
+ });
1131
1136
 
1132
- const isMessageEmpty = Array.from(elements).every((el) => {
1133
- const body = el.innerHTML;
1134
- return !body || body.replace(/<.*?\/?>/gm, "").trim() === "";
1135
- });
1136
-
1137
- if (isMessageEmpty) {
1138
- const container = document.querySelector(
1139
- ".container-customComponent"
1140
- );
1141
- const existingAlert = container.querySelector(".alert-error");
1142
-
1143
- if (!existingAlert) {
1144
- const alert = document.createElement("div");
1145
- alert.className = "alert-error";
1146
- alert.style.cssText = `
1147
- color: #d32f2f;
1148
- background-color: #ffebee;
1149
- border: 1px solid #ef5350;
1150
- border-radius: 4px;
1151
- padding: 12px 16px;
1152
- margin-top: 10px;
1153
- font-size: 14px;
1154
- display: flex;
1155
- align-items: center;
1156
- gap: 8px;
1157
- font-family: 'Roboto', sans-serif;
1158
- text-align: center;
1159
- `;
1160
- alert.innerHTML = `<span>El mensaje no puede estar vacío.</span>`;
1161
- container.appendChild(alert);
1162
- }
1163
- return;
1137
+ if (isMessageEmpty) {
1138
+ const container = document.querySelector(
1139
+ ".container-customComponent",
1140
+ );
1141
+ const existingAlert = container.querySelector(".alert-error");
1142
+
1143
+ if (!existingAlert) {
1144
+ const alert = document.createElement("div");
1145
+ alert.className = "alert-error";
1146
+ alert.style.cssText = `
1147
+ color: #d32f2f;
1148
+ background-color: #ffebee;
1149
+ border: 1px solid #ef5350;
1150
+ border-radius: 4px;
1151
+ padding: 12px 16px;
1152
+ margin-top: 10px;
1153
+ font-size: 14px;
1154
+ display: flex;
1155
+ align-items: center;
1156
+ gap: 8px;
1157
+ font-family: 'Roboto', sans-serif;
1158
+ text-align: center;
1159
+ `;
1160
+ alert.innerHTML = `<span>El mensaje no puede estar vacío.</span>`;
1161
+ container.appendChild(alert);
1164
1162
  }
1163
+ return;
1164
+ }
1165
1165
 
1166
- const fullMessage = Array.from(elements)
1167
- .map((element) => element.innerHTML)
1168
- .join("")
1169
- .replace(/<br\s*\/?>/gi, "\n");
1166
+ const fullMessage = Array.from(elements)
1167
+ .map((element) => element.innerHTML)
1168
+ .join("")
1169
+ .replace(/<br\s*\/?>/gi, "\n");
1170
1170
 
1171
- await createComment(fullMessage, token);
1171
+ await createComment(fullMessage);
1172
1172
 
1173
- rejectAll
1174
- ? handleOnEvaluateAll("R")
1175
- : handleOnSendEvaluation("R");
1176
- setShowRejectModal(false);
1177
- }}
1178
- />,
1179
- ]}
1180
- />
1181
- )}
1182
- <HeaderTop
1183
- setHeaderTop={setHeaderTop}
1184
- withChat={location?.state?.withChat}
1185
- chatType={location?.state?.chatType}
1186
- productSelected={state.product}
1187
- token={token}
1188
- activeRetailer={{
1189
- id: state.active_retailer?.id_retailer,
1190
- name: state.active_retailer?.retailer,
1191
- }}
1173
+ rejectAll
1174
+ ? handleOnEvaluateAll("R")
1175
+ : handleOnSendEvaluation("R");
1176
+ setShowRejectModal(false);
1177
+ }}
1178
+ />,
1179
+ ]}
1192
1180
  />
1193
- <div className="data-container">
1194
- <div className="image-data-panel">
1195
- <ImagePreviewer
1196
- activeImage={state.images_values.values[state.current_image] ?? {}}
1197
- imagesArray={state.images_values || []}
1198
- setActiveImage={handleOnChangeCurrentImage}
1199
- setShowModal={handleOnShowModalGalery}
1181
+ )}
1182
+ <HeaderTop
1183
+ setHeaderTop={setHeaderTop}
1184
+ withChat={location?.state?.withChat}
1185
+ chatType={location?.state?.chatType}
1186
+ productSelected={state.product}
1187
+ token={token}
1188
+ activeRetailer={{
1189
+ id: state.active_retailer?.id_retailer,
1190
+ name: state.active_retailer?.retailer,
1191
+ }}
1192
+ />
1193
+ <div className="data-container">
1194
+ <div className="image-data-panel">
1195
+ <ImagePreviewer
1196
+ activeImage={state.images_values.values[state.current_image] ?? {}}
1197
+ imagesArray={state.images_values || []}
1198
+ setActiveImage={handleOnChangeCurrentImage}
1199
+ setShowModal={handleOnShowModalGalery}
1200
+ />
1201
+ <ImageDataTable
1202
+ lists={state.images_values || []}
1203
+ activeImage={
1204
+ state.images_values?.values
1205
+ ? state.images_values?.values[state.current_image]
1206
+ : {}
1207
+ }
1208
+ assignationsImages={assig}
1209
+ retailerSelected={state.active_retailer?.id_retailer}
1210
+ imagesStatus={state.product?.images_status || "-"}
1211
+ isRetailer={isRetailer}
1212
+ setShowVersionSelector={setShowVersionSelector}
1213
+ version={state.product.version}
1214
+ setImages={handleOnChangeCurrentImage}
1215
+ onClickSave={handleOnClickSaveImages}
1216
+ setAssignation={handleOnChangeAssignations} // No se usa?
1217
+ />
1218
+ </div>
1219
+ <div className="product-information">
1220
+ <div className="product-information">
1221
+ <FullProductNameHeader
1222
+ headerData={state.product}
1223
+ percent={state.active_percentage.percentagesGeneral.required}
1224
+ activeRetailer={{
1225
+ id: state.active_retailer?.id_retailer,
1226
+ name: state.active_retailer?.retailer,
1227
+ image: state.active_retailer?.image,
1228
+ }}
1229
+ showValidationButtons={canShowValidationButtons()}
1230
+ showApproveRejectAll={canShowValidationButtons()}
1231
+ servicesData={state.services_data ? state.services_data : null}
1232
+ approveAll={handleOnApproveAll}
1233
+ rejectAll={handleOnRejectAll}
1234
+ approve={() => handleOnSendEvaluation("A")}
1235
+ reject={handleOnReject}
1236
+ setActiveRetailer={handleOnChangeActiveRetailer}
1200
1237
  />
1201
- <ImageDataTable
1202
- lists={state.images_values || []}
1203
- activeImage={
1204
- state.images_values?.values
1205
- ? state.images_values?.values[state.current_image]
1206
- : {}
1207
- }
1208
- assignationsImages={assig}
1209
- retailerSelected={state.active_retailer?.id_retailer}
1210
- imagesStatus={state.product?.images_status || "-"}
1238
+ <FullTabsMenu
1239
+ tabsSections={tabsSections}
1240
+ status={getStatusByCurrentServiceAndRetailer()}
1241
+ activeTab={state.active_tab}
1242
+ user={user}
1211
1243
  isRetailer={isRetailer}
1212
- setShowVersionSelector={setShowVersionSelector}
1244
+ assig={assig}
1213
1245
  version={state.product.version}
1214
- setImages={handleOnChangeCurrentImage}
1215
- onClickSave={handleOnClickSaveImages}
1216
- setAssignation={handleOnChangeAssignations} // No se usa?
1246
+ updatedDescriptions={state.updated_descriptions_inputs}
1247
+ updatedDatasheets={state.updated_datasheets_inputs}
1248
+ updatedImages={state.updated_images_values}
1249
+ images={state.services.images}
1250
+ // actions
1251
+ downloadImages={handleOnDownloadImages}
1252
+ askToDeleteImages={handleOnAskToDeleteImages}
1253
+ showSaveButton={canShowSaveButton(state.product.version_status)}
1254
+ onClickSave={handleOnClickSave}
1255
+ // setters
1256
+ setActiveTab={handleOnChangeActiveTab}
1257
+ setImageLayout={handleOnSetImageLayout}
1258
+ setUpdatedDescriptions={handleOnSetUpdatedDescriptions}
1259
+ setUpdatedDatasheets={handleOnSetUpdatedDatasheets}
1260
+ setAssignation={handleOnSetAssignation} // No se usa?
1261
+ setImages={handleOnSetImages} // No se usa?
1262
+ // setSelectedImages={handleOnSetSelectedImages} // Se pasa hasta TabsMenu, pero no se usa
1263
+ setShowVersionSelector={setShowVersionSelector}
1217
1264
  />
1218
- </div>
1219
- <div className="product-information">
1220
- <div className="product-information">
1221
- <FullProductNameHeader
1222
- headerData={state.product}
1223
- percent={state.active_percentage.percentagesGeneral.required}
1224
- activeRetailer={{
1225
- id: state.active_retailer?.id_retailer,
1226
- name: state.active_retailer?.retailer,
1227
- image: state.active_retailer?.image,
1228
- }}
1229
- showValidationButtons={canShowValidationButtons()}
1230
- showApproveRejectAll={canShowValidationButtons()}
1231
- servicesData={state.services_data ? state.services_data : null}
1232
- approveAll={handleOnApproveAll}
1233
- rejectAll={handleOnRejectAll}
1234
- approve={() => handleOnSendEvaluation("A")}
1235
- reject={handleOnReject}
1236
- setActiveRetailer={handleOnChangeActiveRetailer}
1237
- />
1238
- <FullTabsMenu
1239
- tabsSections={tabsSections}
1240
- status={getStatusByCurrentServiceAndRetailer()}
1241
- activeTab={state.active_tab}
1242
- user={user}
1243
- isRetailer={isRetailer}
1244
- assig={assig}
1245
- version={state.product.version}
1246
- updatedDescriptions={state.updated_descriptions_inputs}
1247
- updatedDatasheets={state.updated_datasheets_inputs}
1248
- updatedImages={state.updated_images_values}
1249
- images={state.services.images}
1250
- // actions
1251
- downloadImages={handleOnDownloadImages}
1252
- askToDeleteImages={handleOnAskToDeleteImages}
1253
- showSaveButton={canShowSaveButton(state.product.version_status)}
1254
- onClickSave={handleOnClickSave}
1255
- // setters
1256
- setActiveTab={handleOnChangeActiveTab}
1257
- setImageLayout={handleOnSetImageLayout}
1258
- setUpdatedDescriptions={handleOnSetUpdatedDescriptions}
1259
- setUpdatedDatasheets={handleOnSetUpdatedDatasheets}
1260
- setAssignation={handleOnSetAssignation} // No se usa?
1261
- setImages={handleOnSetImages} // No se usa?
1262
- // setSelectedImages={handleOnSetSelectedImages} // Se pasa hasta TabsMenu, pero no se usa
1263
- setShowVersionSelector={setShowVersionSelector}
1264
- />
1265
- <div
1266
- className={
1267
- "services-information-container " +
1268
- (imageLayout && state.active_tab === "Imágenes"
1269
- ? "image-services"
1270
- : "")
1271
- }
1272
- >
1273
- {state.saving ? (
1274
- <Loading />
1275
- ) : (
1276
- <>
1277
- {state.active_tab === "Descripción" &&
1278
- (state.product?.description_status !== "NS" ? (
1279
- <InputGroup
1280
- activeSection={state.active_tab}
1281
- inputGroup={state.descriptions_inputs[0]}
1282
- updatedDescriptions={state.updated_descriptions_inputs}
1283
- articleId={state.product?.id_article}
1284
- version={state.product.version}
1285
- isShowbox={false}
1286
- dinamicHeight={true}
1287
- setUpdatedDescriptions={handleOnSetUpdatedDescriptions}
1288
- updateApprovedInputs={handleOnUpdateApprovedInputs} // No se usa?
1289
- />
1290
- ) : (
1291
- <ScreenHeader
1292
- text={"No cuentas con este servicio"}
1293
- headerType={"input-name-header"}
1294
- />
1295
- ))}
1296
-
1297
- {state.active_tab === "Ficha técnica" &&
1298
- (state.product?.datasheet_status !== "NS" ? (
1299
- <>
1300
- {state.datasheets_inputs[0]?.data?.map(
1301
- (dataGroup, index) => (
1302
- <InputGroup
1303
- index={index}
1304
- key={index + "-" + state.active_retailer.retailer}
1305
- articleId={state.product.id_article}
1306
- version={state.version}
1307
- activeSection={state.active_tab}
1308
- inputGroup={dataGroup}
1309
- dataInputs={state.datasheets_inputs[1]}
1310
- activeRetailer={
1311
- state.services.datasheets[
1312
- state.active_retailer.id_retailer
1313
- ]
1314
- }
1315
- groupData={
1316
- state.services.datasheets[
1317
- state.active_retailer.id_retailer
1318
- ].data
1319
- }
1320
- updatedDatasheets={
1321
- state.updated_datasheets_inputs
1322
- }
1323
- setUpdatedDatasheets={
1324
- handleOnSetUpdatedDatasheets
1325
- }
1326
- isShowbox={true}
1327
- setUpdatedBoxData={(e) => {
1328
- setBoxData(e);
1329
- }}
1330
- updateApprovedInputs={
1331
- handleOnUpdateApprovedInputs // No se usa?
1332
- }
1333
- />
1334
- )
1335
- )}
1336
- </>
1337
- ) : (
1338
- <ScreenHeader
1339
- text={"No cuentas con este servicio"}
1340
- headerType={"input-name-header"}
1341
- />
1342
- ))}
1343
-
1344
- {state.active_tab === "Imágenes" &&
1345
- (state.product?.images_status !== "NS" ? (
1346
- <>
1347
- {!imageLayout && (
1348
- <GalleryHeader
1349
- checkAll={state.all_image_checked} // Determina si el checkbox "Seleccionar todo" está marcado
1350
- setCheckAll={handleOnSetCheckAll} // Toggler de true o false para el checkbox "Seleccionar todo"
1351
- setSelectedImages={handleOnSetSelectedImages}
1265
+ <div
1266
+ className={
1267
+ "services-information-container " +
1268
+ (imageLayout && state.active_tab === "Imágenes"
1269
+ ? "image-services"
1270
+ : "")
1271
+ }
1272
+ >
1273
+ {state.saving ? (
1274
+ <Loading />
1275
+ ) : (
1276
+ <>
1277
+ {state.active_tab === "Descripción" &&
1278
+ (state.product?.description_status !== "NS" ? (
1279
+ <InputGroup
1280
+ activeSection={state.active_tab}
1281
+ inputGroup={state.descriptions_inputs[0]}
1282
+ updatedDescriptions={state.updated_descriptions_inputs}
1283
+ articleId={state.product?.id_article}
1284
+ version={state.product.version}
1285
+ isShowbox={false}
1286
+ dinamicHeight={true}
1287
+ setUpdatedDescriptions={handleOnSetUpdatedDescriptions}
1288
+ updateApprovedInputs={handleOnUpdateApprovedInputs} // No se usa?
1289
+ />
1290
+ ) : (
1291
+ <ScreenHeader
1292
+ text={"No cuentas con este servicio"}
1293
+ headerType={"input-name-header"}
1294
+ />
1295
+ ))}
1296
+
1297
+ {state.active_tab === "Ficha técnica" &&
1298
+ (state.product?.datasheet_status !== "NS" ? (
1299
+ <>
1300
+ {state.datasheets_inputs[0]?.data?.map(
1301
+ (dataGroup, index) => (
1302
+ <InputGroup
1303
+ index={index}
1304
+ key={index + "-" + state.active_retailer.retailer}
1305
+ articleId={state.product.id_article}
1306
+ version={state.version}
1307
+ activeSection={state.active_tab}
1308
+ inputGroup={dataGroup}
1309
+ dataInputs={state.datasheets_inputs[1]}
1310
+ activeRetailer={
1311
+ state.services.datasheets[
1312
+ state.active_retailer.id_retailer
1313
+ ]
1314
+ }
1315
+ groupData={
1316
+ state.services.datasheets[
1317
+ state.active_retailer.id_retailer
1318
+ ].data
1319
+ }
1320
+ updatedDatasheets={
1321
+ state.updated_datasheets_inputs
1322
+ }
1323
+ setUpdatedDatasheets={
1324
+ handleOnSetUpdatedDatasheets
1325
+ }
1326
+ isShowbox={true}
1327
+ setUpdatedBoxData={(e) => {
1328
+ setBoxData(e);
1329
+ }}
1330
+ updateApprovedInputs={
1331
+ handleOnUpdateApprovedInputs // No se usa?
1332
+ }
1352
1333
  />
1353
- )}
1354
- <section
1355
- className="container"
1356
- style={{ position: "relative" }}
1334
+ ),
1335
+ )}
1336
+ </>
1337
+ ) : (
1338
+ <ScreenHeader
1339
+ text={"No cuentas con este servicio"}
1340
+ headerType={"input-name-header"}
1341
+ />
1342
+ ))}
1343
+
1344
+ {state.active_tab === "Imágenes" &&
1345
+ (state.product?.images_status !== "NS" ? (
1346
+ <>
1347
+ {!imageLayout && (
1348
+ <GalleryHeader
1349
+ checkAll={state.all_image_checked} // Determina si el checkbox "Seleccionar todo" está marcado
1350
+ setCheckAll={handleOnSetCheckAll} // Toggler de true o false para el checkbox "Seleccionar todo"
1351
+ setSelectedImages={handleOnSetSelectedImages}
1352
+ />
1353
+ )}
1354
+ <section
1355
+ className="container"
1356
+ style={{ position: "relative" }}
1357
+ >
1358
+ <div
1359
+ {...getRootProps({
1360
+ className: `dropzone ${
1361
+ isDragActive ? "drag-active" : ""
1362
+ }`,
1363
+ })}
1357
1364
  >
1365
+ <input {...getInputProps()} />
1366
+ {isDragActive && (
1367
+ <div className="drag-overlay">
1368
+ <p>Suelta las imágenes aquí</p>
1369
+ </div>
1370
+ )}
1371
+ <aside>{thumbs()}</aside>
1372
+ </div>
1373
+ {state.images_values?.values.length === 0 && (
1358
1374
  <div
1359
- {...getRootProps({
1360
- className: `dropzone ${
1361
- isDragActive ? "drag-active" : ""
1362
- }`,
1363
- })}
1375
+ style={{
1376
+ position: "absolute",
1377
+ top: "50%",
1378
+ left: "50%",
1379
+ transform: "translate(-50%, -50%)",
1380
+ textAlign: "center",
1381
+ padding: "40px",
1382
+ width: "80%",
1383
+ maxWidth: "500px",
1384
+ fontFamily: "Arial, sans-serif",
1385
+ }}
1364
1386
  >
1365
- <input {...getInputProps()} />
1366
- {isDragActive && (
1367
- <div className="drag-overlay">
1368
- <p>Suelta las imágenes aquí</p>
1369
- </div>
1370
- )}
1371
- <aside>{thumbs()}</aside>
1372
- </div>
1373
- {state.images_values?.values.length === 0 && (
1374
- <div
1387
+ <p
1375
1388
  style={{
1376
- position: "absolute",
1377
- top: "50%",
1378
- left: "50%",
1379
- transform: "translate(-50%, -50%)",
1380
- textAlign: "center",
1381
- padding: "40px",
1382
- width: "80%",
1383
- maxWidth: "500px",
1384
- fontFamily: "Arial, sans-serif",
1389
+ fontSize: "18px",
1390
+ color: "#666",
1391
+ marginBottom: "16px",
1385
1392
  }}
1386
1393
  >
1387
- <p
1388
- style={{
1389
- fontSize: "18px",
1390
- color: "#666",
1391
- marginBottom: "16px",
1392
- }}
1393
- >
1394
- Este producto no tiene imágenes
1395
- </p>
1396
- <p
1394
+ Este producto no tiene imágenes
1395
+ </p>
1396
+ <p
1397
+ style={{
1398
+ fontSize: "14px",
1399
+ color: "#999",
1400
+ marginBottom: "20px",
1401
+ }}
1402
+ >
1403
+ Arrastra las imágenes aquí o{" "}
1404
+ <span
1405
+ onClick={open}
1397
1406
  style={{
1398
- fontSize: "14px",
1399
- color: "#999",
1400
- marginBottom: "20px",
1407
+ color: "#007bff",
1408
+ cursor: "pointer",
1409
+ textDecoration: "underline",
1401
1410
  }}
1402
1411
  >
1403
- Arrastra las imágenes aquí o{" "}
1404
- <span
1405
- onClick={open}
1406
- style={{
1407
- color: "#007bff",
1408
- cursor: "pointer",
1409
- textDecoration: "underline",
1410
- }}
1411
- >
1412
- haz clic para abrir el explorador de archivos
1413
- </span>
1414
- </p>
1415
- </div>
1416
- )}
1417
- </section>
1418
- </>
1419
- ) : (
1420
- <ScreenHeader
1421
- text={"No cuentas con este servicio"}
1422
- headerType={"input-name-header"}
1423
- />
1424
- ))}
1425
- </>
1426
- )}
1427
- </div>
1412
+ haz clic para abrir el explorador de archivos
1413
+ </span>
1414
+ </p>
1415
+ </div>
1416
+ )}
1417
+ </section>
1418
+ </>
1419
+ ) : (
1420
+ <ScreenHeader
1421
+ text={"No cuentas con este servicio"}
1422
+ headerType={"input-name-header"}
1423
+ />
1424
+ ))}
1425
+ </>
1426
+ )}
1428
1427
  </div>
1429
1428
  </div>
1430
1429
  </div>
1431
- </Container>
1432
- </AiProductEditionProvider>
1430
+ </div>
1431
+ </Container>
1433
1432
  );
1434
1433
  };
1435
1434
 
1436
1435
  export const ProviderProductEdition = (props) => {
1437
1436
  return (
1438
1437
  <ProviderProductEditionProvider>
1439
- <ProviderProductEditionView {...props} />
1438
+ <ProviderProductEditionView {...props} />
1440
1439
  </ProviderProductEditionProvider>
1441
1440
  );
1442
1441
  };