Checkpoint: Ajout de badges Actif/Inactif dans la liste des apprenants et création d'une page dédiée aux établissements avec statistiques de participation

This commit is contained in:
Manus Sandbox
2025-11-23 17:28:12 -05:00
parent 9a38fc9dd3
commit a0049436cc
8 changed files with 287 additions and 2 deletions

View File

@@ -280,7 +280,24 @@ export async function getApprenants() {
const db = await getDb();
if (!db) return [];
return await db.select().from(apprenants);
const apprenantsData = await db.select().from(apprenants);
// Pour chaque apprenant, récupérer ses inscriptions
const apprenantsWithInscriptions = await Promise.all(
apprenantsData.map(async (apprenant) => {
const inscriptionsData = await db
.select()
.from(inscriptions)
.where(eq(inscriptions.apprenantId, apprenant.id));
return {
...apprenant,
inscriptions: inscriptionsData,
};
})
);
return apprenantsWithInscriptions;
}
export async function getApprenantById(id: number): Promise<Apprenant | undefined> {