import PropTypes from 'prop-types'; import React from 'react'; import ImmutablePropTypes from 'react-immutable-proptypes'; import ImmutablePureComponent from 'react-immutable-pure-component'; import { injectIntl, FormattedMessage } from 'react-intl'; import { connect } from 'react-redux'; import { Link } from 'react-router-dom'; import Avatar from 'soapbox/components/avatar'; import StillImage from 'soapbox/components/still_image'; import VerificationBadge from 'soapbox/components/verification_badge'; import { getAcct } from 'soapbox/utils/accounts'; import { shortNumberFormat } from 'soapbox/utils/numbers'; import { displayFqn } from 'soapbox/utils/state'; import { HStack, Stack, Text } from '../../../components/ui'; import { makeGetAccount } from '../../../selectors'; class UserPanel extends ImmutablePureComponent { static propTypes = { account: ImmutablePropTypes.map, displayFqn: PropTypes.bool, intl: PropTypes.object.isRequired, domain: PropTypes.string, } render() { const { account, action, badges, displayFqn, intl, domain } = this.props; 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.length > 0 && ( {badges} )} @{getAcct(account, displayFqn)} {account.get('statuses_count') >= 0 && ( {shortNumberFormat(account.get('statuses_count'))} )} {account.get('followers_count') >= 0 && ( {shortNumberFormat(account.get('followers_count'))} )} {account.get('following_count') >= 0 && ( {shortNumberFormat(account.get('following_count'))} )}
); } } const makeMapStateToProps = () => { const getAccount = makeGetAccount(); const mapStateToProps = (state, { accountId }) => ({ account: getAccount(state, accountId), displayFqn: displayFqn(state), }); return mapStateToProps; }; export default injectIntl( connect(makeMapStateToProps, null, null, { forwardRef: true, })(UserPanel));