From bea7392db542478051ce73ab25b336498d36f49a Mon Sep 17 00:00:00 2001 From: Mihoub Date: Tue, 28 May 2024 09:34:18 +0200 Subject: [PATCH] fix(modal): add a graph, team comment, and change data for a state --- src/api/send-mail/index.tsx | 11 +-- src/components/edit-modal/index.tsx | 24 ++++- src/components/graphs/comment-by-team.tsx | 87 +++++++++++++++++++ src/pages/api-operation-page/index.tsx | 18 ++-- .../api-operation-page/message-preview.tsx | 8 ++ .../staff-production-action.tsx | 16 ++-- .../contribution-page/message-preview.tsx | 8 ++ src/pages/contribution-page/staff-action.tsx | 11 ++- src/pages/contribution-page/styles.scss | 7 ++ src/pages/home/index.tsx | 4 + src/types/index.ts | 6 ++ 11 files changed, 178 insertions(+), 22 deletions(-) create mode 100644 src/components/graphs/comment-by-team.tsx diff --git a/src/api/send-mail/index.tsx b/src/api/send-mail/index.tsx index bf1229b..a87d9e5 100644 --- a/src/api/send-mail/index.tsx +++ b/src/api/send-mail/index.tsx @@ -15,7 +15,7 @@ function EmailSender({ const [userResponse, setUserResponse] = useState(""); let basePath = "contact"; - if (window.location.pathname.includes("contribute")) { + if (window.location.pathname.includes("contributionpage")) { basePath = "contribute"; } else if (window.location.pathname.includes("apioperations")) { basePath = "contribute_productions"; @@ -33,7 +33,7 @@ function EmailSender({ const dataForBrevo = { sender: { email: "mihoub.debache@enseignementsup.gouv.fr", - name: "Debache ", + name: `${selectedProfile} de l'équipe scanR`, }, to: [ { @@ -41,7 +41,7 @@ function EmailSender({ name: "Mihoub mihoub", }, ], - subject: `${selectedProfile} de l'équipe scanR`, + subject: `Réponse à votre contribution`, htmlContent: userResponse, }; @@ -59,7 +59,8 @@ function EmailSender({ } const dataForScanR = { - comment: userResponse, + mailSent: userResponse, + mailSentDate: new Date(), responseFrom: selectedProfile, }; @@ -99,7 +100,7 @@ function EmailSender({ onClick={sendEmail} size="sm" > - {contribution.comment ? "Renvoyer un mail" : "Répondre"} + {contribution.mailSent ? "Renvoyer un mail" : "Répondre"} diff --git a/src/components/edit-modal/index.tsx b/src/components/edit-modal/index.tsx index 97f40c4..b28eedf 100644 --- a/src/components/edit-modal/index.tsx +++ b/src/components/edit-modal/index.tsx @@ -26,6 +26,7 @@ const EditModal: React.FC = ({ isOpen, data, onClose }) => { status: data.status, tag: "", idRef: "", + comment: "", }); useEffect(() => { @@ -34,6 +35,7 @@ const EditModal: React.FC = ({ isOpen, data, onClose }) => { status: "treated", tag: "", idRef: "", + comment: "", }); }, [data, user]); @@ -48,6 +50,10 @@ const EditModal: React.FC = ({ isOpen, data, onClose }) => { const newTag = event.target.value; setInputs((prevInputs) => ({ ...prevInputs, tag: newTag })); }; + const handleCommentChange = (event) => { + const newComment = event.target.value; + setInputs((prevInputs) => ({ ...prevInputs, comment: newComment })); + }; const handleIdRefChange = (event) => { const newIdref = event.target.value; @@ -56,7 +62,7 @@ const EditModal: React.FC = ({ isOpen, data, onClose }) => { let basePath = "contact"; - if (window.location.pathname.includes("contribute")) { + if (window.location.pathname.includes("contributionpage")) { basePath = "contribute"; } else if (window.location.pathname.includes("apioperations")) { basePath = "contribute_productions"; @@ -73,6 +79,7 @@ const EditModal: React.FC = ({ isOpen, data, onClose }) => { status: inputs.status, tag: inputs.tag, idref: inputs.idRef, + comment: inputs.comment, }), } ); @@ -140,6 +147,21 @@ const EditModal: React.FC = ({ isOpen, data, onClose }) => { /> + + +