contentoh-components-library 21.3.53 → 21.3.54

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 (59) hide show
  1. package/.env.development +2 -0
  2. package/dist/components/atoms/ButtonV2/styles.js +1 -1
  3. package/dist/components/atoms/Status/styles.js +1 -1
  4. package/dist/components/atoms/VerticalSideMenuMainPage/index.js +18 -23
  5. package/dist/components/atoms/VerticalSideMenuMainPage/styles.js +4 -4
  6. package/dist/components/molecules/CarouselImagesLogin/index.js +1 -1
  7. package/dist/components/molecules/HeaderTop/index.js +68 -11
  8. package/dist/components/organisms/Chat/Chat.stories.js +21 -1
  9. package/dist/components/organisms/Chat/ContainerItems/index.js +19 -3
  10. package/dist/components/organisms/Chat/ContainerItems/styles.js +1 -1
  11. package/dist/components/organisms/Chat/ContentChat/index.js +343 -191
  12. package/dist/components/organisms/Chat/Footer/index.js +48 -39
  13. package/dist/components/organisms/Chat/index.js +48 -3
  14. package/dist/components/organisms/DashboardMetric/dashboardMetricUtils.js +27 -0
  15. package/dist/components/organisms/FullProductNameHeader/index.js +2 -2
  16. package/dist/components/organisms/GlobalModal/styles.js +1 -1
  17. package/dist/components/organisms/OrderDetail/styles.js +1 -1
  18. package/dist/components/organisms/OrderDetail/utils/Table/styles.js +1 -1
  19. package/dist/components/pages/Dashboard/Dashboard.stories.js +31 -50
  20. package/dist/components/pages/ProviderProductEdition/ProviderProductEdition.stories.js +198 -81
  21. package/dist/components/pages/ProviderProductEdition/index.js +725 -429
  22. package/dist/components/pages/ProviderProductEdition/styles.js +1 -1
  23. package/dist/components/pages/RetailerProductEdition/RetailerProductEdition.stories.js +72 -89
  24. package/dist/components/pages/RetailerProductEdition/index.js +267 -278
  25. package/dist/components/pages/RetailerProductEdition/styles.js +1 -1
  26. package/dist/components/pages/RetailerProductEdition/utils.js +61 -2
  27. package/dist/index.js +13 -0
  28. package/package.json +7 -6
  29. package/src/components/atoms/ButtonV2/styles.js +1 -1
  30. package/src/components/atoms/Status/styles.js +4 -0
  31. package/src/components/atoms/VerticalSideMenuMainPage/index.js +18 -22
  32. package/src/components/atoms/VerticalSideMenuMainPage/styles.js +3 -4
  33. package/src/components/molecules/CarouselImagesLogin/index.js +1 -1
  34. package/src/components/molecules/HeaderTop/index.js +52 -6
  35. package/src/components/organisms/Chat/Chat.stories.js +21 -0
  36. package/src/components/organisms/Chat/ContainerItems/index.js +18 -2
  37. package/src/components/organisms/Chat/ContainerItems/styles.js +10 -2
  38. package/src/components/organisms/Chat/ContentChat/index.js +81 -6
  39. package/src/components/organisms/Chat/Footer/index.js +11 -0
  40. package/src/components/organisms/Chat/index.js +47 -3
  41. package/src/components/organisms/DashboardMetric/dashboardMetricUtils.js +18 -1
  42. package/src/components/organisms/FullProductNameHeader/index.js +1 -1
  43. package/src/components/organisms/GlobalModal/styles.js +10 -0
  44. package/src/components/organisms/OrderDetail/index.js +1 -0
  45. package/src/components/organisms/OrderDetail/styles.js +1 -1
  46. package/src/components/organisms/OrderDetail/utils/Table/styles.js +0 -1
  47. package/src/components/organisms/TableResizable/TableResizable.stories.js +17 -0
  48. package/src/components/organisms/TableResizable/index.js +119 -0
  49. package/src/components/organisms/TableResizable/styles.js +133 -0
  50. package/src/components/organisms/TableResizable/utils.js +46 -0
  51. package/src/components/pages/Dashboard/Dashboard.stories.js +31 -55
  52. package/src/components/pages/ProviderProductEdition/ProviderProductEdition.stories.js +214 -88
  53. package/src/components/pages/ProviderProductEdition/index.js +323 -160
  54. package/src/components/pages/ProviderProductEdition/styles.js +5 -1
  55. package/src/components/pages/RetailerProductEdition/RetailerProductEdition.stories.js +75 -91
  56. package/src/components/pages/RetailerProductEdition/index.js +111 -137
  57. package/src/components/pages/RetailerProductEdition/styles.js +4 -0
  58. package/src/components/pages/RetailerProductEdition/utils.js +37 -0
  59. package/src/index.js +1 -0
@@ -19,9 +19,6 @@ import { useDropzone } from "react-dropzone";
19
19
  import axios from "axios";
20
20
  import { v4 as uuidv4 } from "uuid";
21
21
  import AWS from "aws-sdk";
22
- import attributesSent from "../../../assets/images/modalsSVGs/attributesSent.svg";
23
- import descriptionSent from "../../../assets/images/modalsSVGs/descriptionSent.svg";
24
- import imagesSent from "../../../assets/images/modalsSVGs/uploadingImages.svg";
25
22
  import { TagAndInput } from "../../molecules/TagAndInput/index";
26
23
  import { Button } from "../../atoms/GeneralButton";
27
24
  import { Commentary } from "../../atoms/Commentary";
@@ -42,7 +39,9 @@ import Slide1_4 from "../../../assets/images/sliderToolTip/slide4.svg";
42
39
  import Slide1_5 from "../../../assets/images/sliderToolTip/slide5.svg";
43
40
  import { VersionSelector } from "../../organisms/VersionSelector";
44
41
  import { useCloseModal } from "../../../global-files/customHooks";
45
- import { number } from "prop-types";
42
+ import { createMessage, sendMessage } from "../RetailerProductEdition/utils";
43
+ import { Modal } from "../../organisms/Modal";
44
+ import { ButtonV2 } from "../../atoms/ButtonV2";
46
45
 
47
46
  const reducerImages = (state, action) => {
48
47
  let { values, attrForImgs, inputsByRetailer } = state;
@@ -134,6 +133,7 @@ export const ProviderProductEdition = ({
134
133
  setShowContentohRequestModal,
135
134
  showSurvey,
136
135
  company,
136
+ addToCart,
137
137
  }) => {
138
138
  const [activeTab, setActiveTab] = useState("Descripción");
139
139
  const [activeImage, setActiveImage] = useState();
@@ -205,7 +205,6 @@ export const ProviderProductEdition = ({
205
205
  ? JSON.parse(sessionStorage.getItem("productEdit"))
206
206
  : productToEdit
207
207
  );
208
- const [icon, setIcon] = useState(null);
209
208
  const [version, setVersion] = useState(product?.version);
210
209
  const [comments] = useState({});
211
210
  const [comment, setComment] = useState("");
@@ -218,6 +217,7 @@ export const ProviderProductEdition = ({
218
217
  const isRetailer = user?.is_retailer;
219
218
  const [loading, setLoading] = useState(true);
220
219
  const [validatedAll, setValidatedAll] = useState(false);
220
+ const [showRejectModal, setShowRejectModal] = useState(false);
221
221
 
222
222
  const originProp = location?.state?.origin;
223
223
  const [origin, setOrigin] = useState({
@@ -226,9 +226,6 @@ export const ProviderProductEdition = ({
226
226
  Imágenes: originProp,
227
227
  });
228
228
  const [inCart, setInCart] = useState(false);
229
- const [modalSent, setModalSent] = useState(false);
230
- const [modalViewError, setModalViewError] = useState(false);
231
- const [showGenericModal, setShowGenericModal] = useState(false);
232
229
  const [dataGenericModal, setDataGenericModal] = useState({
233
230
  message: "¿Estás seguro de continuar?",
234
231
  detail: ` ${
@@ -238,7 +235,7 @@ export const ProviderProductEdition = ({
238
235
  }`,
239
236
  button1: {
240
237
  name: "Cerrar",
241
- action: () => setModalViewTextArea(false),
238
+ action: closeGlobalModal,
242
239
  },
243
240
  button2: {
244
241
  name: "Continuar",
@@ -246,7 +243,6 @@ export const ProviderProductEdition = ({
246
243
  },
247
244
  img: face,
248
245
  });
249
- const [modalViewTextArea, setModalViewTextArea] = useState(false);
250
246
  const [socketType, setSocketType] = useState(null);
251
247
  const [saving, setSaving] = useState(loading);
252
248
  const [retailerStatus, setRetailerStatus] = useState(
@@ -254,6 +250,205 @@ export const ProviderProductEdition = ({
254
250
  );
255
251
  const [showVersionSelector, setShowVersionSelector] =
256
252
  useCloseModal("version-selector");
253
+ const [globalModal, setGlobalModal] = useState();
254
+
255
+ const updateAuditStatus = async (status) => {
256
+ const productTemp = product;
257
+ productTemp.article_status = status;
258
+ productTemp.datasheet_status = status;
259
+ productTemp.description_status = status;
260
+ productTemp.images_status = status;
261
+
262
+ const retailerStatusCopy = { ...retailerStatus };
263
+ const conceptArray = ["description", "datasheet", "images"];
264
+ Object.keys(retailerStatusCopy).forEach((key) => {
265
+ conceptArray.forEach((concept) => {
266
+ if (retailerStatusCopy[key][concept]) {
267
+ retailerStatusCopy[key][concept] = status;
268
+ }
269
+ });
270
+ });
271
+ setRetailerStatus(retailerStatusCopy);
272
+ productTemp.statusByRetailer = retailerStatusCopy;
273
+ setProduct(productTemp);
274
+ sessionStorage.setItem("productSelected", JSON.stringify(productTemp));
275
+ setProductEdit({
276
+ ArticleId: productTemp.id_article,
277
+ idCategory: productTemp.article.id_category,
278
+ product: productTemp,
279
+ });
280
+ sessionStorage.setItem(
281
+ "productEdit",
282
+ JSON.stringify({
283
+ ArticleId: productTemp.id_article,
284
+ idCategory: productTemp.article.id_category,
285
+ product: productTemp,
286
+ })
287
+ );
288
+ await loadData();
289
+ };
290
+
291
+ const addCart = async (retailers) => {
292
+ const { article, version } = product;
293
+ const articleToOrder = [
294
+ {
295
+ articleId: article.id_article,
296
+ version,
297
+ userId: user.id_user,
298
+ discount: 0,
299
+ subtotal: 0,
300
+ companyId: user.id_company,
301
+ datasheet: retailers,
302
+ description: retailers,
303
+ image: retailers,
304
+ attributeTranslations: false,
305
+ descriptionTranslations: false,
306
+ build: "[]",
307
+ manual: "[]",
308
+ userCreated: user.id_user,
309
+ },
310
+ ];
311
+ let modatlType = "addedToCartError";
312
+ if (addToCart) {
313
+ const resCart = await addToCart({ data: articleToOrder });
314
+ if (resCart.data.statusCode === 200) {
315
+ modatlType = "addedToCart";
316
+ }
317
+ }
318
+ showGlobalModal(modatlType);
319
+ };
320
+
321
+ const closeGlobalModal = () => setGlobalModal();
322
+
323
+ const seenByProvider = async () => {
324
+ const productTemp = product;
325
+ const articleId = productTemp.id_article;
326
+ const orderId = productTemp.id_order ?? productTemp.orderId;
327
+ const promises = [];
328
+ const conceptArray = ["description", "datasheet", "images"];
329
+ conceptArray.forEach((concept) => {
330
+ const sectionStatusKey = `${concept}_status`;
331
+ const evalStatus = product[sectionStatusKey] || product?.version_status;
332
+ const data = { articleId, orderId, concept, evalStatus };
333
+ promises.push(
334
+ axios.put(`${process.env.REACT_APP_SEND_EVAL}`, data, {
335
+ headers: {
336
+ Authorization: token,
337
+ },
338
+ })
339
+ );
340
+ });
341
+ await Promise.all(promises);
342
+ closeGlobalModal();
343
+ await updateAuditStatus("FAP");
344
+ };
345
+
346
+ const showGlobalModal = useCallback(
347
+ (type) => {
348
+ const formatter = new Intl.ListFormat("es", { type: "conjunction" });
349
+ switch (type) {
350
+ case "generic":
351
+ setGlobalModal(dataGenericModal);
352
+ break;
353
+ case "commentsSent":
354
+ setGlobalModal({
355
+ message: "Gracias, tus comentarios fueron entregados.",
356
+ detail: "Trabajaremos en conjunto para resolverlo.",
357
+ button1: {
358
+ name: "Cerrar",
359
+ action: closeGlobalModal,
360
+ },
361
+ img: face,
362
+ textArea: false,
363
+ });
364
+ break;
365
+ case "RAC":
366
+ const servicesRejected = [];
367
+ const translateServices = {
368
+ datasheet: "ficha técnica",
369
+ description: "descripción",
370
+ images: "imágenes",
371
+ };
372
+ Object.keys(translateServices).forEach((service) => {
373
+ if (product[`${service}_status`] === "RAC") {
374
+ servicesRejected.push(translateServices[service]);
375
+ }
376
+ });
377
+ const plural = ["Los servicios", "cumplen"];
378
+ const singular = ["El servicio", "cumple"];
379
+ const grammar = servicesRejected.length > 1 ? plural : singular;
380
+ const formatted = formatter.format(servicesRejected);
381
+ const text1 = `${grammar[0]} de ${formatted} no ${grammar[1]} con lo que la cadena necesita.`;
382
+ const text2 = `¡Solicita el servicio de Content-oh! para completarlo!`;
383
+ const retailers = product.retailersWithService.map((retailer) =>
384
+ Number(retailer)
385
+ );
386
+ setGlobalModal({
387
+ message:
388
+ "Tu producto no cumple con los requerimientos de la cadena",
389
+ customComponent: (
390
+ <>
391
+ <p className="generic-text">
392
+ {text1}
393
+ <br />
394
+ <br />
395
+ {text2}
396
+ </p>
397
+ </>
398
+ ),
399
+ button1: {
400
+ name: "Continuar",
401
+ action: async () => await seenByProvider(),
402
+ },
403
+ button2: {
404
+ name: "Solicitar a Content-oh!",
405
+ action: async () => {
406
+ await addCart(retailers);
407
+ await seenByProvider();
408
+ },
409
+ },
410
+ img: errorModal,
411
+ });
412
+ break;
413
+ case "AAC":
414
+ setGlobalModal({
415
+ message: "Felicidades",
416
+ detail: "Tu producto cumple con los requerimientos de la cadena.",
417
+ button1: {
418
+ name: "Continuar",
419
+ action: async () => await seenByProvider(),
420
+ },
421
+ img: face,
422
+ });
423
+ break;
424
+ case "addedToCartError":
425
+ setGlobalModal({
426
+ detail:
427
+ "Parece que algo salió mal al intentar añadir tu producto a tu carrito.",
428
+ button1: {
429
+ name: "Continuar",
430
+ action: closeGlobalModal,
431
+ },
432
+ });
433
+ break;
434
+ case "addedToCart":
435
+ setGlobalModal({
436
+ message: "Producto añadido",
437
+ detail: "Tu producto se añadió al carrito de compras.",
438
+ button1: {
439
+ name: "Continuar",
440
+ action: closeGlobalModal,
441
+ },
442
+ img: face,
443
+ });
444
+ break;
445
+ default:
446
+ closeGlobalModal();
447
+ break;
448
+ }
449
+ },
450
+ [activeTab, dataGenericModal, product]
451
+ );
257
452
 
258
453
  useEffect(() => {
259
454
  checkAll && setSelectedImages(images.values);
@@ -303,7 +498,9 @@ export const ProviderProductEdition = ({
303
498
  );
304
499
  setServicesData(parsedResponse);
305
500
  }
306
- !activeRetailer.id && setActiveRetailer(active ? active : retailers[0]);
501
+ retailers &&
502
+ !activeRetailer.id &&
503
+ setActiveRetailer(active ? active : retailers[0]);
307
504
  };
308
505
 
309
506
  const isRevision = () => {
@@ -352,6 +549,8 @@ export const ProviderProductEdition = ({
352
549
  getCart();
353
550
  fetchUsers(token).then((res) => setUserGroups(res));
354
551
  setImages({ action: "orderImages", retailerId: activeRetailer.id });
552
+ if (["RAC", "AAC"].includes(product.article_status))
553
+ showGlobalModal(product.article_status);
355
554
  }, [product, version]);
356
555
 
357
556
  useEffect(() => {
@@ -377,7 +576,7 @@ export const ProviderProductEdition = ({
377
576
  });
378
577
  }
379
578
  setProduct(productTemp);
380
- setActivePercentage(retailers[0]?.percentage);
579
+ retailers && setActivePercentage(retailers[0]?.percentage);
381
580
  }, [percentages]);
382
581
 
383
582
  const loadInputs = () => {
@@ -618,48 +817,19 @@ export const ProviderProductEdition = ({
618
817
  }
619
818
  };
620
819
 
621
- const getSectionIcon = () => {
622
- switch (activeTab) {
623
- case "Ficha técnica":
624
- setIcon(attributesSent);
625
- break;
626
- case "Descripción":
627
- setIcon(descriptionSent);
628
- break;
629
- case "Imágenes0,,":
630
- setIcon(imagesSent);
631
- break;
632
- default:
633
- break;
634
- }
635
- };
636
-
637
- const createComment = async (e, body, tab) => {
638
- let concept = "";
639
- switch (activeTab) {
640
- case "Ficha técnica":
641
- concept = "datasheet";
642
- break;
643
- case "Imágenes":
644
- concept = "images";
645
- break;
646
-
647
- default:
648
- concept = "description";
649
- break;
650
- }
820
+ const createComment = async (messages = [], retailerId) => {
651
821
  const data = {
652
- articleId: product?.id_article,
653
- orderId: product?.orderId,
654
- message: body,
655
- concept: concept,
656
- version: version,
657
- };
658
- await axios.post(`${process.env.REACT_APP_COMMENTS_ENDPOINT}`, data, {
659
- headers: {
660
- Authorization: token,
822
+ paramsBody: {
823
+ id: product.article.id_article || productEdit.ArticleId,
824
+ version: version,
825
+ items: messages,
826
+ retailerId: retailerId,
827
+ status: product.status || productEdit.product.status,
661
828
  },
662
- });
829
+ paramsHeader: { Authorization: token },
830
+ };
831
+ setMessage("");
832
+ return sendMessage(data);
663
833
  };
664
834
 
665
835
  useEffect(() => {
@@ -716,21 +886,6 @@ export const ProviderProductEdition = ({
716
886
  sessionStorage.setItem("productSelected", JSON.stringify(productTemp));
717
887
  };
718
888
 
719
- const evaluationComplete = (tab) => {
720
- const concept = getConcept(tab);
721
- let serv = servicesData.filter((item) => item.service === concept);
722
- if (
723
- ["RequestWithContentoh", "RequestWithoutContentoh"].includes(origin[tab])
724
- ) {
725
- serv = serv.filter((f) => f.id_retailer === activeRetailer.id);
726
- }
727
- const statusArray =
728
- user.is_retailer === 1 ? ["ACA", "RCA"] : ["AP", "RP", "ACA"];
729
- return (
730
- serv.length > 0 && serv.every((item) => statusArray.includes(item.status))
731
- );
732
- };
733
-
734
889
  const downloadImages = () => {
735
890
  selectedImages.length > 0
736
891
  ? selectedImages.forEach((e) => {
@@ -824,21 +979,6 @@ export const ProviderProductEdition = ({
824
979
  }
825
980
  };
826
981
 
827
- const confirmStatusComplete = () => {
828
- const { datasheet_status, description_status, images_status } = product;
829
- const completionStates =
830
- user.is_retailer === 1
831
- ? ["ACA", "Evaluated", "NS"]
832
- : ["AP", "Evaluated", "NS"];
833
- const dsEvaluated = completionStates.includes(datasheet_status);
834
- const descsEvaluated = completionStates.includes(description_status);
835
- const imgsEvaluated = completionStates.includes(images_status);
836
-
837
- const AllEvaluated = dsEvaluated && descsEvaluated && imgsEvaluated;
838
-
839
- return AllEvaluated;
840
- };
841
-
842
982
  const sendEvaluation = async (result) => {
843
983
  setLoading(true);
844
984
  const concept = getConcept(activeTab);
@@ -889,6 +1029,27 @@ export const ProviderProductEdition = ({
889
1029
  const { newArticleStatus, newServiceStatus, newStatus } = JSON.parse(
890
1030
  res.data.body
891
1031
  );
1032
+
1033
+ const message = createMessage(
1034
+ product.retailers || product.retailersAvailable,
1035
+ activeRetailer.id,
1036
+ product[sectionStatusKey],
1037
+ newStatus,
1038
+ activeTab
1039
+ );
1040
+
1041
+ const messageData = {
1042
+ paramsBody: {
1043
+ id: product.article.id_article || productEdit.ArticleId,
1044
+ version: version,
1045
+ items: [{ type: "status", value: message }],
1046
+ retailerId: activeRetailer.id,
1047
+ status: product.status || productEdit.product.status,
1048
+ },
1049
+ paramsHeader: { Authorization: token },
1050
+ };
1051
+ await sendMessage(messageData);
1052
+
892
1053
  if (newArticleStatus) productTemp.status = newArticleStatus[articleId];
893
1054
  const retailerStatusCopy = { ...retailerStatus };
894
1055
  retailerStatusCopy[activeRetailer.id][concept] = newStatus;
@@ -920,6 +1081,7 @@ export const ProviderProductEdition = ({
920
1081
  result,
921
1082
  isAproved: result === "A",
922
1083
  };
1084
+ const messages = [];
923
1085
  servicesData?.forEach((ret) => {
924
1086
  const { service, id_retailer } = ret;
925
1087
  let data = {};
@@ -936,24 +1098,37 @@ export const ProviderProductEdition = ({
936
1098
  },
937
1099
  })
938
1100
  );
1101
+ if (product[`${ret.service}_status`] !== "NS") {
1102
+ const message = createMessage(
1103
+ product.retailers,
1104
+ ret.id_retailer,
1105
+ product[`${ret.service}_status`],
1106
+ `${result}A`,
1107
+ ret.service
1108
+ );
1109
+ messages.push(
1110
+ createComment([{ type: "status", value: message }], ret.id_retailer)
1111
+ );
1112
+ }
939
1113
  });
940
- const evalResponse = await Promise.all(evaluationArray);
1114
+ await Promise.all(evaluationArray);
941
1115
  const userType = user.is_retailer === 1 ? "CA" : "P";
942
1116
 
943
1117
  const productTemp = product;
944
- productTemp.article_status = `${result}${userType}`;
1118
+ const status = `${result}${userType}`;
1119
+ productTemp.article_status = status;
945
1120
  productTemp.datasheet_status =
946
- productTemp.datasheet_status === "NA" ? "NA" : `${result}${userType}`;
1121
+ productTemp.datasheet_status === "NA" ? "NA" : status;
947
1122
  productTemp.description_status =
948
- productTemp.description_status === "NA" ? "NA" : `${result}${userType}`;
1123
+ productTemp.description_status === "NA" ? "NA" : status;
949
1124
  productTemp.images_status =
950
- productTemp.images_status === "NA" ? "NA" : `${result}${userType}`;
1125
+ productTemp.images_status === "NA" ? "NA" : status;
951
1126
 
952
1127
  const retailerStatusCopy = { ...retailerStatus };
953
1128
  Object.keys(retailerStatusCopy).forEach((key) => {
954
1129
  conceptArray.forEach((concept) => {
955
1130
  if (retailerStatusCopy[key][concept]) {
956
- retailerStatusCopy[key][concept] = `${result}${userType}`;
1131
+ retailerStatusCopy[key][concept] = status;
957
1132
  }
958
1133
  });
959
1134
  });
@@ -974,6 +1149,7 @@ export const ProviderProductEdition = ({
974
1149
  product: productTemp,
975
1150
  })
976
1151
  );
1152
+ await Promise.all(messages);
977
1153
 
978
1154
  await loadData();
979
1155
  } catch (error) {
@@ -1004,7 +1180,7 @@ export const ProviderProductEdition = ({
1004
1180
  prod.product.services_status = `["${statusComplete}","${statusComplete}","${statusComplete}"]`;
1005
1181
  sessionStorage.setItem("productEdit", JSON.stringify(prod));
1006
1182
  setProduct(prod);
1007
- setShowGenericModal && setShowGenericModal(false);
1183
+ showGlobalModal("generic");
1008
1184
  await loadData();
1009
1185
  };
1010
1186
 
@@ -1075,7 +1251,7 @@ export const ProviderProductEdition = ({
1075
1251
  action: () => evaluationToRetailer("A"),
1076
1252
  },
1077
1253
  }));
1078
- setShowGenericModal(true);
1254
+ showGlobalModal("generic");
1079
1255
  } else if (user.is_retailer) {
1080
1256
  if (product.id_order || product.orderId) {
1081
1257
  sendEvaluation("A");
@@ -1087,7 +1263,7 @@ export const ProviderProductEdition = ({
1087
1263
  action: () => evaluationToRetailer("A"),
1088
1264
  },
1089
1265
  }));
1090
- setShowGenericModal(true);
1266
+ showGlobalModal("generic");
1091
1267
  }
1092
1268
  } else {
1093
1269
  sendEvaluation("A");
@@ -1101,8 +1277,7 @@ export const ProviderProductEdition = ({
1101
1277
  return;
1102
1278
  } else if (user.is_retailer) {
1103
1279
  if (product.id_order || product.orderId) {
1104
- setValidatedAll(true);
1105
- setModalViewError(true);
1280
+ sendEvaluation("R");
1106
1281
  } else {
1107
1282
  setDataGenericModal((prev) => ({
1108
1283
  ...prev,
@@ -1111,11 +1286,10 @@ export const ProviderProductEdition = ({
1111
1286
  action: () => evaluationToRetailer("R"),
1112
1287
  },
1113
1288
  }));
1114
- setShowGenericModal(true);
1289
+ showGlobalModal("generic");
1115
1290
  }
1116
1291
  } else {
1117
- setValidatedAll(true);
1118
- setModalViewError(true);
1292
+ sendEvaluation("R");
1119
1293
  }
1120
1294
  }
1121
1295
  };
@@ -1124,6 +1298,7 @@ export const ProviderProductEdition = ({
1124
1298
  <HeaderTop
1125
1299
  setHeaderTop={setHeaderTop}
1126
1300
  withChat={location?.state?.withChat}
1301
+ chatType={location?.state?.chatType}
1127
1302
  productSelected={productSelected}
1128
1303
  token={token}
1129
1304
  activeRetailer={activeRetailer}
@@ -1174,7 +1349,7 @@ export const ProviderProductEdition = ({
1174
1349
  action: () => evaluationToRetailer("A"),
1175
1350
  },
1176
1351
  }));
1177
- setShowGenericModal(true);
1352
+ showGlobalModal("generic");
1178
1353
  } else if (user.is_retailer) {
1179
1354
  if (product.id_order || product.orderId) {
1180
1355
  validateAll("A");
@@ -1186,7 +1361,7 @@ export const ProviderProductEdition = ({
1186
1361
  action: () => evaluationToRetailer("A"),
1187
1362
  },
1188
1363
  }));
1189
- setShowGenericModal(true);
1364
+ showGlobalModal("generic");
1190
1365
  }
1191
1366
  } else {
1192
1367
  validateAll("A");
@@ -1202,7 +1377,7 @@ export const ProviderProductEdition = ({
1202
1377
  } else if (user.is_retailer) {
1203
1378
  if (product.id_order || product.orderId) {
1204
1379
  setValidatedAll(true);
1205
- setModalViewError(true);
1380
+ setShowRejectModal(true);
1206
1381
  } else {
1207
1382
  setDataGenericModal((prev) => ({
1208
1383
  ...prev,
@@ -1211,15 +1386,17 @@ export const ProviderProductEdition = ({
1211
1386
  action: () => evaluationToRetailer("R"),
1212
1387
  },
1213
1388
  }));
1214
- setShowGenericModal(true);
1389
+ showGlobalModal("generic");
1215
1390
  }
1216
1391
  } else {
1392
+ setShowRejectModal(true);
1217
1393
  setValidatedAll(true);
1218
- setModalViewError(true);
1219
1394
  }
1220
1395
  }}
1221
1396
  approve={() => sendToEvaluation("A")}
1222
- reject={() => sendToEvaluation("R")}
1397
+ reject={() => {
1398
+ setShowRejectModal(true);
1399
+ }}
1223
1400
  />
1224
1401
  <FullTabsMenu
1225
1402
  tabsSections={tabsSections}
@@ -1442,64 +1619,7 @@ export const ProviderProductEdition = ({
1442
1619
  onClick={() => setMessage("")}
1443
1620
  />
1444
1621
  )}
1445
- {modalSent && (
1446
- <GlobalModal
1447
- close={() => setModalSent(false)}
1448
- message={message}
1449
- detail={""}
1450
- bold={!evaluationComplete(activeTab) && "Aprueba / Rechaza"}
1451
- widthImg={!evaluationComplete(activeTab) ? "160px" : "354px"}
1452
- heightImg={!evaluationComplete(activeTab) ? "84px" : "354px"}
1453
- img={getSectionIcon()}
1454
- />
1455
- )}
1456
- {modalViewError && (
1457
- <GlobalModal
1458
- close={() => setModalViewError(false)}
1459
- message={`${activeTab} rechazada`}
1460
- detail={"Agrega tu comentarios para enviar el rechazo"}
1461
- button1={{
1462
- name: "Enviar",
1463
- action: (e) => {
1464
- const textArea = document.querySelector("#area");
1465
- if (textArea.value) {
1466
- textArea.style.border = "none";
1467
- createComment(e, textArea.value);
1468
- setModalViewError(false);
1469
- setModalViewTextArea(true);
1470
- validatedAll ? validateAll("R") : sendEvaluation("R");
1471
- } else {
1472
- textArea.style.border = "2px solid red";
1473
- }
1474
- },
1475
- }}
1476
- img={errorModal}
1477
- textArea={true}
1478
- />
1479
- )}
1480
- {showGenericModal && (
1481
- <GlobalModal
1482
- close={() => setShowGenericModal(false)}
1483
- message={dataGenericModal.message}
1484
- detail={dataGenericModal.detail}
1485
- button1={dataGenericModal.button1}
1486
- button2={dataGenericModal.button2}
1487
- img={dataGenericModal.img}
1488
- />
1489
- )}
1490
- {modalViewTextArea && (
1491
- <GlobalModal
1492
- close={() => setModalViewTextArea(false)}
1493
- message={`Gracias, tus comentarios fueron entregados.`}
1494
- detail={"Trabajaremos en conjunto para resolverlo."}
1495
- button1={{
1496
- name: "Cerrar",
1497
- action: () => setModalViewTextArea(false),
1498
- }}
1499
- img={face}
1500
- textArea={false}
1501
- />
1502
- )}
1622
+ {globalModal && <GlobalModal close={closeGlobalModal} {...globalModal} />}
1503
1623
  {showVersionSelector && (
1504
1624
  <VersionSelector
1505
1625
  modalId={"version-selector"}
@@ -1511,6 +1631,49 @@ export const ProviderProductEdition = ({
1511
1631
  jwt={token}
1512
1632
  />
1513
1633
  )}
1634
+ {showRejectModal && (
1635
+ <Modal
1636
+ title={"Agregar mensaje de rechazo"}
1637
+ show={showRejectModal}
1638
+ customComponent={
1639
+ <TagAndInput
1640
+ label={"Caja de Comentario"}
1641
+ inputType={"textarea"}
1642
+ inputId={"modal-message-box"}
1643
+ index={0}
1644
+ color={"white"}
1645
+ />
1646
+ }
1647
+ buttons={[
1648
+ <ButtonV2
1649
+ key={"btn-Cancelar"}
1650
+ type={"white"}
1651
+ label={"Cancelar"}
1652
+ size={12}
1653
+ onClick={() => {
1654
+ setShowRejectModal(false);
1655
+ }}
1656
+ />,
1657
+ <ButtonV2
1658
+ key={"btn-Aceptar"}
1659
+ type={"pink"}
1660
+ label={"Aceptar"}
1661
+ size={12}
1662
+ onClick={async () => {
1663
+ const body = document.querySelector(
1664
+ "#modal-message-box .ql-container .ql-editor > p"
1665
+ ).innerHTML;
1666
+ const messages = [
1667
+ { type: "message", value: body?.replace(/<.*?\/?>/gm, "") },
1668
+ ];
1669
+ await createComment(messages, activeRetailer.id);
1670
+ validatedAll ? validateAll("R") : sendToEvaluation("R");
1671
+ setShowRejectModal(false);
1672
+ }}
1673
+ />,
1674
+ ]}
1675
+ />
1676
+ )}
1514
1677
  </Container>
1515
1678
  );
1516
1679
  };