2020-02-28 10:20:47 -05:00
|
|
|
import { Fragment } from 'react'
|
2020-04-11 18:29:19 -04:00
|
|
|
import { defineMessages, injectIntl } from 'react-intl'
|
2020-02-28 10:20:47 -05:00
|
|
|
import ImmutablePropTypes from 'react-immutable-proptypes'
|
|
|
|
import ImmutablePureComponent from 'react-immutable-pure-component'
|
|
|
|
import { fetchGroup } from '../actions/groups'
|
2020-04-11 18:29:19 -04:00
|
|
|
import PageTitle from '../features/ui/util/page_title'
|
2020-02-28 10:20:47 -05:00
|
|
|
import GroupLayout from '../layouts/group_layout'
|
|
|
|
import TimelineComposeBlock from '../components/timeline_compose_block'
|
|
|
|
import Divider from '../components/divider'
|
2020-08-06 00:13:19 -05:00
|
|
|
import GroupSortBlock from '../components/group_sort_block'
|
2019-07-15 16:47:05 +03:00
|
|
|
|
2020-04-11 18:29:19 -04:00
|
|
|
const messages = defineMessages({
|
|
|
|
group: { id: 'group', defaultMessage: 'Group' },
|
|
|
|
})
|
|
|
|
|
2019-07-15 16:47:05 +03:00
|
|
|
const mapStateToProps = (state, { params: { id } }) => ({
|
|
|
|
group: state.getIn(['groups', id]),
|
|
|
|
relationships: state.getIn(['group_relationships', id]),
|
2020-02-28 10:20:47 -05:00
|
|
|
})
|
2019-07-15 16:47:05 +03:00
|
|
|
|
2020-05-08 22:17:19 -04:00
|
|
|
const mapDispatchToProps = (dispatch) => ({
|
|
|
|
onFetchGroup(groupId) {
|
|
|
|
dispatch(fetchGroup(groupId))
|
2020-08-06 00:13:19 -05:00
|
|
|
},
|
2020-04-11 18:29:19 -04:00
|
|
|
})
|
|
|
|
|
2020-02-25 11:04:44 -05:00
|
|
|
export default
|
2020-04-11 18:29:19 -04:00
|
|
|
@injectIntl
|
|
|
|
@connect(mapStateToProps, mapDispatchToProps)
|
2019-07-15 16:47:05 +03:00
|
|
|
class GroupPage extends ImmutablePureComponent {
|
|
|
|
|
2020-02-28 10:20:47 -05:00
|
|
|
static propTypes = {
|
2020-04-11 18:29:19 -04:00
|
|
|
intl: PropTypes.object.isRequired,
|
2020-02-28 10:20:47 -05:00
|
|
|
group: ImmutablePropTypes.map,
|
2020-05-07 01:55:24 -04:00
|
|
|
children: PropTypes.node.isRequired,
|
2019-07-15 16:47:05 +03:00
|
|
|
relationships: ImmutablePropTypes.map,
|
2020-05-08 22:17:19 -04:00
|
|
|
onFetchGroup: PropTypes.func.isRequired,
|
2020-08-06 00:13:19 -05:00
|
|
|
sortByValue: PropTypes.string.isRequired,
|
|
|
|
sortByTopValue: PropTypes.string.isRequired,
|
2020-03-12 12:09:15 -04:00
|
|
|
}
|
|
|
|
|
2020-04-11 18:29:19 -04:00
|
|
|
componentDidMount() {
|
2020-05-08 22:17:19 -04:00
|
|
|
this.props.onFetchGroup(this.props.params.id)
|
2020-08-06 00:13:19 -05:00
|
|
|
// this.props.onFetchGroup(this.props.params.slug)
|
2019-07-15 16:47:05 +03:00
|
|
|
}
|
|
|
|
|
2020-02-28 10:20:47 -05:00
|
|
|
render() {
|
2020-04-11 18:29:19 -04:00
|
|
|
const {
|
|
|
|
intl,
|
|
|
|
children,
|
|
|
|
group,
|
|
|
|
relationships,
|
2020-08-06 00:13:19 -05:00
|
|
|
isTimeline,
|
2020-04-11 18:29:19 -04:00
|
|
|
} = this.props
|
2020-02-28 10:20:47 -05:00
|
|
|
|
2020-04-11 18:29:19 -04:00
|
|
|
const groupTitle = !!group ? group.get('title') : ''
|
2020-07-14 18:46:43 -05:00
|
|
|
const groupId = !!group ? group.get('id') : undefined
|
2020-08-06 00:13:19 -05:00
|
|
|
|
2019-07-15 16:47:05 +03:00
|
|
|
return (
|
2020-02-28 10:20:47 -05:00
|
|
|
<GroupLayout
|
2020-04-11 18:29:19 -04:00
|
|
|
showBackBtn
|
2020-08-06 00:13:19 -05:00
|
|
|
title={'Group'}
|
2020-02-29 10:42:47 -05:00
|
|
|
group={group}
|
2020-07-15 23:05:08 -05:00
|
|
|
groupId={groupId}
|
2020-02-29 10:42:47 -05:00
|
|
|
relationships={relationships}
|
2020-08-06 00:13:19 -05:00
|
|
|
isTimeline={isTimeline}
|
2019-08-07 01:02:36 -04:00
|
|
|
>
|
2020-04-11 18:29:19 -04:00
|
|
|
<PageTitle path={[groupTitle, intl.formatMessage(messages.group)]} />
|
|
|
|
|
2020-02-28 10:20:47 -05:00
|
|
|
{
|
2020-08-06 00:13:19 -05:00
|
|
|
!!relationships && isTimeline && relationships.get('member') &&
|
2020-02-28 10:20:47 -05:00
|
|
|
<Fragment>
|
2020-07-14 18:46:43 -05:00
|
|
|
<TimelineComposeBlock size={46} groupId={groupId} autoFocus />
|
2020-02-28 10:20:47 -05:00
|
|
|
<Divider />
|
|
|
|
</Fragment>
|
|
|
|
}
|
2020-04-11 18:29:19 -04:00
|
|
|
|
2020-08-06 00:13:19 -05:00
|
|
|
{
|
|
|
|
isTimeline && <GroupSortBlock />
|
|
|
|
}
|
|
|
|
|
2019-08-07 01:02:36 -04:00
|
|
|
{children}
|
2020-02-28 10:20:47 -05:00
|
|
|
</GroupLayout>
|
2019-07-15 16:47:05 +03:00
|
|
|
)
|
|
|
|
}
|
2019-08-07 01:02:36 -04:00
|
|
|
}
|