diff --git a/src/components/pages/view-group.tsx b/src/components/pages/view-group.tsx index 9813c45..b181337 100644 --- a/src/components/pages/view-group.tsx +++ b/src/components/pages/view-group.tsx @@ -15,6 +15,7 @@ import { AppState, EntityType, Group, GroupMembershipType, AppThunkDispatch } fr import PageHeader from 'src/components/page-header' import GroupInfo from 'src/components/group-info' import Loading from 'src/components/pages/loading' +import { getAuthenticated } from 'src/selectors/authentication' interface Params { id: string @@ -23,6 +24,7 @@ interface Params { const ViewGroup: FC = () => { const { id } = useParams() const group = useSelector(state => getEntity(state, EntityType.Group, id)) + const authenticated = useSelector(getAuthenticated) const dispatch = useDispatch() const config = useConfig() const history = useHistory() @@ -42,6 +44,7 @@ const ViewGroup: FC = () => { if (!group) return const isAdmin = group.membership === GroupMembershipType.Admin + const isMember = !!group.membership const imageUrl = group.imageUrl ? urlForBlob(config, group.imageUrl) : undefined return ( @@ -72,19 +75,23 @@ const ViewGroup: FC = () => {
- - - - - Create an Account - - - + {!authenticated && + + + + + Create an Account + + } + + {!isMember && + + } {isAdmin && diff --git a/src/components/pages/view-user.tsx b/src/components/pages/view-user.tsx index 961baae..31122b6 100644 --- a/src/components/pages/view-user.tsx +++ b/src/components/pages/view-user.tsx @@ -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() + const self = useSelector(getAuthenticatedUser) const user = useSelector(state => getEntity(state, EntityType.User, id)) const dispatch = useDispatch() const config = useConfig() @@ -41,6 +42,9 @@ const ViewUser: FC = () => { }, [user]) if (!user) return + + 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 = () => { Susbcribe - + {!isSelf && + + } - {user.group && + {user.group && !isGroup &&