gab-social/app/javascript/gabsocial/components/panel/profile_stats_panel.js

64 lines
2.0 KiB
JavaScript
Raw Normal View History

2020-02-28 15:20:47 +00:00
import { defineMessages, injectIntl } from 'react-intl'
import ImmutablePureComponent from 'react-immutable-pure-component'
import ImmutablePropTypes from 'react-immutable-proptypes'
import { me, favouritesCount } from '../../initial_state'
2020-02-28 15:20:47 +00:00
import { shortNumberFormat } from '../../utils/numbers'
import PanelLayout from './panel_layout'
import UserStat from '../user_stat'
const messages = defineMessages({
gabs: { id: 'account.gabs', defaultMessage: 'Gabs' },
followers: { id: 'account.followers', defaultMessage: 'Followers' },
follows: { id: 'account.follows', defaultMessage: 'Follows' },
2020-03-24 04:39:12 +00:00
likes: { id: 'likes', defaultMessage: 'Likes' },
2020-02-28 15:20:47 +00:00
})
export default
@injectIntl
class ProfileStatsPanel extends ImmutablePureComponent {
static propTypes = {
2020-03-24 04:39:12 +00:00
account: ImmutablePropTypes.map,
2020-02-28 15:20:47 +00:00
intl: PropTypes.object.isRequired,
}
render() {
const { intl, account } = this.props
if (!account) return null
return (
<PanelLayout>
{
!!account &&
<div className={[_s.default, _s.flexRow].join(' ')}>
<UserStat
title={intl.formatMessage(messages.gabs)}
value={shortNumberFormat(account.get('statuses_count'))}
to={`/${account.get('acct')}`}
/>
<UserStat
title={intl.formatMessage(messages.follows)}
value={shortNumberFormat(account.get('following_count'))}
to={`/${account.get('acct')}/following`}
/>
<UserStat
title={intl.formatMessage(messages.followers)}
value={shortNumberFormat(account.get('followers_count'))}
to={`/${account.get('acct')}/followers`}
/>
{
account.get('id') === me &&
<UserStat
2020-03-24 04:39:12 +00:00
title={intl.formatMessage(messages.likes)}
value={shortNumberFormat(favouritesCount)}
2020-03-24 04:39:12 +00:00
to={`/${account.get('acct')}/likes`}
2020-02-28 15:20:47 +00:00
/>
}
</div>
}
</PanelLayout>
)
}
}