| 5129 |
stevensc |
1 |
/* eslint-disable camelcase */
|
|
|
2 |
import React, { useEffect, useState } from 'react'
|
|
|
3 |
import { connect } from 'react-redux'
|
| 5130 |
stevensc |
4 |
import { debounce } from '../../../utils'
|
| 5129 |
stevensc |
5 |
import { addNotification } from '../../../redux/notification/notification.actions'
|
| 5130 |
stevensc |
6 |
import { searchEntities } from '../../../services/search'
|
| 5129 |
stevensc |
7 |
import Profile from '../../../components/Profile'
|
|
|
8 |
import SearchList from '../../../components/SearchList'
|
| 5130 |
stevensc |
9 |
import TitleSection from '../../../components/TitleSection'
|
|
|
10 |
import EmptySection from '../../../shared/empty-section/EmptySection'
|
| 5129 |
stevensc |
11 |
import Spinner from '../../../shared/loading-spinner/Spinner'
|
| 1 |
www |
12 |
|
| 5129 |
stevensc |
13 |
const InvitationsReceived = () => {
|
|
|
14 |
const [invitationsReceived, setInvitationsReceived] = useState([])
|
|
|
15 |
const [loading, setLoading] = useState(false)
|
| 1 |
www |
16 |
|
|
|
17 |
useEffect(() => {
|
| 5129 |
stevensc |
18 |
fetchInvitations()
|
|
|
19 |
}, [])
|
| 1 |
www |
20 |
|
| 2393 |
stevensc |
21 |
const fetchInvitations = async (searchValue = '') => {
|
| 5129 |
stevensc |
22 |
setLoading(true)
|
| 5130 |
stevensc |
23 |
const response = await searchEntities('connection/invitations-received', searchValue)
|
|
|
24 |
if (response.success) setInvitationsReceived(response.data)
|
| 5129 |
stevensc |
25 |
setLoading(false)
|
|
|
26 |
}
|
| 1 |
www |
27 |
|
| 5130 |
stevensc |
28 |
const handleSearch = (value) => debounce(fetchInvitations(value), 500)
|
|
|
29 |
|
|
|
30 |
if (loading) return <Spinner />
|
|
|
31 |
|
| 1 |
www |
32 |
return (
|
| 5129 |
stevensc |
33 |
<section className="companies-info container">
|
|
|
34 |
<TitleSection title={LABELS.INVITATIONS_RECEIVED}/>
|
| 5130 |
stevensc |
35 |
<SearchList onChange={handleSearch}/>
|
| 5129 |
stevensc |
36 |
<div className="companies-list">
|
|
|
37 |
{invitationsReceived.length
|
|
|
38 |
? invitationsReceived.map(({ name, image, link_approve, link_reject, link_view }, id) =>
|
| 2393 |
stevensc |
39 |
<Profile
|
|
|
40 |
key={id}
|
|
|
41 |
image={image}
|
|
|
42 |
name={name}
|
|
|
43 |
link_approve={link_approve}
|
|
|
44 |
link_reject={link_reject}
|
|
|
45 |
link_view={link_view}
|
|
|
46 |
fetchCallback={fetchInvitations}
|
|
|
47 |
/>
|
|
|
48 |
)
|
| 5129 |
stevensc |
49 |
: <EmptySection align='left' message={LABELS.DATATABLE_SZERORECORDS} />}
|
| 1 |
www |
50 |
</div>
|
|
|
51 |
</section>
|
| 5129 |
stevensc |
52 |
)
|
|
|
53 |
}
|
| 1 |
www |
54 |
|
|
|
55 |
const mapDispatchToProps = {
|
| 5129 |
stevensc |
56 |
addNotification: (notification) => addNotification(notification)
|
|
|
57 |
}
|
| 1 |
www |
58 |
|
| 5129 |
stevensc |
59 |
export default connect(null, mapDispatchToProps)(InvitationsReceived)
|