Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 1596 | Rev 2332 | 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";
1156 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";
8
import CompanyTemplate from "./companyTemplate/CompanyTemplate";
1596 steven 9
import SearchList from "../../../components/SearchList";
10
import Profile from "../../../components/Profile";
1 www 11
 
12
const RequestSent = (props) => {
13
  // states
14
  const [companies, setCompanies] = useState([]);
15
  const [loading, setLoading] = useState(true);
16
  useEffect(() => {
17
    fetchCompanies();
18
  }, []);
19
 
1156 stevensc 20
  const fetchCompanies = async (searchParam = '') => {
1 www 21
    setLoading(true);
22
    await axios
1156 stevensc 23
      .get("/company/requests-sent?search=" + searchParam)
1 www 24
      .then((response) => {
25
        const resData = response.data;
1156 stevensc 26
        (resData);
1 www 27
        if (resData.success) {
28
          setCompanies(resData.data);
29
        }
30
      });
31
    setLoading(false);
32
  };
33
 
34
  return (
35
    <section className="companies-info">
36
      <div className="container">
1596 steven 37
        <SearchList
38
          title="Solicitudes enviadas"
39
          fetchCallback={fetchCompanies}
40
        />
41
 
1 www 42
        <div className="companies-list">
43
          <div
44
            className="row"
45
            id="profiles-container"
46
            style={{
47
              position: "relative",
48
            }}
49
          >
50
            {companies.length > 0 ? (
1596 steven 51
              companies.map(({name, image, link_cancel, link_view}, id) => (
52
                <Profile
2033 steven 53
                  image={image}
1596 steven 54
                  name={name}
55
                  link_cancel={link_cancel}
56
                  link_view={link_view}
1 www 57
                  key={id}
1596 steven 58
                  fetchCallback={fetchCompanies}
1 www 59
                />
60
              ))
61
            ) : (
62
              <div style={{ margin: "auto", textAlign: "center" }}>
63
                Ningún registro coincidio con su consulta
64
              </div>
65
            )}
66
            {loading && (
67
              <div className="spinner-container">
68
                <Spinner />
69
              </div>
70
            )}
71
          </div>
72
          {/* <!--product-feed-tab end--> */}
73
        </div>
74
      </div>
75
    </section>
76
  );
77
};
78
 
79
// const mapStateToProps = (state) => ({});
80
 
81
const mapDispatchToProps = {
82
  addNotification: (notification) => addNotification(notification),
83
};
84
 
85
export default connect(null, mapDispatchToProps)(RequestSent);