Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 1158 | Rev 1591 | 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}
1 www 74
                      link_unfollow={link_unfollow}
75
                    />
1158 stevensc 76
                  ))
77
                  :
78
                  <div style={{ margin: "auto", textAlign: "center" }}>
79
                    Ningún registro coincidio con su consulta
80
                  </div>
81
              }
82
              {
83
                loading
84
                &&
1 www 85
                <StyledSpinnerContainer>
86
                  <Spinner />
87
                </StyledSpinnerContainer>
1158 stevensc 88
              }
1 www 89
            </div>
90
            {/* <!--product-feed-tab end--> */}
91
          </div>
92
        </div>
93
      </section>
94
    </React.Fragment>
95
  );
96
};
97
 
98
// const mapStateToProps = (state) => ({
99
 
100
// })
101
 
102
const mapDispatchToProps = {
103
  addNotification: (notification) => addNotification(notification),
104
};
105
 
106
export default connect(null, mapDispatchToProps)(FollowingCompanies);