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
@@ -24,15 +24,20 @@ import descriptionSent from "../../../assets/images/modalsSVGs/descriptionSent.s
24
24
  import imagesSent from "../../../assets/images/modalsSVGs/uploadingImages.svg";
25
25
  import { TagAndInput } from "../../molecules/TagAndInput/index";
26
26
  import { Button } from "../../atoms/GeneralButton";
27
- import { Commentary } from "../../atoms/Commentary";
28
27
  import { GenericModal } from "../../atoms/GenericModal";
29
28
  import { ScreenHeader } from "../../atoms/ScreenHeader";
30
29
  import { Loading } from "../../atoms/Loading";
31
30
  import succes from "../../../assets/images/genericModal/genericModalCheck.svg";
32
- import errorModal from "../../../assets/images/genericModal/errorModal.svg";
33
31
  import { VersionSelector } from "../../organisms/VersionSelector";
34
32
  import { useCloseModal } from "../../../global-files/customHooks";
35
- import { getAuditVersion, getInputsData } from "./utils";
33
+ import {
34
+ getAuditVersion,
35
+ getInputsData,
36
+ createMessage,
37
+ sendMessage,
38
+ } from "./utils";
39
+ import { Modal } from "../../organisms/Modal";
40
+ import { ButtonV2 } from "../../atoms/ButtonV2";
36
41
 
37
42
  const reducerImages = (state, action) => {
38
43
  let { values, attrForImgs, inputsByRetailer } = state;
@@ -132,6 +137,7 @@ export const RetailerProductEdition = ({
132
137
  const [datasheets, setDatasheets] = useState([]);
133
138
  const [images, setImages] = useReducer(reducerImages, {});
134
139
  const [showModal, setShowModal] = useState(false);
140
+ const [showRejectModal, setShowRejectModal] = useState(false);
135
141
  const { getRootProps, getInputProps } = useDropzone({
136
142
  accept: "image/*",
137
143
  noKeyboard: true,
@@ -218,6 +224,7 @@ export const RetailerProductEdition = ({
218
224
  const [auditDescriptions, setAuditDescriptions] = useState([]);
219
225
  const [auditImages, setAuditImages] = useState([]);
220
226
  const [compare, setCompare] = useState(false);
227
+ const [valRejAll, setValRejAll] = useState(false);
221
228
 
222
229
  useEffect(async () => {
223
230
  const { id_article } = product?.article || {};
@@ -855,6 +862,25 @@ export const RetailerProductEdition = ({
855
862
  const { newStatus, newOrderStatus, newArticleStatus } = JSON.parse(
856
863
  res.data.body
857
864
  );
865
+ const messageToChat = createMessage(
866
+ product.retailers,
867
+ activeRetailer.id,
868
+ evalStatus,
869
+ newStatus,
870
+ activeTab
871
+ );
872
+
873
+ const data = {
874
+ paramsBody: {
875
+ id: product.article.id_article,
876
+ version: version,
877
+ items: [{ type: "status", value: messageToChat }],
878
+ retailerId: activeRetailer.id,
879
+ status: product.status,
880
+ },
881
+ paramsHeader: { Authorization: token },
882
+ };
883
+ await sendMessage(data);
858
884
  if (newOrderStatus) productTemp.status = newArticleStatus[articleId];
859
885
  productTemp[`${concept}_status`] = newStatus;
860
886
  await loadData();
@@ -897,35 +923,19 @@ export const RetailerProductEdition = ({
897
923
  return product?.article[`id_auditor`] === user.id_user;
898
924
  };
899
925
 
900
- const createComment = async (e, body, tab) => {
901
- let concept = "";
902
- switch (activeTab) {
903
- case "Ficha técnica":
904
- concept = "datasheet";
905
- break;
906
- case "Imágenes":
907
- concept = "images";
908
- break;
909
-
910
- default:
911
- concept = "description";
912
- break;
913
- }
926
+ const createComment = async (messages = [], retailerId) => {
914
927
  const data = {
915
- articleId: product?.article?.id_article,
916
- orderId: product?.orderId,
917
- message: body?.replace(/<.*?\/?>/gm, ""),
918
- concept: concept,
919
- version: version,
920
- };
921
- await axios.post(`${process.env.REACT_APP_COMMENTS_ENDPOINT}`, data, {
922
- headers: {
923
- Authorization: token,
928
+ paramsBody: {
929
+ id: product.article.id_article,
930
+ version: version,
931
+ items: messages,
932
+ retailerId: retailerId,
933
+ status: product.status,
924
934
  },
925
- });
926
- await getComments(tab);
935
+ paramsHeader: { Authorization: token },
936
+ };
927
937
  setMessage("");
928
- setComponentsArray([]);
938
+ return sendMessage(data);
929
939
  };
930
940
 
931
941
  const getRequired = (services) => {
@@ -1207,6 +1217,8 @@ export const RetailerProductEdition = ({
1207
1217
  break;
1208
1218
  }
1209
1219
 
1220
+ const messages = [];
1221
+
1210
1222
  servicesData?.forEach((ret) => {
1211
1223
  if (conceptArray.includes(ret.service)) {
1212
1224
  let data = {
@@ -1217,6 +1229,21 @@ export const RetailerProductEdition = ({
1217
1229
  evalStatus: ret.status,
1218
1230
  retailerId: ret.id_retailer,
1219
1231
  };
1232
+ if (product[`${ret.service}_status`] !== "NS") {
1233
+ const message = createMessage(
1234
+ product.retailers,
1235
+ ret.id_retailer,
1236
+ product[`${ret.service}_status`],
1237
+ `${result}A`,
1238
+ ret.service
1239
+ );
1240
+ messages.push(
1241
+ createComment(
1242
+ [{ type: "status", value: message }],
1243
+ ret.id_retailer
1244
+ )
1245
+ );
1246
+ }
1220
1247
  evaluationArray.push(
1221
1248
  axios.put(`${process.env.REACT_APP_EVALUATION_ENDPOINT}`, data, {
1222
1249
  headers: {
@@ -1226,19 +1253,19 @@ export const RetailerProductEdition = ({
1226
1253
  );
1227
1254
  }
1228
1255
  });
1229
-
1230
1256
  await Promise.all(evaluationArray);
1231
1257
 
1232
1258
  const productTemp = product;
1233
1259
  productTemp.status = `${result}A`;
1234
1260
  productTemp.datasheet_status =
1235
- productTemp.datasheet_status === "NA" ? "NA" : `${result}A`;
1261
+ productTemp.datasheet_status === "NS" ? "NS" : `${result}A`;
1236
1262
  productTemp.description_status =
1237
- productTemp.description_status === "NA" ? "NA" : `${result}A`;
1263
+ productTemp.description_status === "NS" ? "NS" : `${result}A`;
1238
1264
  productTemp.images_status =
1239
- productTemp.images_status === "NA" ? "NA" : `${result}A`;
1265
+ productTemp.images_status === "NS" ? "NS" : `${result}A`;
1240
1266
  sessionStorage.setItem("productSelected", JSON.stringify(productTemp));
1241
1267
  setProduct(productTemp);
1268
+ const messagesResponse = await Promise.all(messages);
1242
1269
 
1243
1270
  await loadData();
1244
1271
  } catch (error) {
@@ -1254,8 +1281,10 @@ export const RetailerProductEdition = ({
1254
1281
  setCompare={setCompare}
1255
1282
  isAuditor={[1, 6].includes(user.id_role)}
1256
1283
  withChat={location?.state?.withChat}
1257
- productSelected={productSelected}
1284
+ chatType={location?.state?.chatType}
1285
+ productSelected={product}
1258
1286
  token={token}
1287
+ activeRetailer={activeRetailer}
1259
1288
  />
1260
1289
  <div className="data-container">
1261
1290
  <div className="image-data-panel">
@@ -1295,36 +1324,7 @@ export const RetailerProductEdition = ({
1295
1324
  sendToFacilitator("A");
1296
1325
  }}
1297
1326
  reject={() => {
1298
- sendToFacilitator("R");
1299
- setMessage("Rechazado");
1300
- setComponentsArray([
1301
- <img src={errorModal} />,
1302
- <ScreenHeader
1303
- text={"Agrega tu comentarios para enviar el rechazo"}
1304
- headerType={"input-name-header"}
1305
- color={"white"}
1306
- />,
1307
- <TagAndInput
1308
- label={"Caja de Comentario"}
1309
- inputType={"textarea"}
1310
- inputId={"modal-commentary-box"}
1311
- index={0}
1312
- color={"white"}
1313
- />,
1314
- <Button
1315
- buttonType={"general-default-button"}
1316
- label={"Enviar comentario"}
1317
- onClick={(e) =>
1318
- createComment(
1319
- e,
1320
- document.querySelector(
1321
- "#modal-commentary-box .ql-container .ql-editor > p"
1322
- ).innerHTML,
1323
- activeTab
1324
- )
1325
- }
1326
- />,
1327
- ]);
1327
+ setShowRejectModal(true);
1328
1328
  }}
1329
1329
  showApproveRejectAll={
1330
1330
  approveRejectAllButtons() && (auditorAssigned() || userAssigned())
@@ -1334,36 +1334,8 @@ export const RetailerProductEdition = ({
1334
1334
  }
1335
1335
  approveAll={() => validateAll("A")}
1336
1336
  rejectAll={() => {
1337
- validateAll("R");
1338
- setMessage("Rechazado");
1339
- setComponentsArray([
1340
- <img src={errorModal} />,
1341
- <ScreenHeader
1342
- text={"Agrega tu comentarios para enviar el rechazo"}
1343
- headerType={"input-name-header"}
1344
- color={"white"}
1345
- />,
1346
- <TagAndInput
1347
- label={"Caja de Comentario"}
1348
- inputType={"textarea"}
1349
- inputId={"modal-commentary-box"}
1350
- index={0}
1351
- color={"white"}
1352
- />,
1353
- <Button
1354
- buttonType={"general-default-button"}
1355
- label={"Enviar comentario"}
1356
- onClick={(e) =>
1357
- createComment(
1358
- e,
1359
- document.querySelector(
1360
- "#modal-commentary-box .ql-container .ql-editor > p"
1361
- ).innerHTML,
1362
- activeTab
1363
- )
1364
- }
1365
- />,
1366
- ]);
1337
+ setShowRejectModal(true);
1338
+ setValRejAll(true);
1367
1339
  }}
1368
1340
  />
1369
1341
  <FullTabsMenu
@@ -1484,47 +1456,6 @@ export const RetailerProductEdition = ({
1484
1456
  {(userAssigned(activeTab) || auditorAssigned()) &&
1485
1457
  product[`${getConcept(activeTab)}_status`] !== "NS" && (
1486
1458
  <div className="commentary-box">
1487
- {!comment ? (
1488
- <div className="commentary">
1489
- <TagAndInput
1490
- label={"Caja de Comentario"}
1491
- inputType={"textarea"}
1492
- inputCols={80}
1493
- inputRows={4}
1494
- inputId={"commentary-box"}
1495
- index={0}
1496
- />
1497
- <div className="buttons-box">
1498
- <Button
1499
- buttonType={"general-transparent-button"}
1500
- label={"Enviar comentario"}
1501
- onClick={(e) =>
1502
- createComment(
1503
- e,
1504
- document.querySelector(
1505
- "#commentary-box .ql-container .ql-editor > p"
1506
- ).innerHTML,
1507
- activeTab
1508
- )
1509
- }
1510
- />
1511
- </div>
1512
- </div>
1513
- ) : (
1514
- <div className="feedback-box">
1515
- <Commentary
1516
- comment={comment?.message?.replace(/<.*?\/?>/gm, "")}
1517
- reviewed={crossComment}
1518
- />
1519
- <Button
1520
- buttonType={"circular-button accept-button"}
1521
- onClick={async () => {
1522
- setCrossComment(true);
1523
- commentRevised();
1524
- }}
1525
- />
1526
- </div>
1527
- )}
1528
1459
  {[7, 8].includes(user.id_role) && (
1529
1460
  <Button
1530
1461
  buttonType={
@@ -1582,6 +1513,50 @@ export const RetailerProductEdition = ({
1582
1513
  jwt={token}
1583
1514
  />
1584
1515
  )}
1516
+ {showRejectModal && (
1517
+ <Modal
1518
+ title={"Agregar mensaje de rechazo"}
1519
+ show={showRejectModal}
1520
+ customComponent={
1521
+ <TagAndInput
1522
+ label={"Caja de Comentario"}
1523
+ inputType={"textarea"}
1524
+ inputId={"modal-message-box"}
1525
+ index={0}
1526
+ color={"white"}
1527
+ />
1528
+ }
1529
+ buttons={[
1530
+ <ButtonV2
1531
+ key={"btn-Cancelar"}
1532
+ type={"white"}
1533
+ label={"Cancelar"}
1534
+ size={12}
1535
+ onClick={() => {
1536
+ setShowRejectModal(false);
1537
+ }}
1538
+ />,
1539
+ <ButtonV2
1540
+ key={"btn-Aceptar"}
1541
+ type={"pink"}
1542
+ label={"Aceptar"}
1543
+ size={12}
1544
+ onClick={async () => {
1545
+ const body = document.querySelector(
1546
+ "#modal-message-box .ql-container .ql-editor > p"
1547
+ ).innerHTML;
1548
+ const messages = [
1549
+ { type: "message", value: body?.replace(/<.*?\/?>/gm, "") },
1550
+ ];
1551
+ await createComment(messages, activeRetailer.id);
1552
+ valRejAll ? validateAll("R") : sendToFacilitator("R");
1553
+ setMessage("Rechazado");
1554
+ setShowRejectModal(false);
1555
+ }}
1556
+ />,
1557
+ ]}
1558
+ />
1559
+ )}
1585
1560
  </Container>
1586
1561
  );
1587
1562
  };
@@ -89,6 +89,10 @@ export const Container = styled.div`
89
89
  }
90
90
  }
91
91
  }
92
+ #modal-message-box {
93
+ width: 400px;
94
+ height: 100px;
95
+ }
92
96
  .container {
93
97
  width: 100%;
94
98
  height: 100%;
@@ -1,4 +1,5 @@
1
1
  import axios from "axios";
2
+ import { fetchPOST } from "../../../global-files/handle_http";
2
3
 
3
4
  export const getAuditVersion = async (articleId, setState, token) => {
4
5
  const auditResponse = await axios.get(
@@ -32,3 +33,39 @@ export const getInputsData = (
32
33
  setDescriptionState(descriptions);
33
34
  }
34
35
  };
36
+
37
+ export const translateService = (tab) => {
38
+ switch (tab) {
39
+ case "description":
40
+ case "Descripción":
41
+ return "Descripciones";
42
+ case "datasheet":
43
+ case "Ficha técnica":
44
+ return "Fichas técnicas";
45
+ case "images":
46
+ case "Imágenes":
47
+ return "Imágenes";
48
+ }
49
+ };
50
+
51
+ export const createMessage = (
52
+ retailers,
53
+ idRetailer,
54
+ oldStatus,
55
+ newStatus,
56
+ service
57
+ ) => {
58
+ const [retailer] = retailers?.filter((ret) => ret.id === idRetailer) || [];
59
+ return `${translateService(service)} de ${
60
+ retailer.name
61
+ } |${oldStatus}| a |${newStatus}`;
62
+ };
63
+
64
+ export const sendMessage = async (data) => {
65
+ const { paramsBody, paramsHeader } = data;
66
+ return fetchPOST(
67
+ process.env.REACT_APP_CREATE_MESSAGES,
68
+ paramsBody,
69
+ paramsHeader
70
+ );
71
+ };