Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

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

Rev 2401 Rev 5141
Línea -... Línea 1...
-
 
1
/* eslint-disable camelcase */
1
import React from "react";
2
/* eslint-disable react/prop-types */
2
import { useEffect, useState } from "react";
3
import React, { useEffect, useState } from 'react'
3
import { connect } from "react-redux";
4
import { connect } from 'react-redux'
4
import { axios } from "../../../utils";
5
import { debounce } from '../../../utils'
-
 
6
import { searchEntities } from '../../../services/search'
5
import { addNotification } from "../../../redux/notification/notification.actions";
7
import { addNotification } from '../../../redux/notification/notification.actions'
6
import Spinner from "../../../shared/loading-spinner/Spinner";
8
import Profile from '../../../components/Profile'
7
import "../../../css/shared/global.scss";
9
import SearchList from '../../../components/SearchList'
8
import SearchList from "../../../components/SearchList";
10
import Spinner from '../../../shared/loading-spinner/Spinner'
-
 
11
import EmptySection from '../../../shared/empty-section/EmptySection'
9
import Profile from "../../../components/Profile";
12
import TitleSection from '../../../components/TitleSection'
10
 
13
 
11
const PeopleYouMayKnow = (props) => {
14
const PeopleYouMayKnow = ({ addNotification }) => {
12
  // states
-
 
13
  const [entities, setEntities] = useState([]);
15
  const [entities, setEntities] = useState([])
14
  const [loading, setLoading] = useState(false);
16
  const [loading, setLoading] = useState(false)
-
 
17
 
15
  useEffect(() => {
18
  useEffect(() => {
16
    fetchEntitys();
19
    fetchEntities()
17
  }, []);
20
  }, [])
-
 
21
 
-
 
22
  const fetchEntities = async (searchValue) => {
-
 
23
    setLoading(true)
-
 
24
    const response = await searchEntities('connection/people-blocked', searchValue)
Línea 18... Línea -...
18
 
-
 
19
  const fetchEntitys = async (searchValue) => {
-
 
20
    setLoading(true);
-
 
21
    await axios
-
 
22
      .get("/connection/people-blocked?search=" + (searchValue || ''))
25
 
23
      .then((response) => {
26
    if (!response.success) {
24
        const resData = response.data;
27
      addNotification({ style: 'danger', msg: response.data })
25
        if (resData.success) {
-
 
26
          setEntities(resData.data);
28
      setLoading(false)
27
        }
29
      return
-
 
30
    }
-
 
31
 
28
      });
32
    setEntities(response.data)
29
    setLoading(false);
33
    setLoading(false)
-
 
34
  }
-
 
35
 
Línea 30... Línea 36...
30
  };
36
  const onChange = (value) => debounce(fetchEntities(value), 500)
31
 
37
 
32
  return (
-
 
33
    <section className="companies-info">
-
 
34
      <div className="container">
38
  return (
35
        <SearchList
39
    <section className="companies-info container">
36
          title="Personas Bloqueadas"
-
 
37
          fetchCallback={fetchEntitys}
-
 
38
        />
40
      <TitleSection title={LABELS.PEOPLE_BLOCKED} />
39
        <div
41
      <SearchList onChange={onChange} />
40
          className="companies-list"
42
      <div className="companies-list">
41
          id="profiles-container"
-
 
42
          style={{ position: "relative", padding: "0 15px" }}
43
        {loading && <Spinner />}
43
        >
-
 
44
          {entities.length > 0 ? (
44
        {(!loading && Boolean(!entities.length)) && <EmptySection align='left' message={LABELS.DATATABLE_SZERORECORDS} />}
45
            entities.map(
45
        {(!loading && Boolean(entities.length)) &&
46
              ({ image, link_unblock, link_view, name }, index) => (
46
          entities.map(({ image, link_unblock, link_view, name }, index) =>
47
                <Profile
47
            <Profile
48
                  image={image}
48
              image={image}
49
                  name={name}
49
              name={name}
50
                  key={index}
50
              key={index}
51
                  link_view={link_view}
51
              link_view={link_view}
52
                  link_unblock={link_unblock}
-
 
53
                  fetchCallback={fetchEntitys}
-
 
54
                />
-
 
55
              )
-
 
56
            )
-
 
57
          ) : (
-
 
58
            <p>No hay resultados</p>
-
 
59
          )}
-
 
60
          {loading ? (
-
 
61
            <div className="spinner-container">
-
 
62
              <Spinner />
-
 
63
            </div>
52
              link_unblock={link_unblock}
64
          ) : (
53
              fetchCallback={fetchEntities}
65
            ""
-
 
66
          )}
54
            />
67
        </div>
55
          )}
68
      </div>
56
      </div>
69
    </section>
57
    </section>
Línea 70... Línea 58...
70
  );
58
  )
71
};
59
}
72
 
60
 
Línea 73... Línea 61...
73
const mapDispatchToProps = {
61
const mapDispatchToProps = {