Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 39 | Rev 928 | 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(() => {
38 steven 327
    if(window.location.pathname === '/group/my-groups'){
328
      const items = document.getElementsByClassName('sc-jSgupP')
329
      if(items && items.length > 0)
330
        items[0].style.display='none';
331
    }
1 www 332
    if (!minimized) {
333
      clearInterval(getMessageInterval);
334
      getMessageInterval = setInterval(() => {
335
        handleGetMessages();
336
      }, 1000);
337
    } else {
338
      clearInterval(getMessageInterval);
339
    }
340
    return () => {
341
      clearInterval(getMessageInterval);
342
    };
33 steven 343
  });
1 www 344
 
345
  const handleConfirmModalShow = () => {
346
    setConfirmModalShow(!confirmModalShow);
347
  };
348
 
349
  const handleConfirmModalAccept = () => {
350
    handleConfirmModalAction();
351
  };
352
 
353
  const handleShareFileModalShow = () => {
354
    setShareFileModalShow(!shareFileModalShow);
355
  };
356
 
357
  const messagesRender = () => {
358
    return (
359
      <React.Fragment>
360
        {currentPage < pages ? <li ref={loader}>Cargando...</li> : ""}
361
        {oldMessages.map((oldMessage) => (
362
          <MessageTemplate message={oldMessage} />
363
        ))}
364
        {messages.map((message) => (
365
          <MessageTemplate message={message} />
366
        ))}
367
      </React.Fragment>
368
    );
369
  };
370
 
371
  const optionRender = () => {
372
    switch (optionTab) {
373
      case optionTabs.add_person_to_group:
374
        return addPersonToGroupTab;
375
      case optionTabs.group_contacts_list:
376
        return groupContactsListTab;
377
      default:
378
        return optionsDefaultTab;
379
    }
380
  };
381
 
382
  // useEffect for tabs changing
383
  useEffect(() => {
384
    switch (optionTab) {
385
      case optionTabs.add_person_to_group:
386
        loadPersonsAvailable();
387
        break;
388
      case optionTabs.group_contacts_list:
389
        loadGroupContacts();
390
      default:
391
        break;
392
    }
393
  }, [optionTab]);
394
 
395
  const loadPersonsAvailable = async () => {
396
    setOptionsLoading(true);
397
    await axios.get(url_get_contacts_availables_for_group).then((response) => {
398
      const resData = response.data;
399
      if (resData.success) {
400
        setAvailableContactsToAdd(resData.data);
401
      }
402
    });
403
    setOptionsLoading(false);
404
  };
405
 
406
  const loadGroupContacts = async () => {
407
    setOptionsLoading(true);
408
    await axios.get(url_get_contact_group_list).then((response) => {
409
      const resData = response.data;
410
      if (resData.success) {
411
        setGroupContactsList(resData.data);
412
      }
413
    });
414
    setOptionsLoading(false);
415
  };
416
 
417
  const handleDeletePersonFromGroup = async (urlDeletePersonFromGroup) => {
418
    await axios.post(urlDeletePersonFromGroup).then((response) => {
419
      const resData = response.data;
420
      if (resData.success) {
421
        loadGroupContacts();
422
      }
423
    });
424
  };
425
 
426
  const optionsDefaultTab = (
427
    <React.Fragment>
428
      <span className="optionBack" onClick={() => handleShowOptions()}>
429
        <i className="fa icon-arrow-left"></i>
430
      </span>
431
      <div className="optionsTab">
432
        <ul>
433
          {!!url_get_contact_group_list && (
434
            <li
435
              className="optionsTab__option"
436
              onClick={() => handleChangeTab(optionTabs.group_contacts_list)}
437
            >
438
              <span className="optionsTab__option__icon">
439
                <i className="fa fa-group"></i>
440
              </span>
441
              Integrantes
442
            </li>
443
          )}
444
          {!!url_add_user_to_group && (
445
            <li
446
              className="optionsTab__option"
447
              onClick={() => handleChangeTab(optionTabs.add_person_to_group)}
448
            >
449
              <span className="optionsTab__option__icon">
450
                <i className="fa fa-user-plus"></i>
451
              </span>
452
              Agregar contactos
453
            </li>
454
          )}
455
          {!!url_delete && (
456
            <li
457
              className="optionsTab__option"
458
              style={{ color: "red" }}
459
              onClick={() => {
460
                handleConfirmModalShow();
461
                modalActionUrl.current = url_delete;
462
              }}
463
            >
464
              <span className="optionsTab__option__icon">
465
                <i className="fa fa-trash"></i>
466
              </span>
467
              Eliminar grupo
468
            </li>
469
          )}
470
          {!!url_leave && (
471
            <li
472
              className="optionsTab__option"
473
              style={{ color: "red" }}
474
              onClick={() => {
475
                handleConfirmModalShow();
476
                modalActionUrl.current = url_leave;
477
              }}
478
            >
479
              <span className="optionsTab__option__icon">
480
                <i className="fa fa-user-times"></i>
481
              </span>
482
              Dejar grupo
483
            </li>
484
          )}
485
        </ul>
486
      </div>
487
    </React.Fragment>
488
  );
489
 
490
  const addPersonToGroupTab = (
491
    <React.Fragment>
492
      <span
493
        className="optionBack"
494
        onClick={() => handleChangeTab(optionTabs.default)}
495
      >
496
        <i className="fa icon-arrow-left"></i>
497
      </span>
498
      <div className="addPersonToGroupTab">
499
        {availableContactsToAdd.length ? (
500
          availableContactsToAdd.map(({ image, name, id }) => (
501
            <div className="addPersonToGroupTab__person" key={id}>
502
              <img
503
                className="chat-image img-circle pull-left"
504
                height="36"
505
                width="36"
506
                src={image}
507
                alt="image-image"
508
              />
509
              <div className="name">{name}</div>
510
              <span
511
                style={{
512
                  cursor: "pointer",
513
                }}
514
                onClick={() => {
515
                  handleAddPersonToGroup(id);
516
                }}
517
              >
518
                <i className="fa fa-plus-circle"></i>
519
              </span>
520
            </div>
521
          ))
522
        ) : (
523
          <div className="addPersonToGroupTab__person">No hay Contactos</div>
524
        )}
525
      </div>
526
    </React.Fragment>
527
  );
528
 
529
  const groupContactsListTab = (
530
    <React.Fragment>
531
      <span
532
        className="optionBack"
533
        onClick={() => handleChangeTab(optionTabs.default)}
534
      >
535
        <i className="fa icon-arrow-left"></i>
536
      </span>
537
      <div className="addPersonToGroupTab">
538
        {groupContactsList.length ? (
539
          groupContactsList.map(
540
            ({ image, name, url_remove_from_group, id }) => (
541
              <div className="addPersonToGroupTab__person" key={id}>
542
                <div style={{ display: "flex", alignItems: "center" }}>
543
                  <img
544
                    className="chat-image img-circle pull-left"
545
                    height="36"
546
                    width="36"
547
                    src={image}
548
                    alt="image-image"
549
                  />
550
                  <div className="name">{name}</div>
551
                </div>
552
                {url_remove_from_group && (
553
                  <span
554
                    style={{
555
                      cursor: "pointer",
556
                    }}
557
                    onClick={() => {
558
                      handleDeletePersonFromGroup(url_remove_from_group);
559
                    }}
560
                  >
561
                    <i className="fa fa-user-times"></i>
562
                  </span>
563
                )}
564
              </div>
565
            )
566
          )
567
        ) : (
568
          <div className="addPersonToGroupTab__person">No hay Contactos</div>
569
        )}
570
      </div>
571
    </React.Fragment>
572
  );
573
 
574
  const shareFileModal = (
575
    <SendFileModal
576
      show={shareFileModalShow}
577
      onHide={() => {
578
        setShareFileModalShow(false);
579
      }}
580
      urlUpload={url_upload}
581
    />
582
  );
583
 
584
  const userChat = (
585
    <React.Fragment>
586
      <div
587
        className="chatbox active-chat"
588
        style={{
589
          bottom: "0px",
590
          right: `${(index + 1) * 295}px`,
11 steven 591
          zIndex: "1",
1 www 592
          display: "block",
593
        }}
594
      >
595
        <div className="chatbox-icon">
596
          <div className="contact-floating red">
597
            <img className="chat-image img-circle pull-left" src={image} />
598
            <small className="unread-msg">2</small>
599
            {/* <small className="status"'+ status+'></small> */}
600
          </div>
601
        </div>
602
        <div className="panel personal-chat">
603
          <StyledChatHead>
604
            <div
605
              className={`panel-heading chatboxhead ${
606
                unsee_messages ? "notify" : ""
607
              }`}
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"
637
                      // onClick="javascript:clearHistory(\''+chatboxtitle+'\')"
638
                      // href="javascript:void(0)"
639
                    >
640
                      {/* <span>
641
                      <i className="fa fa-trash"></i>
642
                    </span> */}
643
                    </div>
644
                    <div
645
                      className="btn-group"
646
                      // onClick="javascript:toggleChatBoxGrowth(\''+chatboxtitle+'\')"
647
                      // href="javascript:void(0)"
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"
658
                      // onClick="javascript:closeChatBox(\''+chatboxtitle+'\')"
659
                      // href="javascript:void(0)"
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
786
              className={`panel-heading chatboxhead ${
787
                unsee_messages ? "notify" : ""
788
              }`}
789
            >
790
              <div className="panel-title-group">
791
                <img
792
                  className="chat-image img-circle pull-left"
793
                  height="36"
794
                  width="36"
795
                  src="/images/users-group.png"
796
                  alt="avatar-image"
797
                />
798
                <div className="header-elements">
799
                  <p>{name}</p>
800
                  <br />
801
                  <div className="pull-right options">
802
                    <div
803
                      className="btn-group uploadFile"
804
                      id="uploadFile"
805
                      data-client="'+chatboxtitle+'"
806
                    >
807
                      {/* <span>
808
                      <i className="fa fa-trash"></i>
809
                    </span> */}
810
                    </div>
811
                    <div
812
                      className="btn-group"
813
                      // onClick="javascript:clearHistory(\''+chatboxtitle+'\')"
814
                      // href="javascript:void(0)"
815
                    >
816
                      {/* <span>
817
                      <i className="fa fa-trash"></i>
818
                    </span> */}
819
                    </div>
820
                    <div
821
                      className="btn-group addUser"
822
                      data-client="8cb2a840-56c2-4f93-9cf1-27ad598acd8f"
823
                      data-name="Grupo de jesus"
824
                    >
825
                      <span>
826
                        <i
827
                          // className="fa fa-user-plus"
828
                          className="fa fa-gear"
829
                          onClick={handleShowOptions}
830
                        ></i>
831
                      </span>
832
                    </div>
833
                    <div
834
                      className="btn-group"
835
                      // onClick="javascript:toggleChatBoxGrowth(\''+chatboxtitle+'\')"
836
                      // href="javascript:void(0)"
837
                    >
838
                      <span>
839
                        <i
840
                          className={`fa fa-minus-circle`}
841
                          onClick={handleActive}
842
                        ></i>
843
                      </span>
844
                    </div>
845
                    <div
846
                      className="btn-group"
847
                      // onClick="javascript:closeChatBox(\''+chatboxtitle+'\')"
848
                      // href="javascript:void(0)"
849
                    >
850
                      <span>
851
                        <i
852
                          className="fa fa-times-circle"
853
                          onClick={handleCloseChat}
854
                        ></i>
855
                      </span>
856
                    </div>
857
                  </div>
858
                </div>
859
              </div>
860
            </div>
861
          </StyledChatHead>
862
          <div
863
            className="panel-body"
864
            style={{ display: !minimized ? "block" : "none" }}
865
          >
866
            <StyledShowOptions className={` ${showOptions ? "show" : "hide"}`}>
867
              {optionRender()}
868
            </StyledShowOptions>
869
 
870
            <div
871
              className="chat-conversation"
872
              style={{
873
                display: showOptions ? "none" : "block",
874
                position: "relative",
875
              }}
876
            >
877
              <div className="reverseChatBox" ref={conversationListEl}>
878
                <ul
879
                  className="conversation-list chatboxcontent"
880
                  id="resultchat_'+chatboxtitle+'"
881
                >
882
                  {messagesRender()}
883
                </ul>
884
              </div>
885
              <div className="wchat-footer wchat-chat-footer chatboxinput">
886
                <div id="chatFrom">
887
                  <div className="block-wchat">
888
                    <button
889
                      className="icon ti-clip attachment font-24 btn-attach btn-attach uploadFile"
890
                      id="uploadFile"
891
                      onClick={handleShareFileModalShow}
892
                    ></button>
893
                    <button
894
                      className="icon ti-face-smile font-24 btn-emoji"
895
                      id="toggle-emoji"
896
                      onClick={handleShowEmojiTab}
897
                    ></button>
898
                    <div className="input-container">
899
                      <div className="input-emoji">
900
                        <div
901
                          className="input-placeholder"
902
                          style={{ visibility: "hidden", display: "none" }}
903
                        >
904
                          Escribe un mensaje
905
                        </div>
906
                        <textarea
907
                          className="input chatboxtextarea"
908
                          id="chatboxtextarea"
909
                          name="chattxt"
910
                          style={{ resize: "none", height: "20px" }}
911
                          placeholder="Escribe un mensaje"
912
                          onKeyDown={handleChatBoxKeyDown}
913
                          ref={textAreaEl}
914
                        ></textarea>
915
                        <input
916
                          id="to_uname"
917
                          name="to_uname"
918
                          value="'+chatboxtitle+'"
919
                          type="hidden"
920
                        />
921
                        <input
922
                          id="from_uname"
923
                          name="from_uname"
924
                          value="Beenny"
925
                          type="hidden"
926
                        />
927
                      </div>
928
                    </div>
929
                  </div>
930
                </div>
931
                <div className="wchat-box-items-positioning-container">
932
                  <div className="wchat-box-items-overlay-container">
933
                    <div
934
                      className="target-emoji"
935
                      style={{ display: showEmojiTab ? "block" : "none" }}
936
                    >
937
                      <div id={`smileyPanel_${id}`}>
938
                        <div>
939
                          <Emojione onClickEmoji={handleClickEmoji} />
940
                        </div>
941
                      </div>
942
                    </div>
943
                  </div>
944
                </div>
945
              </div>
946
            </div>
947
          </div>
948
        </div>
949
      </div>
950
      <ConfirmModal
951
        show={confirmModalShow}
952
        onClose={handleConfirmModalShow}
953
        onAccept={handleConfirmModalAccept}
954
      />
955
      {shareFileModal}
956
    </React.Fragment>
957
  );
958
 
959
  switch (type) {
960
    case "user":
961
      return userChat;
962
    case "group":
963
      return groupChat;
964
    default:
965
      break;
966
  }
967
};
968
 
969
export default PersonalChat;