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:
@@ -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 });
|
||||
|
||||
Reference in New Issue
Block a user