-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhamburger-menu.tsx
More file actions
68 lines (63 loc) · 1.66 KB
/
Copy pathhamburger-menu.tsx
File metadata and controls
68 lines (63 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import type { FC } from "react";
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuLabel,
DropdownMenuSeparator,
DropdownMenuTrigger,
} from "./ui/dropdown-menu";
import { buttonVariants } from "./ui/button";
import { Menu } from "lucide-react";
import { Link } from "nextjs13-progress";
import { MenuLink } from "@/types/MenuLink";
import type { Session } from "next-auth";
interface HamburgerMenuProps {
session: Session | null;
}
const navigation: MenuLink[] = [
{
href: "/orders",
label: "Order",
},
{
href: "/cases",
label: "Cases",
},
{
href: "/proposals",
label: "Proposals",
},
];
const HamburgerMenu: FC<HamburgerMenuProps> = async ({ session }) => {
if (!session) return;
const isAdmin = session.user.permission === "admin";
return (
<div className="md:hidden">
<DropdownMenu>
<DropdownMenuTrigger
className={buttonVariants({ variant: "ghost", size: "icon" })}
>
<Menu />
</DropdownMenuTrigger>
<DropdownMenuContent>
<DropdownMenuLabel>Pages</DropdownMenuLabel>
<DropdownMenuSeparator />
{navigation.map((item, index) => (
<DropdownMenuItem key={index} asChild>
<Link href={item.href}>{item.label}</Link>
</DropdownMenuItem>
))}
{isAdmin && (
<DropdownMenuItem asChild>
<Link href="/admin" className="h-full w-full text-red-500">
Admin Panel
</Link>
</DropdownMenuItem>
)}
</DropdownMenuContent>
</DropdownMenu>
</div>
);
};
export default HamburgerMenu;