Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

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

Rev 6007 Rev 6312
Línea 8... Línea 8...
8
import SendIcon from '@mui/icons-material/Send'
8
import SendIcon from '@mui/icons-material/Send'
Línea 9... Línea 9...
9
 
9
 
10
// Components
10
// Components
Línea 11... Línea 11...
11
import Spinner from '../../../shared/loading-spinner/Spinner'
11
import Spinner from '../../../shared/loading-spinner/Spinner'
12
 
12
 
13
const ContactsModal = ({ show, onClose }) => {
13
const ContactsModal = ({ show, onClose, onComplete }) => {
14
  const [isShow, setIsShow] = useState(show)
14
  const [isShow, setIsShow] = useState(show)
15
  const [contacts, setContacts] = useState([])
15
  const [contacts, setContacts] = useState([])
Línea 37... Línea 37...
37
        setContacts(response.data)
37
        setContacts(response.data)
38
      })
38
      })
39
      .finally(() => setLoading(false))
39
      .finally(() => setLoading(false))
40
  }
40
  }
Línea 41... Línea 41...
41
 
41
 
42
  const startConversation = (create_url = '') => {
42
  const startConversation = ({ link_open_or_create, link_send }) => {
43
    setLoading(true)
43
    setLoading(true)
44
    axios
44
    axios
45
      .post(create_url)
45
      .post(link_open_or_create)
46
      .then(({ data: response }) => {
46
      .then(({ data: response }) => {
-
 
47
        if (response.success) {
-
 
48
          closeModal()
-
 
49
          onComplete(link_send)
47
        if (response.success) closeModal()
50
        }
48
      })
51
      })
49
      .finally(() => setLoading(false))
52
      .finally(() => setLoading(false))
Línea 50... Línea 53...
50
  }
53
  }
Línea 70... Línea 73...
70
        </div>
73
        </div>
71
        {loading ? (
74
        {loading ? (
72
          <Spinner />
75
          <Spinner />
73
        ) : (
76
        ) : (
74
          <ul className="d-flex flex-column gap-3">
77
          <ul className="d-flex flex-column gap-3">
75
            {contacts.map(({ name, image, link_open_or_create }) => (
78
            {contacts.map((user) => (
76
              <li key={name}>
79
              <li key={user.name}>
77
                <div className="d-flex align-items-center justify-content-between gap-3">
80
                <div className="d-flex align-items-center justify-content-between gap-3">
78
                  <div className="d-flex align-items-center gap-3">
81
                  <div className="d-flex align-items-center gap-3">
79
                    <img
82
                    <img
80
                      src={image}
83
                      src={user.image}
81
                      alt={`User ${name} image`}
84
                      alt={`User ${user.name} image`}
82
                      width={40}
85
                      width={40}
83
                      height={40}
86
                      height={40}
84
                      style={{ borderRadius: '50%' }}
87
                      style={{ borderRadius: '50%' }}
85
                    />
88
                    />
86
                    <p>{name}</p>
89
                    <p>{user.name}</p>
87
                  </div>
90
                  </div>
Línea 88... Línea 91...
88
 
91
 
89
                  <button
92
                  <button
90
                    className="btn btn-primary"
93
                    className="btn btn-primary"
91
                    onClick={() => startConversation(link_open_or_create)}
94
                    onClick={() => startConversation(user)}
92
                  >
95
                  >
93
                    <SendIcon />
96
                    <SendIcon />
94
                  </button>
97
                  </button>
95
                </div>
98
                </div>