2019-08-07 06:02:36 +01:00
|
|
|
import { Fragment } from 'react';
|
2019-07-02 08:10:25 +01:00
|
|
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
|
|
|
import ImmutablePureComponent from 'react-immutable-pure-component';
|
|
|
|
import HeaderContainer from '../features/account_timeline/containers/header_container';
|
2020-01-29 21:53:33 +00:00
|
|
|
import ProfileInfoPanel from '../features/account_timeline/components/profile_info_panel/profile_info_panel';
|
2020-01-27 19:46:42 +00:00
|
|
|
import { WhoToFollowPanel, SignUpPanel } from '../components/panel';
|
2019-08-07 06:02:36 +01:00
|
|
|
import LinkFooter from '../components/link_footer';
|
2020-02-03 18:24:24 +00:00
|
|
|
import PageLayout from '../components/page_layout';
|
2019-07-02 08:10:25 +01:00
|
|
|
|
|
|
|
const mapStateToProps = (state, { params: { username }, withReplies = false }) => {
|
|
|
|
const accounts = state.getIn(['accounts']);
|
|
|
|
const accountFetchError = (state.getIn(['accounts', -1, 'username'], '').toLowerCase() == username.toLowerCase());
|
|
|
|
|
|
|
|
let accountId = -1;
|
|
|
|
let account = null;
|
|
|
|
let accountUsername = username;
|
|
|
|
if (accountFetchError) {
|
|
|
|
accountId = null;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
account = accounts.find(acct => username.toLowerCase() == acct.getIn(['acct'], '').toLowerCase());
|
|
|
|
accountId = account ? account.getIn(['id'], null) : -1;
|
|
|
|
accountUsername = account ? account.getIn(['acct'], '') : '';
|
|
|
|
}
|
|
|
|
|
|
|
|
//Children components fetch information
|
|
|
|
|
|
|
|
return {
|
|
|
|
account,
|
|
|
|
accountId,
|
|
|
|
accountUsername,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
export default @connect(mapStateToProps)
|
|
|
|
class ProfilePage extends ImmutablePureComponent {
|
|
|
|
static propTypes = {
|
|
|
|
account: ImmutablePropTypes.map,
|
|
|
|
accountUsername: PropTypes.string.isRequired,
|
2020-01-27 19:46:42 +00:00
|
|
|
accountId: PropTypes.oneOfType([
|
|
|
|
PropTypes.string,
|
|
|
|
PropTypes.number,
|
|
|
|
]).isRequired,
|
2019-08-07 06:02:36 +01:00
|
|
|
children: PropTypes.node,
|
2019-07-02 08:10:25 +01:00
|
|
|
};
|
|
|
|
|
2020-01-27 19:46:42 +00:00
|
|
|
render() {
|
|
|
|
const { accountId, account, accountUsername } = this.props;
|
2019-07-02 08:10:25 +01:00
|
|
|
|
|
|
|
return (
|
2020-02-03 18:24:24 +00:00
|
|
|
<PageLayout
|
2019-08-07 06:02:36 +01:00
|
|
|
layout={{
|
2019-08-09 17:06:27 +01:00
|
|
|
TOP: <HeaderContainer accountId={accountId} username={accountUsername} />,
|
|
|
|
RIGHT: (
|
2019-08-07 06:02:36 +01:00
|
|
|
<Fragment>
|
|
|
|
<SignUpPanel />
|
|
|
|
<WhoToFollowPanel />
|
|
|
|
<LinkFooter />
|
|
|
|
</Fragment>
|
|
|
|
),
|
2019-08-09 17:06:27 +01:00
|
|
|
LEFT: <ProfileInfoPanel username={accountUsername} account={account} />,
|
2019-08-07 06:02:36 +01:00
|
|
|
}}
|
|
|
|
>
|
|
|
|
{this.props.children}
|
2020-02-03 18:24:24 +00:00
|
|
|
</PageLayout>
|
2019-07-02 08:10:25 +01:00
|
|
|
)
|
|
|
|
}
|
2019-08-07 06:02:36 +01:00
|
|
|
}
|