You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
78 lines
2.4 KiB
78 lines
2.4 KiB
import React, { FC } from 'react'
|
|
import { useSelector } from 'react-redux'
|
|
import { Link } from 'react-router-dom'
|
|
|
|
import { getAuthenticatedUser } from 'src/selectors/authentication'
|
|
import { AppState, User } from 'src/types'
|
|
|
|
|
|
const UserInfo: FC = () => {
|
|
const user = useSelector<AppState, User | undefined>(getAuthenticatedUser)
|
|
|
|
const hasAvatar = user && user.imageUrl
|
|
const imageUrl = hasAvatar ? user!.imageUrl : undefined
|
|
|
|
const name = () => {
|
|
if (!user) return <span></span>
|
|
|
|
if (user.name) {
|
|
return (
|
|
<>
|
|
<Link to="/self" className="is-size-4 has-text-white">{user.name}</Link>
|
|
<br />
|
|
<Link to="/self" className="is-size-6 has-text-white-ter">@{user.id}</Link>
|
|
</>
|
|
)
|
|
}
|
|
|
|
return <Link to="/self" className="is-size-4 has-text-white-ter">@{user.id}</Link>
|
|
}
|
|
|
|
const content = () => {
|
|
if (user) {
|
|
return (
|
|
<div className="media-content">
|
|
<div className="content">
|
|
<div>
|
|
{name()}
|
|
<br />
|
|
{user.group &&
|
|
<Link to={`/c/${user.group.id}`} className="is-size-5 has-text-success">{user.group.name}</Link>
|
|
}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
return (
|
|
<div className="media-content">
|
|
<div className="content">
|
|
<div className="has-text-centered">
|
|
<Link to="/login" className="is-size-5 has-text-white">Log In to Flexor</Link>
|
|
<p className="is-size-7 has-text-primary is-uppercase">
|
|
or
|
|
</p>
|
|
<Link to="/communities" className="is-size-6 has-text-light">Create an Account</Link>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
return (
|
|
<article id="user-info" className="media has-background-black">
|
|
{hasAvatar &&
|
|
<figure className="media-left">
|
|
<p className="image is-64x64">
|
|
<img src={imageUrl} />
|
|
</p>
|
|
</figure>
|
|
}
|
|
|
|
{content()}
|
|
</article>
|
|
)
|
|
}
|
|
|
|
export default UserInfo
|