Checkpoint: Correction du bug d'inscription qui associait le mauvais apprenant
Problème identifié : - La procédure apprenants.create était une procédure admin (adminProcedure) - La page d'inscription publique n'est pas authentifiée - Lors de la création d'un apprenant, la mutation échouait silencieusement - Le code récupérait ensuite un mauvais apprenant par email Solution appliquée : - Création d'une nouvelle procédure publique apprenants.createPublic - Modification de Inscription.tsx pour utiliser createPublic au lieu de create - Les nouveaux apprenants peuvent maintenant être créés depuis la page publique - L'inscription associe maintenant le bon apprenant à la séquence
This commit is contained in:
9
.manus/db/db-query-1764582685633.json
Normal file
9
.manus/db/db-query-1764582685633.json
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"query": "SELECT id, nom, prenom, email, codeEtablissement, fonction FROM apprenants WHERE nom LIKE '%MONROE%' OR nom LIKE '%PIGNOL%' ORDER BY id",
|
||||
"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, prenom, email, codeEtablissement, fonction FROM apprenants WHERE nom LIKE '%MONROE%' OR nom LIKE '%PIGNOL%' ORDER BY id",
|
||||
"rows": [],
|
||||
"messages": [],
|
||||
"stdout": "",
|
||||
"stderr": "",
|
||||
"execution_time_ms": 86
|
||||
}
|
||||
74
.manus/db/db-query-1764582688629.json
Normal file
74
.manus/db/db-query-1764582688629.json
Normal file
@@ -0,0 +1,74 @@
|
||||
{
|
||||
"query": "SELECT id, nom, prenom, email, codeEtablissement, fonction FROM apprenants ORDER BY id DESC LIMIT 10",
|
||||
"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, prenom, email, codeEtablissement, fonction FROM apprenants ORDER BY id DESC LIMIT 10",
|
||||
"rows": [
|
||||
{
|
||||
"id": "180001",
|
||||
"nom": "pignol",
|
||||
"prenom": "francois",
|
||||
"email": "o.pareige@itinova.org",
|
||||
"codeEtablissement": "2013ANG",
|
||||
"fonction": "directeur"
|
||||
},
|
||||
{
|
||||
"id": "150001",
|
||||
"nom": "FAYOLLE",
|
||||
"prenom": "Celine",
|
||||
"email": "c.fayolle@itinova.org",
|
||||
"codeEtablissement": "2013ANG",
|
||||
"fonction": "chef_service"
|
||||
},
|
||||
{
|
||||
"id": "120001",
|
||||
"nom": "test4",
|
||||
"prenom": "test",
|
||||
"email": "test4@gmail.com",
|
||||
"codeEtablissement": "1038MBN",
|
||||
"fonction": "chef_service"
|
||||
},
|
||||
{
|
||||
"id": "90002",
|
||||
"nom": "AUBOISDORMANT",
|
||||
"prenom": "Abel",
|
||||
"email": "alerte2.test@example.com",
|
||||
"codeEtablissement": "1001VAR",
|
||||
"fonction": "chef_service"
|
||||
},
|
||||
{
|
||||
"id": "90001",
|
||||
"nom": "TEST",
|
||||
"prenom": "Fred",
|
||||
"email": "test.alerte@example.com",
|
||||
"codeEtablissement": "1069CJO",
|
||||
"fonction": "chef_service"
|
||||
},
|
||||
{
|
||||
"id": "60001",
|
||||
"nom": "PITT",
|
||||
"prenom": "Brad",
|
||||
"email": "test2@gmail.com",
|
||||
"codeEtablissement": "1069CJO",
|
||||
"fonction": "chef_service"
|
||||
},
|
||||
{
|
||||
"id": "30001",
|
||||
"nom": "LIPA",
|
||||
"prenom": "Dua",
|
||||
"email": "nouveau.apprenant@test.com",
|
||||
"codeEtablissement": "2074MAR",
|
||||
"fonction": "directeur"
|
||||
},
|
||||
{
|
||||
"id": "1",
|
||||
"nom": "JOHANSSON ",
|
||||
"prenom": "Scarlett",
|
||||
"email": "opareige@gmail.com",
|
||||
"codeEtablissement": "2013ANG",
|
||||
"fonction": "directeur"
|
||||
}
|
||||
],
|
||||
"messages": [],
|
||||
"stdout": "id\tnom\tprenom\temail\tcodeEtablissement\tfonction\n180001\tpignol\tfrancois\to.pareige@itinova.org\t2013ANG\tdirecteur\n150001\tFAYOLLE\tCeline\tc.fayolle@itinova.org\t2013ANG\tchef_service\n120001\ttest4\ttest\ttest4@gmail.com\t1038MBN\tchef_service\n90002\tAUBOISDORMANT\tAbel\talerte2.test@example.com\t1001VAR\tchef_service\n90001\tTEST\tFred\ttest.alerte@example.com\t1069CJO\tchef_service\n60001\tPITT\tBrad\ttest2@gmail.com\t1069CJO\tchef_service\n30001\tLIPA\tDua\tnouveau.apprenant@test.com\t2074MAR\tdirecteur\n1\tJOHANSSON \tScarlett\topareige@gmail.com\t2013ANG\tdirecteur\n",
|
||||
"stderr": "",
|
||||
"execution_time_ms": 49
|
||||
}
|
||||
110
.manus/db/db-query-1764582692062.json
Normal file
110
.manus/db/db-query-1764582692062.json
Normal file
@@ -0,0 +1,110 @@
|
||||
{
|
||||
"query": "SELECT i.id, i.apprenantId, a.nom, a.prenom, a.email, i.sequenceId, i.statut, i.createdAt \nFROM inscriptions i \nJOIN apprenants a ON i.apprenantId = a.id \nORDER BY i.createdAt DESC LIMIT 10",
|
||||
"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 i.id, i.apprenantId, a.nom, a.prenom, a.email, i.sequenceId, i.statut, i.createdAt \nFROM inscriptions i \nJOIN apprenants a ON i.apprenantId = a.id \nORDER BY i.createdAt DESC LIMIT 10",
|
||||
"rows": [
|
||||
{
|
||||
"id": "360002",
|
||||
"apprenantId": "180001",
|
||||
"nom": "pignol",
|
||||
"prenom": "francois",
|
||||
"email": "o.pareige@itinova.org",
|
||||
"sequenceId": "330001",
|
||||
"statut": "confirmee",
|
||||
"createdAt": "2025-12-01 09:48:55"
|
||||
},
|
||||
{
|
||||
"id": "360001",
|
||||
"apprenantId": "180001",
|
||||
"nom": "pignol",
|
||||
"prenom": "francois",
|
||||
"email": "o.pareige@itinova.org",
|
||||
"sequenceId": "330001",
|
||||
"statut": "annulee",
|
||||
"createdAt": "2025-12-01 09:47:25"
|
||||
},
|
||||
{
|
||||
"id": "330001",
|
||||
"apprenantId": "180001",
|
||||
"nom": "pignol",
|
||||
"prenom": "francois",
|
||||
"email": "o.pareige@itinova.org",
|
||||
"sequenceId": "330001",
|
||||
"statut": "annulee",
|
||||
"createdAt": "2025-12-01 08:40:38"
|
||||
},
|
||||
{
|
||||
"id": "300001",
|
||||
"apprenantId": "1",
|
||||
"nom": "JOHANSSON ",
|
||||
"prenom": "Scarlett",
|
||||
"email": "opareige@gmail.com",
|
||||
"sequenceId": "330001",
|
||||
"statut": "confirmee",
|
||||
"createdAt": "2025-11-30 21:54:11"
|
||||
},
|
||||
{
|
||||
"id": "270001",
|
||||
"apprenantId": "60001",
|
||||
"nom": "PITT",
|
||||
"prenom": "Brad",
|
||||
"email": "test2@gmail.com",
|
||||
"sequenceId": "60001",
|
||||
"statut": "confirmee",
|
||||
"createdAt": "2025-11-23 22:29:23"
|
||||
},
|
||||
{
|
||||
"id": "240001",
|
||||
"apprenantId": "1",
|
||||
"nom": "JOHANSSON ",
|
||||
"prenom": "Scarlett",
|
||||
"email": "opareige@gmail.com",
|
||||
"sequenceId": "60001",
|
||||
"statut": "confirmee",
|
||||
"createdAt": "2025-11-21 14:35:44"
|
||||
},
|
||||
{
|
||||
"id": "210001",
|
||||
"apprenantId": "150001",
|
||||
"nom": "FAYOLLE",
|
||||
"prenom": "Celine",
|
||||
"email": "c.fayolle@itinova.org",
|
||||
"sequenceId": "30001",
|
||||
"statut": "annulee",
|
||||
"createdAt": "2025-11-19 08:32:10"
|
||||
},
|
||||
{
|
||||
"id": "180001",
|
||||
"apprenantId": "120001",
|
||||
"nom": "test4",
|
||||
"prenom": "test",
|
||||
"email": "test4@gmail.com",
|
||||
"sequenceId": "60001",
|
||||
"statut": "confirmee",
|
||||
"createdAt": "2025-11-17 11:01:04"
|
||||
},
|
||||
{
|
||||
"id": "150002",
|
||||
"apprenantId": "90002",
|
||||
"nom": "AUBOISDORMANT",
|
||||
"prenom": "Abel",
|
||||
"email": "alerte2.test@example.com",
|
||||
"sequenceId": "30001",
|
||||
"statut": "confirmee",
|
||||
"createdAt": "2025-11-17 09:50:59"
|
||||
},
|
||||
{
|
||||
"id": "150001",
|
||||
"apprenantId": "90001",
|
||||
"nom": "TEST",
|
||||
"prenom": "Fred",
|
||||
"email": "test.alerte@example.com",
|
||||
"sequenceId": "30001",
|
||||
"statut": "confirmee",
|
||||
"createdAt": "2025-11-17 09:48:05"
|
||||
}
|
||||
],
|
||||
"messages": [],
|
||||
"stdout": "id\tapprenantId\tnom\tprenom\temail\tsequenceId\tstatut\tcreatedAt\n360002\t180001\tpignol\tfrancois\to.pareige@itinova.org\t330001\tconfirmee\t2025-12-01 09:48:55\n360001\t180001\tpignol\tfrancois\to.pareige@itinova.org\t330001\tannulee\t2025-12-01 09:47:25\n330001\t180001\tpignol\tfrancois\to.pareige@itinova.org\t330001\tannulee\t2025-12-01 08:40:38\n300001\t1\tJOHANSSON \tScarlett\topareige@gmail.com\t330001\tconfirmee\t2025-11-30 21:54:11\n270001\t60001\tPITT\tBrad\ttest2@gmail.com\t60001\tconfirmee\t2025-11-23 22:29:23\n240001\t1\tJOHANSSON \tScarlett\topareige@gmail.com\t60001\tconfirmee\t2025-11-21 14:35:44\n210001\t150001\tFAYOLLE\tCeline\tc.fayolle@itinova.org\t30001\tannulee\t2025-11-19 08:32:10\n180001\t120001\ttest4\ttest\ttest4@gmail.com\t60001\tconfirmee\t2025-11-17 11:01:04\n150002\t90002\tAUBOISDORMANT\tAbel\talerte2.test@example.com\t30001\tconfirmee\t2025-11-17 09:50:59\n150001\t90001\tTEST\tFred\ttest.alerte@example.com\t30001\tconfirmee\t2025-11-17 09:48:05\n",
|
||||
"stderr": "",
|
||||
"execution_time_ms": 58
|
||||
}
|
||||
@@ -52,7 +52,7 @@ export default function Inscription() {
|
||||
},
|
||||
});
|
||||
|
||||
const createApprenantMutation = trpc.apprenants.create.useMutation();
|
||||
const createApprenantMutation = trpc.apprenants.createPublic.useMutation();
|
||||
|
||||
const handleSubmit = async (e: React.FormEvent) => {
|
||||
e.preventDefault();
|
||||
@@ -96,7 +96,7 @@ export default function Inscription() {
|
||||
if (existingApprenant) {
|
||||
apprenantId = existingApprenant.id;
|
||||
} else {
|
||||
// Créer l'apprenant
|
||||
// Créer l'apprenant (utiliser la procédure publique)
|
||||
await createApprenantMutation.mutateAsync(formData);
|
||||
// Récupérer l'apprenant nouvellement créé
|
||||
const newApprenant = await utils.client.apprenants.getByEmail.query({ email: formData.email });
|
||||
|
||||
@@ -162,6 +162,18 @@ export const appRouter = router({
|
||||
return { success: true };
|
||||
}),
|
||||
|
||||
// Procédure publique pour créer un apprenant lors de l'inscription
|
||||
createPublic: publicProcedure.input(z.object({
|
||||
nom: z.string().min(1),
|
||||
prenom: z.string().min(1),
|
||||
email: z.string().email(),
|
||||
codeEtablissement: z.string().min(1),
|
||||
fonction: z.enum(["directeur", "chef_service", "autre"]),
|
||||
})).mutation(async ({ input }) => {
|
||||
await db.createApprenant(input);
|
||||
return { success: true };
|
||||
}),
|
||||
|
||||
update: adminProcedure.input(z.object({
|
||||
id: z.number(),
|
||||
nom: z.string().min(1).optional(),
|
||||
|
||||
7
todo.md
7
todo.md
@@ -939,3 +939,10 @@
|
||||
- [x] Analyser la fonction checkExistingInscription
|
||||
- [x] Corriger le filtrage pour ne pas considérer les inscriptions annulées comme existantes
|
||||
- [ ] Tester la réinscription après annulation
|
||||
|
||||
## Bug Inscription - Mauvais apprenant associé lors de l'inscription
|
||||
|
||||
- [x] Analyser le processus d'inscription (page Inscription.tsx et procédure tRPC)
|
||||
- [x] Identifier pourquoi l'inscription de MONROE Marylin crée une inscription pour PIGNOL François
|
||||
- [x] Corriger le code pour associer le bon apprenant lors de l'inscription (création de createPublic)
|
||||
- [ ] Tester l'inscription avec différents apprenants pour vérifier la correction
|
||||
|
||||
Reference in New Issue
Block a user