From bf12b9b680338fdc87ae1e595502afc1b0f4bafc Mon Sep 17 00:00:00 2001 From: Manus Date: Thu, 26 Feb 2026 07:53:53 -0500 Subject: [PATCH] =?UTF-8?q?Checkpoint:=20V1.20=20-=20Am=C3=A9lioration=20d?= =?UTF-8?q?e=20l'envoi=20d'attestations=20par=20groupe.=20Le=20bouton=20d'?= =?UTF-8?q?envoi=20par=20s=C3=A9quence=20est=20maintenant=20toujours=20vis?= =?UTF-8?q?ible=20d=C3=A8s=20qu'il=20y=20a=20des=20attestations=20disponib?= =?UTF-8?q?les,=20permettant=20d'envoyer=20les=20nouvelles=20attestations?= =?UTF-8?q?=20ou=20de=20renvoyer=20celles=20d=C3=A9j=C3=A0=20envoy=C3=A9es?= =?UTF-8?q?.=20Message=20de=20confirmation=20adapt=C3=A9=20selon=20la=20si?= =?UTF-8?q?tuation.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/src/pages/AdminGestionAttestations.tsx | 55 ++++++++++++------- todo.md | 10 +++- 2 files changed, 45 insertions(+), 20 deletions(-) diff --git a/client/src/pages/AdminGestionAttestations.tsx b/client/src/pages/AdminGestionAttestations.tsx index df12221..0805a97 100644 --- a/client/src/pages/AdminGestionAttestations.tsx +++ b/client/src/pages/AdminGestionAttestations.tsx @@ -442,22 +442,37 @@ export default function AdminGestionAttestations() { // Envoyer toutes les attestations d'une séquence const handleSendSequence = (sequenceId: number, sequenceApprenants: any[]) => { - const attestationsReady = sequenceApprenants.filter(item => { + const attestationsWithDocument = sequenceApprenants.filter(item => { const hasDocument = item.attestation && (item.attestation.documentUrl || item.attestation.urlPdf); - return hasDocument && !item.attestation.emailEnvoye; + return hasDocument; }); - if (attestationsReady.length === 0) { - toast.error("Aucune attestation prête à envoyer pour cette séquence"); + if (attestationsWithDocument.length === 0) { + toast.error("Aucune attestation disponible pour cette séquence"); return; } - if (confirm(`Êtes-vous sûr de vouloir envoyer ${attestationsReady.length} attestation(s) pour cette séquence ?`)) { - // Envoyer chaque attestation de la séquence - let successCount = 0; - let errorCount = 0; - - const sendPromises = attestationsReady.map(item => { + const attestationsNotSent = attestationsWithDocument.filter(item => !item.attestation.emailEnvoye); + const attestationsAlreadySent = attestationsWithDocument.filter(item => item.attestation.emailEnvoye); + + let confirmMessage = ''; + if (attestationsNotSent.length > 0 && attestationsAlreadySent.length > 0) { + confirmMessage = `Êtes-vous sûr de vouloir envoyer ${attestationsNotSent.length} attestation(s) et renvoyer ${attestationsAlreadySent.length} attestation(s) déjà envoyée(s) ?`; + } else if (attestationsNotSent.length > 0) { + confirmMessage = `Êtes-vous sûr de vouloir envoyer ${attestationsNotSent.length} attestation(s) pour cette séquence ?`; + } else { + confirmMessage = `Êtes-vous sûr de vouloir renvoyer ${attestationsAlreadySent.length} attestation(s) déjà envoyée(s) ?`; + } + + if (!confirm(confirmMessage)) { + return; + } + + // Envoyer chaque attestation de la séquence + let successCount = 0; + let errorCount = 0; + + const sendPromises = attestationsWithDocument.map(item => { const pdfUrl = item.attestation.documentUrl || item.attestation.urlPdf; return sendAttestationMutation.mutateAsync({ attestationId: item.attestation.id, @@ -475,13 +490,12 @@ export default function AdminGestionAttestations() { }); }); - Promise.all(sendPromises).finally(() => { - if (successCount > 0) { - toast.success(`${successCount} attestation(s) envoyée(s) avec succès${errorCount > 0 ? `, ${errorCount} échec(s)` : ''}`); - } - refetchApprenants(); - }); - } + Promise.all(sendPromises).finally(() => { + if (successCount > 0) { + toast.success(`${successCount} attestation(s) envoyée(s) avec succès${errorCount > 0 ? `, ${errorCount} échec(s)` : ''}`); + } + refetchApprenants(); + }); }; // Ouvrir le dialogue d'upload @@ -748,7 +762,7 @@ export default function AdminGestionAttestations() { {attestationsEnvoyees} / {sequenceApprenants.length} envoyé(es) - {modeEnvoi === "manuel" && attestationsPretesNonEnvoyees > 0 && ( + {modeEnvoi === "manuel" && sequenceApprenants.some(a => a.attestation && (a.attestation.documentUrl || a.attestation.urlPdf)) && ( )} diff --git a/todo.md b/todo.md index 57ec8df..412036a 100644 --- a/todo.md +++ b/todo.md @@ -1646,4 +1646,12 @@ - [x] Ajouter l'URL dans le retour de la procédure generateQRCode - [x] Afficher l'URL sous le QR code (texte cliquable) - [x] Déployer sur TEST pour validation -- [ ] Déployer sur PROD +- [x] Déployer sur PROD + +## Envoi d'attestations par groupe + +- [x] Analyser la page des attestations pour identifier l'emplacement du bouton +- [x] Modifier le bouton existant pour permettre l'envoi/renvoi de toutes les attestations du groupe +- [x] Adapter la logique pour gérer les attestations déjà envoyées (renvoi) +- [x] Déployer sur TEST (recette) +- [x] Déployer sur sandbox (dev local) - déjà actif