diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2016-09-23 20:23:26 +0200 |
---|---|---|
committer | Eugen Rochko <eugen@zeonfederated.com> | 2016-09-23 20:23:26 +0200 |
commit | 3f9708edc4cd799afb68000adc35036dd8b8faa5 (patch) | |
tree | af7e97a0095c562810577acf68933b461e126794 /app/assets/javascripts/components/features/account/components/action_bar.jsx | |
parent | c6d893a71dede65dd88a0dfac81178c8e81e27d2 (diff) |
Change output of api/accounts/:id/follow and unfollow to return relationship
Track relationship in redux state. Display follow/unfollow and following-back information on account view (unstyled)
Diffstat (limited to 'app/assets/javascripts/components/features/account/components/action_bar.jsx')
-rw-r--r-- | app/assets/javascripts/components/features/account/components/action_bar.jsx | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/app/assets/javascripts/components/features/account/components/action_bar.jsx b/app/assets/javascripts/components/features/account/components/action_bar.jsx new file mode 100644 index 000000000..a6eb01d61 --- /dev/null +++ b/app/assets/javascripts/components/features/account/components/action_bar.jsx @@ -0,0 +1,48 @@ +import PureRenderMixin from 'react-addons-pure-render-mixin'; +import ImmutablePropTypes from 'react-immutable-proptypes'; +import Button from '../../../components/button'; + +const ActionBar = React.createClass({ + + propTypes: { + account: ImmutablePropTypes.map.isRequired, + me: React.PropTypes.number.isRequired, + onFollow: React.PropTypes.func.isRequired, + onUnfollow: React.PropTypes.func.isRequired + }, + + mixins: [PureRenderMixin], + + render () { + const { account, me } = this.props; + + let followBack = ''; + let actionButton = ''; + + if (account.get('id') === me) { + actionButton = 'This is you!'; + } else { + if (account.getIn(['relationship', 'following'])) { + actionButton = <Button text='Unfollow' onClick={this.props.onUnfollow} /> + } else { + actionButton = <Button text='Follow' onClick={this.props.onFollow} /> + } + + if (account.getIn(['relationship', 'followed_by'])) { + followBack = 'follows you'; + } + } + + return ( + <div> + {actionButton} + {account.get('followers_count')} followers + {account.get('following_count')} following + {followBack} + </div> + ); + }, + +}); + +export default ActionBar; |