Rev 2336 | Rev 4239 | 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 { useForm } from "react-hook-form";import { axios } from "../../../utils";import Spinner from "../../../shared/loading-spinner/Spinner";import { connect } from "react-redux";import { addNotification } from "../../../redux/notification/notification.actions";import Profile from "../../../components/Profile";import SearchList from "../../../components/SearchList";const InvitationsReceived = (props) => {// redux destructuringconst { addNotification } = props;// statesconst [companies, setCompanies] = useState([]);const [loading, setLoading] = useState(true);// React hook formconst { register, getValues } = useForm();let axiosThrottle = null;useEffect(() => {fetchCompanies();return () => {clearTimeout(axiosThrottle);};}, []);const fetchCompanies = async (searchParam = '') => {setLoading(true);await axios.get("/company/invitations-received?search=" + searchParam).then((response) => {const resData = response.data;if (resData.success) {setCompanies(resData.data);}});setLoading(false);};const handleSearch = () => {// (getValues());clearTimeout(axiosThrottle);// setLoading(true);const searchValue = getValues("search");axiosThrottle = setTimeout(() => {fetchCompanies(searchValue);}, 500);};const handleRequestAction = (link) => {setLoading(true);axios.post(link).then((response) => {const resData = response.data;if (resData.success) {addNotification({style: "success",msg: resData.data,});fetchCompanies();} else {setLoading(false);addNotification({style: "danger",msg: resData.data ?? "ha ocurrido un error",});}});};return (<section className="companies-info"><div className="container"><SearchListtitle="Solicitudes recibidas"fetchCallback={fetchCompanies}/><divclassName="companies-list"id="profiles-container"style={{position: "relative",}}>{companies.length?companies.map(({ image, name, link_view, link_reject, link_accept }, id) => (<Profilekey={id}image={image}name={name}link_view={link_view}link_reject={link_reject}link_accept={link_accept}fetchCallback={fetchCompanies}btnAcceptTitle='Ver Empresa'/>)):<div style={{ margin: "auto", textAlign: "center" }}>Ningún registro coincidio con su consulta</div>}{loading&&<div className="spinner-container"><Spinner /></div>}{/* <!--product-feed-tab end--> */}</div></div></section >);};// const mapStateToProps = (state) => ({});const mapDispatchToProps = {addNotification: (notification) => addNotification(notification),};export default connect(null, mapDispatchToProps)(InvitationsReceived);