Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 1590 | Rev 2330 | 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 styled from "styled-components";
1158 stevensc 4
import { axios } from "../../../utils";
1 www 5
import Spinner from "../../../shared/loading-spinner/Spinner";
6
import { connect } from "react-redux";
7
import { addNotification } from "../../../redux/notification/notification.actions";
1590 steven 8
import SearchList from "../../../components/SearchList";
9
import Profile from "../../../components/Profile";
1 www 10
 
11
const StyledSpinnerContainer = styled.div`
12
  position: absolute;
13
  left: 0;
14
  top: 0;
15
  width: 100%;
16
  height: 100%;
17
  background: rgba(255, 255, 255, 0.4);
18
  display: flex;
19
  justify-content: center;
20
  align-items: center;
21
  z-index: 300;
22
`;
23
 
24
const FollowingCompanies = (props) => {
25
  // states
26
  const [companies, setCompanies] = useState([]);
27
  const [loading, setLoading] = useState(true);
28
  useEffect(() => {
29
    fetchCompanies();
30
  }, []);
31
 
1158 stevensc 32
  const fetchCompanies = async (searchParam = '') => {
1 www 33
    setLoading(true);
34
    await axios
35
      .get(
1158 stevensc 36
        "/company/following-companies?search=" + searchParam)
1 www 37
      .then((response) => {
38
        const resData = response.data;
39
        if (resData.success) {
40
          setCompanies(resData.data);
41
        }
42
      });
43
    setLoading(false);
44
  };
45
 
1590 steven 46
 
1 www 47
 
48
  return (
49
    <React.Fragment>
50
      <section className="companies-info">
51
        <div className="container">
1590 steven 52
          <SearchList
53
            title="Empresas que sigo"
54
            fetchCallback={fetchCompanies}
55
          />
1 www 56
 
57
          <div className="companies-list">
58
            <div
59
              className="row"
60
              id="profiles-container"
61
              style={{
62
                position: "relative",
63
              }}
64
            >
1158 stevensc 65
              {
66
                companies.length
67
                  ?
68
                  companies.map(({ image, name, link_view, link_unfollow }, index) => (
1590 steven 69
                    <Profile
1 www 70
                      image={image}
71
                      name={name}
72
                      link_view={link_view}
1590 steven 73
                      key={index}
1591 steven 74
                      fetchCallback={fetchCompanies}
1 www 75
                      link_unfollow={link_unfollow}
76
                    />
1158 stevensc 77
                  ))
78
                  :
79
                  <div style={{ margin: "auto", textAlign: "center" }}>
80
                    Ningún registro coincidio con su consulta
81
                  </div>
82
              }
83
              {
84
                loading
85
                &&
1 www 86
                <StyledSpinnerContainer>
87
                  <Spinner />
88
                </StyledSpinnerContainer>
1158 stevensc 89
              }
1 www 90
            </div>
91
            {/* <!--product-feed-tab end--> */}
92
          </div>
93
        </div>
94
      </section>
95
    </React.Fragment>
96
  );
97
};
98
 
99
// const mapStateToProps = (state) => ({
100
 
101
// })
102
 
103
const mapDispatchToProps = {
104
  addNotification: (notification) => addNotification(notification),
105
};
106
 
107
export default connect(null, mapDispatchToProps)(FollowingCompanies);