| 5129 |
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 |
|
| 5129 |
stevensc |
12 |
const InvitationsReceived = () => {
|
|
|
13 |
const [invitationsReceived, setInvitationsReceived] = useState([])
|
|
|
14 |
const [loading, setLoading] = useState(false)
|
| 1 |
www |
15 |
|
|
|
16 |
useEffect(() => {
|
| 5129 |
stevensc |
17 |
fetchInvitations()
|
|
|
18 |
}, [])
|
| 1 |
www |
19 |
|
| 2393 |
stevensc |
20 |
const fetchInvitations = async (searchValue = '') => {
|
| 5129 |
stevensc |
21 |
setLoading(true)
|
| 1 |
www |
22 |
await axios
|
| 5129 |
stevensc |
23 |
.get('/connection/invitations-received?search=' + searchValue)
|
|
|
24 |
.then(({ data: response }) => {
|
|
|
25 |
if (response.success) setInvitationsReceived(response.data)
|
|
|
26 |
})
|
|
|
27 |
setLoading(false)
|
|
|
28 |
}
|
| 1 |
www |
29 |
|
|
|
30 |
return (
|
| 5129 |
stevensc |
31 |
<section className="companies-info container">
|
|
|
32 |
<TitleSection title={LABELS.INVITATIONS_RECEIVED}/>
|
|
|
33 |
<SearchList onChange={fetchInvitations}/>
|
|
|
34 |
<div className="companies-list">
|
|
|
35 |
{invitationsReceived.length
|
|
|
36 |
? invitationsReceived.map(({ name, image, link_approve, link_reject, link_view }, id) =>
|
| 2393 |
stevensc |
37 |
<Profile
|
|
|
38 |
key={id}
|
|
|
39 |
image={image}
|
|
|
40 |
name={name}
|
|
|
41 |
link_approve={link_approve}
|
|
|
42 |
link_reject={link_reject}
|
|
|
43 |
link_view={link_view}
|
|
|
44 |
fetchCallback={fetchInvitations}
|
|
|
45 |
/>
|
|
|
46 |
)
|
| 5129 |
stevensc |
47 |
: <EmptySection align='left' message={LABELS.DATATABLE_SZERORECORDS} />}
|
|
|
48 |
{loading && <Spinner />}
|
| 1 |
www |
49 |
</div>
|
|
|
50 |
</section>
|
| 5129 |
stevensc |
51 |
)
|
|
|
52 |
}
|
| 1 |
www |
53 |
|
|
|
54 |
const mapDispatchToProps = {
|
| 5129 |
stevensc |
55 |
addNotification: (notification) => addNotification(notification)
|
|
|
56 |
}
|
| 1 |
www |
57 |
|
| 5129 |
stevensc |
58 |
export default connect(null, mapDispatchToProps)(InvitationsReceived)
|