Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

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