Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 31 | Rev 33 | Ir a la última revisión | | Comparar con el anterior | Ultima modificación | Ver Log |

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