2022-09-13 01:21:56 -07:00
|
|
|
import React, { useCallback } from 'react';
|
2022-04-11 12:58:48 -07:00
|
|
|
import { defineMessages, useIntl } from 'react-intl';
|
2022-11-12 03:43:34 -08:00
|
|
|
import { Link } from 'react-router-dom';
|
2022-04-11 12:58:48 -07:00
|
|
|
|
|
|
|
import Avatar from 'soapbox/components/avatar';
|
2022-05-13 09:12:19 -07:00
|
|
|
import DisplayName from 'soapbox/components/display-name';
|
2022-04-11 12:58:48 -07:00
|
|
|
import Icon from 'soapbox/components/icon';
|
|
|
|
import { useAppSelector } from 'soapbox/hooks';
|
|
|
|
import { makeGetAccount } from 'soapbox/selectors';
|
|
|
|
|
|
|
|
const messages = defineMessages({
|
|
|
|
birthday: { id: 'account.birthday', defaultMessage: 'Born {date}' },
|
|
|
|
});
|
|
|
|
|
|
|
|
interface IAccount {
|
|
|
|
accountId: string,
|
|
|
|
}
|
|
|
|
|
2022-04-17 14:27:33 -07:00
|
|
|
const Account: React.FC<IAccount> = ({ accountId }) => {
|
2022-04-11 12:58:48 -07:00
|
|
|
const intl = useIntl();
|
2022-09-13 01:21:56 -07:00
|
|
|
const getAccount = useCallback(makeGetAccount(), []);
|
|
|
|
|
2022-04-11 12:58:48 -07:00
|
|
|
const account = useAppSelector((state) => getAccount(state, accountId));
|
|
|
|
|
2022-04-17 14:27:33 -07:00
|
|
|
// useEffect(() => {
|
|
|
|
// if (accountId && !account) {
|
|
|
|
// fetchAccount(accountId);
|
|
|
|
// }
|
|
|
|
// }, [accountId]);
|
2022-04-11 12:58:48 -07:00
|
|
|
|
|
|
|
if (!account) return null;
|
|
|
|
|
2022-09-13 01:21:56 -07:00
|
|
|
const birthday = account.birthday;
|
2022-04-11 12:58:48 -07:00
|
|
|
if (!birthday) return null;
|
|
|
|
|
|
|
|
const formattedBirthday = intl.formatDate(birthday, { day: 'numeric', month: 'short', year: 'numeric' });
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div className='account'>
|
|
|
|
<div className='account__wrapper'>
|
2022-11-12 03:43:34 -08:00
|
|
|
<Link className='account__display-name' title={account.get('acct')} to={`/@${account.get('acct')}`}>
|
2022-04-11 12:58:48 -07:00
|
|
|
<div className='account__display-name'>
|
|
|
|
<div className='account__avatar-wrapper'><Avatar account={account} size={36} /></div>
|
|
|
|
<DisplayName account={account} />
|
|
|
|
|
|
|
|
</div>
|
2022-11-12 03:43:34 -08:00
|
|
|
</Link>
|
2022-04-11 12:58:48 -07:00
|
|
|
<div
|
2022-04-17 14:27:33 -07:00
|
|
|
className='flex items-center gap-0.5'
|
2022-04-11 12:58:48 -07:00
|
|
|
title={intl.formatMessage(messages.birthday, {
|
|
|
|
date: formattedBirthday,
|
|
|
|
})}
|
|
|
|
>
|
2022-07-09 09:20:02 -07:00
|
|
|
<Icon src={require('@tabler/icons/ballon.svg')} />
|
2022-04-11 12:58:48 -07:00
|
|
|
{formattedBirthday}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default Account;
|