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