Authorization working
This commit is contained in:
48
src/components/nav/ProtectedNavLinks.tsx
Normal file
48
src/components/nav/ProtectedNavLinks.tsx
Normal file
@@ -0,0 +1,48 @@
|
||||
import { useAuth } from "@/providers/AuthProvider";
|
||||
import { NavLink } from "react-router";
|
||||
|
||||
|
||||
const protectedLinks = [
|
||||
{
|
||||
name: "Games",
|
||||
path: "/game"
|
||||
},
|
||||
{
|
||||
name: "Groups",
|
||||
path: "/raidGroup"
|
||||
},
|
||||
{
|
||||
name: "Admin",
|
||||
path: "/admin"
|
||||
},
|
||||
{
|
||||
name: "Logout",
|
||||
path: "/logout"
|
||||
}
|
||||
];
|
||||
|
||||
|
||||
export default function ProtectedNavLinks(){
|
||||
const { jwt } = useAuth();
|
||||
|
||||
|
||||
if(!jwt){
|
||||
return <></>;
|
||||
}
|
||||
|
||||
|
||||
return (
|
||||
<>
|
||||
{
|
||||
protectedLinks.map((link) => (
|
||||
<NavLink
|
||||
key={link.name}
|
||||
to={link.path}
|
||||
>
|
||||
{link.name}
|
||||
</NavLink>
|
||||
))
|
||||
}
|
||||
</>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user