hide pages from unauthenticated users

This commit is contained in:
João Geonizeli
2021-09-02 14:57:23 -03:00
parent 56faecfbed
commit 8b7a286a9c
4 changed files with 41 additions and 21 deletions

View File

@@ -4,6 +4,7 @@ import { Transition } from "@headlessui/react";
import cs from "classnames";
import { useApp } from "../../contexts/AppProvider";
import { useCurrentUser } from "../../contexts/UserProvider";
type MenuItem = {
label: string;
@@ -38,6 +39,7 @@ const MenuItems: MenuItem[] = [
];
export const SideNav = () => {
const { isAuthenticated } = useCurrentUser();
const { sideNavExpanded, setSideNavExpanded } = useApp();
const location = useLocation();
@@ -51,6 +53,8 @@ export const SideNav = () => {
}
};
if (!isAuthenticated) return null;
return (
<>
<Transition