Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

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