2020-08-17 21:07:16 +01:00
|
|
|
import React from 'react'
|
2020-08-17 21:59:29 +01:00
|
|
|
import PropTypes from 'prop-types'
|
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'
|
2020-11-15 18:48:32 +00:00
|
|
|
import { me } 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'
|
2020-05-09 03:17:19 +01:00
|
|
|
import Dummy from '../dummy'
|
2020-07-28 21:11:51 +01:00
|
|
|
import ProfileStatsPanelPlaceholder from '../placeholder/profile_stats_panel_placeholder'
|
2020-05-09 03:17:19 +01:00
|
|
|
import ResponsiveClassesComponent from '../../features/ui/util/responsive_classes_component'
|
2020-02-28 15:20:47 +00:00
|
|
|
|
|
|
|
class ProfileStatsPanel extends ImmutablePureComponent {
|
|
|
|
|
|
|
|
render() {
|
2020-05-09 03:17:19 +01:00
|
|
|
const {
|
|
|
|
intl,
|
|
|
|
account,
|
|
|
|
noPanel
|
|
|
|
} = this.props
|
2020-02-28 15:20:47 +00:00
|
|
|
|
2020-05-09 03:17:19 +01:00
|
|
|
const Wrapper = noPanel ? Dummy : PanelLayout
|
|
|
|
|
2020-02-28 15:20:47 +00:00
|
|
|
return (
|
2020-05-09 03:17:19 +01:00
|
|
|
<Wrapper>
|
2020-07-28 21:11:51 +01:00
|
|
|
{
|
2020-07-29 21:40:47 +01:00
|
|
|
!account && !noPanel &&
|
2020-07-28 21:11:51 +01:00
|
|
|
<ProfileStatsPanelPlaceholder />
|
|
|
|
}
|
2020-02-28 15:20:47 +00:00
|
|
|
{
|
|
|
|
!!account &&
|
2020-05-09 03:17:19 +01:00
|
|
|
<ResponsiveClassesComponent
|
2020-08-18 21:49:11 +01:00
|
|
|
classNames={[_s.d, _s.flexRow].join(' ')}
|
2020-12-16 07:39:07 +00:00
|
|
|
classNamesXS={[_s.d, _s.flexRow, _s.mt15, _s.flexWrap].join(' ')}
|
2020-05-09 03:17:19 +01:00
|
|
|
>
|
2020-02-28 15:20:47 +00:00
|
|
|
<UserStat
|
|
|
|
title={intl.formatMessage(messages.gabs)}
|
|
|
|
value={shortNumberFormat(account.get('statuses_count'))}
|
|
|
|
to={`/${account.get('acct')}`}
|
2020-12-16 07:39:07 +00:00
|
|
|
isInline={noPanel}
|
2020-02-28 15:20:47 +00:00
|
|
|
/>
|
|
|
|
<UserStat
|
|
|
|
title={intl.formatMessage(messages.followers)}
|
|
|
|
value={shortNumberFormat(account.get('followers_count'))}
|
|
|
|
to={`/${account.get('acct')}/followers`}
|
2020-12-16 07:39:07 +00:00
|
|
|
isInline={noPanel}
|
2020-02-28 15:20:47 +00:00
|
|
|
/>
|
2020-05-18 22:49:35 +01:00
|
|
|
<UserStat
|
2020-12-16 07:39:07 +00:00
|
|
|
isLast
|
2020-05-18 22:49:35 +01:00
|
|
|
title={intl.formatMessage(messages.follows)}
|
|
|
|
value={shortNumberFormat(account.get('following_count'))}
|
|
|
|
to={`/${account.get('acct')}/following`}
|
2020-12-16 07:39:07 +00:00
|
|
|
isInline={noPanel}
|
2020-05-18 22:49:35 +01:00
|
|
|
/>
|
2020-05-09 03:17:19 +01:00
|
|
|
</ResponsiveClassesComponent>
|
2020-02-28 15:20:47 +00:00
|
|
|
}
|
2020-05-09 03:17:19 +01:00
|
|
|
</Wrapper>
|
2020-02-28 15:20:47 +00:00
|
|
|
)
|
|
|
|
}
|
2020-03-10 20:26:34 +00:00
|
|
|
}
|
2020-08-19 01:22:15 +01:00
|
|
|
|
|
|
|
const messages = defineMessages({
|
|
|
|
gabs: { id: 'account.gabs', defaultMessage: 'Gabs' },
|
|
|
|
followers: { id: 'account.followers', defaultMessage: 'Followers' },
|
|
|
|
follows: { id: 'account.follows', defaultMessage: 'Following' },
|
|
|
|
likes: { id: 'likes', defaultMessage: 'Likes' },
|
|
|
|
})
|
|
|
|
|
|
|
|
ProfileStatsPanel.propTypes = {
|
|
|
|
account: ImmutablePropTypes.map,
|
|
|
|
intl: PropTypes.object.isRequired,
|
|
|
|
noPanel: PropTypes.bool,
|
|
|
|
}
|
|
|
|
|
|
|
|
export default injectIntl(ProfileStatsPanel)
|