Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

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