Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 4872 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 4872 Rev 4880
Línea 15... Línea 15...
15
import AddIcon from '@mui/icons-material/Add'
15
import AddIcon from '@mui/icons-material/Add'
Línea 16... Línea 16...
16
 
16
 
Línea 17... Línea 17...
17
const notifyAudio = new Audio("/audio/chat.mp3");
17
const notifyAudio = new Audio("/audio/chat.mp3");
18
 
-
 
19
const Chat = (props) => {
18
 
20
 
19
const Chat = (props) => {
21
  // states
20
  // states
22
  const [contacts, setContacts] = useState([]);
21
  const [contacts, setContacts] = useState([]);
23
  const [groups, setGroups] = useState([]);
22
  const [groups, setGroups] = useState([]);
Línea 27... Línea 26...
27
  const [showModal, setShowModal] = useState(false);
26
  const [showModal, setShowModal] = useState(false);
28
  const [activeTab, setActiveTab] = useState("user");
27
  const [activeTab, setActiveTab] = useState("user");
29
  const [search, setSearch] = useState('');
28
  const [search, setSearch] = useState('');
30
  const [loading, setLoading] = useState(false);
29
  const [loading, setLoading] = useState(false);
31
  const [pendingConversation, setPendingConversation] = useState('')
30
  const [pendingConversation, setPendingConversation] = useState('')
-
 
31
  
-
 
32
  const { defaultNetwork } = props
Línea 32... Línea 33...
32
 
33
 
33
  const filtredContacts = contacts.filter(({ name }) => name.toLowerCase().includes(search.toLowerCase()))
34
  const filtredContacts = contacts.filter(({ name }) => name.toLowerCase().includes(search.toLowerCase()))
Línea 34... Línea 35...
34
  const filtredGroups = groups.filter(({ name }) => name.toLowerCase().includes(search.toLowerCase()))
35
  const filtredGroups = groups.filter(({ name }) => name.toLowerCase().includes(search.toLowerCase()))
Línea 189... Línea 190...
189
 
190
 
190
      if (pendingChat) {
191
      if (pendingChat) {
191
        handleOpenConversation(pendingChat)
192
        handleOpenConversation(pendingChat)
192
        setPendingConversation('')
193
        setPendingConversation('')
193
      }
194
      }
194
      
195
 
195
    }
196
    }
Línea 196... Línea 197...
196
  }, [pendingConversation, contacts])
197
  }, [pendingConversation, contacts])
197
 
198
 
Línea 245... Línea 246...
245
                        value={search}
246
                        value={search}
246
                        onChange={(e) => setSearch(e.target.value)}
247
                        onChange={(e) => setSearch(e.target.value)}
247
                      />
248
                      />
248
                      <i className="searchbutton fas fa-search" />
249
                      <i className="searchbutton fas fa-search" />
249
                    </div>
250
                    </div>
-
 
251
                    {defaultNetwork !== 'y' &&
250
                    <div
252
                      <div
251
                      className="d-flex align-items-center cursor-pointer"
253
                        className="d-flex align-items-center cursor-pointer"
252
                      style={{ gap: '.5rem', background: '#fff' }}
254
                        style={{ gap: '.5rem', background: '#fff' }}
253
                      onClick={() => setShowModal(!showModal)}
255
                        onClick={() => setShowModal(true)}
254
                    >
256
                      >
255
                      <AddIcon />
257
                        <AddIcon />
256
                      <span>Iniciar conversación</span>
258
                        <span>Iniciar conversación</span>
257
                    </div>
259
                      </div>
-
 
260
                    }
258
                    <div className="drupalchat_search_main chatboxinput">
261
                    <div className="drupalchat_search_main chatboxinput">
259
                      <button
262
                      <button
260
                        className={`${activeTab === 'user' ? 'active' : ''}`}
263
                        className={`${activeTab === 'user' ? 'active' : ''}`}
261
                        onClick={() => handleChangeTab("user")}
264
                        onClick={() => handleChangeTab("user")}
262
                      >
265
                      >
Línea 326... Línea 329...
326
      <Chat.ContactsModal
329
      <Chat.ContactsModal
327
        show={showModal}
330
        show={showModal}
328
        setConversation={(url) => setPendingConversation(url)}
331
        setConversation={(url) => setPendingConversation(url)}
329
      />
332
      />
330
      <NotificationAlert />
333
      <NotificationAlert />
331
    </React.Fragment>
334
    </React.Fragment >
332
  ) : (
335
  ) : (
333
    ""
336
    ""
334
  );
337
  );
335
}
338
}
Línea 339... Línea 342...
339
  const [isShow, setIsShow] = useState(show)
342
  const [isShow, setIsShow] = useState(show)
340
  const [searchResult, setSearchResult] = useState({})
343
  const [searchResult, setSearchResult] = useState({})
341
  const [loading, setLoading] = useState(false)
344
  const [loading, setLoading] = useState(false)
342
  const dispatch = useDispatch()
345
  const dispatch = useDispatch()
Línea 343... Línea 346...
343
 
346
 
-
 
347
  const closeModal = () => {
-
 
348
    setIsShow(false)
-
 
349
    setSearchResult({})
Línea 344... Línea 350...
344
  const closeModal = () => setIsShow(false)
350
  }
345
 
351
 
346
  const handleSearch = (contact) => {
352
  const handleSearch = (contact) => {
347
    clearTimeout(axiosThrottle)
353
    clearTimeout(axiosThrottle)
Línea 362... Línea 368...
362
  }
368
  }
Línea 363... Línea 369...
363
 
369
 
364
  const startConversation = async (send_url = '', name = '') => {
370
  const startConversation = async (send_url = '', name = '') => {
365
    const formData = new FormData()
371
    const formData = new FormData()
366
    const fullName = name.split(' ')
372
    const fullName = name.split(' ')
Línea 367... Línea 373...
367
    formData.append("message", `Hola, ${fullName[0]} ${fullName[2]}`)
373
    formData.append("message", `Hola, ${fullName[0]}`)
368
 
374
 
369
    setLoading(true)
375
    setLoading(true)
370
    await axios
376
    await axios