import { GetSessionDataManager, RequestFriendComposer, UserProfileParser } from '@nitrots/nitro-renderer'; import { FC, useEffect, useState } from 'react'; import { FriendlyTime, LocalizeText, SendMessageComposer } from '../../api'; import { LayoutAvatarImageView, Text } from '../../common'; export const UserContainerView: FC<{ userProfile: UserProfileParser; }> = props => { const { userProfile = null } = props; const [ requestSent, setRequestSent ] = useState(userProfile.requestSent); const isOwnProfile = (userProfile.id === GetSessionDataManager().userId); const canSendFriendRequest = !requestSent && (!isOwnProfile && !userProfile.isMyFriend && !userProfile.requestSent); const infostandBackgroundClass = `background-${userProfile.backgroundId ?? 'default'}`; const infostandStandClass = `stand-${userProfile.standId ?? 'default'}`; const infostandOverlayClass = `overlay-${userProfile.overlayId ?? 'default'}`; const profileCardBgClass = userProfile.cardBackgroundId ? `card-background-${userProfile.cardBackgroundId}` : ''; const addFriend = () => { setRequestSent(true); SendMessageComposer(new RequestFriendComposer(userProfile.username)); }; useEffect(() => { setRequestSent(userProfile.requestSent); }, [ userProfile ]); return (
{ userProfile.username }
{ userProfile.motto }
{ LocalizeText('extendedprofile.achievementscore') } { userProfile.achievementPoints }
{ LocalizeText('extendedprofile.me') }
} { userProfile.isMyFriend &&{ LocalizeText('extendedprofile.friend') }
} { (requestSent || userProfile.requestSent) &&{ LocalizeText('extendedprofile.friendrequestsent') }
} > }