Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 1593 | Rev 1936 | 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 { useForm } from "react-hook-form";
4
import {axios} from "../../../utils";
5
import Spinner from "../../../shared/loading-spinner/Spinner";
6
import CompanyTemplate from "./companyTemplate/CompanyTemplate";
7
import { connect } from "react-redux";
8
import { addNotification } from "../../../redux/notification/notification.actions";
1592 steven 9
import SearchList from "../../../components/SearchList";
1593 steven 10
import Profile from "../../../components/Profile";
1 www 11
 
12
const IWorkWith = (props) => {
13
  // redux destructuring
14
  const { addNotification } = props;
15
 
16
  // states
17
  const [companies, setCompanies] = useState([]);
18
  const [loading, setLoading] = useState(true);
19
 
20
  // React hook form
21
  const { register, getValues } = useForm();
22
 
23
  let axiosThrottle = null;
24
 
25
  useEffect(() => {
26
    fetchCompanies();
27
  }, []);
28
 
29
  const fetchCompanies = async (searchParam='') => {
30
    setLoading(true);
31
    await axios
32
      .get(
33
        "/company/i-work-with?search="+searchParam)
34
      .then((response) => {
35
        const resData = response.data;
36
        if (resData.success) {
37
          setCompanies(resData.data);
38
        }
39
      });
40
    setLoading(false);
41
  };
42
 
43
  return (
44
    <section className="companies-info">
45
      <div className="container">
1592 steven 46
        <SearchList
47
          title="Empresas donde trabajo"
48
          fetchCallback={fetchCompanies}
49
        />
1 www 50
        <div className="companies-list">
51
          <div
52
            className="row"
53
            id="profiles-container"
54
            style={{
55
              position: "relative",
56
            }}
57
          >
58
            {companies.length > 0 ? (
1593 steven 59
              companies.map(({image, link_leave, link_view, name}, id) => (
60
                <Profile
1 www 61
                  key={id}
1593 steven 62
                  image={image}
63
                  link_leave={link_leave}
1595 steven 64
                  fetchCallback={fetchCompanies}
1593 steven 65
                  link_view={link_view}
66
                  name={name}
1 www 67
                />
68
              ))
69
            ) : (
70
              <div style={{ margin: "auto", textAlign: "center" }}>
71
                Ningún registro coincidio con su consulta
72
              </div>
73
            )}
74
            {loading && (
75
              <div className="spinner-container">
76
                <Spinner />
77
              </div>
78
            )}
79
          </div>
80
          {/* <!--product-feed-tab end--> */}
81
        </div>
82
      </div>
83
    </section>
84
  );
85
};
86
 
87
// const mapStateToProps = (state) => ({});
88
 
89
const mapDispatchToProps = {
90
  addNotification: (notification) => addNotification(notification),
91
};
92
 
93
export default connect(null, mapDispatchToProps)(IWorkWith);