about summary refs log tree commit diff
path: root/app/assets/javascripts/components/features/account/components
diff options
context:
space:
mode:
Diffstat (limited to 'app/assets/javascripts/components/features/account/components')
-rw-r--r--app/assets/javascripts/components/features/account/components/action_bar.jsx48
-rw-r--r--app/assets/javascripts/components/features/account/components/header.jsx5
2 files changed, 49 insertions, 4 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;
diff --git a/app/assets/javascripts/components/features/account/components/header.jsx b/app/assets/javascripts/components/features/account/components/header.jsx
index 20ed7512b..8a4a629ce 100644
--- a/app/assets/javascripts/components/features/account/components/header.jsx
+++ b/app/assets/javascripts/components/features/account/components/header.jsx
@@ -1,13 +1,10 @@
 import PureRenderMixin    from 'react-addons-pure-render-mixin';
 import ImmutablePropTypes from 'react-immutable-proptypes';
-import Button             from '../../../components/button';
 
 const Header = React.createClass({
 
   propTypes: {
-    account: ImmutablePropTypes.map.isRequired,
-    onFollow: React.PropTypes.func.isRequired,
-    onUnfollow: React.PropTypes.func.isRequired
+    account: ImmutablePropTypes.map.isRequired
   },
 
   mixins: [PureRenderMixin],