Rev 2331 | Rev 5169 | 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 CompanyTemplate from "./companyTemplate/CompanyTemplate";
import { connect } from "react-redux";
import { addNotification } from "../../../redux/notification/notification.actions";
import SearchList from "../../../components/SearchList";
import Profile from "../../../components/Profile";
const IWorkWith = (props) => {
// redux destructuring
const { addNotification } = props;
// states
const [companies, setCompanies] = useState([]);
const [loading, setLoading] = useState(true);
// React hook form
const { register, getValues } = useForm();
let axiosThrottle = null;
useEffect(() => {
fetchCompanies();
}, []);
const fetchCompanies = async (searchParam = '') => {
setLoading(true);
await axios
.get(
"/company/i-work-with?search=" + searchParam)
.then((response) => {
const resData = response.data;
if (resData.success) {
setCompanies(resData.data);
}
});
setLoading(false);
};
return (
<section className="companies-info">
<div className="container">
<SearchList
title="Empresas donde trabajo"
fetchCallback={fetchCompanies}
/>
<div
className="companies-list"
id="profiles-container"
style={{
position: "relative",
}}
>
{companies.length > 0 ? (
companies.map(({ image, link_leave, link_view, name, link_my_company }, id) => (
<Profile
key={id}
image={image}
link_admin={link_my_company}
link_leave={link_leave}
fetchCallback={fetchCompanies}
link_view={link_view}
name={name}
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)(IWorkWith);