Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

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