judge4c/src/components/sidebar/app-sidebar.tsx

139 lines
3.1 KiB
TypeScript
Raw Normal View History

2025-06-20 12:18:13 +00:00
"use client";
import { siteConfig } from "@/config/site";
import * as React from "react";
import {
2025-06-21 09:44:14 +00:00
// BookOpen,
Command,
2025-06-17 09:05:15 +00:00
LifeBuoy,
Send,
2025-06-21 09:44:14 +00:00
// Settings2,
SquareTerminal,
2025-06-20 12:18:13 +00:00
} from "lucide-react";
2025-06-17 09:05:15 +00:00
2025-06-20 12:18:13 +00:00
import { NavMain } from "@/components/nav-main";
import { NavProjects } from "@/components/nav-projects";
import { NavSecondary } from "@/components/nav-secondary";
import { NavUser } from "@/components/nav-user";
import {
Sidebar,
SidebarContent,
SidebarFooter,
SidebarHeader,
2025-06-17 09:05:15 +00:00
SidebarMenu,
SidebarMenuButton,
SidebarMenuItem,
2025-06-20 12:18:13 +00:00
} from "@/components/ui/sidebar";
import { User } from "next-auth";
const data = {
navMain: [
{
2025-06-18 09:49:07 +00:00
title: "页面",
2025-06-17 09:05:15 +00:00
url: "#",
icon: SquareTerminal,
isActive: true,
2025-06-17 09:05:15 +00:00
items: [
{
2025-06-18 09:49:07 +00:00
title: "主页",
2025-06-21 09:44:14 +00:00
url: "/dashboard/student/dashboard",
2025-06-17 09:05:15 +00:00
},
{
2025-06-18 09:49:07 +00:00
title: "题目集",
2025-06-17 09:05:15 +00:00
url: "/problemset",
},
],
},
2025-06-20 12:18:13 +00:00
2025-06-21 09:44:14 +00:00
// {
// title: "已完成事项",
// url: "#",
// icon: BookOpen,
// items: [
// {
// title: "全部编程集",
// url: "#",
// },
// {
// title: "错题集",
// url: "#",
// },
// {
// title: "收藏集",
// url: "#",
// },
// ],
// },
// {
// title: "设置",
// url: "#",
// icon: Settings2,
// items: [
// {
// title: "语言",
// url: "#",
// },
// ],
// },
],
2025-06-17 09:05:15 +00:00
navSecondary: [
{
2025-06-19 08:07:40 +00:00
title: "帮助",
2025-06-17 09:05:15 +00:00
url: "/",
icon: LifeBuoy,
},
{
2025-06-19 08:07:40 +00:00
title: "反馈",
2025-06-17 09:05:15 +00:00
url: siteConfig.url.repo.github,
icon: Send,
},
],
2025-06-20 12:18:13 +00:00
};
2025-06-21 09:44:14 +00:00
interface AppSidebarProps {
user: User;
wrongProblems: {
id: string;
name: string;
status: string;
}[];
}
2025-06-21 09:44:14 +00:00
export function AppSidebar({ user, wrongProblems, ...props }: AppSidebarProps) {
2025-06-20 12:18:13 +00:00
const userInfo = {
name: user.name ?? "",
email: user.email ?? "",
avatar: user.image ?? "",
};
return (
2025-06-20 12:18:13 +00:00
<Sidebar {...props}>
<SidebarHeader>
2025-06-17 09:05:15 +00:00
<SidebarMenu>
<SidebarMenuItem>
<SidebarMenuButton size="lg" asChild>
<a href="#">
<div className="flex aspect-square size-8 items-center justify-center rounded-lg bg-sidebar-primary text-sidebar-primary-foreground">
<Command className="size-4" />
</div>
<div className="grid flex-1 text-left text-sm leading-tight">
<span className="truncate font-semibold">Judge4c</span>
<span className="truncate text-xs">Programming Learning</span>
</div>
</a>
</SidebarMenuButton>
</SidebarMenuItem>
</SidebarMenu>
</SidebarHeader>
<SidebarContent>
<NavMain items={data.navMain} />
2025-06-21 09:44:14 +00:00
<NavProjects projects={wrongProblems} />
2025-06-17 09:05:15 +00:00
<NavSecondary items={data.navSecondary} className="mt-auto" />
</SidebarContent>
<SidebarFooter>
2025-06-20 12:18:13 +00:00
<NavUser user={userInfo} />
</SidebarFooter>
</Sidebar>
2025-06-20 12:18:13 +00:00
);
}