Add log in and log out button
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
import { Link, routes } from '@redwoodjs/router'
|
import { Link, routes } from '@redwoodjs/router'
|
||||||
|
import { useAuth } from '@redwoodjs/auth'
|
||||||
|
|
||||||
const MainLayout = ({ children }) => {
|
const MainLayout = ({ children }) => {
|
||||||
|
const { logIn, logOut, isAuthenticated } = useAuth()
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<header>
|
<header>
|
||||||
@@ -18,6 +20,11 @@ const MainLayout = ({ children }) => {
|
|||||||
<li>
|
<li>
|
||||||
<Link to={routes.contact()}>Contact</Link>
|
<Link to={routes.contact()}>Contact</Link>
|
||||||
</li>
|
</li>
|
||||||
|
<li>
|
||||||
|
<a href="#" onClick={isAuthenticated ? logOut : logIn}>
|
||||||
|
{isAuthenticated ? 'Log Out' : 'Log In'}
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
</header>
|
</header>
|
||||||
|
|||||||
Reference in New Issue
Block a user