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() {