| 5141 |
stevensc |
1 |
/* eslint-disable camelcase */
|
|
|
2 |
/* eslint-disable react/prop-types */
|
|
|
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 Profile from '../../../components/Profile'
|
|
|
9 |
import SearchList from '../../../components/SearchList'
|
|
|
10 |
import Spinner from '../../../shared/loading-spinner/Spinner'
|
|
|
11 |
import EmptySection from '../../../shared/empty-section/EmptySection'
|
|
|
12 |
import TitleSection from '../../../components/TitleSection'
|
| 1 |
www |
13 |
|
| 5141 |
stevensc |
14 |
const PeopleYouMayKnow = ({ addNotification }) => {
|
|
|
15 |
const [entities, setEntities] = useState([])
|
|
|
16 |
const [loading, setLoading] = useState(false)
|
|
|
17 |
|
| 1 |
www |
18 |
useEffect(() => {
|
| 5141 |
stevensc |
19 |
fetchEntities()
|
|
|
20 |
}, [])
|
| 1 |
www |
21 |
|
| 5141 |
stevensc |
22 |
const fetchEntities = async (searchValue) => {
|
|
|
23 |
setLoading(true)
|
|
|
24 |
const response = await searchEntities('connection/people-blocked', searchValue)
|
| 1 |
www |
25 |
|
| 5141 |
stevensc |
26 |
if (!response.success) {
|
|
|
27 |
addNotification({ style: 'danger', msg: response.data })
|
|
|
28 |
setLoading(false)
|
|
|
29 |
return
|
|
|
30 |
}
|
|
|
31 |
|
|
|
32 |
setEntities(response.data)
|
|
|
33 |
setLoading(false)
|
|
|
34 |
}
|
|
|
35 |
|
| 5154 |
stevensc |
36 |
const handleSearch = debounce((value) => fetchEntities(value), 500)
|
| 5141 |
stevensc |
37 |
|
| 1 |
www |
38 |
return (
|
| 5141 |
stevensc |
39 |
<section className="companies-info container">
|
|
|
40 |
<TitleSection title={LABELS.PEOPLE_BLOCKED} />
|
| 5144 |
stevensc |
41 |
<SearchList onChange={handleSearch} />
|
| 5141 |
stevensc |
42 |
<div className="companies-list">
|
|
|
43 |
{loading && <Spinner />}
|
|
|
44 |
{(!loading && Boolean(!entities.length)) && <EmptySection align='left' message={LABELS.DATATABLE_SZERORECORDS} />}
|
|
|
45 |
{(!loading && Boolean(entities.length)) &&
|
|
|
46 |
entities.map(({ image, link_unblock, link_view, name }, index) =>
|
|
|
47 |
<Profile
|
|
|
48 |
image={image}
|
|
|
49 |
name={name}
|
|
|
50 |
key={index}
|
|
|
51 |
link_view={link_view}
|
|
|
52 |
link_unblock={link_unblock}
|
|
|
53 |
fetchCallback={fetchEntities}
|
|
|
54 |
/>
|
| 2401 |
stevensc |
55 |
)}
|
| 1 |
www |
56 |
</div>
|
|
|
57 |
</section>
|
| 5141 |
stevensc |
58 |
)
|
|
|
59 |
}
|
| 1 |
www |
60 |
|
|
|
61 |
const mapDispatchToProps = {
|
| 5141 |
stevensc |
62 |
addNotification: (notification) => addNotification(notification)
|
|
|
63 |
}
|
| 1 |
www |
64 |
|
| 5141 |
stevensc |
65 |
export default connect(null, mapDispatchToProps)(PeopleYouMayKnow)
|