From a40e0bf6cdc6adfe4609759ecfc22b2ec32d6ac0 Mon Sep 17 00:00:00 2001 From: Manus Date: Fri, 6 Feb 2026 09:43:43 -0500 Subject: [PATCH] =?UTF-8?q?Checkpoint:=20Checkpoint:=20Restauration=20de?= =?UTF-8?q?=20la=20proc=C3=A9dure=20sequences.getDatesByFormateurToken=20e?= =?UTF-8?q?t=20de=20la=20fonction=20getSequenceByFormateurToken=20dans=20d?= =?UTF-8?q?b.ts.=20Le=20syst=C3=A8me=20d'=C3=A9margement=20formateur=20fon?= =?UTF-8?q?ctionne=20maintenant=20correctement=20avec=20chargement=20des?= =?UTF-8?q?=20dates.=20Prochaine=20=C3=A9tape=20:=20corriger=20l'affichage?= =?UTF-8?q?=20du=20message=20"[ERREUR=20MUTATION]"=20pour=20les=20doublons?= =?UTF-8?q?.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .manus/db/db-query-1770297902539.json | 9 + .manus/db/db-query-1770298235992.json | 15 + .manus/db/db-query-1770298249539.json | 9 + .manus/db/db-query-1770298254825.json | 15 + .manus/db/db-query-1770298261447.json | 9 + .manus/db/db-query-1770298280697.json | 9 + .manus/db/db-query-1770298337364.json | 13 + .manus/db/db-query-1770298461257.json | 9 + .manus/db/db-query-1770298491456.json | 9 + .manus/db/db-query-1770298504177.json | 9 + .manus/db/db-query-1770298511189.json | 9 + .manus/db/db-query-1770298928415.json | 122 + .manus/db/db-query-1770298942498.json | 40 + .manus/db/db-query-1770370200873.json | 9 + .manus/db/db-query-error-1770298268333.json | 8 + .manus/db/db-query-error-1770298273592.json | 8 + client/src/pages/EmargementFormateurScan.tsx | 74 +- drizzle/meta/0018_snapshot.json | 2313 ++++++++++++++++++ drizzle/meta/_journal.json | 7 + drizzle/schema.ts | 6 +- server/db.ts | 8 + server/presenceDb.ts | 41 +- server/routers.ts | 11 + 23 files changed, 2749 insertions(+), 13 deletions(-) create mode 100644 .manus/db/db-query-1770297902539.json create mode 100644 .manus/db/db-query-1770298235992.json create mode 100644 .manus/db/db-query-1770298249539.json create mode 100644 .manus/db/db-query-1770298254825.json create mode 100644 .manus/db/db-query-1770298261447.json create mode 100644 .manus/db/db-query-1770298280697.json create mode 100644 .manus/db/db-query-1770298337364.json create mode 100644 .manus/db/db-query-1770298461257.json create mode 100644 .manus/db/db-query-1770298491456.json create mode 100644 .manus/db/db-query-1770298504177.json create mode 100644 .manus/db/db-query-1770298511189.json create mode 100644 .manus/db/db-query-1770298928415.json create mode 100644 .manus/db/db-query-1770298942498.json create mode 100644 .manus/db/db-query-1770370200873.json create mode 100644 .manus/db/db-query-error-1770298268333.json create mode 100644 .manus/db/db-query-error-1770298273592.json create mode 100644 drizzle/meta/0018_snapshot.json diff --git a/.manus/db/db-query-1770297902539.json b/.manus/db/db-query-1770297902539.json new file mode 100644 index 0000000..4cba8d4 --- /dev/null +++ b/.manus/db/db-query-1770297902539.json @@ -0,0 +1,9 @@ +{ + "query": "ALTER TABLE sequences ADD COLUMN IF NOT EXISTS qrCodeFormateurToken VARCHAR(255);", + "command": "mysql --batch --raw --column-names --default-character-set=utf8mb4 --host gateway02.us-east-1.prod.aws.tidbcloud.com --port 4000 --user 4CrrYuB5tme73Qo.root --database 7PAT67UmWoxv8vwp8Bbcv6 --execute ALTER TABLE sequences ADD COLUMN IF NOT EXISTS qrCodeFormateurToken VARCHAR(255);", + "rows": [], + "messages": [], + "stdout": "", + "stderr": "", + "execution_time_ms": 553 +} \ No newline at end of file diff --git a/.manus/db/db-query-1770298235992.json b/.manus/db/db-query-1770298235992.json new file mode 100644 index 0000000..58df3b7 --- /dev/null +++ b/.manus/db/db-query-1770298235992.json @@ -0,0 +1,15 @@ +{ + "query": "SELECT id, nom, qrCodeFormateurToken FROM sequences WHERE statut = 'ouverte' LIMIT 1;", + "command": "mysql --batch --raw --column-names --default-character-set=utf8mb4 --host gateway02.us-east-1.prod.aws.tidbcloud.com --port 4000 --user 4CrrYuB5tme73Qo.root --database 7PAT67UmWoxv8vwp8Bbcv6 --execute SELECT id, nom, qrCodeFormateurToken FROM sequences WHERE statut = 'ouverte' LIMIT 1;", + "rows": [ + { + "id": "60001", + "nom": "Groupe C", + "qrCodeFormateurToken": "NULL" + } + ], + "messages": [], + "stdout": "id\tnom\tqrCodeFormateurToken\n60001\tGroupe C\tNULL\n", + "stderr": "", + "execution_time_ms": 951 +} \ No newline at end of file diff --git a/.manus/db/db-query-1770298249539.json b/.manus/db/db-query-1770298249539.json new file mode 100644 index 0000000..a21c0c1 --- /dev/null +++ b/.manus/db/db-query-1770298249539.json @@ -0,0 +1,9 @@ +{ + "query": "UPDATE sequences SET qrCodeFormateurToken = 'test-formateur-token-123' WHERE id = 2;", + "command": "mysql --batch --raw --column-names --default-character-set=utf8mb4 --host gateway02.us-east-1.prod.aws.tidbcloud.com --port 4000 --user 4CrrYuB5tme73Qo.root --database 7PAT67UmWoxv8vwp8Bbcv6 --execute UPDATE sequences SET qrCodeFormateurToken = 'test-formateur-token-123' WHERE id = 2;", + "rows": [], + "messages": [], + "stdout": "", + "stderr": "", + "execution_time_ms": 55 +} \ No newline at end of file diff --git a/.manus/db/db-query-1770298254825.json b/.manus/db/db-query-1770298254825.json new file mode 100644 index 0000000..96d6a65 --- /dev/null +++ b/.manus/db/db-query-1770298254825.json @@ -0,0 +1,15 @@ +{ + "query": "SELECT id, nom, email FROM formateurs LIMIT 1;", + "command": "mysql --batch --raw --column-names --default-character-set=utf8mb4 --host gateway02.us-east-1.prod.aws.tidbcloud.com --port 4000 --user 4CrrYuB5tme73Qo.root --database 7PAT67UmWoxv8vwp8Bbcv6 --execute SELECT id, nom, email FROM formateurs LIMIT 1;", + "rows": [ + { + "id": "1", + "nom": "Jean Dupont", + "email": "opareige@gmail.com" + } + ], + "messages": [], + "stdout": "id\tnom\temail\n1\tJean Dupont\topareige@gmail.com\n", + "stderr": "", + "execution_time_ms": 57 +} \ No newline at end of file diff --git a/.manus/db/db-query-1770298261447.json b/.manus/db/db-query-1770298261447.json new file mode 100644 index 0000000..46f8891 --- /dev/null +++ b/.manus/db/db-query-1770298261447.json @@ -0,0 +1,9 @@ +{ + "query": "SELECT id, sequenceId, dateDebut, dateFin FROM datesFormation WHERE sequenceId = 2 LIMIT 1;", + "command": "mysql --batch --raw --column-names --default-character-set=utf8mb4 --host gateway02.us-east-1.prod.aws.tidbcloud.com --port 4000 --user 4CrrYuB5tme73Qo.root --database 7PAT67UmWoxv8vwp8Bbcv6 --execute SELECT id, sequenceId, dateDebut, dateFin FROM datesFormation WHERE sequenceId = 2 LIMIT 1;", + "rows": [], + "messages": [], + "stdout": "", + "stderr": "", + "execution_time_ms": 54 +} \ No newline at end of file diff --git a/.manus/db/db-query-1770298280697.json b/.manus/db/db-query-1770298280697.json new file mode 100644 index 0000000..ef600b8 --- /dev/null +++ b/.manus/db/db-query-1770298280697.json @@ -0,0 +1,9 @@ +{ + "query": "SELECT s.id, s.nom, s.qrCodeFormateurToken, df.id as dateFormationId, df.dateDebut, df.dateFin FROM sequences s INNER JOIN datesFormation df ON s.id = df.sequenceId WHERE s.statut = 'ouverte' AND df.dateDebut <= CURDATE() AND df.dateFin >= CURDATE() LIMIT 1;", + "command": "mysql --batch --raw --column-names --default-character-set=utf8mb4 --host gateway02.us-east-1.prod.aws.tidbcloud.com --port 4000 --user 4CrrYuB5tme73Qo.root --database 7PAT67UmWoxv8vwp8Bbcv6 --execute SELECT s.id, s.nom, s.qrCodeFormateurToken, df.id as dateFormationId, df.dateDebut, df.dateFin FROM sequences s INNER JOIN datesFormation df ON s.id = df.sequenceId WHERE s.statut = 'ouverte' AND df.dateDebut <= CURDATE() AND df.dateFin >= CURDATE() LIMIT 1;", + "rows": [], + "messages": [], + "stdout": "", + "stderr": "", + "execution_time_ms": 60 +} \ No newline at end of file diff --git a/.manus/db/db-query-1770298337364.json b/.manus/db/db-query-1770298337364.json new file mode 100644 index 0000000..7b87847 --- /dev/null +++ b/.manus/db/db-query-1770298337364.json @@ -0,0 +1,13 @@ +{ + "query": "SELECT email FROM formateurs LIMIT 1;", + "command": "mysql --batch --raw --column-names --default-character-set=utf8mb4 --host gateway02.us-east-1.prod.aws.tidbcloud.com --port 4000 --user 4CrrYuB5tme73Qo.root --database 7PAT67UmWoxv8vwp8Bbcv6 --execute SELECT email FROM formateurs LIMIT 1;", + "rows": [ + { + "email": "opareige@gmail.com" + } + ], + "messages": [], + "stdout": "email\nopareige@gmail.com\n", + "stderr": "", + "execution_time_ms": 56 +} \ No newline at end of file diff --git a/.manus/db/db-query-1770298461257.json b/.manus/db/db-query-1770298461257.json new file mode 100644 index 0000000..97a39a8 --- /dev/null +++ b/.manus/db/db-query-1770298461257.json @@ -0,0 +1,9 @@ +{ + "query": "SELECT id, nom, qrCodeFormateurToken FROM sequences WHERE id = 2;", + "command": "mysql --batch --raw --column-names --default-character-set=utf8mb4 --host gateway02.us-east-1.prod.aws.tidbcloud.com --port 4000 --user 4CrrYuB5tme73Qo.root --database 7PAT67UmWoxv8vwp8Bbcv6 --execute SELECT id, nom, qrCodeFormateurToken FROM sequences WHERE id = 2;", + "rows": [], + "messages": [], + "stdout": "", + "stderr": "", + "execution_time_ms": 53 +} \ No newline at end of file diff --git a/.manus/db/db-query-1770298491456.json b/.manus/db/db-query-1770298491456.json new file mode 100644 index 0000000..9c87351 --- /dev/null +++ b/.manus/db/db-query-1770298491456.json @@ -0,0 +1,9 @@ +{ + "query": "SELECT id, nom, qrCodeFormateurToken FROM sequences WHERE qrCodeFormateurToken = 'test-formateur-token-123';", + "command": "mysql --batch --raw --column-names --default-character-set=utf8mb4 --host gateway02.us-east-1.prod.aws.tidbcloud.com --port 4000 --user 4CrrYuB5tme73Qo.root --database 7PAT67UmWoxv8vwp8Bbcv6 --execute SELECT id, nom, qrCodeFormateurToken FROM sequences WHERE qrCodeFormateurToken = 'test-formateur-token-123';", + "rows": [], + "messages": [], + "stdout": "", + "stderr": "", + "execution_time_ms": 59 +} \ No newline at end of file diff --git a/.manus/db/db-query-1770298504177.json b/.manus/db/db-query-1770298504177.json new file mode 100644 index 0000000..b4ea6bb --- /dev/null +++ b/.manus/db/db-query-1770298504177.json @@ -0,0 +1,9 @@ +{ + "query": "UPDATE sequences SET qrCodeFormateurToken = 'test-formateur-token-123' WHERE id = 2;", + "command": "mysql --batch --raw --column-names --default-character-set=utf8mb4 --host gateway02.us-east-1.prod.aws.tidbcloud.com --port 4000 --user 4CrrYuB5tme73Qo.root --database 7PAT67UmWoxv8vwp8Bbcv6 --execute UPDATE sequences SET qrCodeFormateurToken = 'test-formateur-token-123' WHERE id = 2;", + "rows": [], + "messages": [], + "stdout": "", + "stderr": "", + "execution_time_ms": 57 +} \ No newline at end of file diff --git a/.manus/db/db-query-1770298511189.json b/.manus/db/db-query-1770298511189.json new file mode 100644 index 0000000..f7640c1 --- /dev/null +++ b/.manus/db/db-query-1770298511189.json @@ -0,0 +1,9 @@ +{ + "query": "SELECT id, nom, qrCodeFormateurToken FROM sequences WHERE qrCodeFormateurToken = 'test-formateur-token-123';", + "command": "mysql --batch --raw --column-names --default-character-set=utf8mb4 --host gateway02.us-east-1.prod.aws.tidbcloud.com --port 4000 --user 4CrrYuB5tme73Qo.root --database 7PAT67UmWoxv8vwp8Bbcv6 --execute SELECT id, nom, qrCodeFormateurToken FROM sequences WHERE qrCodeFormateurToken = 'test-formateur-token-123';", + "rows": [], + "messages": [], + "stdout": "", + "stderr": "", + "execution_time_ms": 54 +} \ No newline at end of file diff --git a/.manus/db/db-query-1770298928415.json b/.manus/db/db-query-1770298928415.json new file mode 100644 index 0000000..28262f6 --- /dev/null +++ b/.manus/db/db-query-1770298928415.json @@ -0,0 +1,122 @@ +{ + "query": "SHOW COLUMNS FROM sequences;", + "command": "mysql --batch --raw --column-names --default-character-set=utf8mb4 --host gateway02.us-east-1.prod.aws.tidbcloud.com --port 4000 --user 4CrrYuB5tme73Qo.root --database 7PAT67UmWoxv8vwp8Bbcv6 --execute SHOW COLUMNS FROM sequences;", + "rows": [ + { + "Field": "id", + "Type": "int(11)", + "Null": "NO", + "Key": "PRI", + "Default": "NULL", + "Extra": "auto_increment" + }, + { + "Field": "formationId", + "Type": "int(11)", + "Null": "NO", + "Key": "", + "Default": "NULL", + "Extra": "" + }, + { + "Field": "nom", + "Type": "varchar(255)", + "Null": "NO", + "Key": "", + "Default": "NULL", + "Extra": "" + }, + { + "Field": "lieu", + "Type": "varchar(500)", + "Null": "NO", + "Key": "", + "Default": "NULL", + "Extra": "" + }, + { + "Field": "capaciteMax", + "Type": "int(11)", + "Null": "NO", + "Key": "", + "Default": "12", + "Extra": "" + }, + { + "Field": "dateBlocage", + "Type": "datetime", + "Null": "YES", + "Key": "", + "Default": "NULL", + "Extra": "" + }, + { + "Field": "statut", + "Type": "enum('ouverte','bloquee','terminee')", + "Null": "NO", + "Key": "", + "Default": "ouverte", + "Extra": "" + }, + { + "Field": "createdAt", + "Type": "timestamp", + "Null": "NO", + "Key": "", + "Default": "CURRENT_TIMESTAMP", + "Extra": "" + }, + { + "Field": "updatedAt", + "Type": "timestamp", + "Null": "NO", + "Key": "", + "Default": "CURRENT_TIMESTAMP", + "Extra": "DEFAULT_GENERATED on update CURRENT_TIMESTAMP" + }, + { + "Field": "publicCible", + "Type": "enum('directeur','chef_service','autre','tous')", + "Null": "YES", + "Key": "", + "Default": "tous", + "Extra": "" + }, + { + "Field": "formateur", + "Type": "varchar(255)", + "Null": "YES", + "Key": "", + "Default": "NULL", + "Extra": "" + }, + { + "Field": "formateurId", + "Type": "int(11)", + "Null": "YES", + "Key": "", + "Default": "NULL", + "Extra": "" + }, + { + "Field": "qrCodeToken", + "Type": "varchar(64)", + "Null": "YES", + "Key": "", + "Default": "NULL", + "Extra": "" + }, + { + "Field": "qrCodeFormateurToken", + "Type": "varchar(255)", + "Null": "YES", + "Key": "", + "Default": "NULL", + "Extra": "" + } + ], + "messages": [], + "stdout": "Field\tType\tNull\tKey\tDefault\tExtra\nid\tint(11)\tNO\tPRI\tNULL\tauto_increment\nformationId\tint(11)\tNO\t\tNULL\t\nnom\tvarchar(255)\tNO\t\tNULL\t\nlieu\tvarchar(500)\tNO\t\tNULL\t\ncapaciteMax\tint(11)\tNO\t\t12\t\ndateBlocage\tdatetime\tYES\t\tNULL\t\nstatut\tenum('ouverte','bloquee','terminee')\tNO\t\touverte\t\ncreatedAt\ttimestamp\tNO\t\tCURRENT_TIMESTAMP\t\nupdatedAt\ttimestamp\tNO\t\tCURRENT_TIMESTAMP\tDEFAULT_GENERATED on update CURRENT_TIMESTAMP\npublicCible\tenum('directeur','chef_service','autre','tous')\tYES\t\ttous\t\nformateur\tvarchar(255)\tYES\t\tNULL\t\nformateurId\tint(11)\tYES\t\tNULL\t\nqrCodeToken\tvarchar(64)\tYES\t\tNULL\t\nqrCodeFormateurToken\tvarchar(255)\tYES\t\tNULL\t\n", + "stderr": "", + "execution_time_ms": 57 +} \ No newline at end of file diff --git a/.manus/db/db-query-1770298942498.json b/.manus/db/db-query-1770298942498.json new file mode 100644 index 0000000..2eeda57 --- /dev/null +++ b/.manus/db/db-query-1770298942498.json @@ -0,0 +1,40 @@ +{ + "query": "SELECT id, nom, qrCodeToken, qrCodeFormateurToken FROM sequences LIMIT 5;", + "command": "mysql --batch --raw --column-names --default-character-set=utf8mb4 --host gateway02.us-east-1.prod.aws.tidbcloud.com --port 4000 --user 4CrrYuB5tme73Qo.root --database 7PAT67UmWoxv8vwp8Bbcv6 --execute SELECT id, nom, qrCodeToken, qrCodeFormateurToken FROM sequences LIMIT 5;", + "rows": [ + { + "id": "30001", + "nom": "Groupe A", + "qrCodeToken": "78172a40ea01dda8843d80592adcaa8562dba6faee3c8e8db9232c32f63b17b2", + "qrCodeFormateurToken": "NULL" + }, + { + "id": "60001", + "nom": "Groupe C", + "qrCodeToken": "55b8210ef0712422f1749ef901b8c9901017de4610a78c4b2da34edfcc125330", + "qrCodeFormateurToken": "NULL" + }, + { + "id": "90002", + "nom": "Groupe B", + "qrCodeToken": "NULL", + "qrCodeFormateurToken": "NULL" + }, + { + "id": "120001", + "nom": "Groupe D", + "qrCodeToken": "NULL", + "qrCodeFormateurToken": "NULL" + }, + { + "id": "150001", + "nom": "Groupe 1", + "qrCodeToken": "NULL", + "qrCodeFormateurToken": "NULL" + } + ], + "messages": [], + "stdout": "id\tnom\tqrCodeToken\tqrCodeFormateurToken\n30001\tGroupe A\t78172a40ea01dda8843d80592adcaa8562dba6faee3c8e8db9232c32f63b17b2\tNULL\n60001\tGroupe C\t55b8210ef0712422f1749ef901b8c9901017de4610a78c4b2da34edfcc125330\tNULL\n90002\tGroupe B\tNULL\tNULL\n120001\tGroupe D\tNULL\tNULL\n150001\tGroupe 1\tNULL\tNULL\n", + "stderr": "", + "execution_time_ms": 54 +} \ No newline at end of file diff --git a/.manus/db/db-query-1770370200873.json b/.manus/db/db-query-1770370200873.json new file mode 100644 index 0000000..4e4059c --- /dev/null +++ b/.manus/db/db-query-1770370200873.json @@ -0,0 +1,9 @@ +{ + "query": "UPDATE sequences SET qrCodeFormateurToken = '11cbbb5039e8d5f4f8b7c09a30c8e55d5a9a4d3c0ce9de11348aa7b9d5f7d0bc' WHERE id = 20;", + "command": "mysql --batch --raw --column-names --default-character-set=utf8mb4 --host gateway02.us-east-1.prod.aws.tidbcloud.com --port 4000 --user 4CrrYuB5tme73Qo.root --database 7PAT67UmWoxv8vwp8Bbcv6 --execute UPDATE sequences SET qrCodeFormateurToken = '11cbbb5039e8d5f4f8b7c09a30c8e55d5a9a4d3c0ce9de11348aa7b9d5f7d0bc' WHERE id = 20;", + "rows": [], + "messages": [], + "stdout": "", + "stderr": "", + "execution_time_ms": 289 +} \ No newline at end of file diff --git a/.manus/db/db-query-error-1770298268333.json b/.manus/db/db-query-error-1770298268333.json new file mode 100644 index 0000000..58a1290 --- /dev/null +++ b/.manus/db/db-query-error-1770298268333.json @@ -0,0 +1,8 @@ +{ + "query": "INSERT INTO datesFormation (sequenceId, dateDebut, dateFin, heureDebut, heureFin) VALUES (2, CURDATE(), CURDATE(), '09:00:00', '17:00:00');", + "command": "mysql --batch --raw --column-names --default-character-set=utf8mb4 --host gateway02.us-east-1.prod.aws.tidbcloud.com --port 4000 --user 4CrrYuB5tme73Qo.root --database 7PAT67UmWoxv8vwp8Bbcv6 --execute INSERT INTO datesFormation (sequenceId, dateDebut, dateFin, heureDebut, heureFin) VALUES (2, CURDATE(), CURDATE(), '09:00:00', '17:00:00');", + "returncode": 1, + "logs": [ + "ERROR 1054 (42S22) at line 1: Unknown column 'heureDebut' in 'field list'" + ] +} \ No newline at end of file diff --git a/.manus/db/db-query-error-1770298273592.json b/.manus/db/db-query-error-1770298273592.json new file mode 100644 index 0000000..1c4c7bd --- /dev/null +++ b/.manus/db/db-query-error-1770298273592.json @@ -0,0 +1,8 @@ +{ + "query": "INSERT INTO datesFormation (sequenceId, dateDebut, dateFin) VALUES (2, CURDATE(), CURDATE());", + "command": "mysql --batch --raw --column-names --default-character-set=utf8mb4 --host gateway02.us-east-1.prod.aws.tidbcloud.com --port 4000 --user 4CrrYuB5tme73Qo.root --database 7PAT67UmWoxv8vwp8Bbcv6 --execute INSERT INTO datesFormation (sequenceId, dateDebut, dateFin) VALUES (2, CURDATE(), CURDATE());", + "returncode": 1, + "logs": [ + "ERROR 1364 (HY000) at line 1: Field 'ordre' doesn't have a default value" + ] +} \ No newline at end of file diff --git a/client/src/pages/EmargementFormateurScan.tsx b/client/src/pages/EmargementFormateurScan.tsx index 359198e..b15817e 100644 --- a/client/src/pages/EmargementFormateurScan.tsx +++ b/client/src/pages/EmargementFormateurScan.tsx @@ -19,6 +19,7 @@ import SignaturePadComponent from "@/components/SignaturePad"; export default function EmargementFormateurScan() { const { token } = useParams<{ token: string }>(); const [email, setEmail] = useState(""); + const [selectedDateFormationId, setSelectedDateFormationId] = useState(null); const [selectedPeriode, setSelectedPeriode] = useState<"matin" | "apres_midi">("matin"); const [success, setSuccess] = useState(false); const [heureEnregistrement, setHeureEnregistrement] = useState(null); @@ -26,9 +27,24 @@ export default function EmargementFormateurScan() { const [showSignaturePad, setShowSignaturePad] = useState(false); const [signatureDataUrl, setSignatureDataUrl] = useState(null); + // Récupérer les dates de formation pour cette séquence + const { data: sequenceData, isLoading: loadingDates } = trpc.sequences.getDatesByFormateurToken.useQuery( + { token: token || "" }, + { enabled: !!token } + ); + // Valider la présence formateur const { mutate: validerPresence, isPending: validating } = trpc.presences.valider.useMutation({ - onSuccess: () => { + onSuccess: (data) => { + // Vérifier si la validation a réussi + if (data.success === false) { + // Cas d'un doublon : afficher le message sans passer par l'erreur + setError(data.message || "Erreur lors de la validation"); + toast.error(data.message || "Erreur lors de la validation"); + return; + } + + // Succès normal const now = new Date(); setHeureEnregistrement(now); setSuccess(true); @@ -55,6 +71,11 @@ export default function EmargementFormateurScan() { return; } + if (!selectedDateFormationId) { + toast.error("Veuillez sélectionner une date de formation"); + return; + } + // Afficher le pad de signature setShowSignaturePad(true); }; @@ -65,13 +86,18 @@ export default function EmargementFormateurScan() { return; } + if (!selectedDateFormationId) { + toast.error("Veuillez sélectionner une date de formation"); + return; + } + validerPresence({ token: token || "", email, + dateFormationId: selectedDateFormationId, periode: selectedPeriode, modeValidation: "qrcode", signatureDataUrl: dataUrl, - typeUtilisateur: "formateur", }); }; @@ -213,16 +239,54 @@ export default function EmargementFormateurScan() { placeholder="formateur@exemple.com" value={email} onChange={(e) => setEmail(e.target.value)} - disabled={validating} + disabled={validating || loadingDates} /> + {loadingDates ? ( +
+ + Chargement des dates... +
+ ) : sequenceData && sequenceData.dates.length > 0 ? ( +
+ + +
+ ) : ( +
+

+ Aucune date de formation disponible pour cette séquence. +

+
+ )} +