Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 1158 | Rev 2320 | Ir a la última revisión | Autoría | Comparar con el anterior | Ultima modificación | Ver Log |

import React from "react";
import { useEffect, useState } from "react";
import { connect } from "react-redux";
import { useForm } from "react-hook-form";
import { axios } from "../../../utils";
import { addNotification } from "../../../redux/notification/notification.actions";
import Spinner from "../../../shared/loading-spinner/Spinner";
import RequestTemplate from "./requestTemplate/RequestTemplate";
import SearchList from "../../../components/SearchList";
import Profile from "../../../components/Profile";

const RequestsSent = () => {
  // states
  const [sentRequests, setSentRequests] = useState([]);
  const [loading, setLoading] = useState(true);

  useEffect(() => {
    fetchSentRequests();
  }, []);

  const fetchSentRequests = async (searchParam = '') => {
    setLoading(true);
    await axios.get("/group/requests-sent?search=" + searchParam)
      .then((response) => {
        const resData = response.data;
        if (resData.success) {
          setSentRequests(resData.data);
        }
      });
    setLoading(false);
  };

  return (
    <section className="companies-info" style={{ position: "relative" }}>
      <div className="container">
        <SearchList
          title="Solicitudes enviadas"
          fetchCallback={fetchSentRequests}
        />

        <div
          className="companies-list"
          style={{
            padding: "0 15px",
          }}
        >
          <div
            className="row"
            id="profiles-container"
          >
            {
              sentRequests.length
                ?
                sentRequests.map((request, index) => {
                  return (
                    <Profile
                      {...request}
                      key={index}
                      fetchCallback={fetchSentRequests}
                    />
                  )
                }
                )
                :
                <div style={{ margin: "auto", textAlign: "center" }}>
                  Ningún registro coincidio con su consulta
                </div>
            }
          </div>
          {/* <!--product-feed-tab end--> */}
        </div>
      </div>
      {loading && (
        <div className="spinner-container">
          <Spinner />
        </div>
      )}
    </section>
  );
};

// const mapStateToProps = (state) => ({});

const mapDispatchToProps = {
  addNotification: (notification) => addNotification(notification),
};

export default connect(null, mapDispatchToProps)(RequestsSent);