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:
@@ -721,8 +721,13 @@ export const appRouter = router({
|
||||
if (inscriptionSequence.formateurId) {
|
||||
const formateur = await db.getFormateurById(inscriptionSequence.formateurId);
|
||||
if (formateur && formateur.email) {
|
||||
const nbInscritsActuel = await db.countInscriptionsBySequence(input.sequenceId, 'confirmee');
|
||||
try {
|
||||
// Vérifier si les notifications sont activées
|
||||
const { getParametres } = await import("./parametresDb");
|
||||
const parametres = await getParametres();
|
||||
|
||||
if (parametres.notificationsActives) {
|
||||
const nbInscritsActuel = await db.countInscriptionsBySequence(input.sequenceId, 'confirmee');
|
||||
try {
|
||||
await sendNotificationFormateurNouvelleInscription({
|
||||
formateurEmail: formateur.email,
|
||||
formateurNom: formateur.nom,
|
||||
@@ -764,6 +769,9 @@ export const appRouter = router({
|
||||
messageErreur: e.message,
|
||||
});
|
||||
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) {
|
||||
const formateur = await db.getFormateurById(sequence.formateurId);
|
||||
if (formateur && formateur.email) {
|
||||
const nbInscritsApres = await db.countInscriptionsBySequence(input.sequenceId, 'confirmee');
|
||||
try {
|
||||
// Vérifier si les notifications sont activées
|
||||
const { getParametres } = await import("./parametresDb");
|
||||
const parametres = await getParametres();
|
||||
|
||||
if (parametres.notificationsActives) {
|
||||
const nbInscritsApres = await db.countInscriptionsBySequence(input.sequenceId, 'confirmee');
|
||||
try {
|
||||
await sendNotificationFormateurAnnulation({
|
||||
formateurEmail: formateur.email,
|
||||
formateurNom: formateur.nom,
|
||||
@@ -902,6 +915,9 @@ export const appRouter = router({
|
||||
messageErreur: e.message,
|
||||
});
|
||||
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);
|
||||
|
||||
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({
|
||||
formateurEmail: formateur.email,
|
||||
formateurNom: formateur.nom,
|
||||
@@ -1003,8 +1024,11 @@ export const appRouter = router({
|
||||
});
|
||||
console.log(`[Notification] Place disponible envoyée au formateur ${formateur.email}`);
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(`[Notification] Erreur envoi notification formateur:`, e);
|
||||
} catch (e) {
|
||||
console.error(`[Notification] Erreur envoi notification formateur:`, e);
|
||||
}
|
||||
} else {
|
||||
console.log(`[Notification] Notifications désactivées - notification formateur annulation non envoyée`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user