Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 40 | Rev 932 | Ir a la última revisión | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 www 1
import React from "react";
2
import { useState, useRef, useEffect } from "react";
3
import styled from "styled-components";
4
import {axios} from "../../../utils";
5
import Spinner from "../../../shared/loading-spinner/Spinner";
6
import Emojione from "./emojione/Emojione";
7
import SendFileModal from "./send-file-modal/SendFileModal";
8
import ConfirmModal from "../../../shared/confirm-modal/ConfirmModal";
9
import MessageTemplate from "./messageTemplate/MessageTemplate";
10
 
11
const StyledChatHead = styled.div`
12
  .notify {
13
    animation: notify 2s infinite;
14
  }
15
 
16
  @keyframes notify {
17
    0% {
18
      background-color: unset;
19
    }
20
    50% {
21
      background-color: #00b0ff;
22
    }
23
    100% {
24
      background-color: unset;
25
    }
26
  }
27
`;
28
 
29
const StyledShowOptions = styled.div`
30
  height: 342px;
31
  flex-direction: column;
32
  overflow-y: auto;
33
  position: relative;
34
  &.show {
35
    display: flex;
36
  }
37
  &.hide {
38
    display: none;
39
  }
40
  .optionBack {
41
    margin: 1rem 0 0.5rem 1rem;
42
    cursor: pointer;
43
  }
44
  .optionsTab {
45
    &__option {
46
      padding: 0.5rem;
47
      border-bottom: 1px solid #e2e2e2;
48
      cursor: pointer;
49
      &:hover {
50
        background-color: #e2e2e2;
51
      }
52
      &__icon {
53
        margin-right: 0.3rem;
54
      }
55
    }
56
  }
57
  .addPersonToGroupTab {
58
    display: flex;
59
    flex-direction: column;
60
    &__person {
61
      display: flex;
62
      justify-content: space-between;
63
      align-items: center;
64
      padding: 0.2rem 0.5rem;
65
      border-bottom: 1px solid #e2e2e2;
66
    }
67
  }
68
`;
69
 
70
const PersonalChat = (props) => {
71
  // props destructuring
72
  const { index, onClose, onMinimize, onRead } = props;
73
  // entity destructuring
74
  const {
75
    id,
76
    image,
77
    name,
78
    online,
79
    type,
80
    unsee_messages,
81
    url_clear,
82
    url_close,
83
    url_get_all_messages,
84
    url_send,
85
    url_upload,
86
    minimized,
87
    profile,
88
    // group
89
    url_leave,
90
    url_delete,
91
    url_add_user_to_group,
92
    url_get_contact_group_list,
93
    url_get_contacts_availables_for_group,
94
  } = props.entity;
95
 
96
  // states
97
  const [messages, setMessages] = useState([]);
98
  const [newMessages, setNewMessages] = useState([]);
99
  const [oldMessages, setOldMessages] = useState([]);
100
  const [currentPage, setCurrentPage] = useState(1);
101
  const [pages, setPages] = useState(1);
102
  const [loading, setLoading] = useState(false);
103
  const [showOptions, setShowOptions] = useState(false);
104
  const [optionTab, setOptionTab] = useState("default");
105
  const [availableContactsToAdd, setAvailableContactsToAdd] = useState([]);
106
  const [groupContactsList, setGroupContactsList] = useState([]);
107
  const [confirmModalShow, setConfirmModalShow] = useState(false);
108
  const [optionsLoading, setOptionsLoading] = useState(false);
109
  const [showEmojiTab, setShowEmojiTab] = useState(false);
110
  const [shareFileModalShow, setShareFileModalShow] = useState(false);
111
 
112
  // refs
113
  const conversationListEl = useRef(null);
114
  const loader = useRef(null);
115
  const modalActionUrl = useRef("");
116
  const chatboxEl = useRef(null);
117
  const textAreaEl = useRef(null);
118
 
119
  // optionTabs
120
  const optionTabs = {
121
    add_person_to_group: "add_person_to_group",
122
    group_contacts_list: "group_contacts_list",
123
    default: "default",
124
  };
125
 
126
  // timeIntervals
127
  let getMessageInterval;
128
 
129
  const handleActive = () => {
130
    onRead(index);
131
    onMinimize(index);
132
  };
133
 
134
  // const handleGetMessages = async () => {
135
  //   await axios.get(url_get_all_messages).then((response) => {
136
  //     const resData = response.data;
137
  //     if (resData.success) {
138
  //       const updatedMessages = resData.data.items.slice();
139
  //       let newNewMessages = [];
140
  //       updatedMessages.map((updatedNewMessage) => {
141
  //         const existInNewMessages = newMessages.findIndex(
142
  //           (newMessage) => newMessage.id === updatedNewMessage.id
143
  //         );
144
  //         if (existInNewMessages === -1) {
145
  //           newNewMessages = [updatedNewMessage, ...newNewMessages];
146
  //           setPages(resData.data.pages);
147
  //         }
148
  //       });
149
  //       if (newNewMessages.length > 0) {
150
  //         setNewMessages((prevState) => [...prevState, ...newNewMessages]);
151
  //       }
152
 
153
  //       // setMessages([...resData.data.items, ...oldMessages]);
154
  //     }
155
  //   });
156
  //   onRead(index);
157
  // };
158
 
159
  const handleGetMessages = async () => {
160
    const response = await axios.get(url_get_all_messages);
161
    const resData = response.data;
162
    if (!resData.success) {
163
      return  ("ha ocurrido un error", resData);
164
    }
165
    const updatedMessages = [...resData.data.items].reverse();
166
    const newMessages = updatedMessages.reduce((acum, updatedMessage) => {
167
      if (
168
        messages.findIndex((message) => message.id === updatedMessage.id) === -1
169
      ) {
170
        acum = [...acum, updatedMessage];
171
      }
172
      return acum;
173
    }, []);
174
    if (newMessages.length > 0) {
175
      setMessages([...messages, ...newMessages]);
176
      setPages(resData.data.pages);
177
      scrollToBottom();
178
    }
179
    setLoading(false);
180
  };
181
 
182
  const handleLoadMore = async () => {
183
    await axios
184
      .get(url_get_all_messages, {
185
        params: {
186
          page: currentPage,
187
        },
188
      })
189
      .then((response) => {
190
        const resData = response.data;
191
        if (resData.success) {
192
          if (resData.data.page > 1) {
193
            const updatedOldMessages = [...resData.data.items].reverse();
194
            setOldMessages([...updatedOldMessages, ...oldMessages]);
195
            scrollDownBy(100);
196
          }
197
        }
198
      });
199
  };
200
 
201
  const handleCloseChat = () => {
202
    onClose(id, url_close);
203
  };
204
 
205
  const handleChatBoxKeyDown = async (e) => {
206
    if (e.key === "Enter") {
207
      e.preventDefault();
208
      const message = e.target.value;
209
      const formData = new FormData();
210
      formData.append("message", emojione.toShort(message));
211
      await axios.post(url_send, formData).then((response) => {
212
        const resData = response.data;
213
        if (resData.success) {
214
        }
215
      });
216
      e.target.value = "";
217
      await handleGetMessages();
218
      setShowEmojiTab(false);
219
    }
220
  };
221
 
222
  const handleShowOptions = () => {
223
    onMinimize(index, false);
224
    setShowOptions(!showOptions);
225
  };
226
 
227
  const handleChangeTab = (tab) => {
228
    setOptionTab(tab);
229
  };
230
 
231
  const handleAddPersonToGroup = async (id) => {
232
    const formData = new FormData();
233
    formData.append("uid", id);
234
    await axios.post(url_add_user_to_group, formData).then((response) => {
235
      const resData = response.data;
236
      if (resData.success) {
237
        loadPersonsAvailable();
238
      }
239
    });
240
  };
241
 
242
  const handleConfirmModalAction = async () => {
243
    await axios.post(modalActionUrl.current).then((response) => {
244
      const resData = response.data;
245
      if (resData.success) {
246
      }
247
    });
248
    await onClose(id, url_close);
249
  };
250
 
251
  const handleObserver = (entities) => {
252
    const target = entities[0];
253
    if (target.isIntersecting) {
254
      setCurrentPage((prevState) => prevState + 1);
255
    }
256
  };
257
 
258
  const scrollToBottom = () => {
259
    if (!!conversationListEl.current) {
260
      conversationListEl.current.scrollTop =
261
        conversationListEl.current.scrollHeight * 9;
262
    }
263
  };
264
 
265
  const scrollDownBy = (scrollDistance) => {
266
    if (!!conversationListEl.current) {
267
      conversationListEl.current.scrollTop = scrollDistance;
268
    }
269
  };
270
 
271
  const handleShowEmojiTab = () => {
272
    setShowEmojiTab(!showEmojiTab);
273
    // smiley_tpl(`${id}`);
274
  };
275
 
276
  const handleClickEmoji = (e) => {
277
    const shortname = e.currentTarget.dataset.shortname;
278
    const currentText = textAreaEl.current.value;
279
    let cursorPosition = textAreaEl.current.selectionStart;
280
    const textBehind = currentText.substring(0, cursorPosition);
281
    const textForward = currentText.substring(cursorPosition);
282
    const unicode = emojione.shortnameToUnicode(shortname);
283
    textAreaEl.current.value = `${textBehind}${unicode}${textForward}`;
284
    textAreaEl.current.focus();
285
    textAreaEl.current.setSelectionRange(
286
      cursorPosition + unicode.length,
287
      cursorPosition + unicode.length
288
    );
289
  };
290
 
291
  // useEffect(() => {
292
  //   setMessages([...oldMessages, ...newMessages]);
293
  // }, [newMessages, oldMessages]);
294
 
295
  // getMessageOnMaximize and subscribe to infinite Loader
296
  useEffect(async () => {
297
    if (!minimized) {
298
      await handleGetMessages();
299
      // loader observer
300
      let options = {
301
        root: null,
302
        rootMargin: "20px",
303
        treshold: 1.0,
304
      };
305
      const observer = new IntersectionObserver(handleObserver, options);
306
      if (loader.current) {
307
        observer.observe(loader.current);
308
      }
309
    }
310
    return () => {
311
      if (loader.current) {
312
        observer.unobserve(loader.current);
313
      }
314
    };
315
  }, [minimized]);
316
 
317
  // LoadMore on change page
318
  useEffect(() => {
319
    let loadMore = handleLoadMore();
928 stevensc 320
    loadMore()
1 www 321
    return () => {
322
      loadMore = null;
323
    };
324
  }, [currentPage]);
325
 
326
  // getMessagesInterval
327
  useEffect(() => {
38 steven 328
    if(window.location.pathname === '/group/my-groups'){
329
      const items = document.getElementsByClassName('sc-jSgupP')
330
      if(items && items.length > 0)
331
        items[0].style.display='none';
332
    }
1 www 333
    if (!minimized) {
334
      clearInterval(getMessageInterval);
335
      getMessageInterval = setInterval(() => {
336
        handleGetMessages();
337
      }, 1000);
338
    } else {
339
      clearInterval(getMessageInterval);
340
    }
341
    return () => {
342
      clearInterval(getMessageInterval);
343
    };
33 steven 344
  });
1 www 345
 
346
  const handleConfirmModalShow = () => {
347
    setConfirmModalShow(!confirmModalShow);
348
  };
349
 
350
  const handleConfirmModalAccept = () => {
351
    handleConfirmModalAction();
352
  };
353
 
354
  const handleShareFileModalShow = () => {
355
    setShareFileModalShow(!shareFileModalShow);
356
  };
357
 
358
  const messagesRender = () => {
359
    return (
360
      <React.Fragment>
361
        {currentPage < pages ? <li ref={loader}>Cargando...</li> : ""}
362
        {oldMessages.map((oldMessage) => (
363
          <MessageTemplate message={oldMessage} />
364
        ))}
365
        {messages.map((message) => (
366
          <MessageTemplate message={message} />
367
        ))}
368
      </React.Fragment>
369
    );
370
  };
371
 
372
  const optionRender = () => {
373
    switch (optionTab) {
374
      case optionTabs.add_person_to_group:
375
        return addPersonToGroupTab;
376
      case optionTabs.group_contacts_list:
377
        return groupContactsListTab;
378
      default:
379
        return optionsDefaultTab;
380
    }
381
  };
382
 
383
  // useEffect for tabs changing
384
  useEffect(() => {
385
    switch (optionTab) {
386
      case optionTabs.add_person_to_group:
387
        loadPersonsAvailable();
388
        break;
389
      case optionTabs.group_contacts_list:
390
        loadGroupContacts();
391
      default:
392
        break;
393
    }
394
  }, [optionTab]);
395
 
396
  const loadPersonsAvailable = async () => {
397
    setOptionsLoading(true);
398
    await axios.get(url_get_contacts_availables_for_group).then((response) => {
399
      const resData = response.data;
400
      if (resData.success) {
401
        setAvailableContactsToAdd(resData.data);
402
      }
403
    });
404
    setOptionsLoading(false);
405
  };
406
 
407
  const loadGroupContacts = async () => {
408
    setOptionsLoading(true);
409
    await axios.get(url_get_contact_group_list).then((response) => {
410
      const resData = response.data;
411
      if (resData.success) {
412
        setGroupContactsList(resData.data);
413
      }
414
    });
415
    setOptionsLoading(false);
416
  };
417
 
418
  const handleDeletePersonFromGroup = async (urlDeletePersonFromGroup) => {
419
    await axios.post(urlDeletePersonFromGroup).then((response) => {
420
      const resData = response.data;
421
      if (resData.success) {
422
        loadGroupContacts();
423
      }
424
    });
425
  };
426
 
427
  const optionsDefaultTab = (
428
    <React.Fragment>
429
      <span className="optionBack" onClick={() => handleShowOptions()}>
430
        <i className="fa icon-arrow-left"></i>
431
      </span>
432
      <div className="optionsTab">
433
        <ul>
434
          {!!url_get_contact_group_list && (
435
            <li
436
              className="optionsTab__option"
437
              onClick={() => handleChangeTab(optionTabs.group_contacts_list)}
438
            >
439
              <span className="optionsTab__option__icon">
440
                <i className="fa fa-group"></i>
441
              </span>
442
              Integrantes
443
            </li>
444
          )}
445
          {!!url_add_user_to_group && (
446
            <li
447
              className="optionsTab__option"
448
              onClick={() => handleChangeTab(optionTabs.add_person_to_group)}
449
            >
450
              <span className="optionsTab__option__icon">
451
                <i className="fa fa-user-plus"></i>
452
              </span>
453
              Agregar contactos
454
            </li>
455
          )}
456
          {!!url_delete && (
457
            <li
458
              className="optionsTab__option"
459
              style={{ color: "red" }}
460
              onClick={() => {
461
                handleConfirmModalShow();
462
                modalActionUrl.current = url_delete;
463
              }}
464
            >
465
              <span className="optionsTab__option__icon">
466
                <i className="fa fa-trash"></i>
467
              </span>
468
              Eliminar grupo
469
            </li>
470
          )}
471
          {!!url_leave && (
472
            <li
473
              className="optionsTab__option"
474
              style={{ color: "red" }}
475
              onClick={() => {
476
                handleConfirmModalShow();
477
                modalActionUrl.current = url_leave;
478
              }}
479
            >
480
              <span className="optionsTab__option__icon">
481
                <i className="fa fa-user-times"></i>
482
              </span>
483
              Dejar grupo
484
            </li>
485
          )}
486
        </ul>
487
      </div>
488
    </React.Fragment>
489
  );
490
 
491
  const addPersonToGroupTab = (
492
    <React.Fragment>
493
      <span
494
        className="optionBack"
495
        onClick={() => handleChangeTab(optionTabs.default)}
496
      >
497
        <i className="fa icon-arrow-left"></i>
498
      </span>
499
      <div className="addPersonToGroupTab">
500
        {availableContactsToAdd.length ? (
501
          availableContactsToAdd.map(({ image, name, id }) => (
502
            <div className="addPersonToGroupTab__person" key={id}>
503
              <img
504
                className="chat-image img-circle pull-left"
505
                height="36"
506
                width="36"
507
                src={image}
508
                alt="image-image"
509
              />
510
              <div className="name">{name}</div>
511
              <span
512
                style={{
513
                  cursor: "pointer",
514
                }}
515
                onClick={() => {
516
                  handleAddPersonToGroup(id);
517
                }}
518
              >
519
                <i className="fa fa-plus-circle"></i>
520
              </span>
521
            </div>
522
          ))
523
        ) : (
524
          <div className="addPersonToGroupTab__person">No hay Contactos</div>
525
        )}
526
      </div>
527
    </React.Fragment>
528
  );
529
 
530
  const groupContactsListTab = (
531
    <React.Fragment>
532
      <span
533
        className="optionBack"
534
        onClick={() => handleChangeTab(optionTabs.default)}
535
      >
536
        <i className="fa icon-arrow-left"></i>
537
      </span>
538
      <div className="addPersonToGroupTab">
539
        {groupContactsList.length ? (
540
          groupContactsList.map(
541
            ({ image, name, url_remove_from_group, id }) => (
542
              <div className="addPersonToGroupTab__person" key={id}>
543
                <div style={{ display: "flex", alignItems: "center" }}>
544
                  <img
545
                    className="chat-image img-circle pull-left"
546
                    height="36"
547
                    width="36"
548
                    src={image}
549
                    alt="image-image"
550
                  />
551
                  <div className="name">{name}</div>
552
                </div>
553
                {url_remove_from_group && (
554
                  <span
555
                    style={{
556
                      cursor: "pointer",
557
                    }}
558
                    onClick={() => {
559
                      handleDeletePersonFromGroup(url_remove_from_group);
560
                    }}
561
                  >
562
                    <i className="fa fa-user-times"></i>
563
                  </span>
564
                )}
565
              </div>
566
            )
567
          )
568
        ) : (
569
          <div className="addPersonToGroupTab__person">No hay Contactos</div>
570
        )}
571
      </div>
572
    </React.Fragment>
573
  );
574
 
575
  const shareFileModal = (
576
    <SendFileModal
577
      show={shareFileModalShow}
578
      onHide={() => {
579
        setShareFileModalShow(false);
580
      }}
581
      urlUpload={url_upload}
582
    />
583
  );
584
 
585
  const userChat = (
586
    <React.Fragment>
587
      <div
588
        className="chatbox active-chat"
589
        style={{
590
          bottom: "0px",
591
          right: `${(index + 1) * 295}px`,
11 steven 592
          zIndex: "1",
1 www 593
          display: "block",
594
        }}
595
      >
596
        <div className="chatbox-icon">
597
          <div className="contact-floating red">
598
            <img className="chat-image img-circle pull-left" src={image} />
599
            <small className="unread-msg">2</small>
600
            {/* <small className="status"'+ status+'></small> */}
601
          </div>
602
        </div>
603
        <div className="panel personal-chat">
604
          <StyledChatHead>
605
            <div
606
              className={`panel-heading chatboxhead ${
607
                unsee_messages ? "notify" : ""
608
              }`}
609
            >
610
              <div className="panel-title">
611
                <img
612
                  className="chat-image img-circle pull-left"
613
                  height="36"
614
                  width="36"
615
                  src={image}
616
                  alt="avatar-image"
617
                />
618
                <div className="header-elements">
619
                  <a href={profile} target="_blank">
620
                    {name}
621
                  </a>
622
                  <br />
623
                  <small className={`status ${online ? "Online" : "Offline"}`}>
624
                    <b>{online ? "Online" : "Offline"}</b>
625
                  </small>
626
                  <div className="pull-right options">
627
                    <div
628
                      className="btn-group uploadFile"
629
                      id="uploadFile"
630
                      data-client="'+chatboxtitle+'"
631
                    >
632
                      {/* <span>
633
                      <i className="fa fa-trash"></i>
634
                    </span> */}
635
                    </div>
636
                    <div
637
                      className="btn-group"
638
                      // onClick="javascript:clearHistory(\''+chatboxtitle+'\')"
639
                      // href="javascript:void(0)"
640
                    >
641
                      {/* <span>
642
                      <i className="fa fa-trash"></i>
643
                    </span> */}
644
                    </div>
645
                    <div
646
                      className="btn-group"
647
                      // onClick="javascript:toggleChatBoxGrowth(\''+chatboxtitle+'\')"
648
                      // href="javascript:void(0)"
649
                    >
650
                      <span>
651
                        <i
652
                          className={`fa fa-minus-circle`}
653
                          onClick={handleActive}
654
                        ></i>
655
                      </span>
656
                    </div>
657
                    <div
658
                      className="btn-group"
659
                      // onClick="javascript:closeChatBox(\''+chatboxtitle+'\')"
660
                      // href="javascript:void(0)"
661
                    >
662
                      <span>
663
                        <i
664
                          className="fa fa-times-circle"
665
                          onClick={handleCloseChat}
666
                        ></i>
667
                      </span>
668
                    </div>
669
                  </div>
670
                </div>
671
              </div>
672
            </div>
673
          </StyledChatHead>
674
          <div
675
            className="panel-body"
676
            style={{ display: !minimized ? "block" : "none" }}
677
          >
678
            <div
679
              id="uploader_'+chatboxtitle+'"
680
              style={{ display: "none", height: "342px" }}
681
            >
682
              <p>
683
                Your browser does not have Flash, Silverlight or HTML5 support.
684
              </p>
685
            </div>
686
            <div className="chat-conversation" style={{ position: "relative" }}>
687
              <div className="reverseChatBox" ref={conversationListEl}>
688
                <ul
689
                  className="conversation-list chatboxcontent"
690
                  id="resultchat_'+chatboxtitle+'"
691
                >
692
                  {messagesRender()}
693
                </ul>
694
              </div>
695
              <div className="wchat-footer wchat-chat-footer chatboxinput">
696
                <div id="chatFrom">
697
                  <div className="block-wchat">
698
                    <button
699
                      className="icon ti-clip attachment font-24 btn-attach btn-attach uploadFile"
700
                      id="uploadFile"
701
                      onClick={handleShareFileModalShow}
702
                    ></button>
703
                    <button
704
                      className="icon ti-face-smile font-24 btn-emoji"
705
                      id="toggle-emoji"
706
                      onClick={handleShowEmojiTab}
707
                    ></button>
708
                    <div className="input-container">
709
                      <div className="input-emoji">
710
                        <div
711
                          className="input-placeholder"
712
                          style={{ visibility: "hidden", display: "none" }}
713
                        >
714
                          Escribe un mensaje
715
                        </div>
716
                        <textarea
717
                          className="input chatboxtextarea"
718
                          id="chatboxtextarea"
719
                          name="chattxt"
720
                          style={{ resize: "none", height: "20px" }}
721
                          placeholder="Escribe un mensaje"
722
                          onKeyDown={handleChatBoxKeyDown}
723
                          ref={textAreaEl}
724
                        ></textarea>
725
                        <input
726
                          id="to_uname"
727
                          name="to_uname"
728
                          value="'+chatboxtitle+'"
729
                          type="hidden"
730
                        />
731
                        <input
732
                          id="from_uname"
733
                          name="from_uname"
734
                          value="Beenny"
735
                          type="hidden"
736
                        />
737
                      </div>
738
                    </div>
739
                  </div>
740
                </div>
741
                <div className="wchat-box-items-positioning-container">
742
                  <div className="wchat-box-items-overlay-container">
743
                    <div
744
                      className="target-emoji"
745
                      style={{ display: showEmojiTab ? "block" : "none" }}
746
                    >
747
                      <div id={`smileyPanel_${id}`}>
748
                        <div>
749
                          <Emojione onClickEmoji={handleClickEmoji} />
750
                        </div>
751
                      </div>
752
                    </div>
753
                  </div>
754
                </div>
755
              </div>
756
            </div>
757
          </div>
758
        </div>
759
      </div>
760
      {shareFileModal}
761
    </React.Fragment>
762
  );
763
 
764
  const groupChat = (
765
    <React.Fragment>
766
      <div
767
        className="chatbox active-chat"
768
        style={{
769
          bottom: "0px",
770
          right: `${(index + 1) * 295}px`,
771
          zIndes: "1",
772
          display: "block",
773
        }}
774
        id={`chatbox_${id}`}
775
        ref={chatboxEl}
776
      >
777
        <div className="chatbox-icon">
778
          <div className="contact-floating red">
779
            <img className="chat-image img-circle pull-left" src={image} />
780
            <small className="unread-msg">2</small>
781
            {/* <small className="status"'+ status+'></small> */}
782
          </div>
783
        </div>
784
        <div className="panel personal-chat">
785
          <StyledChatHead>
786
            <div
787
              className={`panel-heading chatboxhead ${
788
                unsee_messages ? "notify" : ""
789
              }`}
790
            >
791
              <div className="panel-title-group">
792
                <img
793
                  className="chat-image img-circle pull-left"
794
                  height="36"
795
                  width="36"
796
                  src="/images/users-group.png"
797
                  alt="avatar-image"
798
                />
799
                <div className="header-elements">
800
                  <p>{name}</p>
801
                  <br />
802
                  <div className="pull-right options">
803
                    <div
804
                      className="btn-group uploadFile"
805
                      id="uploadFile"
806
                      data-client="'+chatboxtitle+'"
807
                    >
808
                      {/* <span>
809
                      <i className="fa fa-trash"></i>
810
                    </span> */}
811
                    </div>
812
                    <div
813
                      className="btn-group"
814
                      // onClick="javascript:clearHistory(\''+chatboxtitle+'\')"
815
                      // href="javascript:void(0)"
816
                    >
817
                      {/* <span>
818
                      <i className="fa fa-trash"></i>
819
                    </span> */}
820
                    </div>
821
                    <div
822
                      className="btn-group addUser"
823
                      data-client="8cb2a840-56c2-4f93-9cf1-27ad598acd8f"
824
                      data-name="Grupo de jesus"
825
                    >
826
                      <span>
827
                        <i
828
                          // className="fa fa-user-plus"
829
                          className="fa fa-gear"
830
                          onClick={handleShowOptions}
831
                        ></i>
832
                      </span>
833
                    </div>
834
                    <div
835
                      className="btn-group"
836
                      // onClick="javascript:toggleChatBoxGrowth(\''+chatboxtitle+'\')"
837
                      // href="javascript:void(0)"
838
                    >
839
                      <span>
840
                        <i
841
                          className={`fa fa-minus-circle`}
842
                          onClick={handleActive}
843
                        ></i>
844
                      </span>
845
                    </div>
846
                    <div
847
                      className="btn-group"
848
                      // onClick="javascript:closeChatBox(\''+chatboxtitle+'\')"
849
                      // href="javascript:void(0)"
850
                    >
851
                      <span>
852
                        <i
853
                          className="fa fa-times-circle"
854
                          onClick={handleCloseChat}
855
                        ></i>
856
                      </span>
857
                    </div>
858
                  </div>
859
                </div>
860
              </div>
861
            </div>
862
          </StyledChatHead>
863
          <div
864
            className="panel-body"
865
            style={{ display: !minimized ? "block" : "none" }}
866
          >
867
            <StyledShowOptions className={` ${showOptions ? "show" : "hide"}`}>
868
              {optionRender()}
869
            </StyledShowOptions>
870
 
871
            <div
872
              className="chat-conversation"
873
              style={{
874
                display: showOptions ? "none" : "block",
875
                position: "relative",
876
              }}
877
            >
878
              <div className="reverseChatBox" ref={conversationListEl}>
879
                <ul
880
                  className="conversation-list chatboxcontent"
881
                  id="resultchat_'+chatboxtitle+'"
882
                >
883
                  {messagesRender()}
884
                </ul>
885
              </div>
886
              <div className="wchat-footer wchat-chat-footer chatboxinput">
887
                <div id="chatFrom">
888
                  <div className="block-wchat">
889
                    <button
890
                      className="icon ti-clip attachment font-24 btn-attach btn-attach uploadFile"
891
                      id="uploadFile"
892
                      onClick={handleShareFileModalShow}
893
                    ></button>
894
                    <button
895
                      className="icon ti-face-smile font-24 btn-emoji"
896
                      id="toggle-emoji"
897
                      onClick={handleShowEmojiTab}
898
                    ></button>
899
                    <div className="input-container">
900
                      <div className="input-emoji">
901
                        <div
902
                          className="input-placeholder"
903
                          style={{ visibility: "hidden", display: "none" }}
904
                        >
905
                          Escribe un mensaje
906
                        </div>
907
                        <textarea
908
                          className="input chatboxtextarea"
909
                          id="chatboxtextarea"
910
                          name="chattxt"
911
                          style={{ resize: "none", height: "20px" }}
912
                          placeholder="Escribe un mensaje"
913
                          onKeyDown={handleChatBoxKeyDown}
914
                          ref={textAreaEl}
915
                        ></textarea>
916
                        <input
917
                          id="to_uname"
918
                          name="to_uname"
919
                          value="'+chatboxtitle+'"
920
                          type="hidden"
921
                        />
922
                        <input
923
                          id="from_uname"
924
                          name="from_uname"
925
                          value="Beenny"
926
                          type="hidden"
927
                        />
928
                      </div>
929
                    </div>
930
                  </div>
931
                </div>
932
                <div className="wchat-box-items-positioning-container">
933
                  <div className="wchat-box-items-overlay-container">
934
                    <div
935
                      className="target-emoji"
936
                      style={{ display: showEmojiTab ? "block" : "none" }}
937
                    >
938
                      <div id={`smileyPanel_${id}`}>
939
                        <div>
940
                          <Emojione onClickEmoji={handleClickEmoji} />
941
                        </div>
942
                      </div>
943
                    </div>
944
                  </div>
945
                </div>
946
              </div>
947
            </div>
948
          </div>
949
        </div>
950
      </div>
951
      <ConfirmModal
952
        show={confirmModalShow}
953
        onClose={handleConfirmModalShow}
954
        onAccept={handleConfirmModalAccept}
955
      />
956
      {shareFileModal}
957
    </React.Fragment>
958
  );
959
 
960
  switch (type) {
961
    case "user":
962
      return userChat;
963
    case "group":
964
      return groupChat;
965
    default:
966
      break;
967
  }
968
};
969
 
970
export default PersonalChat;