-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathAdminSidebar.tsx
More file actions
80 lines (76 loc) · 2.07 KB
/
AdminSidebar.tsx
File metadata and controls
80 lines (76 loc) · 2.07 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
69
70
71
72
73
74
75
76
77
78
79
80
"use client";
import * as React from "react";
import Image from "next/image";
import Link from "next/link";
import { NavMain } from "./NavMain";
import { NavSecondary } from "./NavSecondary";
import {
Sidebar,
SidebarContent,
SidebarFooter,
SidebarHeader,
SidebarMenu,
SidebarMenuButton,
SidebarMenuItem,
} from "ui/components/sidebar";
import c from "config";
import { UserWithRole } from "db/types";
import { userHasPermission } from "@/lib/utils/server/admin";
import { adminSidebarData as data } from "@/lib/constants/admin";
export function AdminSidebar({
user,
...props
}: React.ComponentProps<typeof Sidebar> & {
user?: UserWithRole;
}) {
const mainItems = data.navMain.filter((item) =>
item.permission && user
? userHasPermission(user, item.permission)
: !item.permission || !user,
);
const secondaryItems = data.navSecondary.filter((item) =>
item.permission && user
? userHasPermission(user, item.permission)
: !item.permission || !user,
);
return (
<Sidebar variant="inset" {...props}>
<SidebarHeader>
<SidebarMenu>
<SidebarMenuItem>
<SidebarMenuButton size="lg" asChild>
<div className="flex items-center gap-x-4">
<Link
href={"/"}
className="mr-5 flex items-center gap-x-1"
>
<Image
src={c.icon.svg}
alt={c.hackathonName + " Logo"}
width={32}
height={32}
/>
<div className="h-[45%] w-[2px] rotate-[25deg] bg-muted-foreground" />
<h2 className="text-lg font-bold tracking-tight">
Admin
</h2>
</Link>
</div>
</SidebarMenuButton>
</SidebarMenuItem>
</SidebarMenu>
</SidebarHeader>
<SidebarContent>
<NavMain items={mainItems} />
<NavSecondary items={secondaryItems} className="mt-auto" />
</SidebarContent>
<SidebarFooter>
<div className="rounded-md border border-sidebar-border px-3 py-2 text-center text-xs text-muted-foreground">
<span className="uppercase tracking-wide">
Powered by HackKit
</span>
</div>
</SidebarFooter>
</Sidebar>
);
}