Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 5130 | Rev 5138 | Ir a la última revisión | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
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
 
1 www 30
  return (
5129 stevensc 31
    <section className="companies-info container">
32
        <TitleSection title={LABELS.INVITATIONS_RECEIVED}/>
5130 stevensc 33
        <SearchList onChange={handleSearch}/>
5129 stevensc 34
        <div className="companies-list">
5135 stevensc 35
        {loading
36
          ? <Spinner />
37
          : invitationsReceived.length
5129 stevensc 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
            )
5135 stevensc 49
            : <EmptySection align='left' message={LABELS.DATATABLE_SZERORECORDS} />
50
        }
1 www 51
        </div>
52
    </section>
5129 stevensc 53
  )
54
}
1 www 55
 
56
const mapDispatchToProps = {
5129 stevensc 57
  addNotification: (notification) => addNotification(notification)
58
}
1 www 59
 
5129 stevensc 60
export default connect(null, mapDispatchToProps)(InvitationsReceived)