Rev 2931 | Rev 3286 | 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";
import styles from "../people-you-may-know/peopleYouMayKnow.module.scss";
const SuggestedGroupsHelper = (props) => {
// props destructuring
const { groupId } = props;
// states
const [suggestedGroups, setSuggestedGroups] = useState([]);
const [lookMore, setLookMore] = useState(false);
useEffect(() => {
const url = '/helpers/groups-suggestion'
axios.get(url)
.then(({ data }) => {
if (data.success) {
setSuggestedGroups(data.data);
}
});
}, []);
const getData = () => {
let infoFollows = [...suggestedGroups]
if (!lookMore) {
infoFollows = infoFollows.slice(0, 3);
}
return infoFollows
}
return (
<div className={styles.peopleYouMayKnow}>
<div className="sd-title d-flex align-items-center justify-content-between">
<h3>Grupos:</h3>
{
suggestedGroups.length >= 3 &&
<a
href="#"
onClick={(e) => {
e.preventDefault()
setLookMore(!lookMore)
}}
>
{lookMore ? 'Ver menos' : 'Ver mas'}
</a>
}
</div>
<div
className="mb-2"
id="suggestions-similar-groups"
style={{ height: "80%", overflowY: "auto" }}
>
{suggestedGroups.length ? (
getData().map(({ id, name, image, profile }) => (
<div className={styles.user} key={id}>
<div className="w-100 d-flex align-items-center" style={{ gap: '.5rem' }}>
<a href={profile} target="_blank">
<img src={image} alt={`${name} profile image`} />
</a>
<h4>{name}</h4>
</div>
<div className="w-100 d-flex align-items-center justify-content-end" style={{ gap: '.5rem' }}>
<a
className="btn btn-primary"
href={profile}
>
Conectar
</a>
</div>
</div>
))
) : (
<div className="view-more">Sin sugerencias</div>
)}
</div>
</div>
);
};
export default SuggestedGroupsHelper;