import React from 'react'; import { FormattedMessage, useIntl } from 'react-intl'; import { Link } from 'react-router-dom'; import Avatar from 'soapbox/components/avatar'; import StillImage from 'soapbox/components/still_image'; import { HStack, Stack, Text } from 'soapbox/components/ui'; import VerificationBadge from 'soapbox/components/verification_badge'; import { useAppSelector } from 'soapbox/hooks'; import { makeGetAccount } from 'soapbox/selectors'; import { getAcct } from 'soapbox/utils/accounts'; import { shortNumberFormat } from 'soapbox/utils/numbers'; import { displayFqn } from 'soapbox/utils/state'; const getAccount = makeGetAccount(); interface IUserPanel { accountId: string, action?: JSX.Element, badges?: JSX.Element[], domain?: string, } const UserPanel: React.FC = ({ accountId, action, badges, domain }) => { const intl = useIntl(); const account = useAppSelector((state) => getAccount(state, accountId)); const fqn = useAppSelector((state) => displayFqn(state)); if (!account) return null; const displayNameHtml = { __html: account.get('display_name_html') }; const acct = account.get('acct').indexOf('@') === -1 && domain ? `${account.get('acct')}@${domain}` : account.get('acct'); const header = account.get('header'); const verified = account.get('verified'); return (
{header && ( )}
{action && (
{action}
)}
{verified && } {badges && badges.length > 0 && ( {badges} )} @{getAcct(account, fqn)} {account.get('followers_count') >= 0 && ( {shortNumberFormat(account.get('followers_count'))} )} {account.get('following_count') >= 0 && ( {shortNumberFormat(account.get('following_count'))} )}
); }; export default UserPanel;