Rev 2441 | Rev 3642 | Ir a la última revisión | Autoría | Comparar con el anterior | Ultima modificación | Ver Log |
/* eslint-disable react/prop-types */import React from "react";import { useEffect, useState } from "react";import { axios } from "../../../utils";const PeopleViewedHelper = ({ profileId }) => {const [peopleViewedProfile, setPeopleViewedProfile] = useState([]);const [lookMore, setLookMore] = useState(false);useEffect(() => {axios.get(`/helpers/people-viewed-profile/${profileId}`).then(({ data }) => {if (data.success) setPeopleViewedProfile(data.data)});}, []);const getData = () => {let infoFollows = [...peopleViewedProfile]if (!lookMore) {infoFollows = infoFollows.slice(0, 5);}return infoFollows}return (<div className="right-sidebar peopleYouMayKnow" style={{ maxHeight: '450px', marginTop: '0' }}><div className="sd-title"><h3>Quién ha visto este perfil</h3></div><divclassName="mb-2"id="suggestions-similar-groups"style={{ height: "80%", overflowY: "auto" }}>{peopleViewedProfile.length? getData().map(({ id, name, image, profile }) =><div className="suggestion-usd" key={id}><div className="row"><div className="col-md-4 col-sm-12" ><imgstyle={{ width: "50px", height: "auto" }}src={image}alt=""/></div><div className="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>{peopleViewedProfile.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 PeopleViewedHelper;