Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

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