Skip to content

Commit

Permalink
fix(send-mail): format response for br to work
Browse files Browse the repository at this point in the history
  • Loading branch information
Mihoub2 committed Jul 18, 2024
1 parent 7c00f72 commit 22dc2c6
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/api/send-mail/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ function EmailSender({ contribution, refetch }: EmailSenderProps) {
return;
}

const formattedResponse = userResponse.replace(/\n/g, "<br/>");

const dataForBrevo = {
sender: {
email: "scanr@recherche.gouv.fr",
Expand All @@ -73,11 +75,12 @@ function EmailSender({ contribution, refetch }: EmailSenderProps) {
templateId: 262,
params: {
date: new Date().toLocaleDateString(),
userResponse: userResponse,
userResponse: formattedResponse,
message: contribution.message,
selectedProfile: selectedProfile,
},
};

try {
const responseBrevo = await fetch(brevoUrl, {
method: "POST",
Expand Down Expand Up @@ -162,7 +165,7 @@ function EmailSender({ contribution, refetch }: EmailSenderProps) {
<div>
<h4>Message:</h4>
{userResponse ? (
<p>{userResponse}</p>
<pre style={{ whiteSpace: "pre-wrap" }}>{userResponse}</pre>
) : (
<Alert
variant="warning"
Expand Down

0 comments on commit 22dc2c6

Please sign in to comment.