Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

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

Rev Autor Línea Nro. Línea
1 www 1
import React from "react";
2
import { useEffect, useState } from "react";
3
import { connect } from "react-redux";
4
import { useForm } from "react-hook-form";
5
import styled from "styled-components";
2384 stevensc 6
import { axios } from "../../../utils";
1 www 7
import { addNotification } from "../../../redux/notification/notification.actions";
8
import Spinner from "../../../shared/loading-spinner/Spinner";
9
import Entity from "./entity/Entity";
1564 steven 10
import Profile from "../../../components/Profile";
1569 steven 11
import SearchList from "../../../components/SearchList";
1 www 12
 
13
const StyledSpinnerContainer = styled.div`
14
  position: absolute;
15
  left: 0;
16
  top: 0;
17
  width: 100%;
18
  height: 100%;
19
  background: rgba(255, 255, 255, 0.4);
20
  display: flex;
21
  justify-content: center;
22
  align-items: center;
23
  z-index: 300;
24
`;
25
 
26
const MyConnections = (props) => {
27
  // states
28
  const [myConnections, setMyConnections] = useState([]);
29
  const [loading, setLoading] = useState(true);
2384 stevensc 30
 
1 www 31
  useEffect(() => {
32
    fetchMyConnections();
33
  }, []);
34
 
2384 stevensc 35
  const fetchMyConnections = async (searchParam = '') => {
1 www 36
    setLoading(true);
37
    await axios
38
      .get(
2384 stevensc 39
        "/connection/my-connections?search=" + searchParam)
1 www 40
      .then((response) => {
41
        const resData = response.data;
42
        if (resData.success) {
43
          setMyConnections(resData.data);
44
        }
45
      });
46
    setLoading(false);
47
  };
48
 
49
  return (
50
    <section className="companies-info">
51
      <div className="container">
1569 steven 52
        <SearchList
53
          title="Personas con Relación directa, de 1er nivel"
54
          fetchCallback={fetchMyConnections}
55
        />
2384 stevensc 56
        <div
57
          className="companies-list"
58
          id="profiles-container"
59
          style={{ position: "relative", padding: "0 15px" }}
60
        >
61
          {myConnections.length > 0 ? (
62
            myConnections.map(
63
              (
64
                {
65
                  image,
66
                  name,
67
                  link_view,
68
                  link_inmail,
69
                  link_cancel,
70
                  link_block,
71
                },
72
                id
73
              ) => (
74
                <Profile
75
                  isTopData
76
                  key={id}
77
                  image={image}
78
                  name={name}
79
                  link_inmail={link_inmail}
80
                  link_view={link_view}
81
                  link_cancel={link_cancel}
82
                  link_block={link_block}
83
                  fetchCallback={fetchMyConnections}
84
                />
1 www 85
              )
2384 stevensc 86
            )
87
          ) : (
88
            <p>No hay resultados</p>
89
          )}
90
          {loading && (
91
            <StyledSpinnerContainer>
92
              <Spinner />
93
            </StyledSpinnerContainer>
94
          )}
1 www 95
        </div>
96
      </div>
97
    </section>
98
  );
99
};
100
 
101
// const mapStateToProps = (state) => ({});
102
 
103
const mapDispatchToProps = {
104
  addNotification: (notification) => addNotification(notification),
105
};
106
 
107
export default connect(null, mapDispatchToProps)(MyConnections);