Rev 5154 | 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 { connect } from 'react-redux'
import { debounce } from '../../../utils'
import { searchEntities } from '../../../services/search'
import { addNotification } from '../../../redux/notification/notification.actions'
import ProfileCard from '../../../components/Profile'
import SearchList from '../../../components/SearchList'
import TitleSection from '../../../components/TitleSection'
import EmptySection from '../../../shared/empty-section/EmptySection'
import Spinner from '../../../shared/loading-spinner/Spinner'
const AppliedJobs = ({ addNotification }) => {
const [appliedJobs, setAppliedJobs] = useState([])
const [loading, setLoading] = useState(true)
useEffect(() => {
fetchAppliedJobs()
}, [])
const fetchAppliedJobs = async (searchValue = '') => {
setLoading(true)
const response = await searchEntities('job/applied-jobs', searchValue)
if (!response.success) {
addNotification({ style: 'danger', msg: response.data })
setLoading(false)
return
}
setAppliedJobs(response.data)
setLoading(false)
}
const handleSearch = debounce((value) => fetchAppliedJobs(value), 500)
return (
<section className="companies-info container">
<TitleSection title={LABELS.JOBS_APPLIED} />
<SearchList onChange={handleSearch} />
<div className="companies-list">
{loading && <Spinner />}
{(!loading && Boolean(!appliedJobs.length)) && <EmptySection align='left' message={LABELS.DATATABLE_SZERORECORDS} />}
{(!loading && Boolean(appliedJobs.length)) &&
appliedJobs.map(({ title, employment_type, link_view, link_remove }, index) =>
<ProfileCard
key={index}
name={title}
status={employment_type}
link_view={link_view}
link_delete={link_remove}
fetchCallback={fetchAppliedJobs}
btnAcceptTitle={LABELS.VIEW_JOB}
btnCancelTitle={LABELS.JOB_REQUEST_CANCEL}
/>
)}
</div>
</section>
)
}
const mapDispatchToProps = {
addNotification: (notification) => addNotification(notification)
}
export default connect(null, mapDispatchToProps)(AppliedJobs)