import React from 'react'; import { FormattedMessage } from 'react-intl'; import { Redirect, useHistory } from 'react-router-dom'; import { Column, Layout, Tabs } from 'soapbox/components/ui'; import Header from 'soapbox/features/account/components/header'; import LinkFooter from 'soapbox/features/ui/components/link-footer'; import BundleContainer from 'soapbox/features/ui/containers/bundle-container'; import { WhoToFollowPanel, ProfileInfoPanel, ProfileMediaPanel, ProfileFieldsPanel, SignUpPanel, CtaBanner, PinnedAccountsPanel, } from 'soapbox/features/ui/util/async-components'; import { useAppSelector, useFeatures, useSoapboxConfig } from 'soapbox/hooks'; import { findAccountByUsername, makeGetAccount } from 'soapbox/selectors'; import { getAcct, isLocal } from 'soapbox/utils/accounts'; interface IProfilePage { params?: { username?: string, }, } const getAccount = makeGetAccount(); /** Page to display a user's profile. */ const ProfilePage: React.FC = ({ params, children }) => { const history = useHistory(); const username = params?.username || ''; const account = useAppSelector(state => { if (username) { const account = findAccountByUsername(state, username); if (account) { return getAccount(state, account.id) || undefined; } } }); const me = useAppSelector(state => state.me); const features = useFeatures(); const { displayFqn } = useSoapboxConfig(); // Fix case of username if (account && account.acct !== username) { return ; } const tabItems = [ { text: , to: `/@${username}`, name: 'profile', }, { text: , to: `/@${username}/with_replies`, name: 'replies', }, { text: , to: `/@${username}/media`, name: 'media', }, ]; if (account) { const ownAccount = account.id === me; if (ownAccount || !account.pleroma.get('hide_favorites', true)) { tabItems.push({ text: , to: `/@${account.acct}/favorites`, name: 'likes', }); } } let activeItem; const pathname = history.location.pathname.replace(`@${username}/`, ''); if (pathname.endsWith('/with_replies')) { activeItem = 'replies'; } else if (pathname.endsWith('/media')) { activeItem = 'media'; } else if (pathname.endsWith('/favorites')) { activeItem = 'likes'; } else { activeItem = 'profile'; } const showTabs = !['/following', '/followers', '/pins'].some(path => pathname.endsWith(path)); return ( <>
{Component => } {account && showTabs && ( )} {children}
{!me && ( {Component => } )}
{!me && ( {Component => } )} {Component => } {account && !account.fields.isEmpty() && ( {Component => } )} {(features.accountEndorsements && account && isLocal(account)) ? ( {Component => } ) : me && features.suggestions && ( {Component => } )} ); }; export default ProfilePage;