From 1ee10f929f6c85dc4120724e1b163f8270567f87 Mon Sep 17 00:00:00 2001 From: "jeremy.ducourthial" Date: Wed, 21 Dec 2022 19:31:58 +0100 Subject: [PATCH] Suppression bug affichage dashboard --- src/pages/Dashboard.js | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/pages/Dashboard.js b/src/pages/Dashboard.js index 73d8c92..23a2822 100644 --- a/src/pages/Dashboard.js +++ b/src/pages/Dashboard.js @@ -10,7 +10,7 @@ const api = axios.create({ function Dashboard() { const [infoContactRecent, setInfoContactRecent] = useState([]); - const [datakey, setDataKey] = useState([]); + const [dataKey, setDataKey] = useState([]); const [infoBestCustomer, setinfoBestCustomer] = useState([]); const [theme, setTheme] = useState("light"); @@ -28,17 +28,22 @@ function Dashboard() { const apiString = '/Contact/LastAdd3/' + Session.get("idUser"); api.get(apiString).then((response) => { - setInfoContactRecent(response.data); + if (response.data.length > 0) + setInfoContactRecent(response.data); }); const apiStringKey = '/Sale/KeyNumber/' + Session.get("idUser") + "/" + month + "/" + year; api.get(apiStringKey).then((response) => { - setDataKey(response.data[0]); - }); + if (response.data.length > 0) + setDataKey(response.data[0]); + }); const apiStringBestCustomer = '/Sale/BestCustomer/' + Session.get("idUser"); api.get(apiStringBestCustomer).then((response) => { - setinfoBestCustomer(response.data[0]); + if (response.data.length > 0) + setinfoBestCustomer(response.data[0]); + else + setinfoBestCustomer({name :"Aucun client",total: "0"}); }); }, []); @@ -75,11 +80,11 @@ function Dashboard() {
Chiffre_clés -
{datakey.total}
+
{dataKey.total}
Chiffre_clés -
{datakey.totalcontact}
+
{dataKey.totalcontact}