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