Rev 1771 | Rev 2944 | 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 (
<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>
<div className="mb-2" id="suggestions-similar-groups" style={{ height: '80%', overflowY: 'auto' }}>
{companyFollowers.length
? getData().map(({ id, name, image, profile }) => (
<div key={id} className="suggestion-usd d-flex justify-content-start align-items-center">
<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>
<div className="w-100 text-center">
<button className="btn btn-primary" onClick={() => setLookMore(!lookMore)}>
{lookMore ? 'Ver menos' : 'Ver mas'}
</button>
</div>
</div>
);
};
export default CompanyFollowersHelper;