import React from 'react';
import styles from './index.scss';
import { Link } from 'react-router';
import { actions as currentUserActions } from 'redux/modules/currentUser';
import { connect } from 'react-redux';

const mapStateToProps = (state) => ({
  currentUser: state.currentUser,
});

export default class NavBar extends React.Component {
  static propTypes = {
    currentUser: React.PropTypes.object,
  }

  render() {
    const {
      currentUser,
    } = this.props;

    return (
      <div className={styles.component}>
        <Link to={currentUser ? '/home' : '/'}>
          Gift Thing
        </Link>

        <div>
          {currentUser &&
            <div>
              {currentUser.name}{' '}
              <a href="/auth/logout">Log out</a>
            </div>
          }
          {!currentUser &&
            <Link to="/auth/login/facebook">Log in</Link>
          }
        </div>
      </div>
    );
  }
}

export default connect(mapStateToProps, currentUserActions)(NavBar);

import React from 'react';
import styles from './index.scss';
import { Link } from 'react-router';
import { actions as currentUserActions } from 'redux/modules/currentUser';
import { connect } from 'react-redux';

const mapStateToProps = (state) => ({
  currentUser: state.currentUser,
});

export default class NavBar extends React.Component {
  static propTypes = {
    currentUser: React.PropTypes.object,
  }

  render() {
    const {
      currentUser,
    } = this.props;

    return (
      <div className={styles.component}>
        <Link to={currentUser ? '/home' : '/'}>
          Gift Thing
        </Link>

        <div>
          {currentUser &&
            <div>
              {currentUser.name}{' '}
              <a href="/auth/logout">Log out</a>
            </div>
          }
          {!currentUser &&
            <a href="/auth/login/facebook">Log in</a>
          }
        </div>
      </div>
    );
  }
}

export default connect(mapStateToProps, currentUserActions)(NavBar);

Use <a> for log in link in <NavBar>
Use <a> for log in link in <NavBar>

This needs to be a regular link, not one handled by the router. I'm not
sure if there is a better way to do this, but this works for now so I'm
rolling with it.
