diff --git a/src/api/send-mail/index.tsx b/src/api/send-mail/index.tsx index b5be945..3fd8a8b 100644 --- a/src/api/send-mail/index.tsx +++ b/src/api/send-mail/index.tsx @@ -1,6 +1,6 @@ import { useEffect, useState } from "react"; import { Button, Col, Container, Row, TextArea } from "@dataesr/dsfr-plus"; -import { Contribution } from "../../types"; +import { Contribution, Contribute_Production } from "../../types"; import { postHeaders } from "../../config/api"; import { toast } from "react-toastify"; @@ -8,7 +8,7 @@ function EmailSender({ contribution, setResponseScanR, }: { - contribution: Contribution; + contribution: Contribution | Contribute_Production; setResponseScanR: any; }) { const [, setEmailSent] = useState(false); diff --git a/src/api/utils/buildURL.tsx b/src/api/utils/buildURL.tsx index d07dc85..e92b48b 100644 --- a/src/api/utils/buildURL.tsx +++ b/src/api/utils/buildURL.tsx @@ -8,9 +8,13 @@ export const buildURL = ( searchInMessages: boolean = false ): string => { const location = useLocation(); - const baseUrl = location.pathname.includes("contributionpage") - ? "contribute" - : "contact"; + let baseUrl = "contact"; + + if (location.pathname.includes("contributionpage")) { + baseUrl = "contribute"; + } else if (location.pathname.includes("apioperations")) { + baseUrl = "contribute_productions"; + } const sorted = sort === "ASC" ? "sort=created_at" : "sort=-created_at"; const where: any = {}; diff --git a/src/components/edit-modal/index.tsx b/src/components/edit-modal/index.tsx index 24e42d2..09a05ac 100644 --- a/src/components/edit-modal/index.tsx +++ b/src/components/edit-modal/index.tsx @@ -54,21 +54,28 @@ const EditModal: React.FC = ({ isOpen, data, onClose }) => { setInputs((prevInputs) => ({ ...prevInputs, idRef: newIdref })); }; - const basePath = window.location.pathname.includes("contact") - ? "contact" - : "contribute"; + let basePath = "contact"; + + if (window.location.pathname.includes("contribute")) { + basePath = "contribute"; + } else if (window.location.pathname.includes("contribute_production")) { + basePath = "contribute_production"; + } const handleSubmit = async () => { try { - const response = await fetch(`${window.location.origin}/api/${basePath}/${data._id}`, { - method: "PATCH", - headers: postHeaders, - body: JSON.stringify({ - status: inputs.status, - tag: inputs.tag, - idref: inputs.idRef, - }), - }); + const response = await fetch( + `${window.location.origin}/api/${basePath}/${data._id}`, + { + method: "PATCH", + headers: postHeaders, + body: JSON.stringify({ + status: inputs.status, + tag: inputs.tag, + idref: inputs.idRef, + }), + } + ); if (!response.ok) { console.log("Erreur de réponse", response); } else { @@ -133,7 +140,6 @@ const EditModal: React.FC = ({ isOpen, data, onClose }) => { /> - + + + ); +}; + +export default MessagePreview; diff --git a/src/pages/api-operation-page/staff-production-action.tsx b/src/pages/api-operation-page/staff-production-action.tsx new file mode 100644 index 0000000..6d3c1aa --- /dev/null +++ b/src/pages/api-operation-page/staff-production-action.tsx @@ -0,0 +1,25 @@ +import EmailSender from "../../api/send-mail"; +import type { Contribute_Production } from "../../types"; +import { useState } from "react"; +import { Col, Text } from "@dataesr/dsfr-plus"; + +const StaffProductionActions = ({ data }: { data: Contribute_Production }) => { + const [responseScanR, setResponseScanR] = useState(null); + + return ( + <> + {data?.comment && ( + + + Réponse apportée par {responseScanR?.responseFrom || data.team[0]}{" "} + le {new Date(data?.modified_at).toLocaleDateString()}{" "} + + {responseScanR?.comment || data.comment} + + )} + + + ); +}; + +export default StaffProductionActions; diff --git a/src/pages/api-operation-page/styles.scss b/src/pages/api-operation-page/styles.scss new file mode 100644 index 0000000..57d400d --- /dev/null +++ b/src/pages/api-operation-page/styles.scss @@ -0,0 +1,20 @@ +.contributorProductionSideInfo { + display: flex; + justify-content: center; +} +.contributorProductionSide { + display: flex; + flex-direction: row; + flex-wrap: wrap; + justify-content: center; +} +.staffSide { + text-align: right; + background-color: var(--background-alt-blue-ecume); + border-radius: 20px; + padding: 20px; + margin-left: 140px; +} +.textInCard { + text-align: center; +} diff --git a/src/router.tsx b/src/router.tsx index aabf662..a481973 100644 --- a/src/router.tsx +++ b/src/router.tsx @@ -15,7 +15,7 @@ export default function Router() { element={} /> } /> - } /> + } /> ); diff --git a/src/types/index.ts b/src/types/index.ts index c300ef8..3555f00 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -52,3 +52,30 @@ export type StaffActionsProps = { export type MessagePreviewProps = { renderMessage: any; }; + +export type Contribute_Production = { + _id: string; + team: any; + modified_at: string | number | Date; + comment: any; + id: string; + treated_at: Date; + created_at: Date; + email: string; + message?: string; + name: string; + status: string; + productions: any[]; +}; + +export type EditModalProps = { + isOpen: boolean; + "data-production": Contribute_Production[]; + data: Contribution[]; + onClose: () => void; +}; + +export type Production = { + id: string; + treated: boolean; +};