2016-09-23 11:23:26 -07:00
|
|
|
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,
|
2016-10-03 09:49:52 -07:00
|
|
|
onFollow: React.PropTypes.func.isRequired,
|
|
|
|
onBlock: React.PropTypes.func.isRequired
|
2016-09-23 11:23:26 -07:00
|
|
|
},
|
|
|
|
|
|
|
|
mixins: [PureRenderMixin],
|
|
|
|
|
|
|
|
render () {
|
|
|
|
const { account, me } = this.props;
|
2016-10-02 06:14:26 -07:00
|
|
|
|
2016-09-25 05:58:07 -07:00
|
|
|
let infoText = '';
|
2016-10-03 09:49:52 -07:00
|
|
|
let follow = '';
|
2016-10-02 06:14:26 -07:00
|
|
|
let buttonText = '';
|
2016-10-03 09:49:52 -07:00
|
|
|
let block = '';
|
|
|
|
let disabled = false;
|
2016-09-23 11:23:26 -07:00
|
|
|
|
|
|
|
if (account.get('id') === me) {
|
2016-10-02 06:14:26 -07:00
|
|
|
buttonText = 'This is you!';
|
2016-10-03 09:49:52 -07:00
|
|
|
disabled = true;
|
2016-09-23 11:23:26 -07:00
|
|
|
} else {
|
2016-10-03 09:49:52 -07:00
|
|
|
let blockText = '';
|
|
|
|
|
|
|
|
if (account.getIn(['relationship', 'blocking'])) {
|
|
|
|
buttonText = 'Blocked';
|
|
|
|
disabled = true;
|
|
|
|
blockText = 'Unblock';
|
2016-09-23 11:23:26 -07:00
|
|
|
} else {
|
2016-10-03 09:49:52 -07:00
|
|
|
if (account.getIn(['relationship', 'following'])) {
|
|
|
|
buttonText = 'Unfollow';
|
|
|
|
} else {
|
|
|
|
buttonText = 'Follow';
|
|
|
|
}
|
|
|
|
|
|
|
|
if (account.getIn(['relationship', 'followed_by'])) {
|
|
|
|
infoText = 'Follows you!';
|
|
|
|
}
|
2016-09-23 11:23:26 -07:00
|
|
|
|
2016-10-03 09:49:52 -07:00
|
|
|
blockText = 'Block';
|
2016-09-23 11:23:26 -07:00
|
|
|
}
|
2016-10-03 09:49:52 -07:00
|
|
|
|
|
|
|
block = <Button text={blockText} onClick={this.props.onBlock} />;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!account.getIn(['relationship', 'blocking'])) {
|
|
|
|
follow = <Button text={buttonText} onClick={this.props.onFollow} disabled={disabled} />;
|
2016-09-23 11:23:26 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
2016-09-25 06:48:20 -07:00
|
|
|
<div style={{ borderTop: '1px solid #363c4b', borderBottom: '1px solid #363c4b', padding: '10px', lineHeight: '36px', overflow: 'hidden', flex: '0 0 auto' }}>
|
2016-10-03 09:49:52 -07:00
|
|
|
{follow} {block}
|
|
|
|
<span style={{ color: '#616b86', fontWeight: '500', textTransform: 'uppercase', float: 'right', display: 'block' }}>{infoText}</span>
|
2016-09-23 11:23:26 -07:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
},
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
export default ActionBar;
|