'use strict'; import React from 'react'; import ImmutablePropTypes from 'react-immutable-proptypes'; import PropTypes from 'prop-types'; import { connect } from 'react-redux'; import { defineMessages, injectIntl, FormattedMessage } from 'react-intl'; import ImmutablePureComponent from 'react-immutable-pure-component'; import Icon from 'soapbox/components/icon'; import VerificationBadge from 'soapbox/components/verification_badge'; import Badge from 'soapbox/components/badge'; import { List as ImmutableList } from 'immutable'; import { getAcct, isAdmin, isModerator } from 'soapbox/utils/accounts'; import { displayFqn } from 'soapbox/utils/state'; import classNames from 'classnames'; import CryptoAddress from 'soapbox/features/crypto_donate/components/crypto_address'; const TICKER_REGEX = /\$([a-zA-Z]*)/i; const getTicker = value => (value.match(TICKER_REGEX) || [])[1]; const isTicker = value => Boolean(getTicker(value)); const messages = defineMessages({ linkVerifiedOn: { id: 'account.link_verified_on', defaultMessage: 'Ownership of this link was checked on {date}' }, account_locked: { id: 'account.locked_info', defaultMessage: 'This account privacy status is set to locked. The owner manually reviews who can follow them.' }, deactivated: { id: 'account.deactivated', defaultMessage: 'Deactivated' }, bot: { id: 'account.badges.bot', defaultMessage: 'Bot' }, }); const dateFormatOptions = { month: 'short', day: 'numeric', year: 'numeric', hour12: false, hour: '2-digit', minute: '2-digit', }; class ProfileInfoPanel extends ImmutablePureComponent { static propTypes = { account: ImmutablePropTypes.map, identity_proofs: ImmutablePropTypes.list, intl: PropTypes.object.isRequired, username: PropTypes.string, displayFqn: PropTypes.bool, }; render() { const { account, displayFqn, intl, identity_proofs, username } = this.props; if (!account) { return (

@{username}

); } const lockedIcon = account.get('locked') ? () : ''; const content = { __html: account.get('note_emojified') }; const fields = account.get('fields'); const deactivated = !account.getIn(['pleroma', 'is_active'], true); const displayNameHtml = deactivated ? { __html: intl.formatMessage(messages.deactivated) } : { __html: account.get('display_name_html') }; const memberSinceDate = intl.formatDate(account.get('created_at'), { month: 'long', year: 'numeric' }); const verified = account.getIn(['pleroma', 'tags'], ImmutableList()).includes('verified'); return (

{verified && } {account.get('bot') && } { @{getAcct(account, displayFqn)} {lockedIcon} }

{isAdmin(account) && } {isModerator(account) && } {account.getIn(['patron', 'is_patron']) && } {account.get('acct').includes('@') ||
}
{ (account.get('note').length > 0 && account.get('note') !== '

') &&
} {(fields.size > 0 || identity_proofs.size > 0) && (
{identity_proofs.map((proof, i) => (
))} {fields.map((pair, i) => isTicker(pair.get('name', '')) ? ( ) : (
{pair.get('verified_at') && }
), )}
)}
); } } const mapStateToProps = (state, { account }) => { const identity_proofs = account ? state.getIn(['identity_proofs', account.get('id')], ImmutableList()) : ImmutableList(); return { identity_proofs, domain: state.getIn(['meta', 'domain']), displayFqn: displayFqn(state), }; }; export default injectIntl( connect(mapStateToProps, null, null, { forwardRef: true, }, )(ProfileInfoPanel));