import React, { useState, useEffect } from 'react';
import PropTypes from 'prop-types';
import { Link } from 'react-router-dom';
import { UserType } from './Types';
import { info, fetchUserUri } from '../api';
import Avatar from './Avatar';
import Icon from './Icon';
import SearchBox from './SearchBox';
import './UserInfo.css';
let isMounted;
export default function UserInfo(props) {
const [user, setUser] = useState({ uname: props.user, uid: 0 });
const { onUpdate } = props;
useEffect(() => {
isMounted = true;
info(user.uname).then(response => {
if (isMounted) {
setUser(response.data);
onUpdate && onUpdate(response.data);
}
});
return () => {
isMounted = false;
};
}, [onUpdate, user.uname]);
return (
<>
Was online recently
{
user.uid > 0 &&
<>
PMRecommendationsPhotos
>
}
{props.children}
>
);
}
function Summary({ user }) {
let read = user.read && I read: {user.read.length};
let readers = user.readers && My readers: {user.readers.length}
let mybl = user.statsMyBL && My blacklist: {user.statsMyBL}
let presentItems = [read, readers, mybl].filter(Boolean);
return (