mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-07-12 22:32:51 -05:00
Add admin page to menu
This commit is contained in:
parent
80b901a121
commit
ab82ed4d28
|
|
@ -3,6 +3,8 @@ import { Link } from "@remix-run/react";
|
|||
import navItems from "./nav-items.json";
|
||||
import { Image } from "../Image";
|
||||
import { useIsMounted } from "~/hooks/useIsMounted";
|
||||
import { canPerformAdminActions } from "~/permissions";
|
||||
import { useUser } from "~/modules/auth";
|
||||
|
||||
export function Menu({
|
||||
expanded,
|
||||
|
|
@ -11,15 +13,24 @@ export function Menu({
|
|||
expanded: boolean;
|
||||
closeMenu: () => void;
|
||||
}) {
|
||||
const user = useUser();
|
||||
const isMounted = useIsMounted();
|
||||
|
||||
// without this menu is initially visible due to SSR and not knowing user screen width on server (probably)
|
||||
if (!isMounted) return null;
|
||||
|
||||
const visibleNavItems = navItems.filter((navItem) => {
|
||||
if (navItem.name === "admin") {
|
||||
return canPerformAdminActions(user);
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
return (
|
||||
<nav className={clsx("layout__menu", { expanded })} aria-hidden={!expanded}>
|
||||
<div className="layout__menu__links">
|
||||
{navItems.map((navItem, i) => (
|
||||
{visibleNavItems.map((navItem, i) => (
|
||||
<Link
|
||||
key={navItem.name}
|
||||
className={clsx("layout__menu__link", {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,9 @@
|
|||
[
|
||||
{
|
||||
"name": "admin",
|
||||
"displayName": "Admin",
|
||||
"url": "admin"
|
||||
},
|
||||
{ "name": "badges", "displayName": "Badges", "url": "badges" },
|
||||
{
|
||||
"name": "plus",
|
||||
|
|
|
|||
BIN
public/img/layout/admin.avif
Normal file
BIN
public/img/layout/admin.avif
Normal file
Binary file not shown.
BIN
public/img/layout/admin.png
Normal file
BIN
public/img/layout/admin.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 28 KiB |
Loading…
Reference in New Issue
Block a user