Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 5087 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 5087 Rev 5174
Línea 1... Línea 1...
1
/* eslint-disable camelcase */
1
/* eslint-disable camelcase */
2
/* eslint-disable react/prop-types */
2
/* eslint-disable react/prop-types */
3
import React, { useEffect, useState } from 'react'
3
import React, { useEffect, useState } from 'react'
4
import { axios } from '../../../utils'
4
import { debounce } from '../../../utils'
-
 
5
import { searchEntities } from '../../../services/search'
-
 
6
import { addNotification } from '../../../redux/notification/notification.actions'
-
 
7
import { useDispatch } from 'react-redux'
5
import Spinner from '../../../shared/loading-spinner/Spinner'
8
import Spinner from '../../../shared/loading-spinner/Spinner'
6
import Profile from '../../../components/Profile'
9
import Profile from '../../../components/Profile'
7
import SearchList from '../../../components/SearchList'
10
import SearchList from '../../../components/SearchList'
-
 
11
import EmptySection from '../../../shared/empty-section/EmptySection'
-
 
12
import TitleSection from '../../../components/TitleSection'
Línea 8... Línea 13...
8
 
13
 
9
const InvitationsReceived = () => {
14
const InvitationsReceived = () => {
10
  const [companies, setCompanies] = useState([])
15
  const [companies, setCompanies] = useState([])
11
  const [loading, setLoading] = useState(true)
-
 
12
 
16
  const [loading, setLoading] = useState(true)
Línea 13... Línea 17...
13
  const axiosThrottle = null
17
  const dispatch = useDispatch()
14
 
18
 
15
  useEffect(() => {
-
 
16
    fetchCompanies()
-
 
17
    return () => {
-
 
18
      clearTimeout(axiosThrottle)
19
  useEffect(() => {
Línea 19... Línea 20...
19
    }
20
    getCompanies()
20
  }, [])
21
  }, [])
21
 
-
 
22
  const fetchCompanies = (searchParam = '') => {
22
 
-
 
23
  const getCompanies = async (searchValue = '') => {
23
    setLoading(true)
24
    setLoading(true)
24
    axios
25
    const response = await searchEntities('company/invitations-received', searchValue)
25
      .get('/company/invitations-received?search=' + searchParam)
26
 
26
      .then(({ data: response }) => {
27
    if (!response.success) {
27
        if (response.success) {
28
      dispatch(addNotification({ style: 'danger', msg: response.data }))
-
 
29
      setLoading(false)
28
          setCompanies(response.data)
30
      return
29
        }
31
    }
30
      })
32
 
Línea -... Línea 33...
-
 
33
    setCompanies(response.data)
-
 
34
    setLoading(false)
31
      .finally(() => setLoading(false))
35
  }
32
    setLoading(false)
36
 
33
  }
-
 
34
 
-
 
35
  return (
37
  const handleSearch = debounce((value) => getCompanies(value), 500)
36
    <section className="companies-info">
38
 
37
      <div className="container">
-
 
38
        <SearchList
39
  return (
39
          title={LABELS.invitation_received}
40
    <section className="companies-info container">
40
          fetchCallback={fetchCompanies}
-
 
-
 
41
      <TitleSection title={LABELS.INVITATIONS_RECEIVED} />
41
        />
42
      <SearchList onChange={handleSearch} />
42
        <div className="companies-list position-relative">
43
      <div className="companies-list position-relative">
43
          {loading && <Spinner />}
44
        {loading && <Spinner />}
44
          {
45
        {(!loading && Boolean(!companies.length)) && <EmptySection align='left' message={LABELS.DATATABLE_SZERORECORDS} />}
45
            companies.length
46
        {(!loading && Boolean(companies.length)) &&
46
              ? companies.map(({ image, name, link_view, link_reject, link_accept }, id) => (
47
          companies.map(({ image, name, link_view, link_reject, link_accept }, id) =>
47
                <Profile
48
            <Profile
48
                  key={id}
49
              key={id}
49
                  image={image}
50
              image={image}
50
                  name={name}
51
              name={name}
51
                  link_view={link_view}
52
              link_view={link_view}
52
                  link_reject={link_reject}
53
              link_reject={link_reject}
53
                  link_accept={link_accept}
-
 
54
                  fetchCallback={fetchCompanies}
-
 
55
                  btnAcceptTitle='Ver Empresa'
-
 
56
                />
-
 
57
              ))
54
              link_accept={link_accept}
58
              : <div style={{ margin: 'auto', textAlign: 'center' }}>
-
 
59
                {LABELS.not_found}
55
              fetchCallback={getCompanies}
60
              </div>
56
              btnAcceptTitle={LABELS.VIEW_COMPANY}
61
          }
57
            />
62
        </div>
58
          )}