Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 2405 | Rev 5152 | Ir a la última revisión | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
5151 stevensc 1
/* eslint-disable react/prop-types */
2
/* eslint-disable camelcase */
3
import React, { useEffect, useState } from 'react'
4
import { connect } from 'react-redux'
5
import { debounce } from '../../../utils'
6
import { searchEntities } from '../../../services/search'
7
import { addNotification } from '../../../redux/notification/notification.actions'
8
import ProfileCard from '../../../components/Profile'
9
import SearchList from '../../../components/SearchList'
10
import TitleSection from '../../../components/TitleSection'
11
import EmptySection from '../../../shared/empty-section/EmptySection'
12
import Spinner from '../../../shared/loading-spinner/Spinner'
1 www 13
 
5151 stevensc 14
const AppliedJobs = ({ addNotification }) => {
15
  const [appliedJobs, setAppliedJobs] = useState([])
16
  const [loading, setLoading] = useState(true)
1 www 17
 
18
  useEffect(() => {
5151 stevensc 19
    fetchAppliedJobs()
20
  }, [])
1 www 21
 
5151 stevensc 22
  const fetchAppliedJobs = async (searchValue = '') => {
23
    setLoading(true)
24
    const response = await searchEntities('job/applied-jobs', searchValue)
1 www 25
 
5151 stevensc 26
    if (!response.success) {
27
      addNotification({ style: 'danger', msg: response.data })
28
      setLoading(false)
29
      return
30
    }
1 www 31
 
5151 stevensc 32
    setAppliedJobs(response.data)
33
    setLoading(false)
34
  }
2343 stevensc 35
 
5151 stevensc 36
  const handleSearch = (value) => debounce(fetchAppliedJobs(value), 500)
37
 
1 www 38
  return (
5151 stevensc 39
    <section className="companies-info" style={{ position: 'relative' }}>
1 www 40
      <div className="container">
5151 stevensc 41
        <TitleSection title={LABELS.PEOPLE_BLOCKED} />
42
        <SearchList onChange={handleSearch} />
43
        <div className="companies-list">
44
          {loading && <Spinner />}
45
          {(!loading && Boolean(!appliedJobs.length)) && <EmptySection align='left' message={LABELS.DATATABLE_SZERORECORDS} />}
46
          {(!loading && Boolean(appliedJobs.length)) &&
47
            appliedJobs.map(({ title, employment_type, link_view, link_remove }, index) =>
48
              <ProfileCard
49
                key={index}
50
                name={title}
51
                status={employment_type}
52
                link_view={link_view}
53
                link_delete={link_remove}
54
                fetchCallback={fetchAppliedJobs}
55
                btnAcceptTitle={LABELS.VIEW_JOB}
56
                btnCancelTitle={LABELS.JOB_REQUEST_CANCEL}
57
              />
58
            )}
1 www 59
        </div>
60
      </div>
61
    </section>
5151 stevensc 62
  )
63
}
1 www 64
 
65
const mapDispatchToProps = {
5151 stevensc 66
  addNotification: (notification) => addNotification(notification)
67
}
1 www 68
 
5151 stevensc 69
export default connect(null, mapDispatchToProps)(AppliedJobs)