Skip to content

Commit

Permalink
fix(link-publication): update toast message if name different from pu…
Browse files Browse the repository at this point in the history
…blications, and update graphs
  • Loading branch information
Mihoub2 committed Jun 25, 2024
1 parent 61fff03 commit c6e2640
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 7 deletions.
1 change: 0 additions & 1 deletion src/components/edit-modal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,6 @@ const EditModal: React.FC<EditModalProps> = ({
sessionStorage.setItem("selectedProfile", profile);
setShowProfileModal(false);
};

return (
<>
<Modal isOpen={isOpen} hide={onClose}>
Expand Down
2 changes: 1 addition & 1 deletion src/components/graphs/by-status.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const ContributionsGraphByStatus = ({
type: "column",
},
title: {
text: "Contributions par statut",
text: "Les status des contributions",
},
xAxis: {
type: "category",
Expand Down
63 changes: 61 additions & 2 deletions src/components/graphs/contributions-by-name.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,41 @@ const ContributionsGraphByName = ({
{}
);

const newContributionsByName = contributions.reduce(
(acc: Record<string, number>, contribution: Contribution) => {
if (contribution.status === "new") {
const name = contribution.name;

if (!acc[name]) {
acc[name] = 0;
}

acc[name]++;
}

return acc;
},
{}
);

let names: string[] = Object.keys(contributionsByName);
let contributionCounts: number[] = Object.values(contributionsByName);
let newContributionCounts: number[] = names.map(
(name) => newContributionsByName[name] || 0
);

let pairs: [string, number][] = names.map((name, index) => [
let pairs: [string, number, number][] = names.map((name, index) => [
name,
contributionCounts[index],
newContributionCounts[index],
]);

pairs.sort((a, b) => b[1] - a[1]);
pairs = pairs.slice(0, 15);

names = pairs.map((pair) => pair[0]);
contributionCounts = pairs.map((pair) => pair[1]);
newContributionCounts = pairs.map((pair) => pair[2]);

const options = {
chart: {
Expand All @@ -72,14 +94,51 @@ const ContributionsGraphByName = ({
},
},
yAxis: {
min: 0,
title: {
text: "Nombre de contributions",
},
stackLabels: {
enabled: true,
style: {
fontWeight: "bold",
},
},
},
legend: {
align: "right",
x: -30,
verticalAlign: "middle",
layout: "vertical",
floating: false,
backgroundColor:
Highcharts.defaultOptions.legend.backgroundColor || "white",
borderColor: "#CCC",
borderWidth: 1,
shadow: false,
},
tooltip: {
headerFormat: "<b>{point.x}</b><br/>",
pointFormat: "{series.name}: {point.y}<br/>Total: {point.stackTotal}",
},
plotOptions: {
series: {
stacking: "normal",
dataLabels: {
enabled: true,
},
},
},
series: [
{
name: "Contributions",
name: "Toutes Contributions",
data: contributionCounts,
color: "#007bff",
},
{
name: "Contributions non traitées",
data: newContributionCounts,
color: "#ff4d4d",
},
],
};
Expand Down
2 changes: 1 addition & 1 deletion src/components/graphs/treatment-by-admin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const AdminTreatmentGraph = ({
},
},
title: {
text: "Traitements par admin",
text: "Les admins ayant changé le status d'une contribution",
},
plotOptions: {
column: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ const MessagePreview = ({
);
} else {
toast.warn(
`Les publications de "${data.name}" sont déjà dans le panier !`,
`Les publications de "${data.name}" sont déjà dans le panier ! Ou bien, le nom est différent de celui de la contribution. Veuillez vérifier, puis les entrer à la main`,
{
style: {
backgroundColor: "#f57c00",
Expand Down
2 changes: 1 addition & 1 deletion src/pages/contribution-page/contributor-summary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const ContributorSummary: React.FC<ContributorSummaryProps> = ({
<SideMenu title="Contributeurs" sticky fullHeight>
{contributions.map((contribution) => (
<SideMenuItem
key={contribution.id}
key={contribution._id}
title={
<div>
{contribution?.status && (
Expand Down

0 comments on commit c6e2640

Please sign in to comment.