+
+
Établissements
+
+ Vue d'ensemble des établissements et de leur participation
+
+
+
+ {/* Statistiques globales */}
+
+
+
+ Établissements
+
+
+
+ {etablissements?.length || 0}
+ Nombre total
+
+
+
+
+
+ Apprenants
+
+
+
+ {totalApprenants}
+ Tous établissements
+
+
+
+
+
+ Apprenants actifs
+
+
+
+ {totalActifs}
+ Avec inscriptions
+
+
+
+
+
+ Taux de participation
+
+
+
+ {tauxGlobal}%
+ Global
+
+
+
+
+ {/* Tableau des établissements */}
+
+
+ Liste des établissements
+
+ Statistiques de participation par établissement
+
+
+
+ {isLoading ? (
+
+
+
+
+
+ ) : etablissements && etablissements.length > 0 ? (
+
+
+
+ Code établissement
+ Nombre d'apprenants
+ Apprenants actifs
+ Taux de participation
+
+
+
+ {etablissements.map((etab) => (
+
+ {etab.codeEtablissement}
+ {etab.nombreApprenants}
+ {etab.apprenantsActifs}
+
+ = 70 ? "bg-green-100 text-green-800" :
+ etab.tauxParticipation >= 40 ? "bg-orange-100 text-orange-800" :
+ "bg-red-100 text-red-800"
+ }`}>
+ {etab.tauxParticipation}%
+
+
+
+ ))}
+
+
+ ) : (
+
+ Aucun établissement trouvé
+
+ )}
+
+
+
+ );
+}
diff --git a/server/db.ts b/server/db.ts
index edf47c7..f907027 100644
--- a/server/db.ts
+++ b/server/db.ts
@@ -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