contentoh-components-library 21.2.98 → 21.2.100

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 (95) hide show
  1. package/.env.development +0 -3
  2. package/.env.production +23 -23
  3. package/dist/components/molecules/CustomSelect/CustomSelect.stories.js +22 -21
  4. package/dist/components/molecules/CustomSelect/SelectItem.js +1 -10
  5. package/dist/components/molecules/HeaderTop/index.js +5 -10
  6. package/dist/components/molecules/HeaderTop/styles.js +1 -1
  7. package/dist/components/organisms/OrderDetail/OrderDetail.stories.js +1 -1
  8. package/dist/components/organisms/OrderDetail/index.js +20 -11
  9. package/dist/components/organisms/OrderDetail/styles.js +1 -1
  10. package/dist/global-files/fonts.css +0 -12
  11. package/dist/global-files/variables.js +0 -2
  12. package/dist/index.js +46 -241
  13. package/package.json +1 -12
  14. package/src/components/molecules/CustomSelect/CustomSelect.stories.js +12 -20
  15. package/src/components/molecules/CustomSelect/SelectItem.js +0 -7
  16. package/src/components/molecules/HeaderTop/index.js +6 -11
  17. package/src/components/molecules/HeaderTop/styles.js +0 -4
  18. package/src/components/organisms/OrderDetail/OrderDetail.stories.js +1 -1
  19. package/src/components/organisms/OrderDetail/index.js +19 -12
  20. package/src/components/organisms/OrderDetail/styles.js +1 -0
  21. package/src/global-files/fonts.css +0 -12
  22. package/src/global-files/variables.js +0 -2
  23. package/src/index.js +0 -15
  24. package/src/assets/images/customSelect/starIcon.svg +0 -14
  25. package/src/assets/images/defaultImages/Spinner.gif +0 -0
  26. package/src/assets/images/defaultImages/notFound.svg +0 -124
  27. package/src/components/atoms/ButtonFileChooser/ButtonFileChooser.stories.js +0 -47
  28. package/src/components/atoms/ButtonFileChooser/index.js +0 -69
  29. package/src/components/atoms/ButtonFileChooser/styles.js +0 -4
  30. package/src/components/atoms/ButtonV2/ButtonV2.stories.js +0 -51
  31. package/src/components/atoms/ButtonV2/index.js +0 -79
  32. package/src/components/atoms/ButtonV2/styles.js +0 -195
  33. package/src/components/atoms/CustomIcon/CustomIcon.stories.js +0 -36
  34. package/src/components/atoms/CustomIcon/index.js +0 -41
  35. package/src/components/atoms/CustomIcon/styles.js +0 -85
  36. package/src/components/atoms/IconFile/IconFile.stories.js +0 -35
  37. package/src/components/atoms/IconFile/index.js +0 -119
  38. package/src/components/atoms/IconFile/styles.js +0 -67
  39. package/src/components/atoms/Image/Image.stories.js +0 -51
  40. package/src/components/atoms/Image/index.js +0 -55
  41. package/src/components/atoms/Image/styles.js +0 -34
  42. package/src/components/atoms/ImageLink/ImageLink.stories.js +0 -43
  43. package/src/components/atoms/ImageLink/index.js +0 -57
  44. package/src/components/atoms/ImageLink/styles.js +0 -30
  45. package/src/components/atoms/ImagePreview/ImagePreview.stories.js +0 -52
  46. package/src/components/atoms/ImagePreview/index.js +0 -191
  47. package/src/components/atoms/ImagePreview/styles.js +0 -77
  48. package/src/components/atoms/InputText/InputText.stories.js +0 -39
  49. package/src/components/atoms/InputText/index.js +0 -61
  50. package/src/components/atoms/InputText/styles.js +0 -89
  51. package/src/components/atoms/NotFound/NotFound.stories.js +0 -19
  52. package/src/components/atoms/NotFound/index.js +0 -52
  53. package/src/components/atoms/NotFound/styles.js +0 -55
  54. package/src/components/atoms/SelectItemV2/SelectItemV2.stories.js +0 -26
  55. package/src/components/atoms/SelectItemV2/index.js +0 -45
  56. package/src/components/atoms/SelectItemV2/styles.js +0 -55
  57. package/src/components/atoms/Tooltip/Tooltip.stories.js +0 -51
  58. package/src/components/atoms/Tooltip/index.js +0 -59
  59. package/src/components/atoms/Tooltip/styles.js +0 -42
  60. package/src/components/molecules/ButtonDownloadFile/DownloadFile.stories.js +0 -54
  61. package/src/components/molecules/ButtonDownloadFile/index.js +0 -111
  62. package/src/components/molecules/ButtonDownloadFile/styles.js +0 -66
  63. package/src/components/molecules/ImageTooltip/ImageTooltip.stories.js +0 -46
  64. package/src/components/molecules/ImageTooltip/index.js +0 -62
  65. package/src/components/molecules/ImageTooltip/styles.js +0 -18
  66. package/src/components/molecules/SelectV2/SelectV2.stories.js +0 -114
  67. package/src/components/molecules/SelectV2/index.js +0 -332
  68. package/src/components/molecules/SelectV2/styles.js +0 -100
  69. package/src/components/organisms/Chat/Chat.stories.js +0 -199
  70. package/src/components/organisms/Chat/ChatLists/ChatLists.stories.js +0 -65
  71. package/src/components/organisms/Chat/ChatLists/Rotoplas.jpeg +0 -0
  72. package/src/components/organisms/Chat/ChatLists/THD.png +0 -0
  73. package/src/components/organisms/Chat/ChatLists/index.js +0 -141
  74. package/src/components/organisms/Chat/ChatLists/styles.js +0 -162
  75. package/src/components/organisms/Chat/ContainerItems/ContainerItems.stories.js +0 -142
  76. package/src/components/organisms/Chat/ContainerItems/index.js +0 -549
  77. package/src/components/organisms/Chat/ContainerItems/styles.js +0 -328
  78. package/src/components/organisms/Chat/ContentChat/ContentChat.stories.js +0 -102
  79. package/src/components/organisms/Chat/ContentChat/Rotoplas.jpeg +0 -0
  80. package/src/components/organisms/Chat/ContentChat/THD.png +0 -0
  81. package/src/components/organisms/Chat/ContentChat/index.js +0 -900
  82. package/src/components/organisms/Chat/ContentChat/styles.js +0 -41
  83. package/src/components/organisms/Chat/Footer/Footer.stories.js +0 -22
  84. package/src/components/organisms/Chat/Footer/index.js +0 -669
  85. package/src/components/organisms/Chat/Footer/styles.js +0 -286
  86. package/src/components/organisms/Chat/Header/Header.stories.js +0 -66
  87. package/src/components/organisms/Chat/Header/index.js +0 -94
  88. package/src/components/organisms/Chat/Header/styles.js +0 -49
  89. package/src/components/organisms/Chat/index.js +0 -294
  90. package/src/components/organisms/Chat/styles.js +0 -42
  91. package/src/components/organisms/Modal/Modal.stories.js +0 -55
  92. package/src/components/organisms/Modal/index.js +0 -97
  93. package/src/components/organisms/Modal/styles.js +0 -103
  94. package/src/global-files/handle_http.js +0 -231
  95. package/src/global-files/utils.js +0 -300
@@ -1,142 +0,0 @@
1
- import { ContainerItems } from "./index";
2
-
3
- export default {
4
- title: "Components/organisms/Chat/ContainerItems",
5
- component: ContainerItems,
6
- };
7
-
8
- const Template = (args) => <ContainerItems {...args} />;
9
-
10
- // items de prueba
11
- const items = {
12
- 1: {
13
- date: "2022-10-13 10:10:00",
14
- type: "message",
15
- value: "mensaje 1 user10",
16
- userId: 10,
17
- },
18
- 2: {
19
- date: "2022-10-12 13:19:00",
20
- type: "message",
21
- value: "mensaje 1 user20",
22
- userId: 20,
23
- },
24
- 3: {
25
- date: "2022-10-12 12:33:00",
26
- type: "comment",
27
- value: "comentario 1 user20",
28
- userId: 20,
29
- },
30
- 4: {
31
- date: "2022-10-12 11:56:00",
32
- type: "comment",
33
- value: "comentario 1 user30",
34
- userId: 30,
35
- },
36
- 5: {
37
- date: "2022-10-12 8:41:00",
38
- type: "statusService",
39
- value: "La sección imágenes ha sido validada",
40
- userId: 20,
41
- },
42
- 6: {
43
- date: "2022-10-11 14:58:00",
44
- type: "img",
45
- value: "84300/1/chat/playa-213f791b-d890-48e1-be19-28bf5a95d517.jpeg",
46
- userId: 10,
47
- },
48
- 7: {
49
- date: "2022-10-10 16:12:00",
50
- type: "img",
51
- value: `84300/1/chat/21dba1da-3c60-42c4-97bd-033664808256-fb19ff57-b91c-4ef2-ba2a-d857b55fb33b.svg`,
52
- userId: 30,
53
- },
54
- 8: {
55
- date: "2022-10-10 15:55:00",
56
- type: "statusArticle",
57
- value: "El estatus cambio a Aprobado Coordinador",
58
- userId: 20,
59
- },
60
- 9: {
61
- date: "2022-10-10 9:15:00",
62
- type: "comment",
63
- value: "comentario 1 user10",
64
- userId: 10,
65
- },
66
- 10: {
67
- date: "2022-10-9 6:24:00",
68
- type: "file",
69
- value:
70
- "84300/1/chat/acuse RFC-8b2eb177-5bfc-4266-9b26-4e7297880594-9e2e5853-4697-442a-8ff7-3b7a1ede0856.pdf",
71
- userId: 10,
72
- },
73
- 11: {
74
- date: "2022-10-9 4:29:00",
75
- type: "file",
76
- value: "84300/1/chat/noExiste.docx",
77
- userId: 30,
78
- },
79
- 12: {
80
- date: "2022-10-9 2:39:00",
81
- type: "file",
82
- value: "84300/1/chat/noExiste2.xlsx",
83
- userId: 20,
84
- },
85
- 13: {
86
- date: "2022-10-8 23:46:00",
87
- type: "file",
88
- value: "84300/1/chat/noExiste3.csv",
89
- userId: 20,
90
- },
91
- 14: {
92
- date: "2022-10-8 23:22:00",
93
- type: "file",
94
- value: "84300/1/chat/noExiste4.pptx",
95
- userId: 30,
96
- },
97
- 15: {
98
- date: "2022-10-8 21:01:00",
99
- type: "file",
100
- value: "84300/1/chat/noExiste5.zip",
101
- userId: 10,
102
- },
103
- 16: {
104
- date: "2022-10-8 20:11:00",
105
- type: "file",
106
- value: "84300/1/chat/noExiste6.txt",
107
- userId: 10,
108
- },
109
- };
110
-
111
- // users de prueba
112
- const users = {
113
- 10: { name: "Pedro Castillo", companyId: 100 },
114
- 20: { name: "Ana Carranza", companyId: 200 },
115
- 30: { name: "Javier Aguayo", companyId: 100 },
116
- };
117
-
118
- // companies de prueba multiple
119
- const companies = {
120
- 100: { name: "Fábrica", statusChat: "enabled" },
121
- 200: { name: "Proveedor", statusChat: "current" },
122
- };
123
-
124
- export const exampleChat = Template.bind({});
125
- exampleChat.args = {
126
- chatData: {
127
- items,
128
- users,
129
- companies,
130
- },
131
- currentUser: { id: 10, companyId: 100 },
132
- };
133
-
134
- export const emptyChat = Template.bind({});
135
- emptyChat.args = {
136
- chatData: {
137
- items: [],
138
- users: [],
139
- companies: [],
140
- },
141
- currentUser: { id: 10, companyId: 100 },
142
- };
@@ -1,549 +0,0 @@
1
- import { Container } from "./styles";
2
- import { useEffect, useState } from "react";
3
- import { getProfilePicture } from "../../../../global-files/data";
4
- import { ImageTooltip } from "../../../molecules/ImageTooltip";
5
- import {
6
- decodeJSON,
7
- getFullDate,
8
- getImageURL,
9
- getResizeImgHeight,
10
- getTime,
11
- } from "../../../../global-files/utils";
12
- import {
13
- faUser as IconUser,
14
- faImage as IconImage,
15
- faRedoAlt as IconReload,
16
- } from "@fortawesome/free-solid-svg-icons";
17
- import { CustomIcon } from "../../../atoms/CustomIcon";
18
- import { ButtonV2 } from "../../../atoms/ButtonV2";
19
- import { ButtonDownloadFile } from "../../../molecules/ButtonDownloadFile";
20
- import { Modal } from "../../Modal";
21
- import { Tooltip } from "../../../atoms/Tooltip";
22
- import { Slide, Zoom } from "@mui/material";
23
- import { useRef } from "react";
24
- import { ImagePreview } from "../../../atoms/ImagePreview";
25
-
26
- export const ContainerItems = (props) => {
27
- const {
28
- items /* [
29
- { id , date , type , value , userId } ,
30
- ...
31
- ] */,
32
- users /* {
33
- id: { name , companyId } ,
34
- ...
35
- } */,
36
- currentUser, // { id , companyId , ... }
37
- activeCompanyId, // number
38
- chatType, // string
39
- showBtnLoadMore, // boolean
40
- onClickBtnLoadMore, // () => {}
41
- } = props;
42
- const [scrollHeight, setScrollHeight] = useState(0);
43
- const [btnLoadMoreLoading, setBtnLoadMoreLoading] = useState(false);
44
- const [customItems, setCustomItems] = useState([]);
45
- const [modalAlert, setModalAlert] = useState({
46
- show: false,
47
- title: "",
48
- message: "",
49
- });
50
- const containerList = useRef(null);
51
-
52
- /*
53
- useEffect(() => {
54
- //console.log("new observer");
55
- const observer = new MutationObserver((mutationList) => {
56
- updateScroll();
57
- });
58
- const itemsList = document.getElementById("ulItems");
59
- const observerOptions = {
60
- attributes: false,
61
- childList: true,
62
- subtree: false,
63
- characterData: false,
64
- attributeOldValue: false,
65
- characterDataOldValue: false,
66
- };
67
- observer.observe(itemsList, observerOptions);
68
-
69
- return () => {
70
- observer.disconnect();
71
- //console.log("remove observer");
72
- };
73
- }, [scrollHeight]);
74
- */
75
-
76
- useEffect(() => {
77
- if (!items) return;
78
- if (chatType === "merchant_product") renderItems();
79
- else if (chatType === "order_product") renderItems();
80
- else if (chatType === "ticket") renderItemsTicket();
81
- else setCustomItems([]);
82
- }, [items]);
83
-
84
- const updateScroll = () => {
85
- const containerScroll = document.getElementById("containerItems");
86
- if (containerScroll) {
87
- const newScrollHeight = containerScroll.scrollHeight + 15;
88
- const positionScroll = newScrollHeight - scrollHeight;
89
-
90
- /*
91
- console.log("========");
92
- console.log("old:", scrollHeight);
93
- console.log("new:", newScrollHeight);
94
- console.log("pos:", positionScroll);
95
- console.log("========");
96
- */
97
-
98
- if (newScrollHeight !== scrollHeight) {
99
- containerScroll.scrollTop = positionScroll;
100
- setScrollHeight(newScrollHeight);
101
- }
102
- }
103
- };
104
-
105
- const renderGrayLabel = (text, key) => {
106
- return (
107
- <Zoom
108
- in={true}
109
- timeout={600}
110
- container={containerList.current}
111
- key={key ?? ""}
112
- >
113
- <li className={`label-gray`}>
114
- <div className="separator"></div>
115
- <label>{text}</label>
116
- <div className="separator"></div>
117
- </li>
118
- </Zoom>
119
- );
120
- };
121
-
122
- const renderStatusService = (text, key) => {
123
- return (
124
- <Zoom
125
- in={true}
126
- timeout={600}
127
- container={containerList.current}
128
- key={key ?? ""}
129
- >
130
- <div className="label-statusService">{text}</div>
131
- </Zoom>
132
- );
133
- };
134
-
135
- const renderStatusArticle = (text, key) => {
136
- return (
137
- <Zoom
138
- in={true}
139
- timeout={600}
140
- container={containerList.current}
141
- key={key ?? ""}
142
- >
143
- <div className="label-statusArticle">{text}</div>
144
- </Zoom>
145
- );
146
- };
147
-
148
- const renderStatusTicket = (item) => {
149
- return <label className="item-statusTicket">{item.value}</label>;
150
- };
151
-
152
- const renderStatusTicketNeutral = (item) => {
153
- return (
154
- <Tooltip
155
- componentTooltip={<label>{users[item.userId].name}</label>}
156
- className="itemStatus ticket"
157
- position={"topCenter"}
158
- addArrow={false}
159
- transitionType={"zoom"}
160
- followCursor={false}
161
- >
162
- {item.value}
163
- </Tooltip>
164
- );
165
- };
166
-
167
- const renderMessage = (item) => {
168
- return <label className="item-message"> {item.value} </label>;
169
- };
170
-
171
- const renderComment = (item) => {
172
- return <label className="item-comment"> {item.value} </label>;
173
- };
174
-
175
- const renderImg = (item) => {
176
- const value = decodeJSON(item.value);
177
- const originalImgURL = `${process.env.REACT_APP_IMAGES_ENDPOINT}/${value.key}`;
178
- // dimensiones de la imagen a mostrar en el chat
179
- const imgHeight = getResizeImgHeight(
180
- value.width ?? 400,
181
- value.height ?? 400,
182
- 400
183
- );
184
- //console.log("newHeight imgURL:", imgHeight);
185
- const imgURL = getImageURL(
186
- process.env.REACT_APP_IMAGES_BUCKET,
187
- value.key,
188
- 400,
189
- imgHeight
190
- );
191
- // dimensiones de la imagen a mostrar en modal full
192
- const modalImgHeight = getResizeImgHeight(
193
- value.width ?? screen.width,
194
- value.height ?? screen.height,
195
- screen.width
196
- );
197
- //console.log("height full:", modalImgHeight);
198
- const modalImgURL = getImageURL(
199
- process.env.REACT_APP_IMAGES_BUCKET,
200
- value.key,
201
- screen.width,
202
- modalImgHeight
203
- );
204
-
205
- return (
206
- <div className="item-img">
207
- <ImagePreview
208
- className="container-ImagePreview"
209
- width={"100%"}
210
- sizeLoading={35}
211
- colorLoading={undefined}
212
- imgURL={imgURL}
213
- modalImgURL={modalImgURL}
214
- downloadImgURL={originalImgURL}
215
- imageName={value.name}
216
- showButtonDownload={true}
217
- componentDefault={
218
- <Tooltip
219
- componentTooltip={<label>{value.name}</label>}
220
- className="label-nameImg"
221
- position={"topCenter"}
222
- addArrow={false}
223
- transitionType={"zoom"}
224
- followCursor={false}
225
- >
226
- <CustomIcon
227
- className="iconDefaultImg"
228
- type={"white"}
229
- size={60}
230
- borderType={"rectangle"}
231
- icon={IconImage}
232
- />
233
- </Tooltip>
234
- }
235
- componentDefaultModal={
236
- <Tooltip
237
- componentTooltip={<label>{value.name}</label>}
238
- className="label-nameImgModal"
239
- position={"topCenter"}
240
- addArrow={false}
241
- transitionType={"zoom"}
242
- followCursor={false}
243
- >
244
- <CustomIcon
245
- className="iconDefaultImgModal"
246
- type={"white"}
247
- size={100}
248
- borderType={"rectangle"}
249
- icon={IconImage}
250
- />
251
- </Tooltip>
252
- }
253
- />
254
- </div>
255
- );
256
- /*
257
- <Tooltip
258
- componentTooltip={<label>{value.name}</label>}
259
- className="label-nameFileShort"
260
- position={"topCenter"}
261
- addArrow={false}
262
- transitionType={"zoom"}
263
- followCursor={false}
264
- >
265
- {value.name}
266
- </Tooltip>
267
- */
268
- };
269
-
270
- const renderFile = (item, ownMessage) => {
271
- const value = decodeJSON(item.value);
272
- const url = `${process.env.REACT_APP_IMAGES_ENDPOINT}/${value.key}`;
273
-
274
- return (
275
- <div className="item-file">
276
- <ButtonDownloadFile
277
- className="btnDownloadFileItem"
278
- size={22}
279
- type={ownMessage ? "black" : "white"}
280
- transparent
281
- url={url}
282
- onDownload={(error) => {
283
- error &&
284
- setModalAlert((prev) => ({
285
- show: true,
286
- title: error.message,
287
- message: error.details,
288
- }));
289
- }}
290
- />
291
- <Tooltip
292
- componentTooltip={<label>{value.name}</label>}
293
- className="label-nameFileShort"
294
- position={"topCenter"}
295
- addArrow={false}
296
- transitionType={"zoom"}
297
- followCursor={false}
298
- >
299
- {value.name}
300
- </Tooltip>
301
- </div>
302
- );
303
- };
304
-
305
- const getUserCreatedItem = (ownMessage, item, lastUserId) => {
306
- return (
307
- <Slide
308
- id={"itemScroll"}
309
- direction={ownMessage ? "left" : "right"}
310
- in={true}
311
- timeout={500}
312
- container={containerList.current}
313
- key={"item-" + item.id}
314
- >
315
- <li
316
- className={
317
- (ownMessage ? "own-message " : "") +
318
- (lastUserId == item.userId ? "sameUser" : "")
319
- }
320
- >
321
- {/* img del user */}
322
- {lastUserId !== item.userId && (
323
- <ImageTooltip
324
- className={"container-imgUser"}
325
- sizeLoading={25}
326
- colorLoading={undefined}
327
- src={getProfilePicture(item.userId, 34, 34)}
328
- componentDefault={
329
- <CustomIcon
330
- className="icon-imgUser"
331
- type={"whiteS2"}
332
- size={17}
333
- borderType={"circle"}
334
- icon={IconUser}
335
- />
336
- }
337
- classNameTooltip={"tooltip-imgUser"}
338
- componentTooltip={
339
- <label className="label-nameUser">
340
- {users[item.userId].name}
341
- </label>
342
- }
343
- />
344
- )}
345
-
346
- {item.type === "message"
347
- ? renderMessage(item)
348
- : item.type === "comment"
349
- ? renderComment(item)
350
- : item.type === "img"
351
- ? renderImg(item)
352
- : item.type === "file"
353
- ? renderFile(item, ownMessage)
354
- : item.type === "statusTicket"
355
- ? renderStatusTicket(item)
356
- : null}
357
-
358
- <label className="label-time">{getTime(item.date)}</label>
359
- </li>
360
- </Slide>
361
- );
362
- };
363
-
364
- const getItemNeutral = (item) => {
365
- return (
366
- <Zoom
367
- in={true}
368
- timeout={600}
369
- container={containerList.current}
370
- key={"item-" + item.id}
371
- >
372
- <li className={"itemNeutral"}>
373
- {item.type === "statusTicket"
374
- ? renderStatusTicketNeutral(item)
375
- : null}
376
- </li>
377
- </Zoom>
378
- );
379
- };
380
-
381
- const renderItems = () => {
382
- let jsxItems = [];
383
- let date = undefined;
384
- let countDate = 1;
385
- for (const item of items) {
386
- // manejo de las etiquetas fechas
387
- if (!date) {
388
- date = getFullDate(new Date(item.date));
389
- } else {
390
- let newDate = getFullDate(new Date(item.date));
391
- if (newDate !== date) {
392
- jsxItems.push(renderGrayLabel(date, `itemDate-${countDate++}`));
393
- date = newDate;
394
- }
395
- }
396
-
397
- // elementos que van alineados al centro
398
- switch (item.type) {
399
- case "statusArticle":
400
- jsxItems.push(renderStatusArticle(item.value, `item-${item.id}`));
401
- continue;
402
- case "statusService":
403
- jsxItems.push(renderStatusService(item.value, `item-${item.id}`));
404
- continue;
405
- }
406
-
407
- // acomodo del item (left o right)
408
- let ownMessage = false;
409
- // CHAT MERCHANT ARTICLE
410
- if (chatType === "merchant_product") {
411
- if (currentUser.companyId == users[item.userId].companyId) {
412
- ownMessage = true;
413
- }
414
- }
415
- // CHAT ORDER ARTICLE
416
- else if (chatType === "order_product") {
417
- if (currentUser.companyId == users[item.userId].companyId) {
418
- if (activeCompanyId && activeCompanyId == currentUser.companyId) {
419
- if (item.userId == currentUser.id) {
420
- ownMessage = true;
421
- }
422
- } else {
423
- ownMessage = true;
424
- }
425
- }
426
- }
427
-
428
- // renderizar tipo de item
429
- jsxItems.push(getUserCreatedItem(ownMessage, item));
430
- }
431
- if (date)
432
- jsxItems.push(
433
- renderGrayLabel(date, `itemDate-${countDate}`, "label-date")
434
- );
435
- setCustomItems(jsxItems);
436
- };
437
-
438
- const renderItemsTicket = () => {
439
- let jsxItems = [];
440
- let date = undefined;
441
- let countDate = 1;
442
- let lastUserId = undefined;
443
- //console.log("isUserTech:", currentUser.isUserTech);
444
-
445
- // recorrido de los items (del mas viejo al mas reciente)
446
- for (let index = items.length - 1; index >= 0; index--) {
447
- const item = items[index];
448
- // manejo de las etiquetas fechas
449
- if (!date) {
450
- date = getFullDate(new Date(item.date));
451
- jsxItems.push(renderGrayLabel(date, `itemDate-${countDate++}`));
452
- lastUserId = undefined;
453
- } else {
454
- let newDate = getFullDate(new Date(item.date));
455
- if (newDate !== date) {
456
- jsxItems.push(renderGrayLabel(newDate, `itemDate-${countDate++}`));
457
- date = newDate;
458
- lastUserId = undefined;
459
- }
460
- }
461
-
462
- // elementos que van alineados al centro
463
- /*
464
- switch (item.type) {
465
- case "statusTicket":
466
- jsxItems.push(getItemNeutral(item));
467
- lastUserId = undefined;
468
- continue;
469
- }
470
- */
471
-
472
- // acomodo del item (left o right)
473
- let ownMessage = false;
474
- // user tech
475
- if (currentUser.isUserTech) {
476
- if (users[item.userId].isUserTech) ownMessage = true;
477
- }
478
- // user normal
479
- else {
480
- if (!users[item.userId].isUserTech) {
481
- if (currentUser.companyId == users[item.userId].companyId) {
482
- ownMessage = true;
483
- }
484
- } else if (currentUser.id == item.userId) {
485
- ownMessage = true;
486
- }
487
- }
488
-
489
- // renderizar tipo de item
490
- //console.log(lastUserId + "<>" + item.userId);
491
- jsxItems.push(getUserCreatedItem(ownMessage, item, lastUserId));
492
- lastUserId = item.userId;
493
- }
494
-
495
- setCustomItems(jsxItems);
496
- };
497
-
498
- return (
499
- <>
500
- <Container id={"containerItems"}>
501
- <div className="btn-loadMore">
502
- {showBtnLoadMore && (
503
- <ButtonV2
504
- className="container-btnLoadMore"
505
- type={"purple"}
506
- label={"cargar más"}
507
- size={10}
508
- borderType="oval"
509
- icon={IconReload}
510
- iconPosition="start"
511
- isLoading={btnLoadMoreLoading}
512
- onClick={async (event) => {
513
- setBtnLoadMoreLoading(true);
514
- if (onClickBtnLoadMore) {
515
- const responseError = await onClickBtnLoadMore();
516
- if (responseError) {
517
- setModalAlert({
518
- show: true,
519
- title: responseError.title,
520
- message: responseError.message,
521
- });
522
- }
523
- }
524
- setBtnLoadMoreLoading(false);
525
- }}
526
- />
527
- )}
528
- </div>
529
-
530
- <ul id="ulItems" ref={containerList}>
531
- {customItems}
532
- </ul>
533
- </Container>
534
-
535
- <Modal
536
- show={modalAlert.show}
537
- title={modalAlert.title}
538
- message={modalAlert.message}
539
- icon={"info"}
540
- onClickBtnDefault={(event) =>
541
- setModalAlert((prev) => ({
542
- ...prev,
543
- show: false,
544
- }))
545
- }
546
- />
547
- </>
548
- );
549
- };