Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 1595 | Rev 2331 | 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 ? (
1936 steven 59
              companies.map(({image, link_leave, link_view, name, link_my_company}, id) => (
1593 steven 60
                <Profile
1 www 61
                  key={id}
1593 steven 62
                  image={image}
1936 steven 63
                  link_admin={link_my_company}
1593 steven 64
                  link_leave={link_leave}
1595 steven 65
                  fetchCallback={fetchCompanies}
1593 steven 66
                  link_view={link_view}
67
                  name={name}
1 www 68
                />
69
              ))
70
            ) : (
71
              <div style={{ margin: "auto", textAlign: "center" }}>
72
                Ningún registro coincidio con su consulta
73
              </div>
74
            )}
75
            {loading && (
76
              <div className="spinner-container">
77
                <Spinner />
78
              </div>
79
            )}
80
          </div>
81
          {/* <!--product-feed-tab end--> */}
82
        </div>
83
      </div>
84
    </section>
85
  );
86
};
87
 
88
// const mapStateToProps = (state) => ({});
89
 
90
const mapDispatchToProps = {
91
  addNotification: (notification) => addNotification(notification),
92
};
93
 
94
export default connect(null, mapDispatchToProps)(IWorkWith);