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.
79 lines
2.8 KiB
79 lines
2.8 KiB
import React, { FC } from 'react'
|
|
import { useSelector } from 'react-redux'
|
|
import { Link } from 'react-router-dom'
|
|
|
|
import { getConfig } from 'src/selectors'
|
|
import { getAuthenticatedUser } from 'src/selectors/authentication'
|
|
import { urlForBlob } from 'src/utils'
|
|
import { AppState, User, Config } from 'src/types'
|
|
|
|
const SelfInfo: FC = () => {
|
|
const user = useSelector<AppState, User | undefined>(getAuthenticatedUser)
|
|
const config = useSelector<AppState, Config>(getConfig)
|
|
|
|
const imageUrl = user && user.imageUrl ? urlForBlob(config, user.imageUrl) : undefined
|
|
|
|
const name = (user: User) => {
|
|
if (user.name) {
|
|
return (
|
|
<Link to="/self" className="has-text-white">
|
|
<span className="is-size-5">{user.name}</span> <span className="is-size-6 has-text-weight-bold">@{user.id}</span>
|
|
</Link>
|
|
)
|
|
}
|
|
|
|
return <Link to="/self" className="is-size-4 has-text-white-ter">@{user.id}</Link>
|
|
}
|
|
|
|
const content = () => {
|
|
if (user) {
|
|
const group = user.group
|
|
const groupImageUrl = group && group.iconImageUrl ? urlForBlob(config, group.iconImageUrl) : undefined
|
|
|
|
return (
|
|
<div>
|
|
{name(user)}
|
|
<br />
|
|
{group &&
|
|
<div>
|
|
{groupImageUrl &&
|
|
<figure className="image is-16x16 is-inline">
|
|
<img src={groupImageUrl} style={{ width: 16 }} />
|
|
</figure>
|
|
}
|
|
|
|
<Link to={`/c/${group.id}`} className="is-size-5 has-text-success">{group.name}</Link>
|
|
</div>
|
|
}
|
|
</div>
|
|
)
|
|
}
|
|
|
|
return (
|
|
<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>
|
|
)
|
|
}
|
|
|
|
return (
|
|
<article id="user-info" className="media has-background-black">
|
|
{imageUrl &&
|
|
<figure className="media-left">
|
|
<p className="image is-32x32">
|
|
<img src={imageUrl} style={{ width: 32 }} />
|
|
</p>
|
|
</figure>
|
|
}
|
|
<div className="media-content">
|
|
<div className="content">
|
|
{content()}
|
|
</div>
|
|
</div>
|
|
</article>
|
|
)
|
|
}
|
|
|
|
export default SelfInfo
|