contentoh-components-library 21.5.92 → 21.5.94

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 +379 -375
  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 +470 -460
  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,14 +148,42 @@ 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
- dispatch({
157
- type: "SET_ACTIVE_RETAILER",
158
- payload: productNormalized.categoryRetailer[0],
159
- });
157
+
158
+ if (
159
+ productNormalized.categoryRetailerInOrder.length > 0 &&
160
+ productNormalized.statusByRetailer
161
+ ) {
162
+ dispatch({
163
+ type: "SET_ACTIVE_RETAILER",
164
+ payload: productNormalized.categoryRetailerInOrder[0],
165
+ });
166
+ const firstRetailerStatus =
167
+ productNormalized.statusByRetailer[
168
+ productNormalized.categoryRetailerInOrder[0].id_retailer
169
+ ];
170
+ const initialTab = firstRetailerStatus.description
171
+ ? "Descripción"
172
+ : firstRetailerStatus.datasheet
173
+ ? "Ficha técnica"
174
+ : firstRetailerStatus.images
175
+ ? "Imágenes"
176
+ : "Imágenes";
177
+ dispatch({
178
+ type: "SET_ACTIVE_TAB",
179
+ payload: initialTab,
180
+ });
181
+ } else {
182
+ dispatch({
183
+ type: "SET_ACTIVE_RETAILER",
184
+ payload: productNormalized.categoryRetailer[0],
185
+ });
186
+ }
160
187
  } catch (error) {
161
188
  console.log("Error setting product data: ", error);
162
189
  }
@@ -200,7 +227,7 @@ const ProviderProductEditionView = ({
200
227
  id_category,
201
228
  version,
202
229
  token,
203
- id_retailer
230
+ id_retailer,
204
231
  ),
205
232
  getPercentage({ data, headers }),
206
233
  getServicesData({
@@ -214,14 +241,14 @@ const ProviderProductEditionView = ({
214
241
  const percentages =
215
242
  JSON.parse(percentageRes?.[0]?.body)?.[0]?.relations ?? [];
216
243
 
217
- const orderMap = services[2].inputsByRetailer
218
- .flat()
219
- .reduce((acc, item) => {
244
+ const orderMap =
245
+ services[2].inputsByRetailer ??
246
+ [].flat().reduce((acc, item) => {
220
247
  acc[item.id_image] = item.order;
221
248
  return acc;
222
249
  }, {});
223
250
 
224
- const orderedValues = [...services[2].values].sort((a, b) => {
251
+ const orderedValues = [...(services[2].values ?? [])].sort((a, b) => {
225
252
  const orderA = orderMap[a.image_id] ?? Number.MAX_SAFE_INTEGER;
226
253
  const orderB = orderMap[b.image_id] ?? Number.MAX_SAFE_INTEGER;
227
254
 
@@ -247,7 +274,7 @@ const ProviderProductEditionView = ({
247
274
  dispatch({
248
275
  type: "SET_ACTIVE_PERCENTAGES",
249
276
  payload: percentages.find(
250
- ({ id_retailer: rId }) => rId === id_retailer
277
+ ({ id_retailer: rId }) => rId === id_retailer,
251
278
  ),
252
279
  });
253
280
  } catch (error) {
@@ -267,46 +294,51 @@ const ProviderProductEditionView = ({
267
294
  console.log("Actualizar inputs del retailer activo");
268
295
  const updateInputsActiveRetailer = () => {
269
296
  if (!state.services) return;
297
+ if (state.services.datasheets) {
298
+ const retailerDatasheets =
299
+ state.services.datasheets[state.active_retailer.id_retailer];
270
300
 
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
- };
301
+ const datasheetsActiveRetailer = {
302
+ ...retailerDatasheets,
303
+ data: Object.values(retailerDatasheets.data),
304
+ };
278
305
 
279
- const descriptionsActiveRetailer = state.services.descriptions.filter(
280
- (item) => item.id === state.active_retailer.id_retailer
281
- );
306
+ dispatch({
307
+ type: "SET_DATASHEETS_INPUTS",
308
+ payload: [datasheetsActiveRetailer, state.services.datasheets.inputs],
309
+ });
310
+ }
282
311
 
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
- )
312
+ if (state.services.descriptions) {
313
+ const descriptionsActiveRetailer = state.services.descriptions.filter(
314
+ (item) => item.id === state.active_retailer.id_retailer,
290
315
  );
291
- });
292
316
 
293
- dispatch({
294
- type: "SET_DATASHEETS_INPUTS",
295
- payload: [datasheetsActiveRetailer, state.services.datasheets.inputs],
296
- });
317
+ dispatch({
318
+ type: "SET_DESCRIPTIONS_INPUTS",
319
+ payload: descriptionsActiveRetailer,
320
+ });
321
+ }
297
322
 
298
- dispatch({
299
- type: "SET_DESCRIPTIONS_INPUTS",
300
- payload: descriptionsActiveRetailer,
301
- });
323
+ if (state.services.images) {
324
+ const filteredValues = state.services.images.values.filter((value) => {
325
+ return state.services.images.inputsByRetailer.some((retailerInput) =>
326
+ retailerInput.some(
327
+ (input) =>
328
+ input.id_retailer === state.active_retailer.id_retailer &&
329
+ input.id_image === value.image_id,
330
+ ),
331
+ );
332
+ });
302
333
 
303
- dispatch({
304
- type: "SET_IMAGES_VALUES",
305
- payload: {
306
- ...state.services.images,
307
- values: filteredValues,
308
- },
309
- });
334
+ dispatch({
335
+ type: "SET_IMAGES_VALUES",
336
+ payload: {
337
+ ...state.services.images,
338
+ values: filteredValues,
339
+ },
340
+ });
341
+ }
310
342
  };
311
343
 
312
344
  updateInputsActiveRetailer();
@@ -340,23 +372,13 @@ const ProviderProductEditionView = ({
340
372
  // No retailer
341
373
  const hasNoOrder = !state.product.id_order && !state.product.orderId;
342
374
 
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;
375
+ return (
376
+ (originTab === "RequestWithoutContentoh" &&
377
+ (["R", "CA"].includes(currentStatus) ||
378
+ (currentStatus === "RCA" && hasNoOrder))) ||
379
+ (["RequestWithContentoh", "Contentoh"].includes(originTab) &&
380
+ currentStatus === "AA")
381
+ );
360
382
  };
361
383
 
362
384
  const canShowSaveButton = (version_status) => {
@@ -388,7 +410,7 @@ const ProviderProductEditionView = ({
388
410
  name: e?.name,
389
411
  required: e?.required,
390
412
  active: state.images_values?.values?.some(
391
- (value) => value?.image_id === e?.id
413
+ (value) => value?.image_id === e?.id,
392
414
  ),
393
415
  }));
394
416
  const imageType = state.images_values?.imageType?.map((e) => ({
@@ -399,7 +421,7 @@ const ProviderProductEditionView = ({
399
421
  (e) => ({
400
422
  value: e?.id,
401
423
  name: e?.name,
402
- })
424
+ }),
403
425
  );
404
426
 
405
427
  return state.images_values?.values?.map((image, index) => (
@@ -640,7 +662,6 @@ const ProviderProductEditionView = ({
640
662
  state.product[sectionStatusKey] || state.product?.version_status;
641
663
 
642
664
  let data = { articleId, orderId, concept, evalStatus };
643
-
644
665
  const retailerId = state.active_retailer?.id_retailer;
645
666
 
646
667
  try {
@@ -655,15 +676,13 @@ const ProviderProductEditionView = ({
655
676
  headers: {
656
677
  Authorization: token,
657
678
  },
658
- }
679
+ },
659
680
  );
660
681
 
661
682
  const newStatuses = JSON.parse(res.data.body);
662
683
  const serviceStatus =
663
684
  newStatuses.newServiceStatus[articleId][`${concept}Status`];
664
685
 
665
- console.log({product: state.product, newStatuses, serviceStatus, servicesData: state.services_data});
666
-
667
686
  // Actualizar el producto con los nuevos estados
668
687
  const updatedProduct = {
669
688
  ...state.product,
@@ -671,17 +690,12 @@ const ProviderProductEditionView = ({
671
690
  ...state.product.statusByRetailer,
672
691
  [retailerId]: {
673
692
  ...state.product.statusByRetailer[retailerId],
674
- [concept]: newStatuses?.newStatus ?? serviceStatus,
693
+ [concept]: serviceStatus,
675
694
  },
676
695
  },
677
696
  };
678
697
 
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 });
698
+ console.log({ updatedProduct });
685
699
 
686
700
  dispatch({ type: "SET_PRODUCT", payload: updatedProduct });
687
701
 
@@ -910,7 +924,7 @@ const ProviderProductEditionView = ({
910
924
  headers: {
911
925
  Authorization: token,
912
926
  },
913
- })
927
+ }),
914
928
  );
915
929
  });
916
930
 
@@ -955,7 +969,7 @@ const ProviderProductEditionView = ({
955
969
  ArticleId: updatedProduct.id_article,
956
970
  idCategory: updatedProduct.id_category,
957
971
  product: updatedProduct,
958
- })
972
+ }),
959
973
  );
960
974
 
961
975
  // Mostrar modal de éxito
@@ -1021,422 +1035,418 @@ const ProviderProductEditionView = ({
1021
1035
  if (state.loading || !state.services || !state.product) return <Loading />;
1022
1036
 
1023
1037
  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}
1038
+ <Container headerTop={headerTop}>
1039
+ {/* <button onClick={() => console.log(state)}>log</button> */}
1040
+ {showVersionSelector && (
1041
+ <VersionSelector
1042
+ modalId={"version-selector"}
1043
+ articleId={state.product.id_article}
1044
+ setVersion={handleOnChangeProductVersion}
1045
+ companyName={company.company_name}
1046
+ currentVersion={state.product.version}
1047
+ setShowVersionSelector={setShowVersionSelector}
1048
+ jwt={token}
1049
+ />
1050
+ )}
1051
+ {showModal && (
1052
+ <ProductImageModal
1053
+ images={state.images_values}
1054
+ setShowModal={setShowModal}
1055
+ approveRejectButtons={canShowValidationButtons()}
1056
+ sendToFacilitator={handleOnSendEvaluation}
1057
+ />
1058
+ )}
1059
+ {state.modal.show && (
1060
+ <GenericModal
1061
+ componentsArray={[
1062
+ state.modal.image && (
1063
+ <img key="1" src={state.modal.image} alt="modal icon" />
1064
+ ),
1065
+ state.modal.title && (
1066
+ <ScreenHeader
1067
+ key="2"
1068
+ headerType={"retailer-name-header"}
1069
+ text={state.modal.title}
1104
1070
  color={"white"}
1105
1071
  />
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
- );
1072
+ ),
1073
+ state.modal.message && (
1074
+ <ScreenHeader
1075
+ key="3"
1076
+ headerType={"retailer-name-header"}
1077
+ text={state.modal.message}
1078
+ color={"white"}
1079
+ />
1080
+ ),
1081
+ state.modal.buttons && (
1082
+ <div key="4" style={{ marginTop: "16px" }}>
1083
+ {state.modal.buttons.map((button, index) => (
1084
+ <Button
1085
+ key={index}
1086
+ buttonType={button.buttonType}
1087
+ label={button.text}
1088
+ onClick={button.action}
1089
+ />
1090
+ ))}
1091
+ </div>
1092
+ ),
1093
+ ].filter(Boolean)}
1094
+ onClick={() =>
1095
+ dispatch({
1096
+ type: "SET_MODAL",
1097
+ payload: { show: false, title: "", message: "", image: null },
1098
+ })
1099
+ }
1100
+ />
1101
+ )}
1102
+ {showRejectModal && (
1103
+ <Modal
1104
+ title={
1105
+ rejectAll
1106
+ ? "Agregar mensaje para rechazar todo"
1107
+ : "Agregar mensaje de rechazo"
1108
+ }
1109
+ show={showRejectModal}
1110
+ customComponent={
1111
+ <TagAndInput
1112
+ inputType={"textarea"}
1113
+ inputId={"modal-message-box"}
1114
+ index={0}
1115
+ color={"white"}
1116
+ />
1117
+ }
1118
+ buttons={[
1119
+ <ButtonV2
1120
+ key={"btn-Cancelar"}
1121
+ type={"white"}
1122
+ label={"Cancelar"}
1123
+ size={12}
1124
+ onClick={() => {
1125
+ setShowRejectModal(false);
1126
+ }}
1127
+ />,
1128
+ <ButtonV2
1129
+ key={"btn-Aceptar"}
1130
+ type={"pink"}
1131
+ label={"Aceptar"}
1132
+ size={12}
1133
+ onClick={async () => {
1134
+ const elements = document.querySelectorAll(
1135
+ "#modal-message-box .ql-container .ql-editor > p",
1136
+ );
1137
+
1138
+ if (!elements || elements.length === 0) {
1139
+ console.error("Elemento no encontrado");
1140
+ return;
1141
+ }
1126
1142
 
1127
- if (!elements || elements.length === 0) {
1128
- console.error("Elemento no encontrado");
1129
- return;
1130
- }
1143
+ const isMessageEmpty = Array.from(elements).every((el) => {
1144
+ const body = el.innerHTML;
1145
+ return !body || body.replace(/<.*?\/?>/gm, "").trim() === "";
1146
+ });
1131
1147
 
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;
1148
+ if (isMessageEmpty) {
1149
+ const container = document.querySelector(
1150
+ ".container-customComponent",
1151
+ );
1152
+ const existingAlert = container.querySelector(".alert-error");
1153
+
1154
+ if (!existingAlert) {
1155
+ const alert = document.createElement("div");
1156
+ alert.className = "alert-error";
1157
+ alert.style.cssText = `
1158
+ color: #d32f2f;
1159
+ background-color: #ffebee;
1160
+ border: 1px solid #ef5350;
1161
+ border-radius: 4px;
1162
+ padding: 12px 16px;
1163
+ margin-top: 10px;
1164
+ font-size: 14px;
1165
+ display: flex;
1166
+ align-items: center;
1167
+ gap: 8px;
1168
+ font-family: 'Roboto', sans-serif;
1169
+ text-align: center;
1170
+ `;
1171
+ alert.innerHTML = `<span>El mensaje no puede estar vacío.</span>`;
1172
+ container.appendChild(alert);
1164
1173
  }
1174
+ return;
1175
+ }
1165
1176
 
1166
- const fullMessage = Array.from(elements)
1167
- .map((element) => element.innerHTML)
1168
- .join("")
1169
- .replace(/<br\s*\/?>/gi, "\n");
1177
+ const fullMessage = Array.from(elements)
1178
+ .map((element) => element.innerHTML)
1179
+ .join("")
1180
+ .replace(/<br\s*\/?>/gi, "\n");
1170
1181
 
1171
- await createComment(fullMessage, token);
1182
+ await createComment(fullMessage);
1172
1183
 
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
- }}
1184
+ rejectAll
1185
+ ? handleOnEvaluateAll("R")
1186
+ : handleOnSendEvaluation("R");
1187
+ setShowRejectModal(false);
1188
+ }}
1189
+ />,
1190
+ ]}
1192
1191
  />
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}
1192
+ )}
1193
+ <HeaderTop
1194
+ setHeaderTop={setHeaderTop}
1195
+ withChat={location?.state?.withChat}
1196
+ chatType={location?.state?.chatType}
1197
+ productSelected={state.product}
1198
+ token={token}
1199
+ activeRetailer={{
1200
+ id: state.active_retailer?.id_retailer,
1201
+ name: state.active_retailer?.retailer,
1202
+ }}
1203
+ />
1204
+ <div className="data-container">
1205
+ <div className="image-data-panel">
1206
+ <ImagePreviewer
1207
+ activeImage={state.images_values.values[state.current_image] ?? {}}
1208
+ imagesArray={state.images_values || []}
1209
+ setActiveImage={handleOnChangeCurrentImage}
1210
+ setShowModal={handleOnShowModalGalery}
1211
+ />
1212
+ <ImageDataTable
1213
+ lists={state.images_values || []}
1214
+ activeImage={
1215
+ state.images_values?.values
1216
+ ? state.images_values?.values[state.current_image]
1217
+ : {}
1218
+ }
1219
+ assignationsImages={assig}
1220
+ retailerSelected={state.active_retailer?.id_retailer}
1221
+ imagesStatus={state.product?.images_status || "-"}
1222
+ isRetailer={isRetailer}
1223
+ setShowVersionSelector={setShowVersionSelector}
1224
+ version={state.product.version}
1225
+ setImages={handleOnChangeCurrentImage}
1226
+ onClickSave={handleOnClickSaveImages}
1227
+ setAssignation={handleOnChangeAssignations} // No se usa?
1228
+ />
1229
+ </div>
1230
+ <div className="product-information">
1231
+ <div className="product-information">
1232
+ <FullProductNameHeader
1233
+ headerData={state.product}
1234
+ percent={state.active_percentage.percentagesGeneral.required}
1235
+ activeRetailer={{
1236
+ id: state.active_retailer?.id_retailer,
1237
+ name: state.active_retailer?.retailer,
1238
+ image: state.active_retailer?.image,
1239
+ }}
1240
+ showValidationButtons={canShowValidationButtons()}
1241
+ showApproveRejectAll={canShowValidationButtons()}
1242
+ servicesData={state.services_data ? state.services_data : null}
1243
+ approveAll={handleOnApproveAll}
1244
+ rejectAll={handleOnRejectAll}
1245
+ approve={() => handleOnSendEvaluation("A")}
1246
+ reject={handleOnReject}
1247
+ setActiveRetailer={handleOnChangeActiveRetailer}
1200
1248
  />
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 || "-"}
1249
+ <FullTabsMenu
1250
+ tabsSections={tabsSections}
1251
+ status={getStatusByCurrentServiceAndRetailer()}
1252
+ activeTab={state.active_tab}
1253
+ user={user}
1211
1254
  isRetailer={isRetailer}
1212
- setShowVersionSelector={setShowVersionSelector}
1255
+ assig={assig}
1213
1256
  version={state.product.version}
1214
- setImages={handleOnChangeCurrentImage}
1215
- onClickSave={handleOnClickSaveImages}
1216
- setAssignation={handleOnChangeAssignations} // No se usa?
1257
+ updatedDescriptions={state.updated_descriptions_inputs}
1258
+ updatedDatasheets={state.updated_datasheets_inputs}
1259
+ updatedImages={state.updated_images_values}
1260
+ images={state.services.images}
1261
+ // actions
1262
+ downloadImages={handleOnDownloadImages}
1263
+ askToDeleteImages={handleOnAskToDeleteImages}
1264
+ showSaveButton={canShowSaveButton(state.product.version_status)}
1265
+ onClickSave={handleOnClickSave}
1266
+ // setters
1267
+ setActiveTab={handleOnChangeActiveTab}
1268
+ setImageLayout={handleOnSetImageLayout}
1269
+ setUpdatedDescriptions={handleOnSetUpdatedDescriptions}
1270
+ setUpdatedDatasheets={handleOnSetUpdatedDatasheets}
1271
+ setAssignation={handleOnSetAssignation} // No se usa?
1272
+ setImages={handleOnSetImages} // No se usa?
1273
+ // setSelectedImages={handleOnSetSelectedImages} // Se pasa hasta TabsMenu, pero no se usa
1274
+ setShowVersionSelector={setShowVersionSelector}
1217
1275
  />
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}
1276
+ <div
1277
+ className={
1278
+ "services-information-container " +
1279
+ (imageLayout && state.active_tab === "Imágenes"
1280
+ ? "image-services"
1281
+ : "")
1282
+ }
1283
+ >
1284
+ {state.saving ? (
1285
+ <Loading />
1286
+ ) : (
1287
+ <>
1288
+ {state.active_tab === "Descripción" &&
1289
+ (state.product?.description_status !== "NS" ? (
1290
+ <InputGroup
1291
+ activeSection={state.active_tab}
1292
+ inputGroup={state.descriptions_inputs[0]}
1293
+ updatedDescriptions={state.updated_descriptions_inputs}
1294
+ articleId={state.product?.id_article}
1295
+ version={state.product.version}
1296
+ isShowbox={false}
1297
+ dinamicHeight={true}
1298
+ setUpdatedDescriptions={handleOnSetUpdatedDescriptions}
1299
+ updateApprovedInputs={handleOnUpdateApprovedInputs} // No se usa?
1300
+ />
1301
+ ) : (
1302
+ <ScreenHeader
1303
+ text={"No cuentas con este servicio"}
1304
+ headerType={"input-name-header"}
1305
+ />
1306
+ ))}
1307
+
1308
+ {state.active_tab === "Ficha técnica" &&
1309
+ (state.product?.datasheet_status !== "NS" ? (
1310
+ <>
1311
+ {state.datasheets_inputs[0].data?.map(
1312
+ (dataGroup, index) => (
1313
+ <InputGroup
1314
+ index={index}
1315
+ key={index + "-" + state.active_retailer.retailer}
1316
+ articleId={state.product.id_article}
1317
+ version={state.version}
1318
+ activeSection={state.active_tab}
1319
+ inputGroup={dataGroup}
1320
+ dataInputs={state.datasheets_inputs[1] ?? []}
1321
+ activeRetailer={
1322
+ state.services.datasheets[
1323
+ state.active_retailer.id_retailer
1324
+ ]
1325
+ }
1326
+ groupData={
1327
+ state.services.datasheets[
1328
+ state.active_retailer.id_retailer
1329
+ ].data
1330
+ }
1331
+ updatedDatasheets={
1332
+ state.updated_datasheets_inputs
1333
+ }
1334
+ setUpdatedDatasheets={
1335
+ handleOnSetUpdatedDatasheets
1336
+ }
1337
+ isShowbox={true}
1338
+ setUpdatedBoxData={(e) => {
1339
+ setBoxData(e);
1340
+ }}
1341
+ updateApprovedInputs={
1342
+ handleOnUpdateApprovedInputs // No se usa?
1343
+ }
1352
1344
  />
1353
- )}
1354
- <section
1355
- className="container"
1356
- style={{ position: "relative" }}
1345
+ ),
1346
+ )}
1347
+ </>
1348
+ ) : (
1349
+ <ScreenHeader
1350
+ text={"No cuentas con este servicio"}
1351
+ headerType={"input-name-header"}
1352
+ />
1353
+ ))}
1354
+
1355
+ {state.active_tab === "Imágenes" &&
1356
+ (state.product?.images_status !== "NS" ? (
1357
+ <>
1358
+ {!imageLayout && (
1359
+ <GalleryHeader
1360
+ checkAll={state.all_image_checked} // Determina si el checkbox "Seleccionar todo" está marcado
1361
+ setCheckAll={handleOnSetCheckAll} // Toggler de true o false para el checkbox "Seleccionar todo"
1362
+ setSelectedImages={handleOnSetSelectedImages}
1363
+ />
1364
+ )}
1365
+ <section
1366
+ className="container"
1367
+ style={{ position: "relative" }}
1368
+ >
1369
+ <div
1370
+ {...getRootProps({
1371
+ className: `dropzone ${
1372
+ isDragActive ? "drag-active" : ""
1373
+ }`,
1374
+ })}
1357
1375
  >
1376
+ <input {...getInputProps()} />
1377
+ {isDragActive && (
1378
+ <div className="drag-overlay">
1379
+ <p>Suelta las imágenes aquí</p>
1380
+ </div>
1381
+ )}
1382
+ <aside>{thumbs()}</aside>
1383
+ </div>
1384
+ {state.images_values?.values.length === 0 && (
1358
1385
  <div
1359
- {...getRootProps({
1360
- className: `dropzone ${
1361
- isDragActive ? "drag-active" : ""
1362
- }`,
1363
- })}
1386
+ style={{
1387
+ position: "absolute",
1388
+ top: "50%",
1389
+ left: "50%",
1390
+ transform: "translate(-50%, -50%)",
1391
+ textAlign: "center",
1392
+ padding: "40px",
1393
+ width: "80%",
1394
+ maxWidth: "500px",
1395
+ fontFamily: "Arial, sans-serif",
1396
+ }}
1364
1397
  >
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
1398
+ <p
1375
1399
  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",
1400
+ fontSize: "18px",
1401
+ color: "#666",
1402
+ marginBottom: "16px",
1385
1403
  }}
1386
1404
  >
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
1405
+ Este producto no tiene imágenes
1406
+ </p>
1407
+ <p
1408
+ style={{
1409
+ fontSize: "14px",
1410
+ color: "#999",
1411
+ marginBottom: "20px",
1412
+ }}
1413
+ >
1414
+ Arrastra las imágenes aquí o{" "}
1415
+ <span
1416
+ onClick={open}
1397
1417
  style={{
1398
- fontSize: "14px",
1399
- color: "#999",
1400
- marginBottom: "20px",
1418
+ color: "#007bff",
1419
+ cursor: "pointer",
1420
+ textDecoration: "underline",
1401
1421
  }}
1402
1422
  >
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>
1423
+ haz clic para abrir el explorador de archivos
1424
+ </span>
1425
+ </p>
1426
+ </div>
1427
+ )}
1428
+ </section>
1429
+ </>
1430
+ ) : (
1431
+ <ScreenHeader
1432
+ text={"No cuentas con este servicio"}
1433
+ headerType={"input-name-header"}
1434
+ />
1435
+ ))}
1436
+ </>
1437
+ )}
1428
1438
  </div>
1429
1439
  </div>
1430
1440
  </div>
1431
- </Container>
1432
- </AiProductEditionProvider>
1441
+ </div>
1442
+ </Container>
1433
1443
  );
1434
1444
  };
1435
1445
 
1436
1446
  export const ProviderProductEdition = (props) => {
1437
1447
  return (
1438
1448
  <ProviderProductEditionProvider>
1439
- <ProviderProductEditionView {...props} />
1449
+ <ProviderProductEditionView {...props} />
1440
1450
  </ProviderProductEditionProvider>
1441
1451
  );
1442
1452
  };