contentoh-components-library 21.5.99 → 21.6.0

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