Rev 5144 | AutorÃa | Comparar con el anterior | Ultima modificación | Ver Log |
/* eslint-disable camelcase */import React, { useEffect, useState } from 'react'import { connect } from 'react-redux'import { debounce } from '../../../utils'import { searchEntities } from '../../../services/search'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)const response = await searchEntities('connection/invitations-sent', searchValue)if (!response.success) {addNotification({ style: 'danger', msg: response.data })setLoading(false)return}setSentInvitations(response.data)setLoading(false)}const handleSearch = debounce((value) => fetchInvitations(value), 500)return (<section className="companies-info container"><TitleSection title={LABELS.INVITATIONS_SENT} /><SearchList onChange={handleSearch} /><div className="companies-list">{loading && <Spinner />}{(!loading && Boolean(!sentInvitations.length)) && <EmptySection align='left' message={LABELS.DATATABLE_SZERORECORDS} />}{(!loading && Boolean(sentInvitations.length)) &&sentInvitations.map(({ name, image, link_delete, link_view }, id) =><Profilekey={id}image={image}name={name}link_delete={link_delete}link_view={link_view}fetchCallback={fetchInvitations}btnCancelTitle={LABELS.REQUEST_CANCEL}/>)}</div></section>)}const mapDispatchToProps = {addNotification: (notification) => addNotification(notification)}export default connect(null, mapDispatchToProps)(InvitationsSent)