diff --git a/src/api/send-mail/index.tsx b/src/api/send-mail/index.tsx index a6f733a..2919904 100644 --- a/src/api/send-mail/index.tsx +++ b/src/api/send-mail/index.tsx @@ -3,7 +3,14 @@ import { Button, Col, Container, Row, TextArea } from "@dataesr/dsfr-plus"; import { Contribution } from "../../types"; import { postHeaders } from "../../config/api"; import { toast } from "react-toastify"; -function EmailSender({ contribution }: { contribution: Contribution }) { + +function EmailSender({ + contribution, + setResponseScanR, +}: { + contribution: Contribution; + setResponseScanR: any; +}) { const [, setEmailSent] = useState(false); const [userResponse, setUserResponse] = useState(""); const basePath = window.location.pathname.includes("contact") @@ -60,7 +67,7 @@ function EmailSender({ contribution }: { contribution: Contribution }) { if (!responseScanR.ok) { throw new Error(`HTTP error! status: ${responseScanR.status}`); } - + setResponseScanR(dataForScanR); setEmailSent(true); toast.success("Mail envoyé!"); }; diff --git a/src/pages/contribution-page/staff-action.tsx b/src/pages/contribution-page/staff-action.tsx index 6e14ed9..337cdd0 100644 --- a/src/pages/contribution-page/staff-action.tsx +++ b/src/pages/contribution-page/staff-action.tsx @@ -2,25 +2,26 @@ import { Col, Text } from "@dataesr/dsfr-plus"; import EmailSender from "../../api/send-mail"; import type { Contribution } from "../../types"; import { useLocation } from "react-router-dom"; +import { useState } from "react"; const StaffActions = ({ data }: { data: Contribution }) => { const location = useLocation(); + const [responseScanR, setResponseScanR] = useState(null); const contributorClassName = location.pathname.includes("contributionpage") ? "staffSide" : "staffSideContact"; - return ( <> {data?.comment && ( - Réponse apportée par {data?.responseFrom || data.team[0]} le{" "} - {new Date(data?.modified_at).toLocaleDateString()}{" "} + Réponse apportée par {responseScanR?.responseFrom || data.team[0]}{" "} + le {new Date(data?.modified_at).toLocaleDateString()}{" "} - {data?.comment} + {responseScanR?.comment || data.comment} )} - + ); };