import React from 'react'
import PropTypes from 'prop-types'
import { defineMessages, injectIntl } from 'react-intl'
import ImmutablePureComponent from 'react-immutable-pure-component'
import ImmutablePropTypes from 'react-immutable-proptypes'
import { List as ImmutableList } from 'immutable'
import { DEFAULT_REL } from '../../constants'
import PanelLayout from './panel_layout'
import Divider from '../divider'
import Icon from '../icon'
import Text from '../text'
import Dummy from '../dummy'
import ProfileInfoPanelPlaceholder from '../placeholder/profile_info_panel_placeholder'
class ProfileInfoPanel extends ImmutablePureComponent {
render() {
const {
intl,
account,
noPanel
} = this.props
const Wrapper = noPanel ? Dummy : PanelLayout
if (!account && !noPanel) {
return (
)
}
const fields = account.get('fields')
const content = { __html: account.get('note_emojified') }
const memberSinceDate = intl.formatDate(account.get('created_at'), { month: 'long', year: 'numeric' })
const hasNote = !!content ? (account.get('note').length > 0 && account.get('note') !== '
') : false
const isBot = !!account.get('bot')
const isPro = account.get('is_pro')
const isDonor = account.get('is_donor')
const isInvestor = account.get('is_investor')
const hasBadges = isPro || isDonor || isInvestor || isBot
return (
{
hasNote &&
}
{
intl.formatMessage(messages.memberSince, {
date: memberSinceDate
})
}
{
hasBadges &&
{
isBot &&
FEED
}
{
isPro &&
PRO
}
{
isInvestor &&
INVESTOR
}
{
isDonor &&
DONOR
}
}
{
fields.size > 0 &&
{
fields.map((pair, i) => (
))
}
}
)
}
}
const messages = defineMessages({
title: { id: 'about', defaultMessage: 'About' },
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.' },
bot: { id: 'account.badges.bot', defaultMessage: 'Bot' },
memberSince: { id: 'account.member_since', defaultMessage: 'Member since {date}' },
})
ProfileInfoPanel.propTypes = {
account: ImmutablePropTypes.map,
noPanel: PropTypes.bool,
intl: PropTypes.object.isRequired,
}
export default injectIntl(ProfileInfoPanel)