Add questions nav links and admin unread badge
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -44,6 +44,9 @@ export default async function StudentLayout({ children }: { children: React.Reac
|
||||
{schoolName}
|
||||
</Link>
|
||||
<div className="flex items-center gap-4">
|
||||
<Link href="/questions" className="text-sm hover:underline" style={{ color: "var(--muted-foreground)" }}>
|
||||
Вопросы
|
||||
</Link>
|
||||
<Link href="/profile" className="text-sm hover:underline" style={{ color: "var(--muted-foreground)" }}>
|
||||
{session.user.name}
|
||||
</Link>
|
||||
|
||||
@@ -2,11 +2,23 @@ import { headers } from "next/headers";
|
||||
import { auth } from "@/lib/auth";
|
||||
import { redirect } from "next/navigation";
|
||||
import { AdminShell } from "@/components/admin/admin-shell";
|
||||
import { prisma } from "@/lib/prisma";
|
||||
|
||||
export default async function AdminLayout({ children }: { children: React.ReactNode }) {
|
||||
const session = await auth.api.getSession({ headers: await headers() });
|
||||
if (!session) redirect("/login");
|
||||
if (session.user.role !== "admin") redirect("/dashboard");
|
||||
|
||||
return <AdminShell userName={session.user.name}>{children}</AdminShell>;
|
||||
const questionsBadge = await prisma.studentQuestion.count({
|
||||
where: {
|
||||
messages: {
|
||||
some: {
|
||||
isRead: false,
|
||||
author: { role: "student" },
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
return <AdminShell userName={session.user.name} questionsBadge={questionsBadge}>{children}</AdminShell>;
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ export default async function CuratorLayout({ children }: { children: React.Reac
|
||||
<nav className="flex-1 py-3 space-y-0.5 px-2">
|
||||
<NavLink href="/curator/dashboard">Обзор</NavLink>
|
||||
<NavLink href="/curator/homework">ДЗ на проверку</NavLink>
|
||||
<NavLink href="/curator/questions">Вопросы</NavLink>
|
||||
</nav>
|
||||
<div className="px-4 py-4" style={{ borderTop: "1px solid rgba(255,255,255,0.08)" }}>
|
||||
<p className="text-xs mb-2 truncate" style={{ color: "#888" }}>{session.user.name}</p>
|
||||
|
||||
Reference in New Issue
Block a user