|
|
@ -7,6 +7,7 @@ import { faUserPlus, faUserMinus, faBan } from '@fortawesome/free-solid-svg-icon |
|
|
|
import { handleApiError } from 'src/api/errors' |
|
|
|
import { fetchUser } from 'src/actions/users' |
|
|
|
import { getEntity } from 'src/selectors/entities' |
|
|
|
import { getAuthenticatedUser } from 'src/selectors/authentication' |
|
|
|
|
|
|
|
import { useDeepCompareEffect, useConfig } from 'src/hooks' |
|
|
|
import { setTitle, urlForBlob } from 'src/utils' |
|
|
@ -15,7 +16,6 @@ import { AppState, EntityType, User, AppThunkDispatch } from 'src/types' |
|
|
|
import PageHeader from 'src/components/page-header' |
|
|
|
import UserInfo from 'src/components/user-info' |
|
|
|
import Loading from 'src/components/pages/loading' |
|
|
|
import GroupAdmin from './group-admin' |
|
|
|
|
|
|
|
interface Params { |
|
|
|
id: string |
|
|
@ -23,6 +23,7 @@ interface Params { |
|
|
|
|
|
|
|
const ViewUser: FC = () => { |
|
|
|
const { id } = useParams<Params>() |
|
|
|
const self = useSelector<AppState, User | undefined>(getAuthenticatedUser) |
|
|
|
const user = useSelector<AppState, User | undefined>(state => getEntity<User>(state, EntityType.User, id)) |
|
|
|
const dispatch = useDispatch<AppThunkDispatch>() |
|
|
|
const config = useConfig() |
|
|
@ -41,6 +42,9 @@ const ViewUser: FC = () => { |
|
|
|
}, [user]) |
|
|
|
|
|
|
|
if (!user) return <Loading /> |
|
|
|
|
|
|
|
const isSelf = self && self.id === user.id |
|
|
|
const isGroup = self && self.group && user.group && self.group.id === user.group.id |
|
|
|
const imageUrl = user.imageUrl ? urlForBlob(config, user.imageUrl) : undefined |
|
|
|
|
|
|
|
return ( |
|
|
@ -81,14 +85,16 @@ const ViewUser: FC = () => { |
|
|
|
<span>Susbcribe</span> |
|
|
|
</button> |
|
|
|
|
|
|
|
<button className="button is-danger"> |
|
|
|
<span className="icon is-small"> |
|
|
|
<FontAwesomeIcon icon={faBan} /> |
|
|
|
</span> |
|
|
|
<span>Block</span> |
|
|
|
</button> |
|
|
|
{!isSelf && |
|
|
|
<button className="button is-danger"> |
|
|
|
<span className="icon is-small"> |
|
|
|
<FontAwesomeIcon icon={faBan} /> |
|
|
|
</span> |
|
|
|
<span>Block</span> |
|
|
|
</button> |
|
|
|
} |
|
|
|
|
|
|
|
{user.group && |
|
|
|
{user.group && !isGroup && |
|
|
|
<button className="button is-danger"> |
|
|
|
<span className="icon is-small"> |
|
|
|
<FontAwesomeIcon icon={faBan} /> |
|
|
|