import React from 'react'; import ImmutablePropTypes from 'react-immutable-proptypes'; import ImmutablePureComponent from 'react-immutable-pure-component'; import { defineMessages, injectIntl } from 'react-intl'; import { Link } from 'react-router-dom'; import { shortNumberFormat } from '../../../utils/numbers'; import { connect } from 'react-redux'; const messages = defineMessages({ members: { id: 'groups.card.members', defaultMessage: 'Members' }, view: { id: 'groups.card.view', defaultMessage: 'View' }, join: { id: 'groups.card.join', defaultMessage: 'Join' }, role_member: { id: 'groups.card.roles.member', defaultMessage: 'You\'re a member' }, role_admin: { id: 'groups.card.roles.admin', defaultMessage: 'You\'re an admin' }, }); const mapStateToProps = (state, { id }) => ({ group: state.getIn(['groups', id]), relationships: state.getIn(['group_relationships', id]), }); export default @connect(mapStateToProps) @injectIntl class GroupCard extends ImmutablePureComponent { static propTypes = { group: ImmutablePropTypes.map, relationships: ImmutablePropTypes.map, } getRole() { const { intl, relationships } = this.props; if (!relationships) return null; if (relationships.get('admin')) return intl.formatMessage(messages.role_admin); if (relationships.get('member')) return intl.formatMessage(messages.role_member); } render() { const { intl, group } = this.props; const coverImageUrl = group.get('cover_image_url'); const role = this.getRole(); return (