import React , { useState, useEffect } from 'react';
import { WhiteBack , Greenline , UDStructure , Grid } from '../css/layout';
import UserInfo from './UserInfo';
import { getImageUrl } from "educoder";
import StarUser from "../../user_info/User/StarUser";
export default (({user})=>{
  useEffect(() => {
    if(user){
      setFansCount(user.watchers_count)
    }
  },[]);
  const [fansCount, setFansCount] = useState(0)
  const fans_count = (count) => {
    let new_fans_count = fansCount + count
    setFansCount(new_fans_count)
  }
 
  return(
    <WhiteBack className="authorCard">
      <UserInfo url={getImageUrl(user && user.image_url)} name={user && user.username} login={user && user.login} column/>
      <p style={{width:"100%"}} className="task-hide grey-8 mt10 mb15 edu-text-center">{user && user.description ? user.description : "这家伙太懒了，还未填写个人描述！"}</p>
      {/* {user && !user.is_current_user && (
          <StarUser
            current_login={user.current_login}
            login={user.login}
            user_id={user.user_id}
            is_watched={user.watched}
            is_blocked={user.is_blocked}
            user_name={user.username}
            is_blocked_by={user.is_blocked_by}
            set_fans_count={fans_count}
            show_block={false}
          ></StarUser>
        )} */}
      <Grid className="mt20">
        <UDStructure>
      <span>{user && user.memos_count}</span>
          <span>文章数</span>
        </UDStructure>
        <UDStructure>
          <span>{user && user.replies_count}</span>
          <span>评论数</span>
        </UDStructure>
        <UDStructure>
          <span>{fansCount}</span>
          <span>关注者</span>
        </UDStructure>
      </Grid>
    </WhiteBack>
  )
})