Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 1193 | Rev 1216 | 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 () => {
936 stevensc 183
    await axios.get(`${url_get_all_messages}?page=${currentPage}`)
1 www 184
      .then((response) => {
185
        const resData = response.data;
186
        if (resData.success) {
187
          if (resData.data.page > 1) {
188
            const updatedOldMessages = [...resData.data.items].reverse();
189
            setOldMessages([...updatedOldMessages, ...oldMessages]);
986 stevensc 190
            /* scrollDownBy(100); */
1 www 191
          }
192
        }
193
      });
194
  };
195
 
196
  const handleCloseChat = () => {
197
    onClose(id, url_close);
198
  };
199
 
200
  const handleChatBoxKeyDown = async (e) => {
201
    if (e.key === "Enter") {
202
      e.preventDefault();
203
      const message = e.target.value;
204
      const formData = new FormData();
205
      formData.append("message", emojione.toShort(message));
206
      await axios.post(url_send, formData).then((response) => {
207
        const resData = response.data;
208
        if (resData.success) {
209
        }
210
      });
211
      e.target.value = "";
212
      await handleGetMessages();
213
      setShowEmojiTab(false);
214
    }
215
  };
216
 
217
  const handleShowOptions = () => {
218
    onMinimize(index, false);
219
    setShowOptions(!showOptions);
220
  };
221
 
222
  const handleChangeTab = (tab) => {
223
    setOptionTab(tab);
224
  };
225
 
226
  const handleAddPersonToGroup = async (id) => {
227
    const formData = new FormData();
228
    formData.append("uid", id);
229
    await axios.post(url_add_user_to_group, formData).then((response) => {
230
      const resData = response.data;
231
      if (resData.success) {
232
        loadPersonsAvailable();
233
      }
234
    });
235
  };
236
 
237
  const handleConfirmModalAction = async () => {
238
    await axios.post(modalActionUrl.current).then((response) => {
239
      const resData = response.data;
240
      if (resData.success) {
241
      }
242
    });
243
    await onClose(id, url_close);
244
  };
245
 
246
  const handleObserver = (entities) => {
247
    const target = entities[0];
248
    if (target.isIntersecting) {
249
      setCurrentPage((prevState) => prevState + 1);
250
    }
251
  };
252
 
253
  const scrollToBottom = () => {
254
    if (!!conversationListEl.current) {
255
      conversationListEl.current.scrollTop =
256
        conversationListEl.current.scrollHeight * 9;
257
    }
258
  };
259
 
260
  const scrollDownBy = (scrollDistance) => {
261
    if (!!conversationListEl.current) {
976 stevensc 262
      conversationListEl.current.scrollTop = scrollDistance;
1 www 263
    }
264
  };
265
 
266
  const handleShowEmojiTab = () => {
267
    setShowEmojiTab(!showEmojiTab);
268
    // smiley_tpl(`${id}`);
269
  };
270
 
271
  const handleClickEmoji = (e) => {
272
    const shortname = e.currentTarget.dataset.shortname;
273
    const currentText = textAreaEl.current.value;
274
    let cursorPosition = textAreaEl.current.selectionStart;
275
    const textBehind = currentText.substring(0, cursorPosition);
276
    const textForward = currentText.substring(cursorPosition);
277
    const unicode = emojione.shortnameToUnicode(shortname);
278
    textAreaEl.current.value = `${textBehind}${unicode}${textForward}`;
279
    textAreaEl.current.focus();
280
    textAreaEl.current.setSelectionRange(
281
      cursorPosition + unicode.length,
282
      cursorPosition + unicode.length
283
    );
284
  };
285
 
286
  // useEffect(() => {
287
  //   setMessages([...oldMessages, ...newMessages]);
288
  // }, [newMessages, oldMessages]);
289
 
290
  // getMessageOnMaximize and subscribe to infinite Loader
291
  useEffect(async () => {
292
    if (!minimized) {
293
      await handleGetMessages();
294
      // loader observer
295
      let options = {
296
        root: null,
297
        rootMargin: "20px",
298
        treshold: 1.0,
299
      };
300
      const observer = new IntersectionObserver(handleObserver, options);
301
      if (loader.current) {
302
        observer.observe(loader.current);
303
      }
304
    }
305
    return () => {
306
      if (loader.current) {
307
        observer.unobserve(loader.current);
308
      }
309
    };
310
  }, [minimized]);
311
 
312
  // LoadMore on change page
313
  useEffect(() => {
932 stevensc 314
    let loadMore = () => handleLoadMore();
928 stevensc 315
    loadMore()
1 www 316
    return () => {
317
      loadMore = null;
318
    };
319
  }, [currentPage]);
320
 
321
  // getMessagesInterval
322
  useEffect(() => {
932 stevensc 323
    if (window.location.pathname === '/group/my-groups') {
38 steven 324
      const items = document.getElementsByClassName('sc-jSgupP')
932 stevensc 325
      if (items && items.length > 0)
326
        items[0].style.display = 'none';
38 steven 327
    }
1 www 328
    if (!minimized) {
329
      clearInterval(getMessageInterval);
330
      getMessageInterval = setInterval(() => {
331
        handleGetMessages();
332
      }, 1000);
333
    } else {
334
      clearInterval(getMessageInterval);
335
    }
336
    return () => {
337
      clearInterval(getMessageInterval);
338
    };
33 steven 339
  });
1 www 340
 
341
  const handleConfirmModalShow = () => {
342
    setConfirmModalShow(!confirmModalShow);
343
  };
344
 
345
  const handleConfirmModalAccept = () => {
346
    handleConfirmModalAction();
347
  };
348
 
349
  const handleShareFileModalShow = () => {
350
    setShareFileModalShow(!shareFileModalShow);
351
  };
352
 
353
  const messagesRender = () => {
354
    return (
355
      <React.Fragment>
356
        {currentPage < pages ? <li ref={loader}>Cargando...</li> : ""}
357
        {oldMessages.map((oldMessage) => (
358
          <MessageTemplate message={oldMessage} />
359
        ))}
1215 stevensc 360
        {messages.map((message, i) => {
361
          let currentTime = message.time;
362
          let prevTime = messages[i - 1].time;
363
          const dailys = ['mes', 'semana', 'dias', "anio"]
364
          const date = new Date(Date.now()).toLocaleDateString()
365
 
366
          if (prevTime !== currentTime && prevTime !== undefined && dailys.includes(prevTime.split(' ')[1])) {
367
            return <>
368
              <h2>{date}</h2>
369
              <MessageTemplate message={message} />
370
            </>
371
          }
372
 
373
          return <MessageTemplate message={message} />
374
        })}
1 www 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
932 stevensc 613
              className={`panel-heading chatboxhead ${unsee_messages ? "notify" : ""
614
                }`}
1 www 615
            >
616
              <div className="panel-title">
617
                <img
618
                  className="chat-image img-circle pull-left"
619
                  height="36"
620
                  width="36"
621
                  src={image}
622
                  alt="avatar-image"
623
                />
624
                <div className="header-elements">
625
                  <a href={profile} target="_blank">
626
                    {name}
627
                  </a>
628
                  <br />
1188 stevensc 629
                  <small className={`status ${online ? "Online" : "Offline"}`}>
630
                    <b>{online ? "En línea" : "Desconectado"}</b>
1 www 631
                  </small>
632
                  <div className="pull-right options">
633
                    <div
634
                      className="btn-group uploadFile"
635
                      id="uploadFile"
636
                      data-client="'+chatboxtitle+'"
637
                    >
638
                      {/* <span>
639
                      <i className="fa fa-trash"></i>
640
                    </span> */}
641
                    </div>
642
                    <div
643
                      className="btn-group"
932 stevensc 644
                    // onClick="javascript:clearHistory(\''+chatboxtitle+'\')"
645
                    // href="javascript:void(0)"
1 www 646
                    >
647
                      {/* <span>
648
                      <i className="fa fa-trash"></i>
649
                    </span> */}
650
                    </div>
651
                    <div
652
                      className="btn-group"
932 stevensc 653
                    // onClick="javascript:toggleChatBoxGrowth(\''+chatboxtitle+'\')"
654
                    // href="javascript:void(0)"
1 www 655
                    >
656
                      <span>
657
                        <i
658
                          className={`fa fa-minus-circle`}
659
                          onClick={handleActive}
660
                        ></i>
661
                      </span>
662
                    </div>
663
                    <div
664
                      className="btn-group"
932 stevensc 665
                    // onClick="javascript:closeChatBox(\''+chatboxtitle+'\')"
666
                    // href="javascript:void(0)"
1 www 667
                    >
668
                      <span>
669
                        <i
670
                          className="fa fa-times-circle"
671
                          onClick={handleCloseChat}
672
                        ></i>
673
                      </span>
674
                    </div>
675
                  </div>
676
                </div>
677
              </div>
678
            </div>
679
          </StyledChatHead>
680
          <div
681
            className="panel-body"
682
            style={{ display: !minimized ? "block" : "none" }}
683
          >
684
            <div
685
              id="uploader_'+chatboxtitle+'"
686
              style={{ display: "none", height: "342px" }}
687
            >
688
              <p>
689
                Your browser does not have Flash, Silverlight or HTML5 support.
690
              </p>
691
            </div>
692
            <div className="chat-conversation" style={{ position: "relative" }}>
693
              <div className="reverseChatBox" ref={conversationListEl}>
694
                <ul
695
                  className="conversation-list chatboxcontent"
696
                  id="resultchat_'+chatboxtitle+'"
697
                >
698
                  {messagesRender()}
699
                </ul>
700
              </div>
701
              <div className="wchat-footer wchat-chat-footer chatboxinput">
702
                <div id="chatFrom">
703
                  <div className="block-wchat">
704
                    <button
705
                      className="icon ti-clip attachment font-24 btn-attach btn-attach uploadFile"
706
                      id="uploadFile"
707
                      onClick={handleShareFileModalShow}
708
                    ></button>
709
                    <button
710
                      className="icon ti-face-smile font-24 btn-emoji"
711
                      id="toggle-emoji"
712
                      onClick={handleShowEmojiTab}
713
                    ></button>
714
                    <div className="input-container">
715
                      <div className="input-emoji">
716
                        <div
717
                          className="input-placeholder"
718
                          style={{ visibility: "hidden", display: "none" }}
719
                        >
720
                          Escribe un mensaje
721
                        </div>
722
                        <textarea
723
                          className="input chatboxtextarea"
724
                          id="chatboxtextarea"
725
                          name="chattxt"
726
                          style={{ resize: "none", height: "20px" }}
727
                          placeholder="Escribe un mensaje"
728
                          onKeyDown={handleChatBoxKeyDown}
729
                          ref={textAreaEl}
730
                        ></textarea>
731
                        <input
732
                          id="to_uname"
733
                          name="to_uname"
734
                          value="'+chatboxtitle+'"
735
                          type="hidden"
736
                        />
737
                        <input
738
                          id="from_uname"
739
                          name="from_uname"
740
                          value="Beenny"
741
                          type="hidden"
742
                        />
743
                      </div>
744
                    </div>
745
                  </div>
746
                </div>
747
                <div className="wchat-box-items-positioning-container">
748
                  <div className="wchat-box-items-overlay-container">
749
                    <div
750
                      className="target-emoji"
751
                      style={{ display: showEmojiTab ? "block" : "none" }}
752
                    >
753
                      <div id={`smileyPanel_${id}`}>
754
                        <div>
755
                          <Emojione onClickEmoji={handleClickEmoji} />
756
                        </div>
757
                      </div>
758
                    </div>
759
                  </div>
760
                </div>
761
              </div>
762
            </div>
763
          </div>
764
        </div>
765
      </div>
766
      {shareFileModal}
767
    </React.Fragment>
768
  );
769
 
770
  const groupChat = (
771
    <React.Fragment>
772
      <div
773
        className="chatbox active-chat"
774
        style={{
775
          bottom: "0px",
776
          right: `${(index + 1) * 295}px`,
777
          zIndes: "1",
778
          display: "block",
779
        }}
780
        id={`chatbox_${id}`}
781
        ref={chatboxEl}
782
      >
783
        <div className="chatbox-icon">
784
          <div className="contact-floating red">
785
            <img className="chat-image img-circle pull-left" src={image} />
786
            <small className="unread-msg">2</small>
787
            {/* <small className="status"'+ status+'></small> */}
788
          </div>
789
        </div>
790
        <div className="panel personal-chat">
791
          <StyledChatHead>
792
            <div
932 stevensc 793
              className={`panel-heading chatboxhead ${unsee_messages ? "notify" : ""
794
                }`}
1 www 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"
932 stevensc 819
                    // onClick="javascript:clearHistory(\''+chatboxtitle+'\')"
820
                    // href="javascript:void(0)"
1 www 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"
932 stevensc 841
                    // onClick="javascript:toggleChatBoxGrowth(\''+chatboxtitle+'\')"
842
                    // href="javascript:void(0)"
1 www 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"
932 stevensc 853
                    // onClick="javascript:closeChatBox(\''+chatboxtitle+'\')"
854
                    // href="javascript:void(0)"
1 www 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;