Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

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