# HG changeset patch # User ymh # Date 1497978282 -7200 # Node ID 14989b339e5d26856cf5659785d28a305a1a1215 # Parent aecde527900af5e09849935842675d13d543840a Use a fonctionnal component for the login part of the navbar diff -r aecde527900a -r 14989b339e5d client/src/components/Navbar.js --- a/client/src/components/Navbar.js Tue Jun 20 17:54:02 2017 +0200 +++ b/client/src/components/Navbar.js Tue Jun 20 19:04:42 2017 +0200 @@ -6,6 +6,37 @@ import { Navbar, Nav, NavItem, NavDropdown, MenuItem } from 'react-bootstrap'; import * as authActions from '../actions/authActions'; +const LoginNav = ({isAuthenticated, currentUser, history, authActions}) => { + + const onClickSettings = (e) => { + e.preventDefault(); + history.push('/settings'); + } + + const onClickLogout = (e) => { + e.preventDefault(); + authActions.logout(); + } + + const onClickLogin = (e) => { + e.preventDefault(); + history.push('/login'); + } + + + if (isAuthenticated) { + return ( + + Settings + Logout + + ); + } + return ( + Login + ); +} + class AppNavbar extends Component { onClickHome = (e) => { @@ -18,37 +49,6 @@ this.props.history.push('/sessions'); } - onClickLogin = (e) => { - e.preventDefault(); - this.props.history.push('/login'); - } - - onClickSettings = (e) => { - e.preventDefault(); - this.props.history.push('/settings'); - } - - onClickLogout = (e) => { - e.preventDefault(); - this.props.authActions.logout(); - } - - renderLogin() { - - if (this.props.isAuthenticated) { - return ( - - Settings - Logout - - ); - } - - return ( - Login - ); - } - render() { return ( @@ -63,7 +63,7 @@ Sessions