gab-social/app/javascript/gabsocial/pages/group_page.js

65 lines
1.7 KiB
JavaScript
Raw Normal View History

import { Fragment } from 'react';
2019-07-15 14:47:05 +01:00
import { PropTypes } from 'prop-types';
import ImmutablePropTypes from 'react-immutable-proptypes';
import ImmutablePureComponent from 'react-immutable-pure-component';
import WhoToFollowPanel from '../components/panel';
import LinkFooter from '../components/link_footer';
import PromoPanel from '../components/panel';
2019-07-15 14:47:05 +01:00
import HeaderContainer from '../features/groups/timeline/containers/header_container';
import GroupPanel from '../features/groups/timeline/components/panel';
import { fetchGroup } from '../actions/groups';
2019-07-20 00:36:55 +01:00
import GroupSidebarPanel from '../features/groups/sidebar_panel';
import ColumnsArea from '../components/columns_area';
2019-07-15 14:47:05 +01:00
const mapStateToProps = (state, { params: { id } }) => ({
group: state.getIn(['groups', id]),
relationships: state.getIn(['group_relationships', id]),
});
export default @connect(mapStateToProps)
class GroupPage extends ImmutablePureComponent {
static propTypes = {
group: ImmutablePropTypes.map,
2019-07-15 14:47:05 +01:00
relationships: ImmutablePropTypes.map,
dispatch: PropTypes.func.isRequired,
};
2019-07-15 14:47:05 +01:00
componentWillMount() {
const { params: { id }, dispatch } = this.props;
dispatch(fetchGroup(id));
}
render () {
const { children, group, relationships } = this.props;
const top = group ? <HeaderContainer groupId={group.get('id')} /> : null;
2019-07-15 14:47:05 +01:00
return (
<ColumnsArea
layout={{
top: top,
right: (
<Fragment>
<GroupSidebarPanel />
<WhoToFollowPanel />
</Fragment>
),
left: (
<Fragment>
{group && relationships &&
<GroupPanel
group={group}
relationships={relationships}
/>}
<PromoPanel />
<LinkFooter />
</Fragment>
)
}}
>
{children}
</ColumnsArea>
2019-07-15 14:47:05 +01:00
)
}
}