SPB Git forge

spb/immbot-ai

Public
1commits 1branches 0releases
1.5 MBsize
maindefault branch
20 days agolast push
TypeScript 98.3% CSS 0.9% Shell 0.7%
981 B · 33 lines tsx
Raw Blame History
1import { redirect } from "next/navigation";2import { currentUser } from "@/lib/auth/session.ts";3import { all } from "@/lib/db/index.ts";4import { AppShell } from "@/components/app-shell";56export default async function AppLayout({ children }: { children: React.ReactNode }) {7  const user = await currentUser();8  if (!user) redirect("/connexion");9  if (user.must_change_password) redirect("/changer-mot-de-passe?force=1");1011  const courses = all<{ code: string; title: string; color: string }>(12    `SELECT c.code, c.title, c.color FROM courses c13     JOIN enrollments e ON e.course_code = c.code14     WHERE e.user_id = ? AND c.active = 1 ORDER BY c.code`,15    user.id16  );1718  return (19    <AppShell20      user={{21        id: user.id,22        username: user.username,23        displayName: user.display_name || user.username,24        role: user.role,25        isInitialAdmin: !!user.is_initial_admin,26      }}27      courses={courses}28    >29      {children}30    </AppShell>31  );32}33