"use client"; // Coquille de l'application : barre latérale (desktop), navigation basse (mobile), // bannière d'avertissement admin initial, raccourcis clavier globaux. import Link from "next/link"; import { usePathname, useRouter } from "next/navigation"; import { useEffect, useState } from "react"; import { GraduationCap, Library, LogOut, MessageSquareText, Settings, ShieldAlert, SlidersHorizontal, } from "lucide-react"; import { ImmbotLogo, ImmbotMark, UqoLogo } from "@/components/logo"; import { ThemeToggle } from "@/components/theme-toggle"; import { cn } from "@/components/ui"; export type ShellUser = { id: number; username: string; displayName: string; role: "student" | "instructor" | "admin"; isInitialAdmin: boolean; }; export function AppShell({ user, courses, children, }: { user: ShellUser; courses: { code: string; title: string; color: string }[]; children: React.ReactNode; }) { const pathname = usePathname(); const router = useRouter(); const [initialPasswordActive] = useState(user.isInitialAdmin); useEffect(() => { const onKey = (e: KeyboardEvent) => { if ((e.metaKey || e.ctrlKey) && e.key === "k") { e.preventDefault(); router.push("/chat?new=1"); } if ((e.metaKey || e.ctrlKey) && e.key === "j") { e.preventDefault(); router.push("/apprendre"); } }; window.addEventListener("keydown", onKey); return () => window.removeEventListener("keydown", onKey); }, [router]); async function logout() { await fetch("/api/auth/logout", { method: "POST" }); router.push("/connexion"); router.refresh(); } const nav = [ { href: "/chat", label: "Chat", icon: MessageSquareText }, { href: "/apprendre", label: "Apprendre", icon: GraduationCap }, { href: "/bibliotheque", label: "Bibliothèque", icon: Library }, { href: "/parametres", label: "Paramètres", icon: Settings }, ...(user.role !== "student" ? [{ href: "/admin", label: "Administration", icon: SlidersHorizontal }] : []), ]; const isActive = (href: string) => pathname === href || pathname.startsWith(href + "/"); return (
DISABLE_INITIAL_ADMIN=true).
{subtitle}
}