import { redirect } from "next/navigation"; import { auth } from "@/auth"; import { db } from "@/lib/db"; import { setRequestLocale } from "next-intl/server"; import Link from "next/link"; import { AdminPathActions } from "./AdminPathActions"; export const dynamic = "force-dynamic"; export default async function AdminPathsPage({ params, }: { params: Promise<{ locale: string }>; }) { const { locale } = await params; setRequestLocale(locale); const session = await auth(); if (!session?.user || (session.user as any).role !== "ADMIN") { redirect(`/${locale}/dashboard`); } const paths = await db.learningPath.findMany({ orderBy: { order: "asc" }, include: { courses: true, _count: { select: { enrollments: true } }, }, }); return (
← Administration

Parcours de formation

+ Nouveau parcours
{paths.length === 0 ? ( ) : ( paths.map((path) => ( )) )}
Titre (FR) Formations Inscrits Statut Actions
Aucun parcours.{" "} Créer le premier.

{path.titleFr}

{path.slug}

{path.courses.length} cours {path._count.enrollments} {path.published ? "Publié" : "Brouillon"}
); }