contentoh-components-library 21.3.61 → 21.3.62

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 (41) hide show
  1. package/.env.development +2 -0
  2. package/dist/assets/fonts/roboto/LICENSE.txt +202 -0
  3. package/dist/components/molecules/CarouselImagesLogin/index.js +1 -1
  4. package/dist/components/molecules/HeaderTop/index.js +68 -11
  5. package/dist/components/organisms/Chat/Chat.stories.js +21 -1
  6. package/dist/components/organisms/Chat/ContainerItems/index.js +19 -3
  7. package/dist/components/organisms/Chat/ContainerItems/styles.js +1 -1
  8. package/dist/components/organisms/Chat/ContentChat/index.js +343 -191
  9. package/dist/components/organisms/Chat/Footer/index.js +48 -39
  10. package/dist/components/organisms/Chat/index.js +48 -3
  11. package/dist/components/organisms/FullProductNameHeader/index.js +2 -2
  12. package/dist/components/organisms/SideModal/SideModal.stories.js +42 -0
  13. package/dist/components/organisms/SideModal/index.js +61 -0
  14. package/dist/components/organisms/SideModal/styles.js +18 -0
  15. package/dist/components/pages/ProviderProductEdition/ProviderProductEdition.stories.js +172 -127
  16. package/dist/components/pages/ProviderProductEdition/index.js +200 -134
  17. package/dist/components/pages/ProviderProductEdition/styles.js +1 -1
  18. package/dist/components/pages/RetailerProductEdition/RetailerProductEdition.stories.js +40 -28
  19. package/dist/components/pages/RetailerProductEdition/index.js +266 -273
  20. package/dist/components/pages/RetailerProductEdition/styles.js +1 -1
  21. package/dist/components/pages/RetailerProductEdition/utils.js +61 -2
  22. package/package.json +1 -1
  23. package/src/components/molecules/CarouselImagesLogin/index.js +1 -1
  24. package/src/components/molecules/HeaderTop/index.js +52 -6
  25. package/src/components/organisms/Chat/Chat.stories.js +21 -0
  26. package/src/components/organisms/Chat/ContainerItems/index.js +18 -2
  27. package/src/components/organisms/Chat/ContainerItems/styles.js +10 -2
  28. package/src/components/organisms/Chat/ContentChat/index.js +81 -6
  29. package/src/components/organisms/Chat/Footer/index.js +11 -0
  30. package/src/components/organisms/Chat/index.js +47 -3
  31. package/src/components/organisms/FullProductNameHeader/index.js +1 -1
  32. package/src/components/organisms/SideModal/SideModal.stories.js +23 -0
  33. package/src/components/organisms/SideModal/index.js +41 -0
  34. package/src/components/organisms/SideModal/styles.js +21 -0
  35. package/src/components/pages/ProviderProductEdition/ProviderProductEdition.stories.js +177 -130
  36. package/src/components/pages/ProviderProductEdition/index.js +116 -59
  37. package/src/components/pages/ProviderProductEdition/styles.js +5 -1
  38. package/src/components/pages/RetailerProductEdition/RetailerProductEdition.stories.js +38 -26
  39. package/src/components/pages/RetailerProductEdition/index.js +110 -135
  40. package/src/components/pages/RetailerProductEdition/styles.js +4 -0
  41. package/src/components/pages/RetailerProductEdition/utils.js +37 -0
@@ -39,6 +39,9 @@ import Slide1_4 from "../../../assets/images/sliderToolTip/slide4.svg";
39
39
  import Slide1_5 from "../../../assets/images/sliderToolTip/slide5.svg";
40
40
  import { VersionSelector } from "../../organisms/VersionSelector";
41
41
  import { useCloseModal } from "../../../global-files/customHooks";
42
+ import { createMessage, sendMessage } from "../RetailerProductEdition/utils";
43
+ import { Modal } from "../../organisms/Modal";
44
+ import { ButtonV2 } from "../../atoms/ButtonV2";
42
45
 
43
46
  const reducerImages = (state, action) => {
44
47
  let { values, attrForImgs, inputsByRetailer } = state;
@@ -214,12 +217,12 @@ export const ProviderProductEdition = ({
214
217
  const isRetailer = user?.is_retailer;
215
218
  const [loading, setLoading] = useState(true);
216
219
  const [validatedAll, setValidatedAll] = useState(false);
220
+ const [showRejectModal, setShowRejectModal] = useState(false);
217
221
 
218
- const originProp = location?.state?.origin;
219
222
  const [origin, setOrigin] = useState({
220
- "Ficha técnica": originProp,
221
- Descripción: originProp,
222
- Imágenes: originProp,
223
+ "Ficha técnica": null,
224
+ Descripción: null,
225
+ Imágenes: null,
223
226
  });
224
227
  const [inCart, setInCart] = useState(false);
225
228
  const [dataGenericModal, setDataGenericModal] = useState({
@@ -343,28 +346,6 @@ export const ProviderProductEdition = ({
343
346
  (type) => {
344
347
  const formatter = new Intl.ListFormat("es", { type: "conjunction" });
345
348
  switch (type) {
346
- case "error":
347
- setGlobalModal({
348
- message: `${activeTab} rechazada`,
349
- detail: "Agrega tu comentarios para enviar el rechazo",
350
- img: errorModal,
351
- textArea: true,
352
- button1: {
353
- name: "Enviar",
354
- action: (e) => {
355
- const textArea = document.querySelector("#area");
356
- if (textArea.value) {
357
- textArea.style.border = "none";
358
- createComment(e, textArea.value);
359
- showGlobalModal("commentsSent");
360
- validatedAll ? validateAll("R") : sendEvaluation("R");
361
- } else {
362
- textArea.style.border = "2px solid red";
363
- }
364
- },
365
- },
366
- });
367
- break;
368
349
  case "generic":
369
350
  setGlobalModal(dataGenericModal);
370
351
  break;
@@ -478,6 +459,14 @@ export const ProviderProductEdition = ({
478
459
  }
479
460
  }, [showModal]);
480
461
 
462
+ useEffect(() => {
463
+ setOrigin({
464
+ "Ficha técnica": location?.state?.origin,
465
+ Descripción: location?.state?.origin,
466
+ Imágenes: location?.state?.origin,
467
+ });
468
+ }, [location?.state?.origin]);
469
+
481
470
  const loadData = async () => {
482
471
  const services = await getRetailerServices(
483
472
  product?.id_article || product?.article?.id_article,
@@ -516,7 +505,9 @@ export const ProviderProductEdition = ({
516
505
  );
517
506
  setServicesData(parsedResponse);
518
507
  }
519
- !activeRetailer.id && setActiveRetailer(active ? active : retailers[0]);
508
+ retailers &&
509
+ !activeRetailer.id &&
510
+ setActiveRetailer(active ? active : retailers[0]);
520
511
  };
521
512
 
522
513
  const isRevision = () => {
@@ -592,7 +583,7 @@ export const ProviderProductEdition = ({
592
583
  });
593
584
  }
594
585
  setProduct(productTemp);
595
- setActivePercentage(retailers[0]?.percentage);
586
+ retailers && setActivePercentage(retailers[0]?.percentage);
596
587
  }, [percentages]);
597
588
 
598
589
  const loadInputs = () => {
@@ -833,32 +824,19 @@ export const ProviderProductEdition = ({
833
824
  }
834
825
  };
835
826
 
836
- const createComment = async (e, body, tab) => {
837
- let concept = "";
838
- switch (activeTab) {
839
- case "Ficha técnica":
840
- concept = "datasheet";
841
- break;
842
- case "Imágenes":
843
- concept = "images";
844
- break;
845
-
846
- default:
847
- concept = "description";
848
- break;
849
- }
827
+ const createComment = async (messages = [], retailerId) => {
850
828
  const data = {
851
- articleId: product?.id_article,
852
- orderId: product?.orderId,
853
- message: body,
854
- concept: concept,
855
- version: version,
856
- };
857
- await axios.post(`${process.env.REACT_APP_COMMENTS_ENDPOINT}`, data, {
858
- headers: {
859
- Authorization: token,
829
+ paramsBody: {
830
+ id: product.article.id_article || productEdit.ArticleId,
831
+ version: version,
832
+ items: messages,
833
+ retailerId: retailerId,
834
+ status: product.status || productEdit.product.status,
860
835
  },
861
- });
836
+ paramsHeader: { Authorization: token },
837
+ };
838
+ setMessage("");
839
+ return sendMessage(data);
862
840
  };
863
841
 
864
842
  useEffect(() => {
@@ -1058,6 +1036,27 @@ export const ProviderProductEdition = ({
1058
1036
  const { newArticleStatus, newServiceStatus, newStatus } = JSON.parse(
1059
1037
  res.data.body
1060
1038
  );
1039
+
1040
+ const message = createMessage(
1041
+ product.retailers || product.retailersAvailable,
1042
+ activeRetailer.id,
1043
+ product[sectionStatusKey],
1044
+ newStatus,
1045
+ activeTab
1046
+ );
1047
+
1048
+ const messageData = {
1049
+ paramsBody: {
1050
+ id: product.article.id_article || productEdit.ArticleId,
1051
+ version: version,
1052
+ items: [{ type: "status", value: message }],
1053
+ retailerId: activeRetailer.id,
1054
+ status: product.status || productEdit.product.status,
1055
+ },
1056
+ paramsHeader: { Authorization: token },
1057
+ };
1058
+ await sendMessage(messageData);
1059
+
1061
1060
  if (newArticleStatus) productTemp.status = newArticleStatus[articleId];
1062
1061
  const retailerStatusCopy = { ...retailerStatus };
1063
1062
  retailerStatusCopy[activeRetailer.id][concept] = newStatus;
@@ -1089,6 +1088,7 @@ export const ProviderProductEdition = ({
1089
1088
  result,
1090
1089
  isAproved: result === "A",
1091
1090
  };
1091
+ const messages = [];
1092
1092
  servicesData?.forEach((ret) => {
1093
1093
  const { service, id_retailer } = ret;
1094
1094
  let data = {};
@@ -1105,6 +1105,18 @@ export const ProviderProductEdition = ({
1105
1105
  },
1106
1106
  })
1107
1107
  );
1108
+ if (product[`${ret.service}_status`] !== "NS") {
1109
+ const message = createMessage(
1110
+ product.retailers,
1111
+ ret.id_retailer,
1112
+ product[`${ret.service}_status`],
1113
+ `${result}A`,
1114
+ ret.service
1115
+ );
1116
+ messages.push(
1117
+ createComment([{ type: "status", value: message }], ret.id_retailer)
1118
+ );
1119
+ }
1108
1120
  });
1109
1121
  await Promise.all(evaluationArray);
1110
1122
  const userType = user.is_retailer === 1 ? "CA" : "P";
@@ -1144,6 +1156,7 @@ export const ProviderProductEdition = ({
1144
1156
  product: productTemp,
1145
1157
  })
1146
1158
  );
1159
+ await Promise.all(messages);
1147
1160
 
1148
1161
  await loadData();
1149
1162
  } catch (error) {
@@ -1271,8 +1284,7 @@ export const ProviderProductEdition = ({
1271
1284
  return;
1272
1285
  } else if (user.is_retailer) {
1273
1286
  if (product.id_order || product.orderId) {
1274
- setValidatedAll(true);
1275
- showGlobalModal("error");
1287
+ sendEvaluation("R");
1276
1288
  } else {
1277
1289
  setDataGenericModal((prev) => ({
1278
1290
  ...prev,
@@ -1284,8 +1296,7 @@ export const ProviderProductEdition = ({
1284
1296
  showGlobalModal("generic");
1285
1297
  }
1286
1298
  } else {
1287
- setValidatedAll(true);
1288
- showGlobalModal("error");
1299
+ sendEvaluation("R");
1289
1300
  }
1290
1301
  }
1291
1302
  };
@@ -1294,6 +1305,7 @@ export const ProviderProductEdition = ({
1294
1305
  <HeaderTop
1295
1306
  setHeaderTop={setHeaderTop}
1296
1307
  withChat={location?.state?.withChat}
1308
+ chatType={location?.state?.chatType}
1297
1309
  productSelected={productSelected}
1298
1310
  token={token}
1299
1311
  activeRetailer={activeRetailer}
@@ -1372,7 +1384,7 @@ export const ProviderProductEdition = ({
1372
1384
  } else if (user.is_retailer) {
1373
1385
  if (product.id_order || product.orderId) {
1374
1386
  setValidatedAll(true);
1375
- showGlobalModal("error");
1387
+ setShowRejectModal(true);
1376
1388
  } else {
1377
1389
  setDataGenericModal((prev) => ({
1378
1390
  ...prev,
@@ -1384,12 +1396,14 @@ export const ProviderProductEdition = ({
1384
1396
  showGlobalModal("generic");
1385
1397
  }
1386
1398
  } else {
1399
+ setShowRejectModal(true);
1387
1400
  setValidatedAll(true);
1388
- showGlobalModal("error");
1389
1401
  }
1390
1402
  }}
1391
1403
  approve={() => sendToEvaluation("A")}
1392
- reject={() => sendToEvaluation("R")}
1404
+ reject={() => {
1405
+ setShowRejectModal(true);
1406
+ }}
1393
1407
  />
1394
1408
  <FullTabsMenu
1395
1409
  tabsSections={tabsSections}
@@ -1624,6 +1638,49 @@ export const ProviderProductEdition = ({
1624
1638
  jwt={token}
1625
1639
  />
1626
1640
  )}
1641
+ {showRejectModal && (
1642
+ <Modal
1643
+ title={"Agregar mensaje de rechazo"}
1644
+ show={showRejectModal}
1645
+ customComponent={
1646
+ <TagAndInput
1647
+ label={"Caja de Comentario"}
1648
+ inputType={"textarea"}
1649
+ inputId={"modal-message-box"}
1650
+ index={0}
1651
+ color={"white"}
1652
+ />
1653
+ }
1654
+ buttons={[
1655
+ <ButtonV2
1656
+ key={"btn-Cancelar"}
1657
+ type={"white"}
1658
+ label={"Cancelar"}
1659
+ size={12}
1660
+ onClick={() => {
1661
+ setShowRejectModal(false);
1662
+ }}
1663
+ />,
1664
+ <ButtonV2
1665
+ key={"btn-Aceptar"}
1666
+ type={"pink"}
1667
+ label={"Aceptar"}
1668
+ size={12}
1669
+ onClick={async () => {
1670
+ const body = document.querySelector(
1671
+ "#modal-message-box .ql-container .ql-editor > p"
1672
+ ).innerHTML;
1673
+ const messages = [
1674
+ { type: "message", value: body?.replace(/<.*?\/?>/gm, "") },
1675
+ ];
1676
+ await createComment(messages, activeRetailer.id);
1677
+ validatedAll ? validateAll("R") : sendToEvaluation("R");
1678
+ setShowRejectModal(false);
1679
+ }}
1680
+ />,
1681
+ ]}
1682
+ />
1683
+ )}
1627
1684
  </Container>
1628
1685
  );
1629
1686
  };
@@ -107,6 +107,10 @@ export const Container = styled.div`
107
107
  }
108
108
  }
109
109
  }
110
+ #modal-message-box {
111
+ width: 400px;
112
+ height: 100px;
113
+ }
110
114
  .container {
111
115
  width: 100%;
112
116
  height: 100%;
@@ -115,4 +119,4 @@ export const Container = styled.div`
115
119
  width: 100%;
116
120
  }
117
121
  }
118
- `;
122
+ `;
@@ -16,26 +16,41 @@ RetailerProductEditionDefault.args = {
16
16
  Imágenes: false,
17
17
  },
18
18
  token:
19
- "eyJraWQiOiJkQWJkZCtlclwvTlwveVRQUWNvUlVyOCtrNUd2M1hMM2N1MWUzQ09zWExVRnc9IiwiYWxnIjoiUlMyNTYifQ.eyJzdWIiOiJhNmM0ZDNkNi0yNGE0LTQxZDQtYWQwZi1kMDg3NDM4YWI1YjYiLCJjb2duaXRvOmdyb3VwcyI6WyJjb2xhYm9yYWRvcmVzX2NvbnRlbnRvaCJdLCJlbWFpbF92ZXJpZmllZCI6dHJ1ZSwiaXNzIjoiaHR0cHM6XC9cL2NvZ25pdG8taWRwLnVzLWVhc3QtMS5hbWF6b25hd3MuY29tXC91cy1lYXN0LTFfWE1aUWRxa0dqIiwiY29nbml0bzp1c2VybmFtZSI6ImE2YzRkM2Q2LTI0YTQtNDFkNC1hZDBmLWQwODc0MzhhYjViNiIsImNvZ25pdG86cm9sZXMiOlsiYXJuOmF3czppYW06Ojg5ODY3MDIzMjgwNzpyb2xlXC9jb250ZW50b2gtZGV2LXVzLWVhc3QtMS1sYW1iZGFSb2xlIl0sImF1ZCI6IjVhYzh0cGdzNmdic3ExM2ZydnJwaWVlcDQwIiwiZXZlbnRfaWQiOiIyYjU3MjZlMy04MjM2LTRmYzMtODBkMi05NWVmYmU4ODdjOTYiLCJ0b2tlbl91c2UiOiJpZCIsImF1dGhfdGltZSI6MTY4MjAxNjI5MSwibmFtZSI6IkNvbGFib3JhZG9yIiwicGhvbmVfbnVt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YxMy04ZGIyLTRlZjUtYjA0Mi01ZDU3MWRkZjIwMWIiLCJ0b2tlbl91c2UiOiJpZCIsImF1dGhfdGltZSI6MTY4Mzg3NTIyNiwibmFtZSI6IkNvbGFib3JhZG9yIiwicGhvbmVfbnVtYmVyIjoiKzUyMTExMSIsImV4cCI6MTY4Mzg3ODgyNiwiaWF0IjoxNjgzODc1MjI2LCJlbWFpbCI6ImlzbWFlbDk3bG9wZXpAZ21haWwuY29tIn0.EtgmT_THMx-Zy_zB5yZK4gz6TXNTVVJEKFt5X0JK2UkGVrp_q_92YCEuejS4n976fyTez0jkwOee6IkVHLV71uZWRBDFt-3Yw4ZxfsZYPNJWhoHXGNxhMU8MCkSntfu597esBTk-VsUpstT5R7L-WJfN8viE7R-qVo-42RlPTG0TFrWA9q0oTcqjv8vbxLpOBUjiEpjmqRhg4blJZwgkGNta6MOlw1vfmisOVbo9wMvqwnCZ9xx9KMKoH9U4uNObK_JomjbvPmTmkcUXsE-wGSD7XcoSwtuhBngLC7-jiu1u8MvL_ff5Z0Qp70sSpLdUglcSS8d1Xf7j_fcZuJ5jKA",
20
20
  productSelected: {
21
- orderId: 15160,
22
- status: "SAC",
23
- datasheet_status: "SAC",
21
+ orderId: 14606,
22
+ status: "RA",
23
+ datasheet_status: "RA",
24
24
  prio: "none",
25
- version: 7,
26
- description_status: "SAC",
27
- images_status: "SAC",
28
- brand: null,
29
- retailerOrder: 1,
30
- missing: {
31
- datasheet: null,
32
- descriptions: null,
33
- images: null,
34
- },
35
- services: {
36
- datasheets: 1,
37
- descriptions: 1,
38
- images: 1,
25
+ version: 3,
26
+ description_status: "RA",
27
+ images_status: "RA",
28
+ statusByRetailer: {
29
+ 4: {
30
+ datasheet: "RA/AC",
31
+ description: "RA/AC",
32
+ images: "RA/AC",
33
+ },
34
+ 5: {
35
+ datasheet: "RA/AC",
36
+ description: "RA/AC",
37
+ images: "RA/AC",
38
+ },
39
+ 6: {
40
+ description: "RA/AC",
41
+ images: "RA/AC",
42
+ datasheet: "RA/AC",
43
+ },
44
+ 12: {
45
+ datasheet: "RA/AC",
46
+ description: "RA/AC",
47
+ images: "RA/AC",
48
+ },
49
+ 17: {
50
+ datasheet: "RA/AC",
51
+ description: "RA/AC",
52
+ images: "RA/AC",
53
+ },
39
54
  },
40
55
  article: {
41
56
  category: "Puertas y Ventanas|Molduras|Molduras Madera Blanda",
@@ -65,16 +80,13 @@ RetailerProductEditionDefault.args = {
65
80
  name: "The Home Depot Merchants",
66
81
  },
67
82
  ],
68
- statusByRetailer: {
69
- 58: {
70
- datasheet: "SAC",
71
- description: "SAC",
72
- images: "SAC",
73
- },
74
- },
75
83
  },
76
84
  location: {
77
- product: { articleId: 39290, versionId: 7 },
85
+ product: { articleId: 354, versionId: 3 },
86
+ state: {
87
+ withChat: true,
88
+ chatType: "product_status",
89
+ },
78
90
  },
79
91
  user: {
80
92
  id_user: 51,