import { redirect } from "next/navigation"; import { currentUser } from "@/lib/auth/session.ts"; import { all } from "@/lib/db/index.ts"; import { AppShell } from "@/components/app-shell"; export default async function AppLayout({ children }: { children: React.ReactNode }) { const user = await currentUser(); if (!user) redirect("/connexion"); if (user.must_change_password) redirect("/changer-mot-de-passe?force=1"); const courses = all<{ code: string; title: string; color: string }>( `SELECT c.code, c.title, c.color FROM courses c JOIN enrollments e ON e.course_code = c.code WHERE e.user_id = ? AND c.active = 1 ORDER BY c.code`, user.id ); return ( {children} ); }