Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

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