Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

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