Core AI runtime - New encoach.ai.agent + encoach.ai.tool models with M2M tool binding, graph topology (simple|plan_review_revise|rag|react), model + fallback, temperature, max_tokens, response_format, max_revisions, quality checks and system prompt fields. - services/agent_runtime.py compiles a langgraph.StateGraph per agent and caches the build per (key, write_date). Emits a structured trace (output, tool_calls, retrieval_hits, revisions, quality_issues, ms, model_used, fallback_used) and auto-falls-back on rate-limit/5xx. - services/agent_tools.py registers 11 tool handlers wrapping existing services: resources.search, rubric.fetch, outcomes.fetch, student.profile, quality.cefr_check, quality.ai_detect, quality.content_gate, course_plan.save (mutates), course_plan.save_materials (mutates), scoring.grade_writing, scoring.grade_speaking. - 7 default agents seeded via data/agents_defaults.xml: course_planner, course_week_materials, exam_generator, exercise_generator, lms_tutor, writing_grader, speaking_grader. - Feature flag encoach_ai.use_langgraph_runtime (default True). - encoach_ai_course pipeline now routes through AgentRuntime when on, legacy SDK path kept as fallback. Admin UI - /admin/ai/prompts is now a tabbed Agents | Tools | Prompts console. - AIAgentsPanel: card grid + config dialog (model/temp/graph/tools/ system prompt) + built-in Test Runner showing live trace. - AIToolsPanel: registry table with category badges, mutates flag, schema viewer, edit dialog. - New /api/ai/agents* and /api/ai/tools* controller (list/get/update/ test, list-tools, toggle-tool). - Sidebar label nav.aiPrompts -> nav.aiAgents (AI Agents and Tools). - EN + AR (RTL) translations for ~80 new keys. Smart Wizard pages - /admin/quick-setup hub + CourseWizard, CoursePlanWizard, RubricWizard, ExamStructureWizard step-by-step flows. - /admin/course-plans list + detail pages. - /teacher/quick-setup mirror. Full demo seed + 8-role E2E - seed_full_demo.py adds the 5 missing user_types (approver, corporate, mastercorporate, agent, developer), activates a 2-stage exam-approval workflow with one pending request, creates a GE1-aligned 12-week B1 course plan with 6 detailed Week-1 materials (reading 400w, writing, listening 4-min script, speaking, grammar present simple vs continuous, vocabulary), and inserts sample ai.log + ai.feedback rows. - reset_demo_passwords.py forces every demo login back to canonical passwords (admin123/teacher123/student123/approver123/corporate123/ master123/agent123/dev123). - e2e_full_scenario.py: 46/46 PASS read-only API smoke across all 8 roles, including a live LangGraph round-trip on writing_grader. - e2e_approval_chain.py: 6/6 PASS mutation E2E - approver approves stage 1, admin approves stage 2, linked encoach.exam.custom flips to status=published, verified via psql. Docs - docs/PROJECT_SUMMARY.md updated to 2026-04-25: new Latest events bullets, refreshed credentials table, full sections 22 (LangGraph runtime) and 23 (full demo seed + 8-role E2E). - docs/ENCOACH_FULL_DEMO_QA_REPORT.md added with credentials, per-endpoint PASS/FAIL, mutation chain proof, LangGraph live output. - backend/GE1 Course Outline_ Fall AY25-26.pdf vendored as the reference outline the GE1 plan/materials are aligned to. Dependencies - requirements.txt: langgraph>=0.2.0, langchain-core>=0.3.0. - encoach_ai/__manifest__.py: external_dependencies updated. Made-with: Cursor
413 lines
19 KiB
TypeScript
413 lines
19 KiB
TypeScript
import { Outlet, Link, useNavigate, useLocation } from "react-router-dom";
|
|
import { Suspense } from "react";
|
|
import { SidebarProvider, SidebarTrigger } from "@/components/ui/sidebar";
|
|
import {
|
|
Sidebar, SidebarContent, SidebarGroup, SidebarGroupContent,
|
|
SidebarGroupLabel, SidebarMenu, SidebarMenuButton, SidebarMenuItem,
|
|
SidebarHeader, SidebarFooter, SidebarSeparator, useSidebar,
|
|
} from "@/components/ui/sidebar";
|
|
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "@/components/ui/collapsible";
|
|
import { NavLink } from "@/components/NavLink";
|
|
import { useAuth } from "@/contexts/AuthContext";
|
|
import NotificationDropdown from "@/components/NotificationDropdown";
|
|
import { ThemeToggle } from "@/components/ThemeToggle";
|
|
import { LanguageToggle } from "@/components/LanguageToggle";
|
|
import AiAssistantDrawer from "@/components/ai/AiAssistantDrawer";
|
|
import AiSearchBar from "@/components/ai/AiSearchBar";
|
|
import { usePermissions } from "@/hooks/usePermissions";
|
|
import { Button } from "@/components/ui/button";
|
|
import {
|
|
DropdownMenu, DropdownMenuContent, DropdownMenuItem,
|
|
DropdownMenuSeparator, DropdownMenuTrigger,
|
|
} from "@/components/ui/dropdown-menu";
|
|
import {
|
|
Breadcrumb, BreadcrumbItem, BreadcrumbLink, BreadcrumbList,
|
|
BreadcrumbPage, BreadcrumbSeparator,
|
|
} from "@/components/ui/breadcrumb";
|
|
import {
|
|
GraduationCap, LogOut, User, Settings, LayoutDashboard, ClipboardList,
|
|
FileText, Layers, BookOpen, Wand2, GitBranch, Users, BarChart3,
|
|
Building2, History, CreditCard, Ticket, BookA, PenTool,
|
|
Calendar, ChevronDown, HelpCircle, LucideIcon, Target, FolderOpen,
|
|
CalendarDays, Landmark, UserPlus, ScrollText, Award,
|
|
HelpCircle as FaqIcon, Bell, Workflow,
|
|
CalendarOff, DollarSign, BookMarked, BarChartHorizontal, TrendingUp,
|
|
Library, Activity, Warehouse, UserCog, Sparkles, Compass,
|
|
} from "lucide-react";
|
|
import React from "react";
|
|
import { useTranslation } from "react-i18next";
|
|
|
|
// ============= Navigation Config =============
|
|
// Items store i18n keys (`titleKey`) rather than literal strings so Arabic
|
|
// language switches update the sidebar without the component having to
|
|
// re-mount.
|
|
interface NavItem { titleKey: string; url: string; icon: LucideIcon }
|
|
|
|
const overviewItems: NavItem[] = [
|
|
{ titleKey: "nav.smartWizard", url: "/admin/smart-wizard", icon: Sparkles },
|
|
{ titleKey: "nav.adminDashboard", url: "/admin/dashboard", icon: LayoutDashboard },
|
|
{ titleKey: "nav.platformDashboard", url: "/admin/platform", icon: BarChart3 },
|
|
];
|
|
|
|
const lmsItems: NavItem[] = [
|
|
{ titleKey: "nav.courses", url: "/admin/courses", icon: BookOpen },
|
|
{ titleKey: "nav.students", url: "/admin/students", icon: Users },
|
|
{ titleKey: "nav.teachers", url: "/admin/teachers", icon: GraduationCap },
|
|
{ titleKey: "nav.batches", url: "/admin/batches", icon: Layers },
|
|
{ titleKey: "nav.timetable", url: "/admin/timetable", icon: Calendar },
|
|
{ titleKey: "nav.reports", url: "/admin/reports", icon: BarChart3 },
|
|
];
|
|
|
|
const academicItems: NavItem[] = [
|
|
{ titleKey: "nav.assignments", url: "/admin/assignments", icon: ClipboardList },
|
|
{ titleKey: "nav.examsList", url: "/admin/examsList", icon: FileText },
|
|
{ titleKey: "nav.examStructures", url: "/admin/exam-structures", icon: Layers },
|
|
{ titleKey: "nav.rubrics", url: "/admin/rubrics", icon: BookOpen },
|
|
{ titleKey: "nav.generation", url: "/admin/generation", icon: Wand2 },
|
|
{ titleKey: "nav.reviewQueue", url: "/admin/exam/review-queue", icon: Sparkles },
|
|
{ titleKey: "nav.aiPrompts", url: "/admin/ai/prompts", icon: Wand2 },
|
|
{ titleKey: "nav.aiFeedback", url: "/admin/ai/feedback", icon: Sparkles },
|
|
{ titleKey: "nav.coursePlans", url: "/admin/course-plans", icon: Compass },
|
|
{ titleKey: "nav.approvalWorkflows", url: "/admin/approval-workflows", icon: GitBranch },
|
|
];
|
|
|
|
const adaptiveItems: NavItem[] = [
|
|
{ titleKey: "nav.taxonomy", url: "/admin/taxonomy", icon: Target },
|
|
{ titleKey: "nav.resources", url: "/admin/resources", icon: FolderOpen },
|
|
];
|
|
|
|
const institutionalItems: NavItem[] = [
|
|
{ titleKey: "nav.academicYears", url: "/admin/academic-years", icon: CalendarDays },
|
|
{ titleKey: "nav.departments", url: "/admin/departments", icon: Landmark },
|
|
{ titleKey: "nav.admissions", url: "/admin/admissions", icon: UserPlus },
|
|
{ titleKey: "nav.admissionRegister", url: "/admin/admission-register", icon: ScrollText },
|
|
{ titleKey: "nav.examSessions", url: "/admin/exam-sessions", icon: FileText },
|
|
{ titleKey: "nav.marksheets", url: "/admin/marksheets", icon: Award },
|
|
{ titleKey: "nav.studentLeave", url: "/admin/student-leave", icon: CalendarOff },
|
|
{ titleKey: "nav.fees", url: "/admin/fees", icon: DollarSign },
|
|
{ titleKey: "nav.lessons", url: "/admin/lessons", icon: BookMarked },
|
|
{ titleKey: "nav.gradebook", url: "/admin/gradebook", icon: BarChartHorizontal },
|
|
{ titleKey: "nav.studentProgress", url: "/admin/student-progress", icon: TrendingUp },
|
|
{ titleKey: "nav.library", url: "/admin/library", icon: Library },
|
|
{ titleKey: "nav.activities", url: "/admin/activities", icon: Activity },
|
|
{ titleKey: "nav.facilities", url: "/admin/facilities", icon: Warehouse },
|
|
];
|
|
|
|
const managementItems: NavItem[] = [
|
|
{ titleKey: "nav.users", url: "/admin/users", icon: Users },
|
|
{ titleKey: "nav.entities", url: "/admin/entities", icon: Building2 },
|
|
{ titleKey: "nav.classrooms", url: "/admin/classrooms", icon: GraduationCap },
|
|
{ titleKey: "nav.userRoles", url: "/admin/user-roles", icon: UserCog },
|
|
{ titleKey: "nav.rolesPermissions", url: "/admin/roles-permissions", icon: Settings },
|
|
{ titleKey: "nav.authorityMatrix", url: "/admin/authority-matrix", icon: Workflow },
|
|
];
|
|
|
|
const reportItems: NavItem[] = [
|
|
{ titleKey: "nav.studentPerformance", url: "/admin/student-performance", icon: BarChart3 },
|
|
{ titleKey: "nav.statsCorporate", url: "/admin/stats-corporate", icon: Building2 },
|
|
{ titleKey: "nav.record", url: "/admin/record", icon: History },
|
|
];
|
|
|
|
const trainingItems: NavItem[] = [
|
|
{ titleKey: "nav.vocabulary", url: "/admin/training/vocabulary", icon: BookA },
|
|
{ titleKey: "nav.grammar", url: "/admin/training/grammar", icon: PenTool },
|
|
];
|
|
|
|
const configItems: NavItem[] = [
|
|
{ titleKey: "nav.faqManager", url: "/admin/faq", icon: FaqIcon },
|
|
{ titleKey: "nav.notificationRules", url: "/admin/notification-rules", icon: Bell },
|
|
{ titleKey: "nav.approvalConfig", url: "/admin/approval-config", icon: Workflow },
|
|
];
|
|
|
|
const supportItems: NavItem[] = [
|
|
{ titleKey: "nav.paymentRecord", url: "/admin/payment-record", icon: CreditCard },
|
|
{ titleKey: "nav.tickets", url: "/admin/tickets", icon: Ticket },
|
|
{ titleKey: "nav.settings", url: "/admin/settings-platform", icon: Settings },
|
|
];
|
|
|
|
// ============= Reusable sidebar group =============
|
|
function SidebarNavGroup({ labelKey, items }: { labelKey: string; items: NavItem[] }) {
|
|
const { state } = useSidebar();
|
|
const { t } = useTranslation();
|
|
const collapsed = state === "collapsed";
|
|
|
|
return (
|
|
<SidebarGroup>
|
|
<SidebarGroupLabel>{t(labelKey)}</SidebarGroupLabel>
|
|
<SidebarGroupContent>
|
|
<SidebarMenu>
|
|
{items.map((item) => {
|
|
const label = t(item.titleKey);
|
|
return (
|
|
<SidebarMenuItem key={item.url}>
|
|
<SidebarMenuButton asChild tooltip={label}>
|
|
<NavLink
|
|
to={item.url}
|
|
end={item.url.endsWith("/dashboard") || item.url.endsWith("/platform")}
|
|
className="flex items-center gap-2 px-2 py-1.5 rounded-md text-sm text-sidebar-foreground hover:bg-sidebar-accent transition-colors"
|
|
activeClassName="bg-sidebar-accent text-sidebar-accent-foreground font-medium"
|
|
>
|
|
<item.icon className="h-4 w-4 shrink-0" />
|
|
{!collapsed && <span>{label}</span>}
|
|
</NavLink>
|
|
</SidebarMenuButton>
|
|
</SidebarMenuItem>
|
|
);
|
|
})}
|
|
</SidebarMenu>
|
|
</SidebarGroupContent>
|
|
</SidebarGroup>
|
|
);
|
|
}
|
|
|
|
// ============= Breadcrumbs =============
|
|
// Map URL segments to i18n keys so breadcrumbs follow the active locale.
|
|
// Segments without an entry fall back to a Title-cased version of the slug.
|
|
const routeLabelKeys: Record<string, string> = {
|
|
admin: "breadcrumb.admin", dashboard: "breadcrumb.dashboard",
|
|
platform: "breadcrumb.platform", courses: "nav.courses",
|
|
students: "nav.students", teachers: "nav.teachers", batches: "nav.batches",
|
|
timetable: "nav.timetable", reports: "nav.reports",
|
|
assignments: "nav.assignments", examsList: "nav.examsList",
|
|
"exam-structures": "nav.examStructures", rubrics: "nav.rubrics",
|
|
generation: "nav.generation", "review-queue": "nav.reviewQueue",
|
|
review: "breadcrumb.review", prompts: "nav.aiPrompts", ai: "breadcrumb.ai",
|
|
feedback: "breadcrumb.feedback",
|
|
"approval-workflows": "nav.approvalWorkflows", users: "nav.users",
|
|
entities: "nav.entities", classrooms: "nav.classrooms",
|
|
"student-performance": "nav.studentPerformance",
|
|
"stats-corporate": "nav.statsCorporate", record: "nav.record",
|
|
training: "sidebarGroup.training", vocabulary: "nav.vocabulary",
|
|
grammar: "nav.grammar", "payment-record": "nav.paymentRecord",
|
|
tickets: "nav.tickets", "settings-platform": "nav.settings",
|
|
settings: "nav.settings", profile: "nav.profile", exam: "breadcrumb.exam",
|
|
"academic-years": "nav.academicYears", departments: "nav.departments",
|
|
admissions: "nav.admissions", "admission-register": "nav.admissionRegister",
|
|
"exam-sessions": "nav.examSessions", marksheets: "nav.marksheets",
|
|
faq: "nav.faqManager", "notification-rules": "nav.notificationRules",
|
|
"approval-config": "nav.approvalConfig",
|
|
"student-leave": "nav.studentLeave", fees: "nav.fees",
|
|
lessons: "nav.lessons", gradebook: "nav.gradebook",
|
|
"student-progress": "nav.studentProgress", library: "nav.library",
|
|
activities: "nav.activities", facilities: "nav.facilities",
|
|
};
|
|
|
|
function AppBreadcrumbs() {
|
|
const location = useLocation();
|
|
const { t } = useTranslation();
|
|
const segments = location.pathname.split("/").filter(Boolean);
|
|
|
|
return (
|
|
<Breadcrumb>
|
|
<BreadcrumbList>
|
|
<BreadcrumbItem>
|
|
<BreadcrumbLink asChild><Link to="/admin/dashboard">{t("common.home")}</Link></BreadcrumbLink>
|
|
</BreadcrumbItem>
|
|
{segments.map((seg, i) => {
|
|
const path = "/" + segments.slice(0, i + 1).join("/");
|
|
const key = routeLabelKeys[seg];
|
|
const label = key ? t(key) : seg.charAt(0).toUpperCase() + seg.slice(1);
|
|
const isLast = i === segments.length - 1;
|
|
return (
|
|
<React.Fragment key={path}>
|
|
<BreadcrumbSeparator />
|
|
<BreadcrumbItem>
|
|
{isLast ? <BreadcrumbPage>{label}</BreadcrumbPage> : <BreadcrumbLink asChild><Link to={path}>{label}</Link></BreadcrumbLink>}
|
|
</BreadcrumbItem>
|
|
</React.Fragment>
|
|
);
|
|
})}
|
|
</BreadcrumbList>
|
|
</Breadcrumb>
|
|
);
|
|
}
|
|
|
|
// ============= Route content fallback =============
|
|
// Shown only inside the main content area while a lazy-loaded route chunk
|
|
// is fetching. Keeping the fallback local means the sidebar and header
|
|
// stay mounted during navigation — previously the page felt like a full
|
|
// browser reload because the outer App-level Suspense replaced everything
|
|
// with a full-viewport spinner.
|
|
function RouteContentFallback() {
|
|
return (
|
|
<div className="flex items-center justify-center py-20">
|
|
<div className="animate-spin rounded-full h-6 w-6 border-b-2 border-primary" />
|
|
</div>
|
|
);
|
|
}
|
|
|
|
// ============= Main Layout =============
|
|
export default function AdminLmsLayout() {
|
|
const { user, logout } = useAuth();
|
|
const navigate = useNavigate();
|
|
const { t } = useTranslation();
|
|
|
|
const initials = user?.name?.split(" ").map(w => w[0]).join("").slice(0, 2).toUpperCase() ?? "??";
|
|
|
|
const handleLogout = async () => {
|
|
await logout();
|
|
navigate("/login");
|
|
};
|
|
|
|
return (
|
|
<SidebarProvider>
|
|
<div className="min-h-screen flex w-full">
|
|
<AdminSidebar />
|
|
<div className="flex-1 flex flex-col min-w-0">
|
|
<header className="h-14 border-b bg-card flex items-center justify-between px-4 shrink-0">
|
|
<div className="flex items-center gap-3">
|
|
<SidebarTrigger aria-label={t("chrome.toggleSidebar")} />
|
|
<AppBreadcrumbs />
|
|
</div>
|
|
<AiSearchBar />
|
|
<div className="flex items-center gap-2">
|
|
<LanguageToggle />
|
|
<ThemeToggle />
|
|
<NotificationDropdown />
|
|
<Button variant="ghost" size="icon" aria-label={t("chrome.ticketsTooltip")} onClick={() => navigate("/admin/tickets")} className="text-muted-foreground hover:text-foreground">
|
|
<Ticket className="h-4 w-4" />
|
|
</Button>
|
|
<DropdownMenu>
|
|
<DropdownMenuTrigger asChild>
|
|
<Button variant="ghost" size="icon" className="rounded-full">
|
|
<div className="h-8 w-8 rounded-full bg-primary flex items-center justify-center">
|
|
<span className="text-xs font-semibold text-primary-foreground">{initials}</span>
|
|
</div>
|
|
</Button>
|
|
</DropdownMenuTrigger>
|
|
<DropdownMenuContent align="end" className="w-48">
|
|
<div className="px-3 py-2">
|
|
<p className="text-sm font-medium">{user?.name ?? t("userMenu.userFallback")}</p>
|
|
<p className="text-xs text-muted-foreground">{user?.email ?? ""}</p>
|
|
</div>
|
|
<DropdownMenuSeparator />
|
|
<DropdownMenuItem onClick={() => navigate("/admin/profile")}>
|
|
<User className="me-2 h-4 w-4" /> {t("userMenu.profile")}
|
|
</DropdownMenuItem>
|
|
<DropdownMenuItem onClick={() => navigate("/admin/settings-platform")}>
|
|
<Settings className="me-2 h-4 w-4" /> {t("userMenu.settings")}
|
|
</DropdownMenuItem>
|
|
<DropdownMenuSeparator />
|
|
<DropdownMenuItem onClick={handleLogout}>
|
|
<LogOut className="me-2 h-4 w-4" /> {t("userMenu.logout")}
|
|
</DropdownMenuItem>
|
|
</DropdownMenuContent>
|
|
</DropdownMenu>
|
|
</div>
|
|
</header>
|
|
<main className="flex-1 overflow-auto p-6">
|
|
<Suspense fallback={<RouteContentFallback />}>
|
|
<Outlet />
|
|
</Suspense>
|
|
</main>
|
|
</div>
|
|
</div>
|
|
<AiAssistantDrawer />
|
|
<Link
|
|
to="/admin/tickets"
|
|
className="fixed bottom-6 end-6 z-50 flex items-center gap-2 rounded-full bg-primary px-4 py-2.5 text-primary-foreground shadow-lg hover:opacity-90 transition-opacity"
|
|
>
|
|
<HelpCircle className="h-4 w-4" />
|
|
<span className="text-sm font-medium">{t("chrome.needHelp")}</span>
|
|
</Link>
|
|
</SidebarProvider>
|
|
);
|
|
}
|
|
|
|
// ============= Admin Sidebar =============
|
|
function AdminSidebar() {
|
|
const { state } = useSidebar();
|
|
const collapsed = state === "collapsed";
|
|
const { user } = useAuth();
|
|
const { hasAnyPermission, isAdmin } = usePermissions();
|
|
const { t, i18n } = useTranslation();
|
|
const sidebarSide = i18n.dir() === "rtl" ? "right" : "left";
|
|
|
|
const showManagement = isAdmin || hasAnyPermission(["view_entities", "view_students", "view_teachers"]);
|
|
const showReports = isAdmin || hasAnyPermission(["view_statistics", "view_student_performance", "view_entity_statistics"]);
|
|
const showPayments = isAdmin || hasAnyPermission(["view_payment_record", "pay_entity"]);
|
|
|
|
return (
|
|
<Sidebar side={sidebarSide} collapsible="icon">
|
|
<SidebarHeader className="p-4">
|
|
<div className="flex items-center gap-2">
|
|
{collapsed ? (
|
|
<img
|
|
src="/logo.png"
|
|
alt={t("chrome.adminAlt")}
|
|
className="h-9 w-9 shrink-0 rounded-lg object-contain"
|
|
/>
|
|
) : (
|
|
<img
|
|
src="/logo.png"
|
|
alt={t("chrome.adminAltLong")}
|
|
className="h-14 w-auto shrink-0 object-contain"
|
|
/>
|
|
)}
|
|
</div>
|
|
</SidebarHeader>
|
|
<SidebarSeparator />
|
|
<SidebarContent>
|
|
<SidebarNavGroup labelKey="sidebarGroup.overview" items={overviewItems} />
|
|
<SidebarNavGroup labelKey="sidebarGroup.lms" items={lmsItems} />
|
|
<SidebarNavGroup labelKey="sidebarGroup.adaptiveLearning" items={adaptiveItems} />
|
|
<SidebarNavGroup labelKey="sidebarGroup.institutional" items={institutionalItems} />
|
|
<SidebarNavGroup labelKey="sidebarGroup.academic" items={academicItems} />
|
|
{showManagement && <SidebarNavGroup labelKey="sidebarGroup.management" items={managementItems} />}
|
|
{showReports && <SidebarNavGroup labelKey="sidebarGroup.reports" items={reportItems} />}
|
|
<SidebarNavGroup labelKey="sidebarGroup.configuration" items={configItems} />
|
|
|
|
<SidebarGroup>
|
|
<Collapsible defaultOpen className="group/collapsible">
|
|
<SidebarGroupLabel asChild>
|
|
<CollapsibleTrigger className="flex w-full items-center justify-between">
|
|
{t("sidebarGroup.training")}
|
|
{!collapsed && <ChevronDown className="h-4 w-4 transition-transform group-data-[state=open]/collapsible:rotate-180" />}
|
|
</CollapsibleTrigger>
|
|
</SidebarGroupLabel>
|
|
<CollapsibleContent>
|
|
<SidebarGroupContent>
|
|
<SidebarMenu>
|
|
{trainingItems.map((item) => {
|
|
const label = t(item.titleKey);
|
|
return (
|
|
<SidebarMenuItem key={item.url}>
|
|
<SidebarMenuButton asChild tooltip={label}>
|
|
<NavLink
|
|
to={item.url}
|
|
className="flex items-center gap-2 px-2 py-1.5 rounded-md text-sm text-sidebar-foreground hover:bg-sidebar-accent transition-colors"
|
|
activeClassName="bg-sidebar-accent text-sidebar-accent-foreground font-medium"
|
|
>
|
|
<item.icon className="h-4 w-4 shrink-0" />
|
|
{!collapsed && <span>{label}</span>}
|
|
</NavLink>
|
|
</SidebarMenuButton>
|
|
</SidebarMenuItem>
|
|
);
|
|
})}
|
|
</SidebarMenu>
|
|
</SidebarGroupContent>
|
|
</CollapsibleContent>
|
|
</Collapsible>
|
|
</SidebarGroup>
|
|
|
|
<SidebarNavGroup labelKey="sidebarGroup.support" items={showPayments ? supportItems : supportItems.filter(i => i.url !== "/admin/payment-record")} />
|
|
</SidebarContent>
|
|
<SidebarSeparator />
|
|
<SidebarFooter className="p-3">
|
|
<div className="flex items-center gap-2">
|
|
<div className="h-8 w-8 rounded-full bg-primary/10 flex items-center justify-center shrink-0">
|
|
<span className="text-xs font-semibold text-primary">{user?.name?.split(" ").map(w => w[0]).join("").slice(0, 2).toUpperCase() ?? "??"}</span>
|
|
</div>
|
|
{!collapsed && (
|
|
<div className="flex flex-col min-w-0">
|
|
<span className="text-sm font-medium truncate text-sidebar-foreground">{user?.name ?? t("userMenu.userFallback")}</span>
|
|
<span className="text-xs text-muted-foreground truncate">{user?.email ?? ""}</span>
|
|
</div>
|
|
)}
|
|
</div>
|
|
</SidebarFooter>
|
|
</Sidebar>
|
|
);
|
|
}
|