contentoh-components-library 21.5.97 → 21.5.99

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/dist/components/atoms/GeneralButton/styles.js +1 -1
  2. package/dist/components/atoms/GeneralInput/index.js +54 -249
  3. package/dist/components/atoms/GeneralInput/styles.js +3 -7
  4. package/dist/components/atoms/InputFormatter/index.js +68 -223
  5. package/dist/components/atoms/InputFormatter/styles.js +4 -20
  6. package/dist/components/molecules/StatusAsignationInfo/index.js +1 -11
  7. package/dist/components/molecules/TabsMenu/index.js +1 -13
  8. package/dist/components/molecules/TagAndInput/index.js +24 -364
  9. package/dist/components/molecules/TagAndInput/styles.js +2 -2
  10. package/dist/components/organisms/FullProductNameHeader/index.js +22 -6
  11. package/dist/components/organisms/InputGroup/index.js +18 -22
  12. package/dist/components/pages/ProviderProductEdition/ProviderProductEdition.stories.js +337 -150
  13. package/dist/components/pages/ProviderProductEdition/context/provider-product-edition.context.js +15 -15
  14. package/dist/components/pages/ProviderProductEdition/index.js +376 -412
  15. package/dist/components/pages/ProviderProductEdition/utils.js +0 -1
  16. package/dist/components/pages/RetailerProductEdition/RetailerProductEdition.stories.js +211 -125
  17. package/dist/components/pages/RetailerProductEdition/index.js +2236 -1738
  18. package/dist/components/pages/RetailerProductEdition/styles.js +2 -4
  19. package/dist/components/pages/RetailerProductEdition/utils.js +2 -251
  20. package/package.json +2 -4
  21. package/src/components/atoms/GeneralButton/styles.js +0 -4
  22. package/src/components/atoms/GeneralInput/index.js +60 -241
  23. package/src/components/atoms/GeneralInput/styles.js +0 -81
  24. package/src/components/atoms/InputFormatter/index.js +51 -200
  25. package/src/components/atoms/InputFormatter/styles.js +0 -284
  26. package/src/components/molecules/StatusAsignationInfo/index.js +1 -9
  27. package/src/components/molecules/TabsMenu/index.js +0 -12
  28. package/src/components/molecules/TagAndInput/index.js +21 -294
  29. package/src/components/molecules/TagAndInput/styles.js +17 -59
  30. package/src/components/organisms/FullProductNameHeader/index.js +28 -4
  31. package/src/components/organisms/FullTabsMenu/index.js +1 -1
  32. package/src/components/organisms/InputGroup/index.js +4 -12
  33. package/src/components/pages/ProviderProductEdition/ProviderProductEdition.stories.js +202 -174
  34. package/src/components/pages/ProviderProductEdition/context/provider-product-edition.context.jsx +14 -14
  35. package/src/components/pages/ProviderProductEdition/index.js +420 -494
  36. package/src/components/pages/ProviderProductEdition/utils.js +2 -2
  37. package/src/components/pages/RetailerProductEdition/RetailerProductEdition.stories.js +243 -136
  38. package/src/components/pages/RetailerProductEdition/index.js +1717 -1563
  39. package/src/components/pages/RetailerProductEdition/styles.js +2 -67
  40. package/src/components/pages/RetailerProductEdition/utils.js +0 -240
  41. package/src/ai/utils/compare-strings.js +0 -45
  42. package/src/assets/images/Icons/arrow.png +0 -0
  43. package/src/assets/images/Icons/cancel.png +0 -0
  44. package/src/assets/images/Icons/ia-icon.png +0 -0
  45. package/src/assets/images/Icons/loading.svg +0 -5
  46. package/src/assets/images/Icons/reload.png +0 -0
  47. package/src/components/atoms/RetailerSelector/RetailerSelector.stories.js +0 -10
  48. package/src/components/atoms/RetailerSelector/index.js +0 -3
  49. package/src/components/atoms/RetailerSelector/styles.js +0 -0
  50. package/src/components/organisms/ChangeStatusModal/index.jsx +0 -488
  51. package/src/components/organisms/ChangeStatusModal/styles.js +0 -333
  52. package/src/components/pages/RetailerProductEdition/context/provider-product-edition.context.jsx +0 -575
  53. package/src/components/pages/RetailerProductEdition/context/provider-product-edition.reducer.js +0 -62
  54. package/src/components/pages/RetailerProductEdition/context/reducers/active-state.js +0 -344
  55. package/src/components/pages/RetailerProductEdition/context/reducers/inputs.js +0 -155
  56. package/src/components/pages/RetailerProductEdition/context/reducers/product.js +0 -114
  57. package/src/components/pages/RetailerProductEdition/context/reducers/system.js +0 -60
  58. package/src/components/pages/RetailerProductEdition/index_old.js +0 -1979
  59. package/src/components/pages/RetailerProductEdition/stories/Auditor.stories.js +0 -101
  60. package/src/components/pages/RetailerProductEdition/stories/ImageEditor.stories.js +0 -115
  61. package/src/components/pages/RetailerProductEdition/stories/TextEditor.stories.js +0 -174
  62. package/src/contexts/AiProductEdition.jsx +0 -347
  63. package/src/global-files/statusDictionary.js +0 -103
@@ -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,
@@ -70,6 +69,7 @@ const ProviderProductEditionView = ({
70
69
 
71
70
  const isRetailer = user?.is_retailer;
72
71
 
72
+ const [boxData, setBoxData] = useState(null);
73
73
  const [showModal, setShowModal] = useState(false);
74
74
  const [showRejectModal, setShowRejectModal] = useState(false);
75
75
  const [headerTop, setHeaderTop] = useState(0);
@@ -143,16 +143,19 @@ const ProviderProductEditionView = ({
143
143
  useEffect(() => {
144
144
  const setProductData = () => {
145
145
  try {
146
- const product = productSelected
147
- ? productSelected
148
- : JSON.parse(sessionStorage.getItem("productSelected"));
146
+ const product = JSON.parse(sessionStorage.getItem("productSelected"))
147
+ ? JSON.parse(sessionStorage.getItem("productSelected"))
148
+ : productSelected;
149
149
 
150
150
  const productNormalized = normalizeProduct(product);
151
151
 
152
+ console.log({ productNormalized });
153
+
152
154
  dispatch({
153
155
  type: "SET_PRODUCT",
154
156
  payload: productNormalized,
155
157
  });
158
+
156
159
  if (
157
160
  productNormalized.categoryRetailerInOrder.length > 0 &&
158
161
  productNormalized.statusByRetailer
@@ -253,29 +256,6 @@ const ProviderProductEditionView = ({
253
256
  return orderA - orderB;
254
257
  });
255
258
 
256
- //Cuando carguemos la información de los servicios, las actualizamos en el estado del producto
257
-
258
- const updatedStatusByRetailer = servicesDataRes.reduce(
259
- (acc, current, idx) => {
260
- const { id_retailer, service, status } = current;
261
-
262
- if (!acc[id_retailer]) acc[id_retailer] = {};
263
-
264
- acc[id_retailer][service] = status;
265
-
266
- return acc;
267
- },
268
- {},
269
- );
270
-
271
- dispatch({
272
- type: "SET_PRODUCT",
273
- payload: {
274
- ...state.product,
275
- statusByRetailer: updatedStatusByRetailer,
276
- },
277
- });
278
-
279
259
  dispatch({
280
260
  type: "SET_SERVICES",
281
261
  payload: {
@@ -295,7 +275,7 @@ const ProviderProductEditionView = ({
295
275
  dispatch({
296
276
  type: "SET_ACTIVE_PERCENTAGES",
297
277
  payload: percentages.find(
298
- ({ id_retailer: rId }) => rId === id_retailer
278
+ ({ id_retailer: rId }) => rId === id_retailer,
299
279
  ),
300
280
  });
301
281
  } catch (error) {
@@ -307,16 +287,7 @@ const ProviderProductEditionView = ({
307
287
  };
308
288
 
309
289
  fetchData();
310
- }, [
311
- state.product?.datasheet_status,
312
- state.product?.description_status,
313
- state.product?.images_status,
314
- state.product?.status,
315
- state.product?.percentages,
316
- state.product?.version,
317
- state.active_retailer,
318
- token
319
- ]);
290
+ }, [state.product, state.active_retailer, token]);
320
291
 
321
292
  // Actualizador de campos del ui para que coincidan con el retailer activo
322
293
  useEffect(() => {
@@ -324,14 +295,15 @@ const ProviderProductEditionView = ({
324
295
  console.log("Actualizar inputs del retailer activo");
325
296
  const updateInputsActiveRetailer = () => {
326
297
  if (!state.services) return;
327
-
328
298
  if (state.services.datasheets) {
329
299
  const retailerDatasheets =
330
300
  state.services.datasheets[state.active_retailer.id_retailer];
301
+
331
302
  const datasheetsActiveRetailer = {
332
303
  ...retailerDatasheets,
333
304
  data: Object.values(retailerDatasheets.data),
334
305
  };
306
+
335
307
  dispatch({
336
308
  type: "SET_DATASHEETS_INPUTS",
337
309
  payload: [datasheetsActiveRetailer, state.services.datasheets.inputs],
@@ -377,54 +349,37 @@ const ProviderProductEditionView = ({
377
349
  const canShowValidationButtons = () => {
378
350
  if (!state.product?.statusByRetailer) return false;
379
351
 
380
- try {
381
- const currentService = getConceptByTab(state.active_tab);
382
- // const currentStatus = state.product[`${currentService}_status`];
383
- const currentRetailer = state.active_retailer.id_retailer;
384
-
385
- //Información del servicio de la cadena seleccionada
386
- const { status: currentStatus } = state.services_data.find(
387
- (service) =>
388
- service.service === currentService &&
389
- service.id_retailer === currentRetailer,
390
- );
391
-
392
- const originTab = origin[state.active_tab];
393
- const isRetailerUser = user?.is_retailer === 1;
394
-
395
- const validStatuses = ["AA", "AP", "R", "CA", "RCA"];
396
- if (!validStatuses.includes(currentStatus)) return false;
352
+ const currentService = getConceptByTab(state.active_tab);
353
+ const currentStatus = state.product[`${currentService}_status`];
354
+ const originTab = origin[state.active_tab];
355
+ const isRetailerUser = user?.is_retailer === 1;
397
356
 
398
- const validOrigins = [
399
- "RequestWithContentoh",
400
- "RequestWithoutContentoh",
401
- "Contentoh",
402
- ];
357
+ const validStatuses = ["AA", "AP", "R", "CA", "RCA"];
358
+ if (!validStatuses.includes(currentStatus)) return false;
403
359
 
404
- if (!validOrigins.includes(originTab)) return false;
360
+ const validOrigins = [
361
+ "RequestWithContentoh",
362
+ "RequestWithoutContentoh",
363
+ "Contentoh",
364
+ ];
405
365
 
406
- // Retailer: solo AP
407
- if (isRetailerUser) {
408
- return currentStatus === "AP";
409
- }
366
+ if (!validOrigins.includes(originTab)) return false;
410
367
 
411
- // No retailer
412
- const hasNoOrder = !state.product.id_order && !state.product.orderId;
368
+ // Retailer: solo AP
369
+ if (isRetailerUser) {
370
+ return currentStatus === "AP";
371
+ }
413
372
 
414
- const condition =
415
- (
416
- originTab === "RequestWithoutContentoh" && (
417
- ["R", "CA"].includes(currentStatus) || (currentStatus === "RCA" && hasNoOrder)
418
- )
419
- ) ||
420
- (
421
- ["RequestWithContentoh", "Contentoh"].includes(originTab) && currentStatus === "AA"
422
- )
373
+ // No retailer
374
+ const hasNoOrder = !state.product.id_order && !state.product.orderId;
423
375
 
424
- return condition;
425
- } catch (error) {
426
- return false;
427
- }
376
+ return (
377
+ (originTab === "RequestWithoutContentoh" &&
378
+ (["R", "CA"].includes(currentStatus) ||
379
+ (currentStatus === "RCA" && hasNoOrder))) ||
380
+ (["RequestWithContentoh", "Contentoh"].includes(originTab) &&
381
+ currentStatus === "AA")
382
+ );
428
383
  };
429
384
 
430
385
  const canShowSaveButton = (version_status) => {
@@ -445,9 +400,8 @@ const ProviderProductEditionView = ({
445
400
 
446
401
  const currentService = getConceptByTab(state.active_tab);
447
402
  const currentRetailer = state.active_retailer.id_retailer;
448
-
449
403
  const currentStatus =
450
- statusByRetailer[currentRetailer][currentService] || "N/S";
404
+ statusByRetailer[currentRetailer][currentService] || "ERR";
451
405
  return currentStatus;
452
406
  };
453
407
 
@@ -709,7 +663,6 @@ const ProviderProductEditionView = ({
709
663
  state.product[sectionStatusKey] || state.product?.version_status;
710
664
 
711
665
  let data = { articleId, orderId, concept, evalStatus };
712
-
713
666
  const retailerId = state.active_retailer?.id_retailer;
714
667
 
715
668
  try {
@@ -730,7 +683,6 @@ const ProviderProductEditionView = ({
730
683
  const newStatuses = JSON.parse(res.data.body);
731
684
  const serviceStatus =
732
685
  newStatuses.newServiceStatus[articleId][`${concept}Status`];
733
-
734
686
 
735
687
  // Actualizar el producto con los nuevos estados
736
688
  const updatedProduct = {
@@ -739,22 +691,12 @@ const ProviderProductEditionView = ({
739
691
  ...state.product.statusByRetailer,
740
692
  [retailerId]: {
741
693
  ...state.product.statusByRetailer[retailerId],
742
- [concept]: newStatuses?.newStatus ?? serviceStatus,
694
+ [concept]: serviceStatus,
743
695
  },
744
696
  },
745
697
  };
746
698
 
747
- const updatedServicesData = state.services_data?.map((service) => ({
748
- ...service,
749
- status:
750
- service?.id_retailer === retailerId && service?.service === concept
751
- ? newStatuses?.newStatus ?? serviceStatus
752
- : service?.status,
753
- }));
754
-
755
- dispatch({ type: "SET_SERVICES_DATA", payload: updatedServicesData });
756
-
757
- // console.log({ updatedProduct });
699
+ console.log({ updatedProduct });
758
700
 
759
701
  dispatch({ type: "SET_PRODUCT", payload: updatedProduct });
760
702
 
@@ -983,7 +925,7 @@ const ProviderProductEditionView = ({
983
925
  headers: {
984
926
  Authorization: token,
985
927
  },
986
- })
928
+ }),
987
929
  );
988
930
  });
989
931
 
@@ -1028,7 +970,7 @@ const ProviderProductEditionView = ({
1028
970
  ArticleId: updatedProduct.id_article,
1029
971
  idCategory: updatedProduct.id_category,
1030
972
  product: updatedProduct,
1031
- })
973
+ }),
1032
974
  );
1033
975
 
1034
976
  // Mostrar modal de éxito
@@ -1094,427 +1036,411 @@ const ProviderProductEditionView = ({
1094
1036
  if (state.loading || !state.services || !state.product) return <Loading />;
1095
1037
 
1096
1038
  return (
1097
- <AiProductEditionProvider
1098
- isCreatorsEdition={false}
1099
- state={state}
1100
- >
1101
- <Container headerTop={headerTop}>
1102
- {showVersionSelector && (
1103
- <VersionSelector
1104
- modalId={"version-selector"}
1105
- articleId={state.product.id_article}
1106
- setVersion={handleOnChangeProductVersion}
1107
- companyName={company.company_name}
1108
- currentVersion={state.product.version}
1109
- setShowVersionSelector={setShowVersionSelector}
1110
- jwt={token}
1111
- />
1112
- )}
1113
- {showModal && (
1114
- <ProductImageModal
1115
- images={state.images_values}
1116
- setShowModal={setShowModal}
1117
- approveRejectButtons={canShowValidationButtons()}
1118
- sendToFacilitator={handleOnSendEvaluation}
1119
- />
1120
- )}
1121
- {state.modal.show && (
1122
- <GenericModal
1123
- componentsArray={[
1124
- state.modal.image && (
1125
- <img key="1" src={state.modal.image} alt="modal icon" />
1126
- ),
1127
- state.modal.title && (
1128
- <ScreenHeader
1129
- key="2"
1130
- headerType={"retailer-name-header"}
1131
- text={state.modal.title}
1132
- color={"white"}
1133
- />
1134
- ),
1135
- state.modal.message && (
1136
- <ScreenHeader
1137
- key="3"
1138
- headerType={"retailer-name-header"}
1139
- text={state.modal.message}
1140
- color={"white"}
1141
- />
1142
- ),
1143
- state.modal.buttons && (
1144
- <div key="4" style={{ marginTop: "16px" }}>
1145
- {state.modal.buttons.map((button, index) => (
1146
- <Button
1147
- key={index}
1148
- buttonType={button.buttonType}
1149
- label={button.text}
1150
- onClick={button.action}
1151
- />
1152
- ))}
1153
- </div>
1154
- ),
1155
- ].filter(Boolean)}
1156
- onClick={() =>
1157
- dispatch({
1158
- type: "SET_MODAL",
1159
- payload: { show: false, title: "", message: "", image: null },
1160
- })
1161
- }
1162
- />
1163
- )}
1164
- {showRejectModal && (
1165
- <Modal
1166
- title={
1167
- rejectAll
1168
- ? "Agregar mensaje para rechazar todo"
1169
- : "Agregar mensaje de rechazo"
1170
- }
1171
- show={showRejectModal}
1172
- customComponent={
1173
- <TagAndInput
1174
- inputType={"textarea"}
1175
- inputId={"modal-message-box"}
1176
- index={0}
1039
+ <Container headerTop={headerTop}>
1040
+ {/* <button onClick={() => console.log(state)}>log</button> */}
1041
+ {showVersionSelector && (
1042
+ <VersionSelector
1043
+ modalId={"version-selector"}
1044
+ articleId={state.product.id_article}
1045
+ setVersion={handleOnChangeProductVersion}
1046
+ companyName={company.company_name}
1047
+ currentVersion={state.product.version}
1048
+ setShowVersionSelector={setShowVersionSelector}
1049
+ jwt={token}
1050
+ />
1051
+ )}
1052
+ {showModal && (
1053
+ <ProductImageModal
1054
+ images={state.images_values}
1055
+ setShowModal={setShowModal}
1056
+ approveRejectButtons={canShowValidationButtons()}
1057
+ sendToFacilitator={handleOnSendEvaluation}
1058
+ />
1059
+ )}
1060
+ {state.modal.show && (
1061
+ <GenericModal
1062
+ componentsArray={[
1063
+ state.modal.image && (
1064
+ <img key="1" src={state.modal.image} alt="modal icon" />
1065
+ ),
1066
+ state.modal.title && (
1067
+ <ScreenHeader
1068
+ key="2"
1069
+ headerType={"retailer-name-header"}
1070
+ text={state.modal.title}
1177
1071
  color={"white"}
1178
1072
  />
1179
- }
1180
- buttons={[
1181
- <ButtonV2
1182
- key={"btn-Cancelar"}
1183
- type={"white"}
1184
- label={"Cancelar"}
1185
- size={12}
1186
- onClick={() => {
1187
- setShowRejectModal(false);
1188
- }}
1189
- />,
1190
- <ButtonV2
1191
- key={"btn-Aceptar"}
1192
- type={"pink"}
1193
- label={"Aceptar"}
1194
- size={12}
1195
- onClick={async () => {
1196
- const elements = document.querySelectorAll(
1197
- "#modal-message-box .ql-container .ql-editor > p",
1198
- );
1073
+ ),
1074
+ state.modal.message && (
1075
+ <ScreenHeader
1076
+ key="3"
1077
+ headerType={"retailer-name-header"}
1078
+ text={state.modal.message}
1079
+ color={"white"}
1080
+ />
1081
+ ),
1082
+ state.modal.buttons && (
1083
+ <div key="4" style={{ marginTop: "16px" }}>
1084
+ {state.modal.buttons.map((button, index) => (
1085
+ <Button
1086
+ key={index}
1087
+ buttonType={button.buttonType}
1088
+ label={button.text}
1089
+ onClick={button.action}
1090
+ />
1091
+ ))}
1092
+ </div>
1093
+ ),
1094
+ ].filter(Boolean)}
1095
+ onClick={() =>
1096
+ dispatch({
1097
+ type: "SET_MODAL",
1098
+ payload: { show: false, title: "", message: "", image: null },
1099
+ })
1100
+ }
1101
+ />
1102
+ )}
1103
+ {showRejectModal && (
1104
+ <Modal
1105
+ title={
1106
+ rejectAll
1107
+ ? "Agregar mensaje para rechazar todo"
1108
+ : "Agregar mensaje de rechazo"
1109
+ }
1110
+ show={showRejectModal}
1111
+ customComponent={
1112
+ <TagAndInput
1113
+ inputType={"textarea"}
1114
+ inputId={"modal-message-box"}
1115
+ index={0}
1116
+ color={"white"}
1117
+ />
1118
+ }
1119
+ buttons={[
1120
+ <ButtonV2
1121
+ key={"btn-Cancelar"}
1122
+ type={"white"}
1123
+ label={"Cancelar"}
1124
+ size={12}
1125
+ onClick={() => {
1126
+ setShowRejectModal(false);
1127
+ }}
1128
+ />,
1129
+ <ButtonV2
1130
+ key={"btn-Aceptar"}
1131
+ type={"pink"}
1132
+ label={"Aceptar"}
1133
+ size={12}
1134
+ onClick={async () => {
1135
+ const elements = document.querySelectorAll(
1136
+ "#modal-message-box .ql-container .ql-editor > p",
1137
+ );
1138
+
1139
+ if (!elements || elements.length === 0) {
1140
+ console.error("Elemento no encontrado");
1141
+ return;
1142
+ }
1199
1143
 
1200
- if (!elements || elements.length === 0) {
1201
- console.error("Elemento no encontrado");
1202
- return;
1203
- }
1144
+ const isMessageEmpty = Array.from(elements).every((el) => {
1145
+ const body = el.innerHTML;
1146
+ return !body || body.replace(/<.*?\/?>/gm, "").trim() === "";
1147
+ });
1204
1148
 
1205
- const isMessageEmpty = Array.from(elements).every((el) => {
1206
- const body = el.innerHTML;
1207
- return (
1208
- !body || body.replace(/<.*?\/?>/gm, "").trim() === ""
1209
- );
1210
- });
1211
-
1212
- if (isMessageEmpty) {
1213
- const container = document.querySelector(
1214
- ".container-customComponent",
1215
- );
1216
- const existingAlert =
1217
- container.querySelector(".alert-error");
1218
-
1219
- if (!existingAlert) {
1220
- const alert = document.createElement("div");
1221
- alert.className = "alert-error";
1222
- alert.style.cssText = `
1223
- color: #d32f2f;
1224
- background-color: #ffebee;
1225
- border: 1px solid #ef5350;
1226
- border-radius: 4px;
1227
- padding: 12px 16px;
1228
- margin-top: 10px;
1229
- font-size: 14px;
1230
- display: flex;
1231
- align-items: center;
1232
- gap: 8px;
1233
- font-family: 'Roboto', sans-serif;
1234
- text-align: center;
1235
- `;
1236
- alert.innerHTML = `<span>El mensaje no puede estar vacío.</span>`;
1237
- container.appendChild(alert);
1238
- }
1239
- return;
1149
+ if (isMessageEmpty) {
1150
+ const container = document.querySelector(
1151
+ ".container-customComponent",
1152
+ );
1153
+ const existingAlert = container.querySelector(".alert-error");
1154
+
1155
+ if (!existingAlert) {
1156
+ const alert = document.createElement("div");
1157
+ alert.className = "alert-error";
1158
+ alert.style.cssText = `
1159
+ color: #d32f2f;
1160
+ background-color: #ffebee;
1161
+ border: 1px solid #ef5350;
1162
+ border-radius: 4px;
1163
+ padding: 12px 16px;
1164
+ margin-top: 10px;
1165
+ font-size: 14px;
1166
+ display: flex;
1167
+ align-items: center;
1168
+ gap: 8px;
1169
+ font-family: 'Roboto', sans-serif;
1170
+ text-align: center;
1171
+ `;
1172
+ alert.innerHTML = `<span>El mensaje no puede estar vacío.</span>`;
1173
+ container.appendChild(alert);
1240
1174
  }
1175
+ return;
1176
+ }
1241
1177
 
1242
- const fullMessage = Array.from(elements)
1243
- .map((element) => element.innerHTML)
1244
- .join("")
1245
- .replace(/<br\s*\/?>/gi, "\n");
1178
+ const fullMessage = Array.from(elements)
1179
+ .map((element) => element.innerHTML)
1180
+ .join("")
1181
+ .replace(/<br\s*\/?>/gi, "\n");
1246
1182
 
1247
- await createComment(fullMessage, token);
1183
+ await createComment(fullMessage);
1248
1184
 
1249
- rejectAll
1250
- ? handleOnEvaluateAll("R")
1251
- : handleOnSendEvaluation("R");
1252
- setShowRejectModal(false);
1253
- }}
1254
- />,
1255
- ]}
1256
- />
1257
- )}
1258
- <HeaderTop
1259
- setHeaderTop={setHeaderTop}
1260
- withChat={location?.state?.withChat}
1261
- chatType={location?.state?.chatType}
1262
- productSelected={state.product}
1263
- token={token}
1264
- activeRetailer={{
1265
- id: state.active_retailer?.id_retailer,
1266
- name: state.active_retailer?.retailer,
1267
- }}
1185
+ rejectAll
1186
+ ? handleOnEvaluateAll("R")
1187
+ : handleOnSendEvaluation("R");
1188
+ setShowRejectModal(false);
1189
+ }}
1190
+ />,
1191
+ ]}
1268
1192
  />
1269
- <div className="data-container">
1270
- <div className="image-data-panel">
1271
- <ImagePreviewer
1272
- activeImage={
1273
- state.images_values.values[state.current_image] ?? {}
1274
- }
1275
- imagesArray={state.images_values || []}
1276
- setActiveImage={handleOnChangeCurrentImage}
1277
- setShowModal={handleOnShowModalGalery}
1193
+ )}
1194
+ <HeaderTop
1195
+ setHeaderTop={setHeaderTop}
1196
+ withChat={location?.state?.withChat}
1197
+ chatType={location?.state?.chatType}
1198
+ productSelected={state.product}
1199
+ token={token}
1200
+ activeRetailer={{
1201
+ id: state.active_retailer?.id_retailer,
1202
+ name: state.active_retailer?.retailer,
1203
+ }}
1204
+ />
1205
+ <div className="data-container">
1206
+ <div className="image-data-panel">
1207
+ <ImagePreviewer
1208
+ activeImage={state.images_values.values[state.current_image] ?? {}}
1209
+ imagesArray={state.images_values || []}
1210
+ setActiveImage={handleOnChangeCurrentImage}
1211
+ setShowModal={handleOnShowModalGalery}
1212
+ />
1213
+ <ImageDataTable
1214
+ lists={state.images_values || []}
1215
+ activeImage={
1216
+ state.images_values?.values
1217
+ ? state.images_values?.values[state.current_image]
1218
+ : {}
1219
+ }
1220
+ assignationsImages={assig}
1221
+ retailerSelected={state.active_retailer?.id_retailer}
1222
+ imagesStatus={state.product?.images_status || "-"}
1223
+ isRetailer={isRetailer}
1224
+ setShowVersionSelector={setShowVersionSelector}
1225
+ version={state.product.version}
1226
+ setImages={handleOnChangeCurrentImage}
1227
+ onClickSave={handleOnClickSaveImages}
1228
+ setAssignation={handleOnChangeAssignations} // No se usa?
1229
+ />
1230
+ </div>
1231
+ <div className="product-information">
1232
+ <div className="product-information">
1233
+ <FullProductNameHeader
1234
+ headerData={state.product}
1235
+ percent={state.active_percentage.percentagesGeneral.required}
1236
+ activeRetailer={{
1237
+ id: state.active_retailer?.id_retailer,
1238
+ name: state.active_retailer?.retailer,
1239
+ image: state.active_retailer?.image,
1240
+ }}
1241
+ showValidationButtons={canShowValidationButtons()}
1242
+ showApproveRejectAll={canShowValidationButtons()}
1243
+ servicesData={state.services_data ? state.services_data : null}
1244
+ approveAll={handleOnApproveAll}
1245
+ rejectAll={handleOnRejectAll}
1246
+ approve={() => handleOnSendEvaluation("A")}
1247
+ reject={handleOnReject}
1248
+ setActiveRetailer={handleOnChangeActiveRetailer}
1278
1249
  />
1279
- <ImageDataTable
1280
- lists={state.images_values || []}
1281
- activeImage={
1282
- state.images_values?.values
1283
- ? state.images_values?.values[state.current_image]
1284
- : {}
1285
- }
1286
- assignationsImages={assig}
1287
- retailerSelected={state.active_retailer?.id_retailer}
1288
- imagesStatus={state.product?.images_status || "-"}
1250
+ <FullTabsMenu
1251
+ tabsSections={tabsSections}
1252
+ status={getStatusByCurrentServiceAndRetailer()}
1253
+ activeTab={state.active_tab}
1254
+ user={user}
1289
1255
  isRetailer={isRetailer}
1290
- setShowVersionSelector={setShowVersionSelector}
1256
+ assig={assig}
1291
1257
  version={state.product.version}
1292
- setImages={handleOnChangeCurrentImage}
1293
- onClickSave={handleOnClickSaveImages}
1294
- setAssignation={handleOnChangeAssignations} // No se usa?
1258
+ updatedDescriptions={state.updated_descriptions_inputs}
1259
+ updatedDatasheets={state.updated_datasheets_inputs}
1260
+ updatedImages={state.updated_images_values}
1261
+ images={state.services.images}
1262
+ // actions
1263
+ downloadImages={handleOnDownloadImages}
1264
+ askToDeleteImages={handleOnAskToDeleteImages}
1265
+ showSaveButton={canShowSaveButton(state.product.version_status)}
1266
+ onClickSave={handleOnClickSave}
1267
+ // setters
1268
+ setActiveTab={handleOnChangeActiveTab}
1269
+ setImageLayout={handleOnSetImageLayout}
1270
+ setUpdatedDescriptions={handleOnSetUpdatedDescriptions}
1271
+ setUpdatedDatasheets={handleOnSetUpdatedDatasheets}
1272
+ setAssignation={handleOnSetAssignation} // No se usa?
1273
+ setImages={handleOnSetImages} // No se usa?
1274
+ // setSelectedImages={handleOnSetSelectedImages} // Se pasa hasta TabsMenu, pero no se usa
1275
+ setShowVersionSelector={setShowVersionSelector}
1295
1276
  />
1296
- </div>
1297
- <div className="product-information">
1298
- <div className="product-information">
1299
- <FullProductNameHeader
1300
- headerData={state.product}
1301
- percent={state.active_percentage.percentagesGeneral.required}
1302
- activeRetailer={{
1303
- id: state.active_retailer?.id_retailer,
1304
- name: state.active_retailer?.retailer,
1305
- image: state.active_retailer?.image,
1306
- }}
1307
- showValidationButtons={canShowValidationButtons()}
1308
- showApproveRejectAll={canShowValidationButtons()}
1309
- servicesData={state.services_data ? state.services_data : null}
1310
- approveAll={handleOnApproveAll}
1311
- rejectAll={handleOnRejectAll}
1312
- approve={() => handleOnSendEvaluation("A")}
1313
- reject={handleOnReject}
1314
- setActiveRetailer={handleOnChangeActiveRetailer}
1315
- />
1316
- <FullTabsMenu
1317
- tabsSections={tabsSections}
1318
- status={getStatusByCurrentServiceAndRetailer()}
1319
- activeTab={state.active_tab}
1320
- user={user}
1321
- isRetailer={isRetailer}
1322
- assig={assig}
1323
- version={state.product.version}
1324
- updatedDescriptions={state.updated_descriptions_inputs}
1325
- updatedDatasheets={state.updated_datasheets_inputs}
1326
- updatedImages={state.updated_images_values}
1327
- images={state.services.images}
1328
- // actions
1329
- downloadImages={handleOnDownloadImages}
1330
- askToDeleteImages={handleOnAskToDeleteImages}
1331
- showSaveButton={canShowSaveButton(state.product.version_status)}
1332
- onClickSave={handleOnClickSave}
1333
- // setters
1334
- setActiveTab={handleOnChangeActiveTab}
1335
- setImageLayout={handleOnSetImageLayout}
1336
- setUpdatedDescriptions={handleOnSetUpdatedDescriptions}
1337
- setUpdatedDatasheets={handleOnSetUpdatedDatasheets}
1338
- setAssignation={handleOnSetAssignation} // No se usa?
1339
- setImages={handleOnSetImages} // No se usa?
1340
- // setSelectedImages={handleOnSetSelectedImages} // Se pasa hasta TabsMenu, pero no se usa
1341
- setShowVersionSelector={setShowVersionSelector}
1342
- />
1343
- <div
1344
- className={
1345
- "services-information-container " +
1346
- (imageLayout && state.active_tab === "Imágenes"
1347
- ? "image-services"
1348
- : "")
1349
- }
1350
- >
1351
- {state.saving ? (
1352
- <Loading />
1353
- ) : (
1354
- <>
1355
- {state.active_tab === "Descripción" &&
1356
- (state.product?.description_status !== "NS" ? (
1357
- <InputGroup
1358
- activeSection={state.active_tab}
1359
- inputGroup={state.descriptions_inputs[0]}
1360
- updatedDescriptions={
1361
- state.updated_descriptions_inputs
1362
- }
1363
- articleId={state.product?.id_article}
1364
- version={state.product.version}
1365
- isShowbox={false}
1366
- dinamicHeight={true}
1367
- setUpdatedDescriptions={
1368
- handleOnSetUpdatedDescriptions
1369
- }
1370
- updateApprovedInputs={handleOnUpdateApprovedInputs} // No se usa?
1371
- />
1372
- ) : (
1373
- <ScreenHeader
1374
- text={"No cuentas con este servicio"}
1375
- headerType={"input-name-header"}
1376
- />
1377
- ))}
1378
-
1379
- {state.active_tab === "Ficha técnica" &&
1380
- (state.product?.datasheet_status !== "NS" ? (
1381
- <>
1382
- {state.datasheets_inputs[0]?.data?.map(
1383
- (dataGroup, index) => (
1384
- <InputGroup
1385
- index={index}
1386
- key={
1387
- index + "-" + state.active_retailer.retailer
1388
- }
1389
- articleId={state.product.id_article}
1390
- version={state.version}
1391
- activeSection={state.active_tab}
1392
- inputGroup={dataGroup}
1393
- dataInputs={state.datasheets_inputs[1] ?? []}
1394
- activeRetailer={
1395
- state.services.datasheets[
1396
- state.active_retailer.id_retailer
1397
- ]
1398
- }
1399
- groupData={
1400
- state.services.datasheets[
1401
- state.active_retailer.id_retailer
1402
- ].data
1403
- }
1404
- updatedDatasheets={
1405
- state.updated_datasheets_inputs
1406
- }
1407
- setUpdatedDatasheets={
1408
- handleOnSetUpdatedDatasheets
1409
- }
1410
- isShowbox={true}
1411
- setUpdatedBoxData={(e) => {
1412
- setBoxData(e);
1413
- }}
1414
- updateApprovedInputs={
1415
- handleOnUpdateApprovedInputs // No se usa?
1416
- }
1417
- />
1418
- ),
1419
- )}
1420
- </>
1421
- ) : (
1422
- <ScreenHeader
1423
- text={"No cuentas con este servicio"}
1424
- headerType={"input-name-header"}
1425
- />
1426
- ))}
1427
-
1428
- {state.active_tab === "Imágenes" &&
1429
- (state.product?.images_status !== "NS" ? (
1430
- <>
1431
- {!imageLayout && (
1432
- <GalleryHeader
1433
- checkAll={state.all_image_checked} // Determina si el checkbox "Seleccionar todo" está marcado
1434
- setCheckAll={handleOnSetCheckAll} // Toggler de true o false para el checkbox "Seleccionar todo"
1435
- setSelectedImages={handleOnSetSelectedImages}
1277
+ <div
1278
+ className={
1279
+ "services-information-container " +
1280
+ (imageLayout && state.active_tab === "Imágenes"
1281
+ ? "image-services"
1282
+ : "")
1283
+ }
1284
+ >
1285
+ {state.saving ? (
1286
+ <Loading />
1287
+ ) : (
1288
+ <>
1289
+ {state.active_tab === "Descripción" &&
1290
+ (state.product?.description_status !== "NS" ? (
1291
+ <InputGroup
1292
+ activeSection={state.active_tab}
1293
+ inputGroup={state.descriptions_inputs[0]}
1294
+ updatedDescriptions={state.updated_descriptions_inputs}
1295
+ articleId={state.product?.id_article}
1296
+ version={state.product.version}
1297
+ isShowbox={false}
1298
+ dinamicHeight={true}
1299
+ setUpdatedDescriptions={handleOnSetUpdatedDescriptions}
1300
+ updateApprovedInputs={handleOnUpdateApprovedInputs} // No se usa?
1301
+ />
1302
+ ) : (
1303
+ <ScreenHeader
1304
+ text={"No cuentas con este servicio"}
1305
+ headerType={"input-name-header"}
1306
+ />
1307
+ ))}
1308
+
1309
+ {state.active_tab === "Ficha técnica" &&
1310
+ (state.product?.datasheet_status !== "NS" ? (
1311
+ <>
1312
+ {state.datasheets_inputs[0].data?.map(
1313
+ (dataGroup, index) => (
1314
+ <InputGroup
1315
+ index={index}
1316
+ key={index + "-" + state.active_retailer.retailer}
1317
+ articleId={state.product.id_article}
1318
+ version={state.version}
1319
+ activeSection={state.active_tab}
1320
+ inputGroup={dataGroup}
1321
+ dataInputs={state.datasheets_inputs[1] ?? []}
1322
+ activeRetailer={
1323
+ state.services.datasheets[
1324
+ state.active_retailer.id_retailer
1325
+ ]
1326
+ }
1327
+ groupData={
1328
+ state.services.datasheets[
1329
+ state.active_retailer.id_retailer
1330
+ ].data
1331
+ }
1332
+ updatedDatasheets={
1333
+ state.updated_datasheets_inputs
1334
+ }
1335
+ setUpdatedDatasheets={
1336
+ handleOnSetUpdatedDatasheets
1337
+ }
1338
+ isShowbox={true}
1339
+ setUpdatedBoxData={(e) => {
1340
+ setBoxData(e);
1341
+ }}
1342
+ updateApprovedInputs={
1343
+ handleOnUpdateApprovedInputs // No se usa?
1344
+ }
1436
1345
  />
1437
- )}
1438
- <section
1439
- className="container"
1440
- style={{ position: "relative" }}
1346
+ ),
1347
+ )}
1348
+ </>
1349
+ ) : (
1350
+ <ScreenHeader
1351
+ text={"No cuentas con este servicio"}
1352
+ headerType={"input-name-header"}
1353
+ />
1354
+ ))}
1355
+
1356
+ {state.active_tab === "Imágenes" &&
1357
+ (state.product?.images_status !== "NS" ? (
1358
+ <>
1359
+ {!imageLayout && (
1360
+ <GalleryHeader
1361
+ checkAll={state.all_image_checked} // Determina si el checkbox "Seleccionar todo" está marcado
1362
+ setCheckAll={handleOnSetCheckAll} // Toggler de true o false para el checkbox "Seleccionar todo"
1363
+ setSelectedImages={handleOnSetSelectedImages}
1364
+ />
1365
+ )}
1366
+ <section
1367
+ className="container"
1368
+ style={{ position: "relative" }}
1369
+ >
1370
+ <div
1371
+ {...getRootProps({
1372
+ className: `dropzone ${
1373
+ isDragActive ? "drag-active" : ""
1374
+ }`,
1375
+ })}
1441
1376
  >
1377
+ <input {...getInputProps()} />
1378
+ {isDragActive && (
1379
+ <div className="drag-overlay">
1380
+ <p>Suelta las imágenes aquí</p>
1381
+ </div>
1382
+ )}
1383
+ <aside>{thumbs()}</aside>
1384
+ </div>
1385
+ {state.images_values?.values.length === 0 && (
1442
1386
  <div
1443
- {...getRootProps({
1444
- className: `dropzone ${
1445
- isDragActive ? "drag-active" : ""
1446
- }`,
1447
- })}
1387
+ style={{
1388
+ position: "absolute",
1389
+ top: "50%",
1390
+ left: "50%",
1391
+ transform: "translate(-50%, -50%)",
1392
+ textAlign: "center",
1393
+ padding: "40px",
1394
+ width: "80%",
1395
+ maxWidth: "500px",
1396
+ fontFamily: "Arial, sans-serif",
1397
+ }}
1448
1398
  >
1449
- <input {...getInputProps()} />
1450
- {isDragActive && (
1451
- <div className="drag-overlay">
1452
- <p>Suelta las imágenes aquí</p>
1453
- </div>
1454
- )}
1455
- <aside>{thumbs()}</aside>
1456
- </div>
1457
- {state.images_values?.values.length === 0 && (
1458
- <div
1399
+ <p
1459
1400
  style={{
1460
- position: "absolute",
1461
- top: "50%",
1462
- left: "50%",
1463
- transform: "translate(-50%, -50%)",
1464
- textAlign: "center",
1465
- padding: "40px",
1466
- width: "80%",
1467
- maxWidth: "500px",
1468
- fontFamily: "Arial, sans-serif",
1401
+ fontSize: "18px",
1402
+ color: "#666",
1403
+ marginBottom: "16px",
1469
1404
  }}
1470
1405
  >
1471
- <p
1472
- style={{
1473
- fontSize: "18px",
1474
- color: "#666",
1475
- marginBottom: "16px",
1476
- }}
1477
- >
1478
- Este producto no tiene imágenes
1479
- </p>
1480
- <p
1406
+ Este producto no tiene imágenes
1407
+ </p>
1408
+ <p
1409
+ style={{
1410
+ fontSize: "14px",
1411
+ color: "#999",
1412
+ marginBottom: "20px",
1413
+ }}
1414
+ >
1415
+ Arrastra las imágenes aquí o{" "}
1416
+ <span
1417
+ onClick={open}
1481
1418
  style={{
1482
- fontSize: "14px",
1483
- color: "#999",
1484
- marginBottom: "20px",
1419
+ color: "#007bff",
1420
+ cursor: "pointer",
1421
+ textDecoration: "underline",
1485
1422
  }}
1486
1423
  >
1487
- Arrastra las imágenes aquí o{" "}
1488
- <span
1489
- onClick={open}
1490
- style={{
1491
- color: "#007bff",
1492
- cursor: "pointer",
1493
- textDecoration: "underline",
1494
- }}
1495
- >
1496
- haz clic para abrir el explorador de
1497
- archivos
1498
- </span>
1499
- </p>
1500
- </div>
1501
- )}
1502
- </section>
1503
- </>
1504
- ) : (
1505
- <ScreenHeader
1506
- text={"No cuentas con este servicio"}
1507
- headerType={"input-name-header"}
1508
- />
1509
- ))}
1510
- </>
1511
- )}
1512
- </div>
1424
+ haz clic para abrir el explorador de archivos
1425
+ </span>
1426
+ </p>
1427
+ </div>
1428
+ )}
1429
+ </section>
1430
+ </>
1431
+ ) : (
1432
+ <ScreenHeader
1433
+ text={"No cuentas con este servicio"}
1434
+ headerType={"input-name-header"}
1435
+ />
1436
+ ))}
1437
+ </>
1438
+ )}
1513
1439
  </div>
1514
1440
  </div>
1515
1441
  </div>
1516
- </Container>
1517
- </AiProductEditionProvider>
1442
+ </div>
1443
+ </Container>
1518
1444
  );
1519
1445
  };
1520
1446