forked from admin/runners-calendar
feat: add registration and authentication
This commit is contained in:
@@ -1,7 +1,10 @@
|
||||
import { Link, NavLink, Outlet } from "react-router-dom";
|
||||
import { useAuth } from "../auth/AuthContext";
|
||||
import { AppShellFooter } from "./AppShellFooter";
|
||||
|
||||
export function AppLayout(): JSX.Element {
|
||||
const { user, logout } = useAuth();
|
||||
|
||||
return (
|
||||
<div className="app-shell">
|
||||
<header className="app-shell__header">
|
||||
@@ -34,6 +37,20 @@ export function AppLayout(): JSX.Element {
|
||||
>
|
||||
+ Добавить
|
||||
</NavLink>
|
||||
{user ? (
|
||||
<button className="app-shell__link app-shell__link--button" type="button" onClick={() => void logout()}>
|
||||
Выйти
|
||||
</button>
|
||||
) : (
|
||||
<NavLink
|
||||
to="/login"
|
||||
className={({ isActive }) =>
|
||||
isActive ? "app-shell__link app-shell__link--active" : "app-shell__link"
|
||||
}
|
||||
>
|
||||
Войти
|
||||
</NavLink>
|
||||
)}
|
||||
</nav>
|
||||
</header>
|
||||
<main className="app-shell__main">
|
||||
|
||||
Reference in New Issue
Block a user