Checkpoint: Implémentation du paramètre notificationsActives pour contrôler les notifications d'inscription et d'annulation aux formateurs. Le paramètre permet maintenant de désactiver les notifications formateur tout en gardant les rappels actifs. Déployé sur TEST.
This commit is contained in:
@@ -211,10 +211,10 @@ export default function AdminParametres() {
|
|||||||
<div className="flex items-center justify-between space-x-2 rounded-lg border p-4">
|
<div className="flex items-center justify-between space-x-2 rounded-lg border p-4">
|
||||||
<div className="space-y-0.5">
|
<div className="space-y-0.5">
|
||||||
<Label htmlFor="notificationsActives" className="text-base">
|
<Label htmlFor="notificationsActives" className="text-base">
|
||||||
Notifications automatiques
|
Notifications formateur
|
||||||
</Label>
|
</Label>
|
||||||
<p className="text-sm text-muted-foreground">
|
<p className="text-sm text-muted-foreground">
|
||||||
Activer ou désactiver l'envoi automatique de notifications
|
Activer ou désactiver les notifications d'inscription et d'annulation envoyées aux formateurs
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<Switch
|
<Switch
|
||||||
|
|||||||
@@ -721,8 +721,13 @@ export const appRouter = router({
|
|||||||
if (inscriptionSequence.formateurId) {
|
if (inscriptionSequence.formateurId) {
|
||||||
const formateur = await db.getFormateurById(inscriptionSequence.formateurId);
|
const formateur = await db.getFormateurById(inscriptionSequence.formateurId);
|
||||||
if (formateur && formateur.email) {
|
if (formateur && formateur.email) {
|
||||||
const nbInscritsActuel = await db.countInscriptionsBySequence(input.sequenceId, 'confirmee');
|
// Vérifier si les notifications sont activées
|
||||||
try {
|
const { getParametres } = await import("./parametresDb");
|
||||||
|
const parametres = await getParametres();
|
||||||
|
|
||||||
|
if (parametres.notificationsActives) {
|
||||||
|
const nbInscritsActuel = await db.countInscriptionsBySequence(input.sequenceId, 'confirmee');
|
||||||
|
try {
|
||||||
await sendNotificationFormateurNouvelleInscription({
|
await sendNotificationFormateurNouvelleInscription({
|
||||||
formateurEmail: formateur.email,
|
formateurEmail: formateur.email,
|
||||||
formateurNom: formateur.nom,
|
formateurNom: formateur.nom,
|
||||||
@@ -764,6 +769,9 @@ export const appRouter = router({
|
|||||||
messageErreur: e.message,
|
messageErreur: e.message,
|
||||||
});
|
});
|
||||||
console.error(`[Notification] Erreur envoi email formateur:`, e);
|
console.error(`[Notification] Erreur envoi email formateur:`, e);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
console.log(`[Notification] Notifications désactivées - notification formateur inscription non envoyée`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -865,8 +873,13 @@ export const appRouter = router({
|
|||||||
if (sequence.formateurId) {
|
if (sequence.formateurId) {
|
||||||
const formateur = await db.getFormateurById(sequence.formateurId);
|
const formateur = await db.getFormateurById(sequence.formateurId);
|
||||||
if (formateur && formateur.email) {
|
if (formateur && formateur.email) {
|
||||||
const nbInscritsApres = await db.countInscriptionsBySequence(input.sequenceId, 'confirmee');
|
// Vérifier si les notifications sont activées
|
||||||
try {
|
const { getParametres } = await import("./parametresDb");
|
||||||
|
const parametres = await getParametres();
|
||||||
|
|
||||||
|
if (parametres.notificationsActives) {
|
||||||
|
const nbInscritsApres = await db.countInscriptionsBySequence(input.sequenceId, 'confirmee');
|
||||||
|
try {
|
||||||
await sendNotificationFormateurAnnulation({
|
await sendNotificationFormateurAnnulation({
|
||||||
formateurEmail: formateur.email,
|
formateurEmail: formateur.email,
|
||||||
formateurNom: formateur.nom,
|
formateurNom: formateur.nom,
|
||||||
@@ -902,6 +915,9 @@ export const appRouter = router({
|
|||||||
messageErreur: e.message,
|
messageErreur: e.message,
|
||||||
});
|
});
|
||||||
console.error(`[Notification] Erreur envoi email formateur:`, e);
|
console.error(`[Notification] Erreur envoi email formateur:`, e);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
console.log(`[Notification] Notifications désactivées - notification formateur annulation non envoyée`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -973,9 +989,14 @@ export const appRouter = router({
|
|||||||
const formation = await db.getFormationById(sequence.formationId);
|
const formation = await db.getFormationById(sequence.formationId);
|
||||||
|
|
||||||
if (formateur && formateur.email && formation) {
|
if (formateur && formateur.email && formation) {
|
||||||
const nbInscritsApres = await db.countInscriptionsBySequence(sequence.id, 'confirmee');
|
// Vérifier si les notifications sont activées
|
||||||
|
const { getParametres } = await import("./parametresDb");
|
||||||
|
const parametres = await getParametres();
|
||||||
|
|
||||||
try {
|
if (parametres.notificationsActives) {
|
||||||
|
const nbInscritsApres = await db.countInscriptionsBySequence(sequence.id, 'confirmee');
|
||||||
|
|
||||||
|
try {
|
||||||
await sendNotificationFormateurAnnulation({
|
await sendNotificationFormateurAnnulation({
|
||||||
formateurEmail: formateur.email,
|
formateurEmail: formateur.email,
|
||||||
formateurNom: formateur.nom,
|
formateurNom: formateur.nom,
|
||||||
@@ -1003,8 +1024,11 @@ export const appRouter = router({
|
|||||||
});
|
});
|
||||||
console.log(`[Notification] Place disponible envoyée au formateur ${formateur.email}`);
|
console.log(`[Notification] Place disponible envoyée au formateur ${formateur.email}`);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(`[Notification] Erreur envoi notification formateur:`, e);
|
console.error(`[Notification] Erreur envoi notification formateur:`, e);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
console.log(`[Notification] Notifications désactivées - notification formateur annulation non envoyée`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
8
todo.md
8
todo.md
@@ -1655,3 +1655,11 @@
|
|||||||
- [x] Adapter la logique pour gérer les attestations déjà envoyées (renvoi)
|
- [x] Adapter la logique pour gérer les attestations déjà envoyées (renvoi)
|
||||||
- [x] Déployer sur TEST (recette)
|
- [x] Déployer sur TEST (recette)
|
||||||
- [x] Déployer sur sandbox (dev local) - déjà actif
|
- [x] Déployer sur sandbox (dev local) - déjà actif
|
||||||
|
|
||||||
|
## Implémenter notificationsActives pour les notifications formateur
|
||||||
|
|
||||||
|
- [x] Identifier tous les endroits où les notifications formateur sont envoyées (inscription, annulation)
|
||||||
|
- [x] Ajouter la vérification du paramètre notificationsActives avant chaque envoi (3 endroits)
|
||||||
|
- [x] Mettre à jour la description du paramètre dans l'interface admin pour clarifier son rôle
|
||||||
|
- [x] Déployer sur TEST pour validation
|
||||||
|
- [ ] Déployer sur PROD
|
||||||
|
|||||||
Reference in New Issue
Block a user