63 lines
922 B
TypeScript
63 lines
922 B
TypeScript
import { useAuth } from "@/providers/AuthProvider";
|
|
import { isSiteAdmin } from "@/util/PermissionUtil";
|
|
import { BsFillPersonFill } from "react-icons/bs";
|
|
import { NavLink } from "react-router";
|
|
|
|
|
|
export default function ProtectedNavLinks(){
|
|
const { jwt, accountPermissions } = useAuth();
|
|
|
|
|
|
if(!jwt){
|
|
return <></>;
|
|
}
|
|
|
|
|
|
const protectedLinks = [
|
|
{
|
|
name: "Game",
|
|
path: "/game"
|
|
},
|
|
{
|
|
name: "Raid Group",
|
|
path: "/raidGroup"
|
|
}
|
|
];
|
|
if(isSiteAdmin(accountPermissions)){
|
|
protectedLinks.push({
|
|
name: "Admin",
|
|
path: "/admin"
|
|
});
|
|
}
|
|
protectedLinks.push({
|
|
name: "Logout",
|
|
path: "/logout"
|
|
});
|
|
|
|
|
|
return (
|
|
<>
|
|
{
|
|
protectedLinks.map((link) => (
|
|
<NavLink
|
|
key={link.name}
|
|
to={link.path}
|
|
>
|
|
{link.name}
|
|
</NavLink>
|
|
))
|
|
}
|
|
{
|
|
jwt &&
|
|
<NavLink
|
|
to="/account"
|
|
>
|
|
<BsFillPersonFill
|
|
size={22}
|
|
/>
|
|
</NavLink>
|
|
}
|
|
</>
|
|
);
|
|
}
|