Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

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

Rev Autor Línea Nro. Línea
5087 stevensc 1
/* eslint-disable camelcase */
4241 stevensc 2
/* eslint-disable react/prop-types */
5087 stevensc 3
import React, { useEffect, useState } from 'react'
4
import { axios } from '../../../utils'
5
import Spinner from '../../../shared/loading-spinner/Spinner'
6
import Profile from '../../../components/Profile'
7
import SearchList from '../../../components/SearchList'
1 www 8
 
4241 stevensc 9
const InvitationsReceived = () => {
5087 stevensc 10
  const [companies, setCompanies] = useState([])
11
  const [loading, setLoading] = useState(true)
1 www 12
 
5087 stevensc 13
  const axiosThrottle = null
1 www 14
 
15
  useEffect(() => {
5087 stevensc 16
    fetchCompanies()
1 www 17
    return () => {
5087 stevensc 18
      clearTimeout(axiosThrottle)
19
    }
20
  }, [])
1 www 21
 
4241 stevensc 22
  const fetchCompanies = (searchParam = '') => {
5087 stevensc 23
    setLoading(true)
4241 stevensc 24
    axios
5087 stevensc 25
      .get('/company/invitations-received?search=' + searchParam)
4241 stevensc 26
      .then(({ data: response }) => {
27
        if (response.success) {
28
          setCompanies(response.data)
1 www 29
        }
4241 stevensc 30
      })
31
      .finally(() => setLoading(false))
5087 stevensc 32
    setLoading(false)
33
  }
1 www 34
 
35
  return (
36
    <section className="companies-info">
37
      <div className="container">
2335 stevensc 38
        <SearchList
4239 stevensc 39
          title={LABELS.invitation_received}
2335 stevensc 40
          fetchCallback={fetchCompanies}
41
        />
4241 stevensc 42
        <div className="companies-list position-relative">
43
          {loading && <Spinner />}
2334 stevensc 44
          {
45
            companies.length
5087 stevensc 46
              ? companies.map(({ image, name, link_view, link_reject, link_accept }, id) => (
2335 stevensc 47
                <Profile
2334 stevensc 48
                  key={id}
2335 stevensc 49
                  image={image}
50
                  name={name}
51
                  link_view={link_view}
52
                  link_reject={link_reject}
53
                  link_accept={link_accept}
54
                  fetchCallback={fetchCompanies}
2509 stevensc 55
                  btnAcceptTitle='Ver Empresa'
2334 stevensc 56
                />
57
              ))
5087 stevensc 58
              : <div style={{ margin: 'auto', textAlign: 'center' }}>
4240 stevensc 59
                {LABELS.not_found}
1 www 60
              </div>
2334 stevensc 61
          }
1 www 62
        </div>
63
      </div>
5087 stevensc 64
    </section>
65
  )
66
}
1 www 67
 
5087 stevensc 68
export default InvitationsReceived