diff --git a/client/src/components/graphs/contributions-by-name.tsx b/client/src/components/graphs/contributions-by-name.tsx
index 86cc1ec..99623d3 100644
--- a/client/src/components/graphs/contributions-by-name.tsx
+++ b/client/src/components/graphs/contributions-by-name.tsx
@@ -15,7 +15,6 @@ const ContributionsGraphByTopContributors = ({
);
}
-
if (isError) {
return
Une erreur s'est produite
;
}
diff --git a/client/src/pages/contact-contributionbyobject-page/types/index.ts b/client/src/pages/contact-contributionbyobject-page/types/index.ts
index 17f23f2..1dee09b 100644
--- a/client/src/pages/contact-contributionbyobject-page/types/index.ts
+++ b/client/src/pages/contact-contributionbyobject-page/types/index.ts
@@ -9,6 +9,7 @@ export interface Contribution {
comment: string;
team: string[];
created_at: string;
+ phone?: string;
type: string;
tags: string[];
objectId: string;
@@ -123,13 +124,12 @@ export interface StaffActionsProps {
url: string;
}
-export interface Response {
- team: string;
-
- responseMessage: string;
-
+export interface ThreadResponse {
+ team: string[];
timestamp: string;
+ responseMessage: string;
}
+
export interface Thread {
- responses: Response[];
+ responses: ThreadResponse[];
}
diff --git a/client/src/pages/stats/index.tsx b/client/src/pages/stats/index.tsx
index 16229da..9f481f1 100644
--- a/client/src/pages/stats/index.tsx
+++ b/client/src/pages/stats/index.tsx
@@ -9,30 +9,49 @@ import ContributionsGraphByTopContributors from "../../components/graphs/contrib
import ContributionsGraphByTime from "../../components/graphs/contributions-by-year";
import { ClipLoader } from "react-spinners";
import "./styles.scss";
+import ContributionAllDatas from "../../api/contribution-api/getAllDatas";
const GetStats = () => {
- const [filter, setFilter] = useState("contacts");
+ const [filter, setFilter] = useState("contact");
const [url, setUrl] = useState(() => buildStatsURL(filter));
+ const isDevelopment = import.meta.env.VITE_HEADER_TAG === "Development";
+ const prodUrl = import.meta.env.VITE_BASE_API_URL;
+ const baseUrl = isDevelopment
+ ? "http://localhost:3000/api"
+ : `${prodUrl}/api`;
+
useEffect(() => {
- const newUrl = buildStatsURL(filter);
- setUrl(newUrl);
+ if (filter !== "global") {
+ setUrl(buildStatsURL(filter));
+ }
}, [filter]);
const { data, isLoading, isError } = ContributionData(url);
+ const {
+ data: allData,
+ isLoading: isLoadingAllData,
+ isError: isErrorAllData,
+ } = ContributionAllDatas(baseUrl);
+
+ const isGlobal = filter === "global";
+ const contributions = isGlobal
+ ? allData?.flatMap((item) => item.data || [])
+ : data?.data;
+ const isLoadingGraphs = isGlobal ? isLoadingAllData : isLoading;
+ const isErrorGraphs = isGlobal ? isErrorAllData : isError;
- if (isLoading) {
+ if (isLoadingGraphs) {
return (
);
}
- if (isError) {
+ if (isErrorGraphs) {
return Une erreur s'est produite
;
}
-
- if (!Array.isArray(data?.data)) {
+ if (!Array.isArray(contributions)) {
return Les données ne sont pas disponibles
;
}
@@ -41,8 +60,8 @@ const GetStats = () => {
Choisissez la table de données à afficher
- Les boutons si dessous filtrent sur les différentes collection, par
- objet étant les contributions visant un objet de scanR
+ Les boutons ci-dessous filtrent sur les différentes collections, par
+ objet étant les contributions visant un objet de scanR.
{
>
Changement de nom
+ setFilter("global")}
+ >
+ Global
+
- {/*
-
- */}
);
diff --git a/client/src/types/index.ts b/client/src/types/index.ts
index 6d01cc8..3cf9037 100644
--- a/client/src/types/index.ts
+++ b/client/src/types/index.ts
@@ -1,9 +1,11 @@
+import { Thread } from "../pages/api-operation-page/types";
+
export interface Contribution {
[x: string]: any;
id: string;
name: string;
email: string;
- phone: string;
+ phone?: string;
tags: string[];
status: string;
comment?: string;
@@ -94,14 +96,6 @@ export interface ChangeNameContribution {
threads?: Thread[];
}
-export interface Thread {
- team: [string];
- responseMessage: string;
- threadId: string;
- responses?: Response[];
- timestamp: string;
-}
-
export interface Response {
read: boolean;
responseMessage: string;
@@ -151,6 +145,7 @@ export type Contribute_Production = {
tag: string;
id: string;
team: string[];
+ phone: string;
modified_at: string | number | Date;
comment: string;
treated_at: Date;
@@ -164,6 +159,12 @@ export type Contribute_Production = {
fromApplication: string;
};
+export type TagSelectionModalProps = {
+ isOpen: boolean;
+ allTags: string[];
+ onClose: (selectedTags: string[]) => void;
+};
+
export type EditModalProps = {
isOpen: boolean;
dataProduction: Contribute_Production[];
@@ -173,12 +174,6 @@ export type EditModalProps = {
allTags: string[];
};
-export type TagSelectionModalProps = {
- isOpen: boolean;
- allTags: string[];
- onClose: (selectedTags: string[]) => void;
-};
-
export type Production = {
lastName: string;
firstName: string;