Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

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