Add questions nav links and admin unread badge
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -9,13 +9,14 @@ const links = [
|
||||
{ href: "/admin/categories", label: "Категории" },
|
||||
{ href: "/admin/users", label: "Пользователи" },
|
||||
{ href: "/curator/homework", label: "ДЗ на проверку" },
|
||||
{ href: "/admin/questions", label: "Вопросы" },
|
||||
{ href: "/admin/quizzes", label: "Тесты" },
|
||||
{ href: "/admin/comments", label: "Комментарии" },
|
||||
{ href: "/admin/import-export", label: "Импорт / Экспорт" },
|
||||
{ href: "/admin/settings", label: "Настройки" },
|
||||
];
|
||||
|
||||
export function AdminNav() {
|
||||
export function AdminNav({ questionsBadge = 0 }: { questionsBadge?: number }) {
|
||||
const pathname = usePathname();
|
||||
|
||||
return (
|
||||
@@ -24,7 +25,7 @@ export function AdminNav() {
|
||||
const active =
|
||||
pathname === href ||
|
||||
(href !== "/admin/dashboard" && href !== "/curator/homework" && pathname.startsWith(href)) ||
|
||||
(href === "/curator/homework" && pathname.startsWith("/curator"));
|
||||
(href === "/curator/homework" && pathname.startsWith("/curator/homework"));
|
||||
return (
|
||||
<Link
|
||||
key={href}
|
||||
@@ -40,7 +41,23 @@ export function AdminNav() {
|
||||
: undefined
|
||||
}
|
||||
>
|
||||
{label}
|
||||
<span className="flex items-center justify-between w-full">
|
||||
{label}
|
||||
{href === "/admin/questions" && questionsBadge > 0 && (
|
||||
<span
|
||||
className="ml-2 inline-flex items-center justify-center rounded-full text-xs font-bold leading-none"
|
||||
style={{
|
||||
minWidth: "1.25rem",
|
||||
height: "1.25rem",
|
||||
padding: "0 0.3rem",
|
||||
backgroundColor: "var(--destructive)",
|
||||
color: "#fff",
|
||||
}}
|
||||
>
|
||||
{questionsBadge}
|
||||
</span>
|
||||
)}
|
||||
</span>
|
||||
</Link>
|
||||
);
|
||||
})}
|
||||
|
||||
@@ -4,9 +4,11 @@ import { LogoutButton } from "@/components/layout/logout-button";
|
||||
export function AdminShell({
|
||||
children,
|
||||
userName,
|
||||
questionsBadge = 0,
|
||||
}: {
|
||||
children: React.ReactNode;
|
||||
userName: string;
|
||||
questionsBadge?: number;
|
||||
}) {
|
||||
return (
|
||||
<div className="min-h-screen flex">
|
||||
@@ -23,7 +25,7 @@ export function AdminShell({
|
||||
</p>
|
||||
</div>
|
||||
<nav className="flex-1 px-2 py-4 space-y-0.5 overflow-y-auto">
|
||||
<AdminNav />
|
||||
<AdminNav questionsBadge={questionsBadge} />
|
||||
</nav>
|
||||
<div className="px-4 py-4" style={{ borderTop: "2px solid var(--sidebar-border)" }}>
|
||||
<p className="text-xs mb-3 truncate" style={{ color: "var(--sidebar-text)" }}>
|
||||
|
||||
Reference in New Issue
Block a user