Rev 2505 | AutorÃa | Comparar con el anterior | Ultima modificación | Ver Log |
/* eslint-disable react/prop-types *//* eslint-disable camelcase */import React, { useEffect, useState } from 'react'import { debounce } from '../../../utils'import { connect } from 'react-redux'import { searchEntities } from '../../../services/search'import { addNotification } from '../../../redux/notification/notification.actions'import Spinner from '../../../shared/loading-spinner/Spinner'import SearchList from '../../../components/SearchList'import Profile from '../../../components/Profile'import TitleSection from '../../../components/TitleSection'import EmptySection from '../../../shared/empty-section/EmptySection'const RequestSent = ({ addNotification }) => {const [companies, setCompanies] = useState([])const [loading, setLoading] = useState(true)useEffect(() => {getCompanies()}, [])const getCompanies = async (searchValue = '') => {setLoading(true)const response = await searchEntities('company/requests-sent', searchValue)if (!response.success) {addNotification({ style: 'danger', msg: response.data })setLoading(false)return}setCompanies(response.data)setLoading(false)}const handleSearch = debounce((value) => getCompanies(value), 500)return (<section className="companies-info container"><TitleSection title={LABELS.REQUESTS_SENT} /><SearchList onChange={handleSearch} /><div className="companies-list">{loading && <Spinner />}{(!loading && Boolean(!companies.length)) && <EmptySection align='left' message={LABELS.DATATABLE_SZERORECORDS} />}{(!loading && Boolean(companies.length)) &&companies.map(({ name, image, link_cancel, link_view }, id) =><Profileimage={image}name={name}link_cancel={link_cancel}link_view={link_view}key={id}fetchCallback={getCompanies}btnAcceptTitle={LABELS.VIEW_COMPANY}btnCancelTitle={LABELS.REQUEST_CANCEL}/>)}</div></section>)}const mapDispatchToProps = {addNotification: (notification) => addNotification(notification)}export default connect(null, mapDispatchToProps)(RequestSent)