Rev 1699 | Rev 2943 | 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 {axios} from "../../../utils";
const CompanyFollowersHelper = (props) => {
// props destructuring
const { companyId } = props;
// states
const [companyFollowers, setCompanyFollowers] = useState([]);
const [lookMore, setLookMore] = useState(false);
useEffect(() => {
axios.get(`/helpers/company-follower/${companyId}`).then((response) => {
const resData = response.data;
if (resData.success) {
setCompanyFollowers(resData.data);
} else {
// alert error
}
});
}, []);
const getData = () => {
let infoFollows = [...companyFollowers]
if(!lookMore){
infoFollows = infoFollows.slice(0, 5);
}
return infoFollows
}
return (
<React.Fragment>
<div
className="widget suggestions full-width d-none d-md-block d-lg-block border-gray border-radius"
id="suggestions-similar-groups"
style={{
height: "auto",
overflowY: "auto",
}}
>
<div className="sd-title font-weight-bold">
<h3>Seguidores</h3>
</div>
{/* <!--sd-title end--> */}
{companyFollowers.length ? (
getData().map(({ id, name, image, profile }) => (
<div className="suggestion-usd d-flex justify-content-start align-items-center " key={id}>
<img
style={{ width: "10%", height: "auto" }}
src={image}
alt=""
/>
<div className="sgt-text">
<a href={profile} target="_blank">
<h4>{name}</h4>
</a>
</div>
</div>
))
) : (
<div className="view-more">Sin seguidores</div>
)}
<div
className="w-100 text-center"
>
<button className="btn btn-primary" onClick={() => setLookMore(!lookMore)}>
{lookMore ? 'Ver menos' : 'Ver mas'}
</button>
</div>
</div>
</React.Fragment>
);
};
export default CompanyFollowersHelper;