Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 37 | Rev 39 | 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();
320
    return () => {
321
      loadMore = null;
322
    };
323
  }, [currentPage]);
324
 
325
  // getMessagesInterval
326
  useEffect(() => {
38 steven 327
    console.log('>>: effect > ')
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
 
333
      // document.querySelectorAll(".sc-jSgupP").forEach(el => {
334
      //   console.log('>>: el > ', el)
335
      //   if(el.parentNode && el.parentNode.removeChild)
336
      //     el.parentNode.removeChild(el);
337
      // });
338
    }
1 www 339
    if (!minimized) {
340
      clearInterval(getMessageInterval);
341
      getMessageInterval = setInterval(() => {
342
        handleGetMessages();
343
      }, 1000);
344
    } else {
345
      clearInterval(getMessageInterval);
346
    }
347
    return () => {
348
      clearInterval(getMessageInterval);
349
    };
33 steven 350
  });
1 www 351
 
352
  const handleConfirmModalShow = () => {
353
    setConfirmModalShow(!confirmModalShow);
354
  };
355
 
356
  const handleConfirmModalAccept = () => {
357
    handleConfirmModalAction();
358
  };
359
 
360
  const handleShareFileModalShow = () => {
361
    setShareFileModalShow(!shareFileModalShow);
362
  };
363
 
364
  const messagesRender = () => {
365
    return (
366
      <React.Fragment>
367
        {currentPage < pages ? <li ref={loader}>Cargando...</li> : ""}
368
        {oldMessages.map((oldMessage) => (
369
          <MessageTemplate message={oldMessage} />
370
        ))}
371
        {messages.map((message) => (
372
          <MessageTemplate message={message} />
373
        ))}
374
      </React.Fragment>
375
    );
376
  };
377
 
378
  const optionRender = () => {
379
    switch (optionTab) {
380
      case optionTabs.add_person_to_group:
381
        return addPersonToGroupTab;
382
      case optionTabs.group_contacts_list:
383
        return groupContactsListTab;
384
      default:
385
        return optionsDefaultTab;
386
    }
387
  };
388
 
389
  // useEffect for tabs changing
390
  useEffect(() => {
391
    switch (optionTab) {
392
      case optionTabs.add_person_to_group:
393
        loadPersonsAvailable();
394
        break;
395
      case optionTabs.group_contacts_list:
396
        loadGroupContacts();
397
      default:
398
        break;
399
    }
400
  }, [optionTab]);
401
 
402
  const loadPersonsAvailable = async () => {
403
    setOptionsLoading(true);
404
    await axios.get(url_get_contacts_availables_for_group).then((response) => {
405
      const resData = response.data;
406
      if (resData.success) {
407
        setAvailableContactsToAdd(resData.data);
408
      }
409
    });
410
    setOptionsLoading(false);
411
  };
412
 
413
  const loadGroupContacts = async () => {
414
    setOptionsLoading(true);
415
    await axios.get(url_get_contact_group_list).then((response) => {
416
      const resData = response.data;
417
      if (resData.success) {
418
        setGroupContactsList(resData.data);
419
      }
420
    });
421
    setOptionsLoading(false);
422
  };
423
 
424
  const handleDeletePersonFromGroup = async (urlDeletePersonFromGroup) => {
425
    await axios.post(urlDeletePersonFromGroup).then((response) => {
426
      const resData = response.data;
427
      if (resData.success) {
428
        loadGroupContacts();
429
      }
430
    });
431
  };
432
 
433
  const optionsDefaultTab = (
434
    <React.Fragment>
435
      <span className="optionBack" onClick={() => handleShowOptions()}>
436
        <i className="fa icon-arrow-left"></i>
437
      </span>
438
      <div className="optionsTab">
439
        <ul>
440
          {!!url_get_contact_group_list && (
441
            <li
442
              className="optionsTab__option"
443
              onClick={() => handleChangeTab(optionTabs.group_contacts_list)}
444
            >
445
              <span className="optionsTab__option__icon">
446
                <i className="fa fa-group"></i>
447
              </span>
448
              Integrantes
449
            </li>
450
          )}
451
          {!!url_add_user_to_group && (
452
            <li
453
              className="optionsTab__option"
454
              onClick={() => handleChangeTab(optionTabs.add_person_to_group)}
455
            >
456
              <span className="optionsTab__option__icon">
457
                <i className="fa fa-user-plus"></i>
458
              </span>
459
              Agregar contactos
460
            </li>
461
          )}
462
          {!!url_delete && (
463
            <li
464
              className="optionsTab__option"
465
              style={{ color: "red" }}
466
              onClick={() => {
467
                handleConfirmModalShow();
468
                modalActionUrl.current = url_delete;
469
              }}
470
            >
471
              <span className="optionsTab__option__icon">
472
                <i className="fa fa-trash"></i>
473
              </span>
474
              Eliminar grupo
475
            </li>
476
          )}
477
          {!!url_leave && (
478
            <li
479
              className="optionsTab__option"
480
              style={{ color: "red" }}
481
              onClick={() => {
482
                handleConfirmModalShow();
483
                modalActionUrl.current = url_leave;
484
              }}
485
            >
486
              <span className="optionsTab__option__icon">
487
                <i className="fa fa-user-times"></i>
488
              </span>
489
              Dejar grupo
490
            </li>
491
          )}
492
        </ul>
493
      </div>
494
    </React.Fragment>
495
  );
496
 
497
  const addPersonToGroupTab = (
498
    <React.Fragment>
499
      <span
500
        className="optionBack"
501
        onClick={() => handleChangeTab(optionTabs.default)}
502
      >
503
        <i className="fa icon-arrow-left"></i>
504
      </span>
505
      <div className="addPersonToGroupTab">
506
        {availableContactsToAdd.length ? (
507
          availableContactsToAdd.map(({ image, name, id }) => (
508
            <div className="addPersonToGroupTab__person" key={id}>
509
              <img
510
                className="chat-image img-circle pull-left"
511
                height="36"
512
                width="36"
513
                src={image}
514
                alt="image-image"
515
              />
516
              <div className="name">{name}</div>
517
              <span
518
                style={{
519
                  cursor: "pointer",
520
                }}
521
                onClick={() => {
522
                  handleAddPersonToGroup(id);
523
                }}
524
              >
525
                <i className="fa fa-plus-circle"></i>
526
              </span>
527
            </div>
528
          ))
529
        ) : (
530
          <div className="addPersonToGroupTab__person">No hay Contactos</div>
531
        )}
532
      </div>
533
    </React.Fragment>
534
  );
535
 
536
  const groupContactsListTab = (
537
    <React.Fragment>
538
      <span
539
        className="optionBack"
540
        onClick={() => handleChangeTab(optionTabs.default)}
541
      >
542
        <i className="fa icon-arrow-left"></i>
543
      </span>
544
      <div className="addPersonToGroupTab">
545
        {groupContactsList.length ? (
546
          groupContactsList.map(
547
            ({ image, name, url_remove_from_group, id }) => (
548
              <div className="addPersonToGroupTab__person" key={id}>
549
                <div style={{ display: "flex", alignItems: "center" }}>
550
                  <img
551
                    className="chat-image img-circle pull-left"
552
                    height="36"
553
                    width="36"
554
                    src={image}
555
                    alt="image-image"
556
                  />
557
                  <div className="name">{name}</div>
558
                </div>
559
                {url_remove_from_group && (
560
                  <span
561
                    style={{
562
                      cursor: "pointer",
563
                    }}
564
                    onClick={() => {
565
                      handleDeletePersonFromGroup(url_remove_from_group);
566
                    }}
567
                  >
568
                    <i className="fa fa-user-times"></i>
569
                  </span>
570
                )}
571
              </div>
572
            )
573
          )
574
        ) : (
575
          <div className="addPersonToGroupTab__person">No hay Contactos</div>
576
        )}
577
      </div>
578
    </React.Fragment>
579
  );
580
 
581
  const shareFileModal = (
582
    <SendFileModal
583
      show={shareFileModalShow}
584
      onHide={() => {
585
        setShareFileModalShow(false);
586
      }}
587
      urlUpload={url_upload}
588
    />
589
  );
590
 
591
  const userChat = (
592
    <React.Fragment>
593
      <div
594
        className="chatbox active-chat"
595
        style={{
596
          bottom: "0px",
597
          right: `${(index + 1) * 295}px`,
11 steven 598
          zIndex: "1",
1 www 599
          display: "block",
600
        }}
601
      >
602
        <div className="chatbox-icon">
603
          <div className="contact-floating red">
604
            <img className="chat-image img-circle pull-left" src={image} />
605
            <small className="unread-msg">2</small>
606
            {/* <small className="status"'+ status+'></small> */}
607
          </div>
608
        </div>
609
        <div className="panel personal-chat">
610
          <StyledChatHead>
611
            <div
612
              className={`panel-heading chatboxhead ${
613
                unsee_messages ? "notify" : ""
614
              }`}
615
            >
616
              <div className="panel-title">
617
                <img
618
                  className="chat-image img-circle pull-left"
619
                  height="36"
620
                  width="36"
621
                  src={image}
622
                  alt="avatar-image"
623
                />
624
                <div className="header-elements">
625
                  <a href={profile} target="_blank">
626
                    {name}
627
                  </a>
628
                  <br />
629
                  <small className={`status ${online ? "Online" : "Offline"}`}>
630
                    <b>{online ? "Online" : "Offline"}</b>
631
                  </small>
632
                  <div className="pull-right options">
633
                    <div
634
                      className="btn-group uploadFile"
635
                      id="uploadFile"
636
                      data-client="'+chatboxtitle+'"
637
                    >
638
                      {/* <span>
639
                      <i className="fa fa-trash"></i>
640
                    </span> */}
641
                    </div>
642
                    <div
643
                      className="btn-group"
644
                      // onClick="javascript:clearHistory(\''+chatboxtitle+'\')"
645
                      // href="javascript:void(0)"
646
                    >
647
                      {/* <span>
648
                      <i className="fa fa-trash"></i>
649
                    </span> */}
650
                    </div>
651
                    <div
652
                      className="btn-group"
653
                      // onClick="javascript:toggleChatBoxGrowth(\''+chatboxtitle+'\')"
654
                      // href="javascript:void(0)"
655
                    >
656
                      <span>
657
                        <i
658
                          className={`fa fa-minus-circle`}
659
                          onClick={handleActive}
660
                        ></i>
661
                      </span>
662
                    </div>
663
                    <div
664
                      className="btn-group"
665
                      // onClick="javascript:closeChatBox(\''+chatboxtitle+'\')"
666
                      // href="javascript:void(0)"
667
                    >
668
                      <span>
669
                        <i
670
                          className="fa fa-times-circle"
671
                          onClick={handleCloseChat}
672
                        ></i>
673
                      </span>
674
                    </div>
675
                  </div>
676
                </div>
677
              </div>
678
            </div>
679
          </StyledChatHead>
680
          <div
681
            className="panel-body"
682
            style={{ display: !minimized ? "block" : "none" }}
683
          >
684
            <div
685
              id="uploader_'+chatboxtitle+'"
686
              style={{ display: "none", height: "342px" }}
687
            >
688
              <p>
689
                Your browser does not have Flash, Silverlight or HTML5 support.
690
              </p>
691
            </div>
692
            <div className="chat-conversation" style={{ position: "relative" }}>
693
              <div className="reverseChatBox" ref={conversationListEl}>
694
                <ul
695
                  className="conversation-list chatboxcontent"
696
                  id="resultchat_'+chatboxtitle+'"
697
                >
698
                  {messagesRender()}
699
                </ul>
700
              </div>
701
              <div className="wchat-footer wchat-chat-footer chatboxinput">
702
                <div id="chatFrom">
703
                  <div className="block-wchat">
704
                    <button
705
                      className="icon ti-clip attachment font-24 btn-attach btn-attach uploadFile"
706
                      id="uploadFile"
707
                      onClick={handleShareFileModalShow}
708
                    ></button>
709
                    <button
710
                      className="icon ti-face-smile font-24 btn-emoji"
711
                      id="toggle-emoji"
712
                      onClick={handleShowEmojiTab}
713
                    ></button>
714
                    <div className="input-container">
715
                      <div className="input-emoji">
716
                        <div
717
                          className="input-placeholder"
718
                          style={{ visibility: "hidden", display: "none" }}
719
                        >
720
                          Escribe un mensaje
721
                        </div>
722
                        <textarea
723
                          className="input chatboxtextarea"
724
                          id="chatboxtextarea"
725
                          name="chattxt"
726
                          style={{ resize: "none", height: "20px" }}
727
                          placeholder="Escribe un mensaje"
728
                          onKeyDown={handleChatBoxKeyDown}
729
                          ref={textAreaEl}
730
                        ></textarea>
731
                        <input
732
                          id="to_uname"
733
                          name="to_uname"
734
                          value="'+chatboxtitle+'"
735
                          type="hidden"
736
                        />
737
                        <input
738
                          id="from_uname"
739
                          name="from_uname"
740
                          value="Beenny"
741
                          type="hidden"
742
                        />
743
                      </div>
744
                    </div>
745
                  </div>
746
                </div>
747
                <div className="wchat-box-items-positioning-container">
748
                  <div className="wchat-box-items-overlay-container">
749
                    <div
750
                      className="target-emoji"
751
                      style={{ display: showEmojiTab ? "block" : "none" }}
752
                    >
753
                      <div id={`smileyPanel_${id}`}>
754
                        <div>
755
                          <Emojione onClickEmoji={handleClickEmoji} />
756
                        </div>
757
                      </div>
758
                    </div>
759
                  </div>
760
                </div>
761
              </div>
762
            </div>
763
          </div>
764
        </div>
765
      </div>
766
      {shareFileModal}
767
    </React.Fragment>
768
  );
769
 
770
  const groupChat = (
771
    <React.Fragment>
772
      <div
773
        className="chatbox active-chat"
774
        style={{
775
          bottom: "0px",
776
          right: `${(index + 1) * 295}px`,
777
          zIndes: "1",
778
          display: "block",
779
        }}
780
        id={`chatbox_${id}`}
781
        ref={chatboxEl}
782
      >
783
        <div className="chatbox-icon">
784
          <div className="contact-floating red">
785
            <img className="chat-image img-circle pull-left" src={image} />
786
            <small className="unread-msg">2</small>
787
            {/* <small className="status"'+ status+'></small> */}
788
          </div>
789
        </div>
790
        <div className="panel personal-chat">
791
          <StyledChatHead>
792
            <div
793
              className={`panel-heading chatboxhead ${
794
                unsee_messages ? "notify" : ""
795
              }`}
796
            >
797
              <div className="panel-title-group">
798
                <img
799
                  className="chat-image img-circle pull-left"
800
                  height="36"
801
                  width="36"
802
                  src="/images/users-group.png"
803
                  alt="avatar-image"
804
                />
805
                <div className="header-elements">
806
                  <p>{name}</p>
807
                  <br />
808
                  <div className="pull-right options">
809
                    <div
810
                      className="btn-group uploadFile"
811
                      id="uploadFile"
812
                      data-client="'+chatboxtitle+'"
813
                    >
814
                      {/* <span>
815
                      <i className="fa fa-trash"></i>
816
                    </span> */}
817
                    </div>
818
                    <div
819
                      className="btn-group"
820
                      // onClick="javascript:clearHistory(\''+chatboxtitle+'\')"
821
                      // href="javascript:void(0)"
822
                    >
823
                      {/* <span>
824
                      <i className="fa fa-trash"></i>
825
                    </span> */}
826
                    </div>
827
                    <div
828
                      className="btn-group addUser"
829
                      data-client="8cb2a840-56c2-4f93-9cf1-27ad598acd8f"
830
                      data-name="Grupo de jesus"
831
                    >
832
                      <span>
833
                        <i
834
                          // className="fa fa-user-plus"
835
                          className="fa fa-gear"
836
                          onClick={handleShowOptions}
837
                        ></i>
838
                      </span>
839
                    </div>
840
                    <div
841
                      className="btn-group"
842
                      // onClick="javascript:toggleChatBoxGrowth(\''+chatboxtitle+'\')"
843
                      // href="javascript:void(0)"
844
                    >
845
                      <span>
846
                        <i
847
                          className={`fa fa-minus-circle`}
848
                          onClick={handleActive}
849
                        ></i>
850
                      </span>
851
                    </div>
852
                    <div
853
                      className="btn-group"
854
                      // onClick="javascript:closeChatBox(\''+chatboxtitle+'\')"
855
                      // href="javascript:void(0)"
856
                    >
857
                      <span>
858
                        <i
859
                          className="fa fa-times-circle"
860
                          onClick={handleCloseChat}
861
                        ></i>
862
                      </span>
863
                    </div>
864
                  </div>
865
                </div>
866
              </div>
867
            </div>
868
          </StyledChatHead>
869
          <div
870
            className="panel-body"
871
            style={{ display: !minimized ? "block" : "none" }}
872
          >
873
            <StyledShowOptions className={` ${showOptions ? "show" : "hide"}`}>
874
              {optionRender()}
875
            </StyledShowOptions>
876
 
877
            <div
878
              className="chat-conversation"
879
              style={{
880
                display: showOptions ? "none" : "block",
881
                position: "relative",
882
              }}
883
            >
884
              <div className="reverseChatBox" ref={conversationListEl}>
885
                <ul
886
                  className="conversation-list chatboxcontent"
887
                  id="resultchat_'+chatboxtitle+'"
888
                >
889
                  {messagesRender()}
890
                </ul>
891
              </div>
892
              <div className="wchat-footer wchat-chat-footer chatboxinput">
893
                <div id="chatFrom">
894
                  <div className="block-wchat">
895
                    <button
896
                      className="icon ti-clip attachment font-24 btn-attach btn-attach uploadFile"
897
                      id="uploadFile"
898
                      onClick={handleShareFileModalShow}
899
                    ></button>
900
                    <button
901
                      className="icon ti-face-smile font-24 btn-emoji"
902
                      id="toggle-emoji"
903
                      onClick={handleShowEmojiTab}
904
                    ></button>
905
                    <div className="input-container">
906
                      <div className="input-emoji">
907
                        <div
908
                          className="input-placeholder"
909
                          style={{ visibility: "hidden", display: "none" }}
910
                        >
911
                          Escribe un mensaje
912
                        </div>
913
                        <textarea
914
                          className="input chatboxtextarea"
915
                          id="chatboxtextarea"
916
                          name="chattxt"
917
                          style={{ resize: "none", height: "20px" }}
918
                          placeholder="Escribe un mensaje"
919
                          onKeyDown={handleChatBoxKeyDown}
920
                          ref={textAreaEl}
921
                        ></textarea>
922
                        <input
923
                          id="to_uname"
924
                          name="to_uname"
925
                          value="'+chatboxtitle+'"
926
                          type="hidden"
927
                        />
928
                        <input
929
                          id="from_uname"
930
                          name="from_uname"
931
                          value="Beenny"
932
                          type="hidden"
933
                        />
934
                      </div>
935
                    </div>
936
                  </div>
937
                </div>
938
                <div className="wchat-box-items-positioning-container">
939
                  <div className="wchat-box-items-overlay-container">
940
                    <div
941
                      className="target-emoji"
942
                      style={{ display: showEmojiTab ? "block" : "none" }}
943
                    >
944
                      <div id={`smileyPanel_${id}`}>
945
                        <div>
946
                          <Emojione onClickEmoji={handleClickEmoji} />
947
                        </div>
948
                      </div>
949
                    </div>
950
                  </div>
951
                </div>
952
              </div>
953
            </div>
954
          </div>
955
        </div>
956
      </div>
957
      <ConfirmModal
958
        show={confirmModalShow}
959
        onClose={handleConfirmModalShow}
960
        onAccept={handleConfirmModalAccept}
961
      />
962
      {shareFileModal}
963
    </React.Fragment>
964
  );
965
 
966
  switch (type) {
967
    case "user":
968
      return userChat;
969
    case "group":
970
      return groupChat;
971
    default:
972
      break;
973
  }
974
};
975
 
976
export default PersonalChat;