import React from 'react'; import { useEffect } from 'react'; import { defineMessages, useIntl } from 'react-intl'; import Avatar from 'soapbox/components/avatar'; import DisplayName from 'soapbox/components/display_name'; import Icon from 'soapbox/components/icon'; import Permalink from 'soapbox/components/permalink'; import { useAppSelector } from 'soapbox/hooks'; import { makeGetAccount } from 'soapbox/selectors'; const messages = defineMessages({ birthday: { id: 'account.birthday', defaultMessage: 'Born {date}' }, }); const getAccount = makeGetAccount(); interface IAccount { accountId: string, fetchAccount: (id: string) => void, } const Account: React.FC = ({ accountId, fetchAccount }) => { const intl = useIntl(); const account = useAppSelector((state) => getAccount(state, accountId)); useEffect(() => { if (accountId && !account) { fetchAccount(accountId); } }, [accountId]); if (!account) return null; const birthday = account.get('birthday'); if (!birthday) return null; const formattedBirthday = intl.formatDate(birthday, { day: 'numeric', month: 'short', year: 'numeric' }); return (
{formattedBirthday}
); }; export default Account;