Proyectos de Subversion LeadersLinked - SPA

Rev

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

Rev 3416 Rev 3432
Línea 1... Línea 1...
1
import React, { useEffect, useState } from "react";
1
import React, { useEffect, useState } from 'react'
2
import { useNavigate } from "react-router-dom";
2
import { useNavigate } from 'react-router-dom'
3
import { useSelector } from "react-redux";
3
import { useSelector } from 'react-redux'
4
import {
4
import {
5
  Avatar,
5
  Avatar,
6
  List,
6
  List,
7
  ListItem,
7
  ListItem,
8
  ListItemAvatar,
8
  ListItemAvatar,
9
  ListItemButton,
9
  ListItemButton,
10
  ListItemText,
10
  ListItemText
11
} from "@mui/material";
11
} from '@mui/material'
Línea 12... Línea 12...
12
 
12
 
13
import { useDebounce } from "@hooks";
13
import { useDebounce } from '@hooks'
Línea 14... Línea 14...
14
import { axios } from "../../utils";
14
import { axios } from '../../utils'
15
 
15
 
Línea 16... Línea 16...
16
import Input from "../UI/inputs/Input";
16
import Input from '../UI/inputs/input'
17
import Modal from "../UI/modal/Modal";
17
import Modal from '../UI/modal/Modal'
18
 
18
 
19
const StartConversationModal = ({ show, setConversation, onClose }) => {
19
const StartConversationModal = ({ show, setConversation, onClose }) => {
20
  const [users, setUsers] = useState([]);
20
  const [users, setUsers] = useState([])
21
  const [search, setSearch] = useState("");
21
  const [search, setSearch] = useState('')
Línea 22... Línea 22...
22
  const debouncedSearch = useDebounce(search, 500);
22
  const debouncedSearch = useDebounce(search, 500)
23
  const navigate = useNavigate();
23
  const navigate = useNavigate()
24
  const labels = useSelector(({ intl }) => intl.labels);
-
 
25
 
24
  const labels = useSelector(({ intl }) => intl.labels)
26
  const searchUsers = async (value) => {
-
 
27
    try {
25
 
28
      const { data } = await axios.get(
26
  const searchUsers = async (value) => {
29
        "/helpers/search-people?search=" + value
27
    try {
30
      );
28
      const { data } = await axios.get('/helpers/search-people?search=' + value)
31
      if (data.success) setUsers(data.data);
29
      if (data.success) setUsers(data.data)
Línea 32... Línea 30...
32
    } catch (error) {
30
    } catch (error) {
33
      console.log(">>: error > ", error);
31
      console.log('>>: error > ', error)
34
    }
32
    }
35
  };
33
  }
Línea 36... Línea 34...
36
 
34
 
37
  const openChat = (uuid) => {
35
  const openChat = (uuid) => {
38
    navigate(`/inmail/${uuid}`);
36
    navigate(`/inmail/${uuid}`)
Línea 39... Línea 37...
39
    onClose();
37
    onClose()
40
  };
38
  }
41
 
39
 
42
  useEffect(() => {
40
  useEffect(() => {
43
    searchUsers(debouncedSearch);
41
    searchUsers(debouncedSearch)
44
  }, [debouncedSearch]);
42
  }, [debouncedSearch])
45
 
43
 
46
  return (
44
  return (
Línea 47... Línea 45...
47
    <Modal title={labels.create_inmail} show={show} onClose={onClose}>
45
    <Modal title={labels.create_inmail} show={show} onClose={onClose}>
48
      <Input
46
      <Input
49
        label={labels.write_name}
47
        label={labels.write_name}
Línea 50... Línea 48...
50
        placeholder={labels.write_person_name}
48
        placeholder={labels.write_person_name}
51
        onChange={(e) => setSearch(e.target.value)}
49
        onChange={(e) => setSearch(e.target.value)}
52
        value={search}
50
        value={search}
53
      />
51
      />
54
 
52
 
55
      <List sx={{ width: "100%" }}>
53
      <List sx={{ width: '100%' }}>
Línea 56... Línea 54...
56
        {users.map((user) => {
54
        {users.map((user) => {
57
          const { text, value } = user;
55
          const { text, value } = user
58
 
56
 
59
          return (
57
          return (
60
            <ListItem key={value} disablePadding disableRipple>
58
            <ListItem key={value} disablePadding disableRipple>
61
              <ListItemButton disableRipple onClick={() => openChat(value)}>
59
              <ListItemButton disableRipple onClick={() => openChat(value)}>
62
                <ListItemAvatar>
60
                <ListItemAvatar>
63
                  <Avatar alt={`${text} image`} src="" />
61
                  <Avatar alt={`${text} image`} src='' />
64
                </ListItemAvatar>
62
                </ListItemAvatar>
Línea 65... Línea 63...
65
 
63