Rev 2511 | Rev 5140 | Ir a la última revisión | Autoría | Comparar con el anterior | Ultima modificación | Ver Log |
/* eslint-disable camelcase */
import React, { useEffect, useState } from 'react'
import { axios } from '../../../utils'
import { connect } from 'react-redux'
import { addNotification } from '../../../redux/notification/notification.actions'
import Profile from '../../../components/Profile'
import SearchList from '../../../components/SearchList'
import Spinner from '../../../shared/loading-spinner/Spinner'
import EmptySection from '../../../shared/empty-section/EmptySection'
import TitleSection from '../../../components/TitleSection'
const InvitationsSent = () => {
const [sentInvitations, setSentInvitations] = useState([])
const [loading, setLoading] = useState(false)
useEffect(() => {
fetchInvitations()
}, [])
const fetchInvitations = async (searchValue = '') => {
setLoading(true)
await axios
.get('/connection/invitations-sent?search=' + searchValue)
.then(({ data: response }) => {
if (response.success) setSentInvitations(response.data)
})
setLoading(false)
}
return (
<section className="companies-info container">
<TitleSection title={LABELS.INVITATIONS_SENT} />
<SearchList onChange={fetchInvitations} />
<div className="companies-list">
{sentInvitations.length > 0
? sentInvitations.map(({ name, image, link_delete, link_view }, id) =>
<Profile
key={id}
image={image}
name={name}
link_delete={link_delete}
link_view={link_view}
fetchCallback={fetchInvitations}
btnCancelTitle={LABELS.REQUEST_CANCEL}
/>
)
: <EmptySection align='left' message={LABELS.DATATABLE_SZERORECORDS} />
}
{loading && <Spinner />}
</div>
</section>
)
}
const mapDispatchToProps = {
addNotification: (notification) => addNotification(notification)
}
export default connect(null, mapDispatchToProps)(InvitationsSent)