mirror of
https://github.com/duckietm/Nitro-V3.git
synced 2026-06-20 15:36:18 +00:00
🆙 Fix user profile
This commit is contained in:
@@ -8,8 +8,11 @@ export const UserContainerView: FC<{
|
|||||||
}> = props =>
|
}> = props =>
|
||||||
{
|
{
|
||||||
const { userProfile = null } = props;
|
const { userProfile = null } = props;
|
||||||
|
|
||||||
const [ requestSent, setRequestSent ] = useState(userProfile.requestSent);
|
const [ requestSent, setRequestSent ] = useState(userProfile.requestSent);
|
||||||
|
|
||||||
const isOwnProfile = (userProfile.id === GetSessionDataManager().userId);
|
const isOwnProfile = (userProfile.id === GetSessionDataManager().userId);
|
||||||
|
|
||||||
const canSendFriendRequest = !requestSent && (!isOwnProfile && !userProfile.isMyFriend && !userProfile.requestSent);
|
const canSendFriendRequest = !requestSent && (!isOwnProfile && !userProfile.isMyFriend && !userProfile.requestSent);
|
||||||
|
|
||||||
const infostandBackgroundClass = `background-${userProfile.backgroundId ?? 'default'}`;
|
const infostandBackgroundClass = `background-${userProfile.backgroundId ?? 'default'}`;
|
||||||
@@ -35,36 +38,75 @@ export const UserContainerView: FC<{
|
|||||||
<LayoutAvatarImageView direction={ 2 } figure={ userProfile.figure } />
|
<LayoutAvatarImageView direction={ 2 } figure={ userProfile.figure } />
|
||||||
<div className={`absolute inset-0 profile-overlay ${infostandOverlayClass}`} />
|
<div className={`absolute inset-0 profile-overlay ${infostandOverlayClass}`} />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex flex-col gap-2">
|
<div className="flex flex-col gap-2">
|
||||||
<div className="flex flex-col gap-0">
|
<div className="flex flex-col gap-0">
|
||||||
<p className="leading-tight font-bold">{ userProfile.username }</p>
|
<p className="leading-tight font-bold">{ userProfile.username }</p>
|
||||||
<p className="text-sm italic leading-tight">{ userProfile.motto }</p>
|
<p className="text-sm italic leading-tight">{ userProfile.motto }</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex flex-col gap-1">
|
<div className="flex flex-col gap-1">
|
||||||
<p className="text-sm leading-none" dangerouslySetInnerHTML={{ __html: LocalizeText('extendedprofile.created', ['created'], [userProfile.registration]) }} />
|
<p
|
||||||
<p className="text-sm leading-none" dangerouslySetInnerHTML={{ __html: LocalizeText('extendedprofile.last.login', ['lastlogin'], [FriendlyTime.format(userProfile.secondsSinceLastVisit, '.ago', 2)]) }} />
|
className="text-sm leading-none"
|
||||||
<p className="text-sm leading-none">
|
dangerouslySetInnerHTML={{
|
||||||
<b>{ LocalizeText('extendedprofile.friends.count') }</b> { userProfile.friendsCount }
|
__html: LocalizeText(
|
||||||
</p>
|
'extendedprofile.created',
|
||||||
|
['created'],
|
||||||
|
[userProfile.registration]
|
||||||
|
)
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<p
|
||||||
|
className="text-sm leading-none"
|
||||||
|
dangerouslySetInnerHTML={{
|
||||||
|
__html: LocalizeText(
|
||||||
|
'extendedprofile.last.login',
|
||||||
|
['lastlogin'],
|
||||||
|
[FriendlyTime.format(userProfile.secondsSinceLastVisit, '.ago', 2)]
|
||||||
|
)
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<p
|
||||||
|
className="text-sm leading-none"
|
||||||
|
dangerouslySetInnerHTML={{
|
||||||
|
__html: LocalizeText(
|
||||||
|
'extendedprofile.friends.count',
|
||||||
|
['count'],
|
||||||
|
[userProfile.friendsCount]
|
||||||
|
)
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
|
||||||
<p className="text-sm leading-none">
|
<p className="text-sm leading-none">
|
||||||
<b>{ LocalizeText('extendedprofile.achievementscore') }</b> { userProfile.achievementPoints }
|
<b>{ LocalizeText('extendedprofile.achievementscore') }</b> { userProfile.achievementPoints }
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex items-center gap-1">
|
<div className="flex items-center gap-1">
|
||||||
{ userProfile.isOnline &&
|
{ userProfile.isOnline &&
|
||||||
<i className="nitro-icon icon-pf-online" /> }
|
<i className="nitro-icon icon-pf-online" /> }
|
||||||
|
|
||||||
{ !userProfile.isOnline &&
|
{ !userProfile.isOnline &&
|
||||||
<i className="nitro-icon icon-pf-offline" /> }
|
<i className="nitro-icon icon-pf-offline" /> }
|
||||||
|
|
||||||
<div className="flex items-center gap-1">
|
<div className="flex items-center gap-1">
|
||||||
{ canSendFriendRequest &&
|
{ canSendFriendRequest &&
|
||||||
<Text pointer small underline onClick={ addFriend }>{ LocalizeText('extendedprofile.addasafriend') }</Text> }
|
<Text pointer small underline onClick={ addFriend }>
|
||||||
|
{ LocalizeText('extendedprofile.addasafriend') }
|
||||||
|
</Text> }
|
||||||
|
|
||||||
{ !canSendFriendRequest &&
|
{ !canSendFriendRequest &&
|
||||||
<>
|
<>
|
||||||
<i className="nitro-icon icon-pf-tick" />
|
<i className="nitro-icon icon-pf-tick" />
|
||||||
|
|
||||||
{ isOwnProfile &&
|
{ isOwnProfile &&
|
||||||
<p>{ LocalizeText('extendedprofile.me') }</p> }
|
<p>{ LocalizeText('extendedprofile.me') }</p> }
|
||||||
|
|
||||||
{ userProfile.isMyFriend &&
|
{ userProfile.isMyFriend &&
|
||||||
<p>{ LocalizeText('extendedprofile.friend') }</p> }
|
<p>{ LocalizeText('extendedprofile.friend') }</p> }
|
||||||
|
|
||||||
{ (requestSent || userProfile.requestSent) &&
|
{ (requestSent || userProfile.requestSent) &&
|
||||||
<p>{ LocalizeText('extendedprofile.friendrequestsent') }</p> }
|
<p>{ LocalizeText('extendedprofile.friendrequestsent') }</p> }
|
||||||
</> }
|
</> }
|
||||||
@@ -73,4 +115,4 @@ export const UserContainerView: FC<{
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@@ -9,7 +9,7 @@ import { FriendsContainerView } from './FriendsContainerView';
|
|||||||
import { GroupsContainerView } from './GroupsContainerView';
|
import { GroupsContainerView } from './GroupsContainerView';
|
||||||
import { UserContainerView } from './UserContainerView';
|
import { UserContainerView } from './UserContainerView';
|
||||||
|
|
||||||
type ProfileTab = 'badge' | 'amici' | 'stanze' | 'gruppi';
|
type ProfileTab = 'badge' | 'friends' | 'rooms' | 'groups';
|
||||||
|
|
||||||
export const UserProfileView: FC<{}> = props =>
|
export const UserProfileView: FC<{}> = props =>
|
||||||
{
|
{
|
||||||
@@ -39,7 +39,7 @@ export const UserProfileView: FC<{}> = props =>
|
|||||||
{
|
{
|
||||||
setActiveTab(tab);
|
setActiveTab(tab);
|
||||||
|
|
||||||
if(tab === 'stanze' && !userRooms && userProfile)
|
if(tab === 'rooms' && !userRooms && userProfile)
|
||||||
{
|
{
|
||||||
SendMessageComposer(new NavigatorSearchComposer('hotel_view', `owner:${ userProfile.username }`));
|
SendMessageComposer(new NavigatorSearchComposer('hotel_view', `owner:${ userProfile.username }`));
|
||||||
}
|
}
|
||||||
@@ -99,7 +99,7 @@ export const UserProfileView: FC<{}> = props =>
|
|||||||
|
|
||||||
useMessageEvent<NavigatorSearchEvent>(NavigatorSearchEvent, event =>
|
useMessageEvent<NavigatorSearchEvent>(NavigatorSearchEvent, event =>
|
||||||
{
|
{
|
||||||
if(!userProfile || activeTab !== 'stanze') return;
|
if(!userProfile || activeTab !== 'rooms') return;
|
||||||
|
|
||||||
const parser = event.getParser();
|
const parser = event.getParser();
|
||||||
const result = parser.result;
|
const result = parser.result;
|
||||||
@@ -145,16 +145,16 @@ export const UserProfileView: FC<{}> = props =>
|
|||||||
</div>
|
</div>
|
||||||
<NitroCard.Tabs>
|
<NitroCard.Tabs>
|
||||||
<NitroCard.TabItem isActive={ activeTab === 'badge' } count={ userBadges.length } onClick={ () => onTabClick('badge') }>
|
<NitroCard.TabItem isActive={ activeTab === 'badge' } count={ userBadges.length } onClick={ () => onTabClick('badge') }>
|
||||||
{ LocalizeText('extendedprofile.tab.badge') }
|
{ LocalizeText('levelinfo.category.badge') }
|
||||||
</NitroCard.TabItem>
|
</NitroCard.TabItem>
|
||||||
<NitroCard.TabItem isActive={ activeTab === 'amici' } count={ userProfile.friendsCount } onClick={ () => onTabClick('amici') }>
|
<NitroCard.TabItem isActive={ activeTab === 'friends' } count={ userProfile.friendsCount } onClick={ () => onTabClick('friends') }>
|
||||||
{ LocalizeText('extendedprofile.tab.friends') }
|
{ LocalizeText('navigator.tab.3') }
|
||||||
</NitroCard.TabItem>
|
</NitroCard.TabItem>
|
||||||
<NitroCard.TabItem isActive={ activeTab === 'stanze' } onClick={ () => onTabClick('stanze') }>
|
<NitroCard.TabItem isActive={ activeTab === 'rooms' } onClick={ () => onTabClick('rooms') }>
|
||||||
{ LocalizeText('extendedprofile.tab.rooms') }
|
{ LocalizeText('navigator.tab.2') }
|
||||||
</NitroCard.TabItem>
|
</NitroCard.TabItem>
|
||||||
<NitroCard.TabItem isActive={ activeTab === 'gruppi' } count={ userProfile.groups?.length } onClick={ () => onTabClick('gruppi') }>
|
<NitroCard.TabItem isActive={ activeTab === 'groups' } count={ userProfile.groups?.length } onClick={ () => onTabClick('groups') }>
|
||||||
{ LocalizeText('extendedprofile.tab.groups') }
|
{ LocalizeText('navigator.searchcode.title.groups') }
|
||||||
</NitroCard.TabItem>
|
</NitroCard.TabItem>
|
||||||
</NitroCard.Tabs>
|
</NitroCard.Tabs>
|
||||||
<div className="flex-1 overflow-auto p-2">
|
<div className="flex-1 overflow-auto p-2">
|
||||||
@@ -172,7 +172,7 @@ export const UserProfileView: FC<{}> = props =>
|
|||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
) }
|
) }
|
||||||
{ activeTab === 'amici' && (
|
{ activeTab === 'friends' && (
|
||||||
<div className="flex flex-col gap-2 h-full">
|
<div className="flex flex-col gap-2 h-full">
|
||||||
{ userRelationships ? (
|
{ userRelationships ? (
|
||||||
<FriendsContainerView friendsCount={ userProfile.friendsCount } relationships={ userRelationships } />
|
<FriendsContainerView friendsCount={ userProfile.friendsCount } relationships={ userRelationships } />
|
||||||
@@ -183,7 +183,7 @@ export const UserProfileView: FC<{}> = props =>
|
|||||||
) }
|
) }
|
||||||
</div>
|
</div>
|
||||||
) }
|
) }
|
||||||
{ activeTab === 'stanze' && (
|
{ activeTab === 'rooms' && (
|
||||||
<div className="flex flex-col gap-1 h-full">
|
<div className="flex flex-col gap-1 h-full">
|
||||||
{ !userRooms && (
|
{ !userRooms && (
|
||||||
<Flex center className="h-full">
|
<Flex center className="h-full">
|
||||||
@@ -206,7 +206,7 @@ export const UserProfileView: FC<{}> = props =>
|
|||||||
)) }
|
)) }
|
||||||
</div>
|
</div>
|
||||||
) }
|
) }
|
||||||
{ activeTab === 'gruppi' && (
|
{ activeTab === 'groups' && (
|
||||||
<div className="h-full">
|
<div className="h-full">
|
||||||
<GroupsContainerView fullWidth groups={ userProfile.groups } itsMe={ userProfile.id === GetSessionDataManager().userId } onLeaveGroup={ onLeaveGroup } />
|
<GroupsContainerView fullWidth groups={ userProfile.groups } itsMe={ userProfile.id === GetSessionDataManager().userId } onLeaveGroup={ onLeaveGroup } />
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user