From b74e575d11667dd31ef924cdf590d7858f117f92 Mon Sep 17 00:00:00 2001
From: Manus
Date: Mon, 2 Feb 2026 10:27:19 -0500
Subject: [PATCH] =?UTF-8?q?Checkpoint:=20Retrait=20des=20compteurs=20dynam?=
=?UTF-8?q?iques=20de=20taux=20de=20pr=C3=A9sence=20et=20ajout=20d'une=20v?=
=?UTF-8?q?=C3=A9rification=20backend=20emp=C3=AAchant=20l'=C3=A9margement?=
=?UTF-8?q?=20avant=20la=20date=20de=20formation=20concern=C3=A9e?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
client/src/pages/FormateurEmargement.tsx | 22 ----------------------
server/presenceDb.ts | 23 +++++++++++++++++++++++
todo.md | 4 ++++
3 files changed, 27 insertions(+), 22 deletions(-)
diff --git a/client/src/pages/FormateurEmargement.tsx b/client/src/pages/FormateurEmargement.tsx
index 0b76b34..0b54af9 100644
--- a/client/src/pages/FormateurEmargement.tsx
+++ b/client/src/pages/FormateurEmargement.tsx
@@ -316,17 +316,6 @@ export default function FormateurEmargement() {
- {/* Statistiques Matin */}
-
- 🌅 Matin
-
- {(() => {
- const stats = getPresenceStats(date.id, "matin");
- return `${stats.present}/${stats.total} présents (${stats.percentage}%)`;
- })()}
-
-
-
{/* Matin */}
@@ -387,17 +376,6 @@ export default function FormateurEmargement() {
)}
- {/* Statistiques Après-midi */}
-
- 🌆 Après-midi
-
- {(() => {
- const stats = getPresenceStats(date.id, "apres_midi");
- return `${stats.present}/${stats.total} présents (${stats.percentage}%)`;
- })()}
-
-
-
{/* Après-midi */}
diff --git a/server/presenceDb.ts b/server/presenceDb.ts
index d952acd..3b231db 100644
--- a/server/presenceDb.ts
+++ b/server/presenceDb.ts
@@ -18,6 +18,29 @@ export async function validerPresence(params: {
const db = await getDb();
if (!db) throw new Error("Database not available");
+ // Récupérer la date de formation
+ const dateFormation = await db
+ .select()
+ .from(datesFormation)
+ .where(eq(datesFormation.id, params.dateFormationId))
+ .limit(1);
+
+ if (dateFormation.length === 0) {
+ throw new Error("Date de formation introuvable");
+ }
+
+ // Vérifier que la date actuelle est le jour de la formation ou après
+ const now = new Date();
+ const dateDebut = new Date(dateFormation[0].dateDebut);
+
+ // Réinitialiser les heures pour comparer uniquement les dates
+ now.setHours(0, 0, 0, 0);
+ dateDebut.setHours(0, 0, 0, 0);
+
+ if (now < dateDebut) {
+ throw new Error("Vous ne pouvez pas émarger avant la date de formation");
+ }
+
// Vérifier si la présence existe déjà pour cette période
const presenceExistante = await db
.select()
diff --git a/todo.md b/todo.md
index 8b4f017..7652368 100644
--- a/todo.md
+++ b/todo.md
@@ -1496,3 +1496,7 @@
- [x] Ajouter un indicateur visuel de rafraîchissement avec badge "Mis à jour il y a X secondes"
- [x] Ajouter des statistiques en temps réel du taux de présence par période
+
+- [x] Retirer les compteurs dynamiques de taux de présence de la page d'émargement numérique
+
+- [x] Empêcher l'émargement avant la date de formation concernée (vérification backend)