diff --git a/src/assets/styles/icons.scss b/src/assets/styles/icons.scss index b80928fd..46ae31e4 100644 --- a/src/assets/styles/icons.scss +++ b/src/assets/styles/icons.scss @@ -521,7 +521,7 @@ &.icon-pf-offline { background: url('../images/profile/icons/offline.png'); - width: 40px; + width: 39px; height: 16px; } diff --git a/src/views/groups/GroupView.scss b/src/views/groups/GroupView.scss index 32ca5256..c7841e34 100644 --- a/src/views/groups/GroupView.scss +++ b/src/views/groups/GroupView.scss @@ -1 +1 @@ -@import './views/GroupinformationView'; +@import './views/information/GroupInformationView'; diff --git a/src/views/groups/views/GroupInformationView.tsx b/src/views/groups/views/GroupInformationView.tsx deleted file mode 100644 index 57db4ca2..00000000 --- a/src/views/groups/views/GroupInformationView.tsx +++ /dev/null @@ -1,90 +0,0 @@ -import { GroupInformationComposer, GroupInformationEvent, GroupInformationParser } from '@nitrots/nitro-renderer'; -import { FC, useCallback, useEffect, useState } from 'react'; -import { LocalizeText } from '../../../api'; -import { CreateMessageHook, SendMessageHook } from '../../../hooks'; -import { BadgeImageView } from '../../shared/badge-image/BadgeImageView'; -import { GroupMembershipType } from '../common/GroupMembershipType'; -import { GroupType } from '../common/GroupType'; -import { GroupInformationViewProps } from './GroupInformationView.types'; - -export const GroupInformationView: FC = props => -{ - const { group = null } = props; - - const [ groupInformation, setGroupInformation ] = useState(null); - - useEffect(() => - { - setGroupInformation(null); - if(group) SendMessageHook(new GroupInformationComposer(group.id, true)); - }, [ group ]); - - const onGroupInformationEvent = useCallback((event: GroupInformationEvent) => - { - const parser = event.getParser(); - setGroupInformation(parser); - }, []); - - CreateMessageHook(GroupInformationEvent, onGroupInformationEvent); - - if(!groupInformation) return null; - - return ( -
-
-
- - - -
- { groupInformation.membershipType === GroupMembershipType.MEMBER && !groupInformation.isAdmin && } - { groupInformation.isAdmin && !groupInformation.isOwner && } - { groupInformation.isOwner && } -
-
-
-
-
- - { groupInformation.canMembersDecorate && } -
{ group.title }
-
-
{ LocalizeText('group.created', ['date', 'owner'], [groupInformation.createdAt, groupInformation.ownerName]) }
-
{ groupInformation.description }
- - - - { groupInformation.type !== GroupType.PRIVATE && - - } -
-
- ); -}; diff --git a/src/views/groups/views/GroupinformationView.scss b/src/views/groups/views/information/GroupInformationView.scss similarity index 100% rename from src/views/groups/views/GroupinformationView.scss rename to src/views/groups/views/information/GroupInformationView.scss diff --git a/src/views/groups/views/information/GroupInformationView.tsx b/src/views/groups/views/information/GroupInformationView.tsx new file mode 100644 index 00000000..53607853 --- /dev/null +++ b/src/views/groups/views/information/GroupInformationView.tsx @@ -0,0 +1,146 @@ +import { GroupInformationComposer, GroupInformationEvent, GroupInformationParser, GroupJoinComposer, GroupRemoveMemberComposer } from '@nitrots/nitro-renderer'; +import { FC, useCallback, useEffect, useState } from 'react'; +import { GetSessionDataManager, LocalizeText } from '../../../../api'; +import { CreateMessageHook, SendMessageHook } from '../../../../hooks'; +import { BadgeImageView } from '../../../shared/badge-image/BadgeImageView'; +import { GroupMembershipType } from '../../common/GroupMembershipType'; +import { GroupType } from '../../common/GroupType'; +import { GroupInformationViewProps } from './GroupInformationView.types'; + +export const GroupInformationView: FC = props => +{ + const { group = null, onLeaveGroup = null } = props; + + const [ groupInformation, setGroupInformation ] = useState(null); + + useEffect(() => + { + setGroupInformation(null); + if(group) SendMessageHook(new GroupInformationComposer(group.id, false)); + }, [ group ]); + + const onGroupInformationEvent = useCallback((event: GroupInformationEvent) => + { + const parser = event.getParser(); + + if(groupInformation) setGroupInformation(null); + + setGroupInformation(parser); + }, [ groupInformation ]); + + CreateMessageHook(GroupInformationEvent, onGroupInformationEvent); + + const tryJoinGroup = useCallback(() => + { + if(!groupInformation) return; + + SendMessageHook(new GroupJoinComposer(groupInformation.id)); + SendMessageHook(new GroupInformationComposer(groupInformation.id, false)); + }, [ groupInformation ]); + + const tryLeaveGroup = useCallback(() => + { + SendMessageHook(new GroupRemoveMemberComposer(groupInformation.id, GetSessionDataManager().userId)); + SendMessageHook(new GroupInformationComposer(groupInformation.id, false)); + if(onLeaveGroup) onLeaveGroup(); + }, [ groupInformation, onLeaveGroup ]); + + const isOwner = useCallback(() => + { + if(!group) return false; + + return (group.ownerId === GetSessionDataManager().userId); + }, [ group, groupInformation ]); + + const getRoleIcon = useCallback(() => + { + if(groupInformation.membershipType === GroupMembershipType.NOT_MEMBER || groupInformation.membershipType === GroupMembershipType.REQUEST_PENDING) return null; + + if(isOwner()) return ; + + if(groupInformation.isAdmin) return ; + + return ; + }, [ groupInformation, isOwner ]); + + const getButtonText = useCallback(() => + { + if(groupInformation.type === GroupType.PRIVATE) return ''; + + if(isOwner()) return 'group.youareowner'; + + if(groupInformation.membershipType === GroupMembershipType.MEMBER) return 'group.leave'; + + if(groupInformation.membershipType === GroupMembershipType.NOT_MEMBER && groupInformation.type === GroupType.REGULAR) return 'group.join'; + + if(groupInformation.type === GroupType.EXCLUSIVE) + { + if(groupInformation.membershipType === GroupMembershipType.NOT_MEMBER) return 'group.requestmembership'; + + if(groupInformation.membershipType === GroupMembershipType.REQUEST_PENDING) return 'group.membershippending'; + } + }, [ groupInformation, isOwner ]); + + const handleButtonClick = useCallback(() => + { + if(groupInformation.type === GroupType.PRIVATE && groupInformation.membershipType === GroupMembershipType.NOT_MEMBER) return; + + if(groupInformation.membershipType === GroupMembershipType.MEMBER) return tryLeaveGroup(); + + return tryJoinGroup(); + }, [ groupInformation, tryLeaveGroup, tryJoinGroup ]); + + if(!group || !groupInformation) return null; + + return ( +
+ +
+
+ + { groupInformation.canMembersDecorate && } +
{ group.title }
+
+
{ LocalizeText('group.created', ['date', 'owner'], [groupInformation.createdAt, groupInformation.ownerName]) }
+
{ groupInformation.description }
+ + + + { groupInformation.type !== GroupType.PRIVATE && + + } +
+
+ ); +}; diff --git a/src/views/groups/views/GroupInformationView.types.ts b/src/views/groups/views/information/GroupInformationView.types.ts similarity index 81% rename from src/views/groups/views/GroupInformationView.types.ts rename to src/views/groups/views/information/GroupInformationView.types.ts index 70aae855..9543b88f 100644 --- a/src/views/groups/views/GroupInformationView.types.ts +++ b/src/views/groups/views/information/GroupInformationView.types.ts @@ -3,4 +3,5 @@ import { GroupDataParser } from '@nitrots/nitro-renderer'; export interface GroupInformationViewProps { group: GroupDataParser; + onLeaveGroup?: () => void; } diff --git a/src/views/navigator/views/room-info/NavigatorRoomInfoView.scss b/src/views/navigator/views/room-info/NavigatorRoomInfoView.scss index 9763a4fc..87a267c7 100644 --- a/src/views/navigator/views/room-info/NavigatorRoomInfoView.scss +++ b/src/views/navigator/views/room-info/NavigatorRoomInfoView.scss @@ -17,4 +17,9 @@ background-color: rgba($black, .125); border-color: $black !important; } + + .group-badge { + width: 50px; + height: 50px; + } } diff --git a/src/views/navigator/views/room-info/NavigatorRoomInfoView.tsx b/src/views/navigator/views/room-info/NavigatorRoomInfoView.tsx index 62e789f7..3991ac6f 100644 --- a/src/views/navigator/views/room-info/NavigatorRoomInfoView.tsx +++ b/src/views/navigator/views/room-info/NavigatorRoomInfoView.tsx @@ -131,10 +131,10 @@ export const NavigatorRoomInfoView: FC = props => { roomThumbnail && } { roomInfoData.enteredGuestRoom.habboGroupId > 0 &&
processAction('open_group_info') }> -
+
-
+
{ LocalizeText('navigator.guildbase', ['groupName'], [roomInfoData.enteredGuestRoom.groupName]) }
} diff --git a/src/views/user-profile/UserProfileView.tsx b/src/views/user-profile/UserProfileView.tsx index 796fda0d..e732b384 100644 --- a/src/views/user-profile/UserProfileView.tsx +++ b/src/views/user-profile/UserProfileView.tsx @@ -1,6 +1,6 @@ -import { RelationshipStatusInfoEvent, RelationshipStatusInfoMessageParser, UserCurrentBadgesComposer, UserCurrentBadgesEvent, UserProfileEvent, UserProfileParser, UserRelationshipsComposer } from '@nitrots/nitro-renderer'; +import { RelationshipStatusInfoEvent, RelationshipStatusInfoMessageParser, UserCurrentBadgesComposer, UserCurrentBadgesEvent, UserProfileComposer, UserProfileEvent, UserProfileParser, UserRelationshipsComposer } from '@nitrots/nitro-renderer'; import { FC, useCallback, useState } from 'react'; -import { LocalizeText } from '../../api'; +import { GetSessionDataManager, LocalizeText } from '../../api'; import { CreateMessageHook, SendMessageHook } from '../../hooks'; import { NitroCardContentView, NitroCardHeaderView, NitroCardView } from '../../layout'; import { BadgesContainerView } from './views/badges-container/BadgesContainerView'; @@ -20,6 +20,11 @@ export const UserProfileView: FC = props => setUserBadges([]); setUserRelationships(null); }, []); + + const onLeaveGroup = useCallback(() => + { + if(userProfile && userProfile.id === GetSessionDataManager().userId) SendMessageHook(new UserProfileComposer(userProfile.id)); + }, [ userProfile ]); const OnUserCurrentBadgesEvent = useCallback((event: UserCurrentBadgesEvent) => { @@ -45,14 +50,14 @@ export const UserProfileView: FC = props => { const parser = event.getParser(); - if(userProfile && userProfile.id !== parser.id) + if(userProfile) { + setUserProfile(null); setUserBadges([]); setUserRelationships(null); } setUserProfile(parser); - console.log(parser); SendMessageHook(new UserCurrentBadgesComposer(parser.id)); SendMessageHook(new UserRelationshipsComposer(parser.id)); }, [userProfile]); @@ -67,8 +72,8 @@ export const UserProfileView: FC = props =>
- - + +
{ @@ -81,7 +86,7 @@ export const UserProfileView: FC = props => {LocalizeText('extendedprofile.rooms')}
- +
) diff --git a/src/views/user-profile/views/badges-container/BadgesContainerView.tsx b/src/views/user-profile/views/badges-container/BadgesContainerView.tsx index ca698bdb..cba4e091 100644 --- a/src/views/user-profile/views/badges-container/BadgesContainerView.tsx +++ b/src/views/user-profile/views/badges-container/BadgesContainerView.tsx @@ -7,7 +7,7 @@ export const BadgesContainerView: FC = props => const { badges = null } = props; return ( -
+
{ diff --git a/src/views/user-profile/views/groups-container/GroupsContainerView.tsx b/src/views/user-profile/views/groups-container/GroupsContainerView.tsx index 8ea5895c..9e10dafa 100644 --- a/src/views/user-profile/views/groups-container/GroupsContainerView.tsx +++ b/src/views/user-profile/views/groups-container/GroupsContainerView.tsx @@ -1,12 +1,12 @@ import classNames from 'classnames'; import { FC, useEffect, useState } from 'react'; -import { GroupInformationView } from '../../../groups/views/GroupInformationView'; +import { GroupInformationView } from '../../../groups/views/information/GroupInformationView'; import { BadgeImageView } from '../../../shared/badge-image/BadgeImageView'; import { GroupsContainerViewProps } from './GroupsContainerView.types'; export const GroupsContainerView: FC = props => { - const { groups = null } = props; + const { groups = null, onLeaveGroup = null } = props; const [ selectedIndex, setSelectedIndex ] = useState(null); @@ -30,7 +30,7 @@ export const GroupsContainerView: FC = props =>
- { selectedIndex > -1 && } + { selectedIndex > -1 && }
); diff --git a/src/views/user-profile/views/groups-container/GroupsContainerView.types.ts b/src/views/user-profile/views/groups-container/GroupsContainerView.types.ts index 3402bd99..0426ca8e 100644 --- a/src/views/user-profile/views/groups-container/GroupsContainerView.types.ts +++ b/src/views/user-profile/views/groups-container/GroupsContainerView.types.ts @@ -3,4 +3,5 @@ import { GroupDataParser } from '@nitrots/nitro-renderer'; export interface GroupsContainerViewProps { groups: GroupDataParser[]; + onLeaveGroup: () => void; } diff --git a/src/views/user-profile/views/user-container/UserContainerView.tsx b/src/views/user-profile/views/user-container/UserContainerView.tsx index a9f5456f..8d024a39 100644 --- a/src/views/user-profile/views/user-container/UserContainerView.tsx +++ b/src/views/user-profile/views/user-container/UserContainerView.tsx @@ -6,38 +6,38 @@ import { UserContainerViewProps } from './UserContainerView.types'; export const UserContainerView: FC = props => { - const { figure = null, username = null, motto = null, creation = null, secondsSinceLastLogin = null, achievementScore, isFriend = null, isOnline = null, id = null, requestSent = null } = props; + const { userProfile = null } = props; const OnlineIcon = useCallback(() => { - if(isOnline) return (); + if(userProfile.isOnline) return (); else return (); - }, [isOnline]); + }, [ userProfile ]); const FriendRequestComponent = useCallback(() => { - if(id === GetSessionDataManager().userId) return ({LocalizeText('extendedprofile.me')} ); + if(userProfile.id === GetSessionDataManager().userId) return ({LocalizeText('extendedprofile.me')} ); - if(isFriend) return ({LocalizeText('extendedprofile.friend')}); + if(userProfile.isMyFriend) return ({LocalizeText('extendedprofile.friend')}); - if(requestSent) return ({LocalizeText('extendedprofile.friendrequestsent')}); + if(userProfile.requestSent) return ({LocalizeText('extendedprofile.friendrequestsent')}); return () - }, [id, isFriend, requestSent]); + }, [ userProfile ]); return (
- +
-
{username}
-
{motto}
-
-
-
{LocalizeText('extendedprofile.achievementscore')} {achievementScore}
-
+
{userProfile.username}
+
{userProfile.motto}
+
+
+
{LocalizeText('extendedprofile.achievementscore')} {userProfile.achievementPoints}
+
diff --git a/src/views/user-profile/views/user-container/UserContainerView.types.ts b/src/views/user-profile/views/user-container/UserContainerView.types.ts index 9ef01c32..88df91d4 100644 --- a/src/views/user-profile/views/user-container/UserContainerView.types.ts +++ b/src/views/user-profile/views/user-container/UserContainerView.types.ts @@ -1,12 +1,6 @@ -export interface UserContainerViewProps { - id: number; - username: string; - figure: string; - motto: string; - creation: string; - secondsSinceLastLogin: number; - achievementScore: number; - isFriend: boolean; - requestSent: boolean; - isOnline: boolean; +import { UserProfileParser } from '@nitrots/nitro-renderer'; + +export interface UserContainerViewProps +{ + userProfile: UserProfileParser; }