From 286a433fc65b740cf83842fddbc0382b44628b64 Mon Sep 17 00:00:00 2001 From: Mihoub <debache.mihoub@gmail.com> Date: Tue, 5 Nov 2024 17:07:24 +0100 Subject: [PATCH] fix(template): update mail template of a new contribution by adding fonctions --- server/routes/contacts/post/index.ts | 7 +++++-- server/routes/contributionObjectRoutes/post/index.ts | 6 +++++- server/routes/remove-user/post/index.ts | 6 +++++- server/routes/update-user-data/post/index.ts | 6 +++++- 4 files changed, 20 insertions(+), 5 deletions(-) diff --git a/server/routes/contacts/post/index.ts b/server/routes/contacts/post/index.ts index 4e8fc9a..731f4da 100644 --- a/server/routes/contacts/post/index.ts +++ b/server/routes/contacts/post/index.ts @@ -33,7 +33,7 @@ postContactsRoutes.post( ...acc, [key]: body.extra ? body.extra[key].toLowerCase() : "", }), - {} + {} as { [key: string]: string } ); const _id = new ObjectId(); const newContribution = { @@ -75,7 +75,7 @@ postContactsRoutes.post( code: "NO_RECIPIENTS_FOUND", }); } - + const fonction = finalContribution.extra.fonction || "non renseigné"; const dataForBrevo = { sender: { email: process.env.MAIL_SENDER, @@ -88,6 +88,9 @@ postContactsRoutes.post( params: { date: new Date().toLocaleDateString("fr-FR"), title: "Nouvelle contribution créée via formulaire de contact", + name: finalContribution.name, + email: finalContribution.email, + fonction: fonction, id: finalContribution.id, link: contributionLink, message: `${finalContribution.message}`, diff --git a/server/routes/contributionObjectRoutes/post/index.ts b/server/routes/contributionObjectRoutes/post/index.ts index 2c02041..2fa1387 100644 --- a/server/routes/contributionObjectRoutes/post/index.ts +++ b/server/routes/contributionObjectRoutes/post/index.ts @@ -26,7 +26,7 @@ postContributionObjectRoutes.post( ...acc, [key]: body.extra ? body.extra[key].toLowerCase() : "", }), - {} + {} as { [key: string]: string } ); const _id = new ObjectId(); @@ -68,6 +68,7 @@ postContributionObjectRoutes.post( const recipients = emailRecipients["contribute"] || { to: process.env.SCANR_EMAIL_RECIPIENTS?.split(",") || [], }; + const fonction = finalContribution.extra.fonction || "non renseigné"; const dataForBrevo = { sender: { @@ -86,6 +87,9 @@ postContributionObjectRoutes.post( title: "Nouvelle contribution créée concernant un objet", id: finalContribution.id, link: contributionLink, + name: finalContribution.name, + fonction: fonction, + email: finalContribution.email, message: `${finalContribution.message}`, }, }; diff --git a/server/routes/remove-user/post/index.ts b/server/routes/remove-user/post/index.ts index 8e0fd49..fd4db66 100644 --- a/server/routes/remove-user/post/index.ts +++ b/server/routes/remove-user/post/index.ts @@ -18,7 +18,7 @@ postRemoveUserRoutes.post( ...acc, [key]: body.extra ? body.extra[key].toLowerCase() : "", }), - {} + {} as { [key: string]: string } ); const _id = new ObjectId(); @@ -58,6 +58,7 @@ postRemoveUserRoutes.post( const recipients = emailRecipients["remove-user"] || { to: process.env.SCANR_EMAIL_RECIPIENTS?.split(",") || [], }; + const fonction = finalContribution.extra.fonction || "non renseigné"; const dataForBrevo = { sender: { @@ -76,6 +77,9 @@ postRemoveUserRoutes.post( title: "Nouvelle demande de suppression de profil", id: finalContribution.id, link: contributionLink, + name: finalContribution.name, + email: finalContribution.email, + fonction: fonction, message: `${finalContribution.message}`, }, }; diff --git a/server/routes/update-user-data/post/index.ts b/server/routes/update-user-data/post/index.ts index cbd9580..a01faa9 100644 --- a/server/routes/update-user-data/post/index.ts +++ b/server/routes/update-user-data/post/index.ts @@ -24,7 +24,7 @@ postUpdateUserDataRoutes.post( ...acc, [key]: body.extra ? body.extra[key].toLowerCase() : "", }), - {} + {} as { [key: string]: string } ); const _id = new ObjectId(); @@ -64,6 +64,7 @@ postUpdateUserDataRoutes.post( const recipients = emailRecipients["update-user-data"] || { to: process.env.SCANR_EMAIL_RECIPIENTS?.split(",") || [], }; + const fonction = finalContribution.extra.fonction || "non renseigné"; const dataForBrevo = { sender: { @@ -82,6 +83,9 @@ postUpdateUserDataRoutes.post( title: "Nouvelle demande de modification de profil", id: finalContribution.id, link: contributionLink, + name: finalContribution.name, + email: finalContribution.email, + fonction: fonction, message: `${finalContribution.message}`, }, };