Rev 2433 | Rev 2925 | 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 SuggestedGroupsHelper = (props) => {// props destructuringconst { groupId } = props;// statesconst [suggestedGroups, setSuggestedGroups] = useState([]);const [lookMore, setLookMore] = useState(false);useEffect(() => {axios.get(`/helpers/groups-suggestion/${groupId}`).then((response) => {const resData = response.data;if (resData.success) {setSuggestedGroups(resData.data);} else {// alert error}});}, []);const getData = () => {let infoFollows = [...suggestedGroups]if (!lookMore) {infoFollows = infoFollows.slice(0, 5);}return infoFollows}return (<div className="right-sidebar border-radius border-gray p-3" style={{ maxHeight: "450px" }}><div className="sd-title"><h3>Grupos Similares</h3></div><divclassName="mb-2"id="suggestions-similar-groups"style={{ height: "80%", overflowY: "auto" }}>{suggestedGroups.length ? (getData().map(({ id, name, image, profile }) => (<div className="suggestion-usd" key={id}><divclassName="row"><divclassName="col-md-4 col-sm-12"><imgstyle={{ width: "50px", height: "auto" }}src={image}alt=""/></div><divclassName="col-8 d-flex align-items-center justify-content-start p-0"><div className="sgt-text"><h4className="cursor-pointer"onClick={() => window.location.href = profile}>{name}</h4></div></div></div></div>))) : (<div className="view-more">Sin sugerencias</div>)}</div>{suggestedGroups.length >= 5 && (<div className="w-100 text-center"><button className="btn btn-primary" onClick={() => setLookMore(!lookMore)}>{lookMore ? 'Ver menos' : 'Ver mas'}</button></div>)}</div>);};export default SuggestedGroupsHelper;