import React from 'react'; import PropTypes from 'prop-types'; import { connect } from 'react-redux'; import { Link } from 'react-router-dom'; import { injectIntl, FormattedMessage } from 'react-intl'; import { makeGetAccount } from '../../../selectors'; import ImmutablePropTypes from 'react-immutable-proptypes'; import ImmutablePureComponent from 'react-immutable-pure-component'; import Avatar from 'soapbox/components/avatar'; import { shortNumberFormat } from 'soapbox/utils/numbers'; import { getAcct } from 'soapbox/utils/accounts'; import { displayFqn } from 'soapbox/utils/state'; import StillImage from 'soapbox/components/still_image'; import VerificationBadge from 'soapbox/components/verification_badge'; import { List as ImmutableList } from 'immutable'; class UserPanel extends ImmutablePureComponent { static propTypes = { account: ImmutablePropTypes.map, displayFqn: PropTypes.bool, intl: PropTypes.object.isRequired, domain: PropTypes.string, } render() { const { account, 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 verified = account.getIn(['pleroma', 'tags'], ImmutableList()).includes('verified'); const header = account.get('header'); return (
{header && }

{verified && } @{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));