File size: 699 Bytes
f5071ca |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
import React from 'react';
const Navbar = ({ currentUser, logout, openModal }) => {
const beforeSession = () => (
<nav className="login-signup">
<button onClick={() => openModal('signup')}>Sign up</button>
<button onClick={() => openModal('login')}>Log in</button>
</nav>
);
const afterSession = () => (
<nav className="login-signup">
<h2 className="welcome-name">Welcome, {currentUser.username}!</h2>
<button onClick={logout}>Log Out</button>
</nav>
);
return (
currentUser ? afterSession(currentUser, logout) : beforeSession()
);
};
export default Navbar; |