Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 5126 | Rev 5144 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

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