diff --git a/app/soapbox/features/ui/components/profile_stats.js b/app/soapbox/features/ui/components/profile_stats.js deleted file mode 100644 index 325a9c72f..000000000 --- a/app/soapbox/features/ui/components/profile_stats.js +++ /dev/null @@ -1,63 +0,0 @@ -import PropTypes from 'prop-types'; -import React from 'react'; -import ImmutablePropTypes from 'react-immutable-proptypes'; -import { injectIntl, defineMessages } from 'react-intl'; -import { NavLink } from 'react-router-dom'; - -import { shortNumberFormat } from 'soapbox/utils/numbers'; - -import { HStack, Text } from '../../../components/ui'; - -const messages = defineMessages({ - followers: { id: 'account.followers', defaultMessage: 'Followers' }, - follows: { id: 'account.follows', defaultMessage: 'Follows' }, -}); - -export default @injectIntl -class ProfileStats extends React.PureComponent { - - static propTypes = { - intl: PropTypes.object.isRequired, - account: ImmutablePropTypes.record.isRequired, - className: PropTypes.string, - onClickHandler: PropTypes.func, - } - - render() { - const { intl } = this.props; - const { account, onClickHandler } = this.props; - - if (!account) { - return null; - } - - const acct = account.get('acct'); - - return ( - - - - - {shortNumberFormat(account.get('followers_count'))} - - - {intl.formatMessage(messages.followers)} - - - - - - - - {shortNumberFormat(account.get('following_count'))} - - - {intl.formatMessage(messages.follows)} - - - - - ); - } - -} diff --git a/app/soapbox/features/ui/components/profile_stats.tsx b/app/soapbox/features/ui/components/profile_stats.tsx new file mode 100644 index 000000000..8ef98374f --- /dev/null +++ b/app/soapbox/features/ui/components/profile_stats.tsx @@ -0,0 +1,56 @@ +import React from 'react'; +import { useIntl, defineMessages } from 'react-intl'; +import { NavLink } from 'react-router-dom'; + +import { shortNumberFormat } from 'soapbox/utils/numbers'; + +import { HStack, Text } from '../../../components/ui'; + +import type { Account } from 'soapbox/types/entities'; + +const messages = defineMessages({ + followers: { id: 'account.followers', defaultMessage: 'Followers' }, + follows: { id: 'account.follows', defaultMessage: 'Follows' }, +}); + +interface IProfileStats { + account: Account | undefined, + onClickHandler?: React.MouseEventHandler, +} + +/** Display follower and following counts for an account. */ +const ProfileStats: React.FC = ({ account, onClickHandler }) => { + const intl = useIntl(); + + if (!account) { + return null; + } + + return ( + + + + + {shortNumberFormat(account.followers_count)} + + + {intl.formatMessage(messages.followers)} + + + + + + + + {shortNumberFormat(account.following_count)} + + + {intl.formatMessage(messages.follows)} + + + + + ); +}; + +export default ProfileStats;