-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(modal): add a graph, team comment, and change data for a state
- Loading branch information
Showing
11 changed files
with
178 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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,15 +33,15 @@ function EmailSender({ | |
const dataForBrevo = { | ||
sender: { | ||
email: "[email protected]", | ||
name: "Debache ", | ||
name: `${selectedProfile} de l'équipe scanR`, | ||
}, | ||
to: [ | ||
{ | ||
email: "[email protected]", | ||
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"} | ||
</Button> | ||
</Col> | ||
</Row> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
import Highcharts from "highcharts"; | ||
import HighchartsReact from "highcharts-react-official"; | ||
import useGetContributionData from "../../api/contribution-api/useGetObjectContributeData"; | ||
import { Contribution } from "../../types"; | ||
import { contactUrl, contributionUrl } from "../../config/api"; | ||
import { useState } from "react"; | ||
import { Button, Col } from "@dataesr/dsfr-plus"; | ||
|
||
const CommentsGraphByTeamMember = () => { | ||
const [filter, setFilter] = useState("contributions"); | ||
const url = filter === "object" ? contributionUrl : contactUrl; | ||
const { data, isLoading, isError } = useGetContributionData(url, 0); | ||
|
||
const contributions = (data as { data: Contribution[] })?.data; | ||
|
||
if (isLoading) { | ||
return <div>Chargement...</div>; | ||
} | ||
|
||
if (isError) { | ||
return <div>Une erreur s'est produite</div>; | ||
} | ||
|
||
if (!Array.isArray(contributions)) { | ||
return <div>Les données ne sont pas disponibles</div>; | ||
} | ||
|
||
const counts = contributions.reduce((acc, curr) => { | ||
if (curr.comment && curr.team) { | ||
acc[curr.team] = (acc[curr.team] || 0) + 1; | ||
} | ||
return acc; | ||
}, {} as { [key: string]: number }); | ||
|
||
const chartData = Object.entries(counts).map(([name, y]) => ({ | ||
name, | ||
y, | ||
})); | ||
|
||
const options = { | ||
chart: { | ||
type: "column", | ||
}, | ||
title: { | ||
text: "Nombre de commentaires par membre de l'équipe", | ||
}, | ||
xAxis: { | ||
type: "category", | ||
}, | ||
yAxis: { | ||
title: { | ||
text: "Nombre de commentaires", | ||
}, | ||
}, | ||
series: [ | ||
{ | ||
name: "Membre de l'équipe", | ||
data: chartData, | ||
}, | ||
], | ||
}; | ||
|
||
return ( | ||
<> | ||
<Col className="fr-mb-3w"> | ||
<Button | ||
className="fr-mr-1w" | ||
size="sm" | ||
variant={filter === "object" ? "primary" : "secondary"} | ||
onClick={() => setFilter("object")} | ||
> | ||
Par objet | ||
</Button> | ||
<Button | ||
size="sm" | ||
variant={filter === "contact" ? "primary" : "secondary"} | ||
onClick={() => setFilter("contact")} | ||
> | ||
Via formulaire contact | ||
</Button> | ||
</Col> | ||
<HighchartsReact highcharts={Highcharts} options={options} /> | ||
</> | ||
); | ||
}; | ||
|
||
export default CommentsGraphByTeamMember; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters