export const dynamic = "force-dynamic"; import { useTranslations } from "next-intl"; import { getTranslations } from "next-intl/server"; import Link from "next/link"; import { db } from "@/lib/db"; import { CourseCard } from "@/components/CourseCard"; import { auth } from "@/auth"; export default async function HomePage({ params, }: { params: Promise<{ locale: string }>; }) { const { locale } = await params; const t = await getTranslations({ locale, namespace: "home" }); const nav = await getTranslations({ locale, namespace: "nav" }); const courseT = await getTranslations({ locale, namespace: "course" }); const session = await auth(); const courses = await db.course.findMany({ where: { published: true }, orderBy: { order: "asc" }, take: 6, include: { _count: { select: { modules: true } } }, }); // Get enrolled course IDs for current user const enrolledIds = new Set(); if (session?.user) { const userId = (session.user as any).id; const enrollments = await db.enrollment.findMany({ where: { userId }, select: { courseId: true }, }); enrollments.forEach((e) => enrolledIds.add(e.courseId)); } const categories = ["GOVERNANCE", "CYBER", "OWLCUB", "OTHER"]; return (
{/* Hero Section */}
{/* Background decoration */}
🦉 OwlCub Academy

{t("hero_title")}

{t("hero_sub")}

{t("cta")} →
{/* Category pills */}
{categories.map((cat) => { const catLabel = t(`categories.${cat}`); return ( {catLabel} ); })}
{/* Course grid */}

Formations populaires

Voir tout →
{courses.length === 0 ? (
📚

Aucune formation disponible pour le moment.

) : (
{courses.map((course) => ( ))}
)}
{/* Stats section */}
{[ { label: "Formations", value: "20+" }, { label: "Apprenants", value: "500+" }, { label: "Certificats délivrés", value: "1 000+" }, ].map((stat) => (
{stat.value}
{stat.label}
))}
); }