contentoh-components-library 21.3.32 → 21.3.34

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 (35) hide show
  1. package/dist/components/atoms/CustomSelectItem/index.js +1 -1
  2. package/dist/components/atoms/InputText/index.js +1 -1
  3. package/dist/components/atoms/ProductPercentCard/index.js +1 -1
  4. package/dist/components/atoms/Select/index.js +1 -1
  5. package/dist/components/molecules/ButtonDownloadFile/index.js +1 -1
  6. package/dist/components/molecules/CarouselImagesLogin/index.js +2 -2
  7. package/dist/components/molecules/ImageTooltip/index.js +7 -21
  8. package/dist/components/molecules/ProductNameHeader/index.js +0 -1
  9. package/dist/components/molecules/SelectV2/index.js +1 -1
  10. package/dist/components/organisms/Chat/Chat.stories.js +6 -5
  11. package/dist/components/organisms/Chat/ChatLists/index.js +2 -2
  12. package/dist/components/organisms/Chat/ContentChat/index.js +85 -49
  13. package/dist/components/organisms/Chat/Footer/index.js +21 -22
  14. package/dist/components/organisms/Chat/index.js +1 -1
  15. package/dist/components/organisms/FullProductNameHeader/index.js +7 -1
  16. package/dist/components/pages/ProviderProductEdition/ProviderProductEdition.stories.js +87 -241
  17. package/dist/global-files/handle_http.js +33 -31
  18. package/package.json +5 -5
  19. package/src/components/atoms/CustomSelectItem/index.js +2 -1
  20. package/src/components/atoms/InputText/index.js +1 -1
  21. package/src/components/atoms/ProductPercentCard/index.js +2 -2
  22. package/src/components/atoms/Select/index.js +1 -1
  23. package/src/components/molecules/ButtonDownloadFile/index.js +1 -1
  24. package/src/components/molecules/CarouselImagesLogin/index.js +2 -2
  25. package/src/components/molecules/ImageTooltip/index.js +7 -17
  26. package/src/components/molecules/ProductNameHeader/index.js +0 -1
  27. package/src/components/molecules/SelectV2/index.js +1 -1
  28. package/src/components/organisms/Chat/Chat.stories.js +5 -4
  29. package/src/components/organisms/Chat/ChatLists/index.js +2 -2
  30. package/src/components/organisms/Chat/ContentChat/index.js +35 -28
  31. package/src/components/organisms/Chat/Footer/index.js +4 -8
  32. package/src/components/organisms/Chat/index.js +1 -1
  33. package/src/components/organisms/FullProductNameHeader/index.js +8 -3
  34. package/src/components/pages/ProviderProductEdition/ProviderProductEdition.stories.js +97 -265
  35. package/src/global-files/handle_http.js +11 -13
@@ -7,7 +7,6 @@ import { Tooltip } from "../../atoms/Tooltip";
7
7
  export const ImageTooltip = (props) => {
8
8
  const {
9
9
  className, // string
10
- width, // string
11
10
  sizeLoading, // number
12
11
  colorLoading, // string
13
12
  classNameLoading, // string
@@ -19,15 +18,6 @@ export const ImageTooltip = (props) => {
19
18
  position, // (string) posicion del contenedor tooltip (values en object positions)
20
19
  } = props;
21
20
  const [imgLoad, setImgLoad] = useState();
22
- const [loading, setLoading] = useState(false);
23
-
24
- /* solo para hacer pruebas en modo dev
25
- useEffect(() => {
26
- setTimeout(() => {
27
- setLoading(false);
28
- }, 5000);
29
- }, []);
30
- */
31
21
 
32
22
  return (
33
23
  <Tooltip
@@ -37,9 +27,9 @@ export const ImageTooltip = (props) => {
37
27
  followCursor={false}
38
28
  className={className}
39
29
  classNameTooltip={classNameTooltip}
40
- componentTooltip={imgLoad !== undefined && !loading && componentTooltip}
30
+ componentTooltip={imgLoad !== undefined && componentTooltip}
41
31
  >
42
- {src && (imgLoad === undefined || loading) && (
32
+ {src && imgLoad === undefined && (
43
33
  <ContainerLoading
44
34
  className={classNameLoading}
45
35
  sizeLoading={sizeLoading}
@@ -49,14 +39,14 @@ export const ImageTooltip = (props) => {
49
39
  </ContainerLoading>
50
40
  )}
51
41
 
52
- {(!src || (imgLoad === false && !loading)) && componentDefault}
42
+ {(!src || imgLoad === false) && componentDefault}
53
43
 
54
44
  <Img
55
45
  className={classNameImg}
56
- src={src}
57
- onLoad={(event) => setImgLoad(true)}
58
- onError={(event) => setImgLoad(false)}
59
- show={imgLoad === true && !loading}
46
+ src={`${src}?${new Date().getMilliseconds()}`}
47
+ onLoad={() => setImgLoad(true)}
48
+ onError={() => setImgLoad(false)}
49
+ show={imgLoad === true}
60
50
  />
61
51
  </Tooltip>
62
52
  );
@@ -7,7 +7,6 @@ import { PriorityFlag } from "../../atoms/PriorityFlag/index";
7
7
  export const ProductNameHeader = ({
8
8
  productName,
9
9
  statusType,
10
- percent,
11
10
  priority,
12
11
  date,
13
12
  percentRequired,
@@ -142,7 +142,7 @@ export const SelectV2 = (props) => {
142
142
  } else if (selectedItemsCopy.length === 1) {
143
143
  let labelItem = undefined;
144
144
  for (const item of items) {
145
- if (item.value == selectedItemsCopy[0]) {
145
+ if (item.value === selectedItemsCopy[0]) {
146
146
  labelItem = item.label;
147
147
  break;
148
148
  }
@@ -135,15 +135,16 @@ chatTicket_userTECH.args = {
135
135
  chatContainerType: "fixed",
136
136
  chatData: {
137
137
  id: 130,
138
- ticketOwnerUserId: 49,
139
- ticketCompany: 817,
140
- statusTicket: "IN_PROGRESS",
138
+ ticketOwnerUserId: 194,
139
+ ticketCompany: undefined,
140
+ statusTicket: "PENDING",
141
141
  currentUser: {
142
142
  token:
143
- "eyJraWQiOiJkQWJkZCtlclwvTlwveVRQUWNvUlVyOCtrNUd2M1hMM2N1MWUzQ09zWExVRnc9IiwiYWxnIjoiUlMyNTYifQ.eyJzdWIiOiJmNTkyN2Y4ZS1jYmY3LTQ5MjItOWUwOS1lNjllYzBiMjczMWEiLCJjb2duaXRvOmdyb3VwcyI6WyJ1c3VhcmlvX2NvbnRlbnRvaCJdLCJlbWFpbF92ZXJpZmllZCI6dHJ1ZSwiaXNzIjoiaHR0cHM6XC9cL2NvZ25pdG8taWRwLnVzLWVhc3QtMS5hbWF6b25hd3MuY29tXC91cy1lYXN0LTFfWE1aUWRxa0dqIiwicGhvbmVfbnVtYmVyX3ZlcmlmaWVkIjpmYWxzZSwiY29nbml0bzp1c2VybmFtZSI6ImY1OTI3ZjhlLWNiZjctNDkyMi05ZTA5LWU2OWVjMGIyNzMxYSIsImNvZ25pdG86cm9sZXMiOlsiYXJuOmF3czppYW06Ojg5ODY3MDIzMjgwN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aUWRxa0dqIiwicGhvbmVfbnVtYmVyX3ZlcmlmaWVkIjpmYWxzZSwiY29nbml0bzp1c2VybmFtZSI6ImY1OTI3ZjhlLWNiZjctNDkyMi05ZTA5LWU2OWVjMGIyNzMxYSIsImNvZ25pdG86cm9sZXMiOlsiYXJuOmF3czppYW06Ojg5ODY3MDIzMjgwNzpyb2xlXC9jb250ZW50b2gtZGV2LXVzLWVhc3QtMS1sYW1iZGFSb2xlIl0sImF1ZCI6IjVhYzh0cGdzNmdic3ExM2ZydnJwaWVlcDQwIiwiZXZlbnRfaWQiOiJlYTRlZmQ1Zi1mYTg4LTRjNDEtYTM3Ny02MWVkNmY0YTMyOTciLCJ0b2tlbl91c2UiOiJpZCIsImF1dGhfdGltZSI6MTY4MDA1Njg2NSwibmFtZSI6IklzbWFlbCBMb3BleiIsInBob25lX251bWJlciI6Iis1MjMxMTEzNjYzMzYiLCJleHAiOjE2ODAwNjA0NjUsImlhdCI6MTY4MDA1Njg2NSwiZW1haWwiOiJpbG9wZXpAY29udGVudG9oLmNvbSJ9.oRuv3LkdvctEMUjmeGw0-XefzV_Aoh1O2hFMik4RxpkkCUeP1O7AjA7lJI6sgoqa9Nwa2fCPRXk6ufi84UbgxGEgkupQmAvXTHQCw_uwCUVAZitlNGXSBl-VSisMuXSnckxdZQ1MvLV5BgLmiw4mu6HxKDN-Uw0xc7yL_yDtGu3NWxoO0Cm2zbej8jYLE9DV9wG297bjfzVQ7hzpEfEcB52I5Tg6nF2VDTx-8_m4mVVrpisbV5uBoYokbFyyOFVLZzUU7Je5uHukscHS5dje9IMTY8DE5S8xUWJubHjf_ktcy7Y2-F2cG5dI5oSdrBNU-wNNW5-OtRLgclSJLmbPCw",
144
144
  id: 28,
145
145
  companyId: 1,
146
146
  isUserTech: true,
147
147
  },
148
148
  },
149
+ classNameContainerFixed: "chatTicket",
149
150
  };
@@ -68,7 +68,7 @@ export const ChatLists = (props) => {
68
68
 
69
69
  {/* label interno */}
70
70
  <div className="container-indicators">
71
- {currentCompanyId == companyId && (
71
+ {currentCompanyId === companyId && (
72
72
  <div className="label-ownCompany">Interno</div>
73
73
  )}
74
74
  </div>
@@ -76,7 +76,7 @@ export const ChatLists = (props) => {
76
76
  );
77
77
 
78
78
  // checar si es chat abierto
79
- if (company.statusChat == "closed") jsxClosedChats.push(itemChat);
79
+ if (company.statusChat === "closed") jsxClosedChats.push(itemChat);
80
80
  else jsxOpenChats.push(itemChat);
81
81
  }
82
82
  setOpenChats(jsxOpenChats);
@@ -97,8 +97,8 @@ export const ContentChat = (props) => {
97
97
 
98
98
  // comenzar temporizador del update de 20s
99
99
  useEffect(() => {
100
- //return; -- descomentarizar para hacer pruebas sin update
101
- if (startUpdate == 0) return;
100
+ // return; // -- descomentarizar para hacer pruebas sin update
101
+ if (startUpdate === 0) return;
102
102
  const processID = setTimeout(() => {
103
103
  setRunUpdate((prev) => prev + 1);
104
104
  }, 15000);
@@ -109,10 +109,10 @@ export const ContentChat = (props) => {
109
109
  // ejecutar update
110
110
  useEffect(() => {
111
111
  if (chatType === "merchant_product") {
112
- if (singleChat.items) getUpdateLatestMerchantProduct();
112
+ if (singleChat.items) getUpdateLatestMerchantProduct(true);
113
113
  else getInitialMerchantProduct();
114
114
  } else if (chatType === "order_product") {
115
- if (companies) getUpdateLatestOrderProduct();
115
+ if (companies) getUpdateLatestOrderProduct(true);
116
116
  else getInitialOrderProduct();
117
117
  } else {
118
118
  if (singleChat.items) getUpdateLatestTicket(true);
@@ -146,6 +146,7 @@ export const ContentChat = (props) => {
146
146
  return;
147
147
  }
148
148
  // success
149
+ setStartUpdate((prev) => prev + 1);
149
150
  setCurrentUser({
150
151
  id: response.body.data.currentUserId,
151
152
  companyId: response.body.data.currentCompanyId,
@@ -379,16 +380,18 @@ export const ContentChat = (props) => {
379
380
  /*=======================================================================
380
381
  PETICION GET UPDATE_LATEST SEGUN EL TIPO DE CHAT
381
382
  ======================================================================= */
382
- const getUpdateLatestMerchantProduct = async () => {
383
+ const getUpdateLatestMerchantProduct = async (fromUpdate = false) => {
383
384
  const paramsQuery = {
384
385
  getType: "updateLatest",
385
386
  id: JSON.stringify(dataChat.id),
386
387
  version: JSON.stringify(dataChat.version),
387
388
  date: encodeURIComponent(lastUpdateDate),
388
389
  };
390
+ const paramsHeaders = { Authorization: dataChat.userToken };
389
391
  const response = await fetchGET(
390
392
  process.env.REACT_APP_PRODUCTS_CHAT_ENDPOINT,
391
- paramsQuery
393
+ paramsQuery,
394
+ paramsHeaders
392
395
  );
393
396
  if (!response.body) {
394
397
  console.log("ERROR updateLatest:", {
@@ -398,6 +401,7 @@ export const ContentChat = (props) => {
398
401
  return;
399
402
  }
400
403
  // success
404
+ setStartUpdate((prev) => prev + 1);
401
405
  setLastUpdateDate(response.body.data.lastUpdateDate);
402
406
  // actualizar la lista de los users
403
407
  updateAllUsers(response.body.users);
@@ -405,12 +409,13 @@ export const ContentChat = (props) => {
405
409
  let newSingleChat = { ...singleChat };
406
410
  newSingleChat.items = addNewItemsChat(
407
411
  newSingleChat.items,
408
- response.body.items
412
+ response.body.items,
413
+ fromUpdate
409
414
  );
410
415
  setSingleChat(newSingleChat);
411
416
  };
412
417
 
413
- const getUpdateLatestOrderProduct = async () => {
418
+ const getUpdateLatestOrderProduct = async (fromUpdate = false) => {
414
419
  const paramsQuery = {
415
420
  getType: "updateLatest",
416
421
  id: JSON.stringify(dataChat.id),
@@ -436,7 +441,7 @@ export const ContentChat = (props) => {
436
441
  return;
437
442
  }
438
443
  // success
439
-
444
+ setStartUpdate((prev) => prev + 1);
440
445
  // cuando cambie la lista de chats por un cambio de version o estatus
441
446
  if (response.body.data.status) {
442
447
  setIsLoading(true);
@@ -481,7 +486,8 @@ export const ContentChat = (props) => {
481
486
  Object.keys(response.body.companies).forEach((companyId) => {
482
487
  companiesList[companyId].items = addNewItemsChat(
483
488
  companiesList[companyId].items,
484
- response.body.companies[companyId].items
489
+ response.body.companies[companyId].items,
490
+ fromUpdate
485
491
  );
486
492
  });
487
493
  setCompanies(companiesList);
@@ -609,15 +615,13 @@ export const ContentChat = (props) => {
609
615
  };
610
616
 
611
617
  const createItemsMerchantProduct = async (items = []) => {
612
- const paramsBody = {
613
- id: JSON.stringify(dataChat.id),
614
- version: JSON.stringify(dataChat.version),
615
- userId: JSON.stringify(currentUser.id),
616
- items: JSON.stringify(items),
617
- };
618
+ const { id, version } = dataChat;
619
+ const paramsBody = { id, version, items };
620
+ const paramsHeaders = { Authorization: dataChat.userToken };
618
621
  const response = await fetchPOST(
619
622
  process.env.REACT_APP_PRODUCTS_CHAT_ENDPOINT,
620
- paramsBody
623
+ paramsBody,
624
+ paramsHeaders
621
625
  );
622
626
  if (!response.body) {
623
627
  return {
@@ -629,17 +633,18 @@ export const ContentChat = (props) => {
629
633
 
630
634
  const createItemsOrderProduct = async (items = []) => {
631
635
  const paramsBody = {
632
- id: JSON.stringify(dataChat.id),
633
- version: JSON.stringify(currentArticle.version),
634
- userId: JSON.stringify(currentUser.id),
635
- items: JSON.stringify(items),
636
- orderId: JSON.stringify(dataChat.orderId),
637
- sentCompanyId: JSON.stringify(currentUser.companyId),
638
- receivedCompanyId: JSON.stringify(activeCompanyId),
636
+ id: dataChat.id,
637
+ version: currentArticle.version,
638
+ items,
639
+ orderId: dataChat.orderId,
640
+ sentCompanyId: currentUser.companyId,
641
+ receivedCompanyId: activeCompanyId,
639
642
  };
643
+ const paramsHeaders = { Authorization: dataChat.userToken };
640
644
  const response = await fetchPOST(
641
645
  process.env.REACT_APP_PRODUCTS_CHAT_ENDPOINT,
642
- paramsBody
646
+ paramsBody,
647
+ paramsHeaders
643
648
  );
644
649
  if (!response.body) {
645
650
  return {
@@ -655,9 +660,11 @@ export const ContentChat = (props) => {
655
660
  userId: JSON.stringify(dataChat.currentUser.id),
656
661
  items: JSON.stringify(items),
657
662
  };
663
+ const paramsHeaders = { Authorization: dataChat.userToken };
658
664
  const response = await fetchPOST(
659
665
  process.env.REACT_APP_TICKETS_CHAT_ENDPOINT,
660
- paramsBody
666
+ paramsBody,
667
+ paramsHeaders
661
668
  );
662
669
  if (!response.body) {
663
670
  return {
@@ -739,8 +746,8 @@ export const ContentChat = (props) => {
739
746
  }, 5000);
740
747
  }
741
748
  return Object.values(itemsId).sort((a, b) => {
742
- if (a.id < b.id) return 1;
743
- if (a.id > b.id) return -1;
749
+ if (a.id > b.id) return 1;
750
+ if (a.id < b.id) return -1;
744
751
  return 0;
745
752
  });
746
753
  };
@@ -3,13 +3,11 @@ import {
3
3
  ContainerItemCarrousel,
4
4
  ContainerMain,
5
5
  ContainerSecondary,
6
- ContainerTooltipFileName,
7
6
  } from "./styles";
8
7
  import { useEffect, useState, useRef } from "react";
9
8
  import AWS from "aws-sdk";
10
9
  import { v4 as uuidv4 } from "uuid";
11
10
  import { Image as CustomImage } from "../../../atoms/Image";
12
- import { ImageTooltip } from "../../../molecules/ImageTooltip";
13
11
  import {
14
12
  faArrowUp as IconSend,
15
13
  faImage as IconImage,
@@ -21,7 +19,7 @@ import { ButtonV2 } from "../../../atoms/ButtonV2";
21
19
  import { IconFile } from "../../../atoms/IconFile";
22
20
  import { Modal } from "../../Modal";
23
21
  import { Tooltip } from "../../../atoms/Tooltip";
24
- import { Fade, Tooltip as TooltipMUI, Zoom } from "@mui/material";
22
+ import { Fade, Tooltip as TooltipMUI } from "@mui/material";
25
23
  import { ButtonFileChooser } from "../../../atoms/ButtonFileChooser";
26
24
  import { Slide } from "@mui/material";
27
25
  // carrousel
@@ -186,7 +184,7 @@ export const Footer = (props) => {
186
184
  }
187
185
  // enviar file a AWS
188
186
  customFiles.push({
189
- itemType: file.type.split("/")[0] == "image" ? "img" : "file",
187
+ itemType: file.type.split("/")[0] === "image" ? "img" : "file",
190
188
  key: fileKey,
191
189
  errorOwn: errorMessage,
192
190
  });
@@ -208,6 +206,7 @@ export const Footer = (props) => {
208
206
  }
209
207
  });
210
208
  } catch (err) {
209
+ console.log(err);
211
210
  disableSecondaryContainer(false);
212
211
  setModalAlert({
213
212
  show: true,
@@ -236,10 +235,7 @@ export const Footer = (props) => {
236
235
  valueItem.height = imgSize.height;
237
236
  }
238
237
  }
239
- items.push({
240
- type: file.itemType,
241
- value: JSON.stringify(valueItem),
242
- });
238
+ items.push({ type: file.itemType, value: JSON.stringify(valueItem) });
243
239
  }
244
240
  }
245
241
 
@@ -166,7 +166,7 @@ export const Chat = (props) => {
166
166
 
167
167
  // convertir user TECH a NORMAL si es el propietario del ticket
168
168
  let isUserTech = currentUser.isUserTech;
169
- if (isUserTech && currentUser.id == ticketOwnerUserId) {
169
+ if (isUserTech && currentUser.id === ticketOwnerUserId) {
170
170
  isUserTech = false;
171
171
  }
172
172
  setData({
@@ -19,6 +19,7 @@ export const FullProductNameHeader = ({
19
19
  showApproveRejectAll,
20
20
  }) => {
21
21
  const [retailers, setRetailers] = useState([]);
22
+
22
23
  useEffect(() => {
23
24
  const rtls = headerData?.retailers || headerData?.retailersAvailable;
24
25
  servicesData &&
@@ -33,6 +34,12 @@ export const FullProductNameHeader = ({
33
34
  });
34
35
  setRetailers(rtls);
35
36
  }, [servicesData]);
37
+
38
+ const getTime = (date) => {
39
+ if (!date) return "";
40
+ return new Date(date).toLocaleDateString();
41
+ };
42
+
36
43
  return (
37
44
  <Container>
38
45
  <ProductNameHeader
@@ -45,9 +52,7 @@ export const FullProductNameHeader = ({
45
52
  percentRequired={percent}
46
53
  percent={percent?.toFixed(0)}
47
54
  priority={headerData?.prio}
48
- date={new Date(
49
- headerData?.article?.timestamp || headerData?.timestamp
50
- ).toLocaleDateString()}
55
+ date={getTime(headerData?.article?.timestamp || headerData?.timestamp)}
51
56
  />
52
57
  <div className="features-bar-container">
53
58
  <FeaturesBar