diff --git a/server-api/api.js b/server-api/api.js index 2a4086d..b634dbb 100644 --- a/server-api/api.js +++ b/server-api/api.js @@ -56,7 +56,7 @@ app.get('/Customer/All', (req, res) => { db.query(sql, (err, result) => { if (err) throw err; - console.log(result); + // console.log(result); res.send(result); }); }); @@ -69,7 +69,7 @@ app.get('/Customer/Id/:id', (req, res) => { db.query(sql, [id], (err, result) => { if (err) throw err; - console.log(result); + // console.log(result); res.send(result); }); }); @@ -150,7 +150,6 @@ app.get('/Sale/Pie/:iduser/:month/:year', (req, res) => { db.query(sql, [iduser,month,year,year], (err, result) => { if (err) throw err; - console.log(result); res.send(result); }); @@ -165,7 +164,7 @@ app.get('/Sale/KeyNumber/:iduser/:month/:year', (req, res) => { db.query(sql, [iduser,month,year], (err, result) => { if (err) throw err; - + console.log(result); res.send(result); }); @@ -180,7 +179,6 @@ app.get('/Sale/BestCustomer/:iduser', (req, res) => { db.query(sql, [iduser], (err, result) => { if (err) throw err; - console.log(result); res.send(result); }); diff --git a/src/pages/Analyse.js b/src/pages/Analyse.js index 57ab2b4..1f3887a 100644 --- a/src/pages/Analyse.js +++ b/src/pages/Analyse.js @@ -65,13 +65,14 @@ const Analyse = () => { }; setPieDatas(data); */ - + setPieDatas(response.data); }); const apiStringLine = '/Sale/Line/' + Session.get("idUser") + '/' + month + '/' + year; api.get(apiStringLine).then((response) => { setLineDatas(response.data); + console.log(response.data); }); }, []); diff --git a/src/pages/Dashboard.js b/src/pages/Dashboard.js index 23a2822..e0e9a3e 100644 --- a/src/pages/Dashboard.js +++ b/src/pages/Dashboard.js @@ -12,6 +12,8 @@ function Dashboard() { const [infoContactRecent, setInfoContactRecent] = useState([]); const [dataKey, setDataKey] = useState([]); const [infoBestCustomer, setinfoBestCustomer] = useState([]); + const [data12, setData12] = useState([]); + const [contact, setContact] = useState([]); const [theme, setTheme] = useState("light"); if (localStorage.getItem('theme') && localStorage.getItem("theme") !== '' && localStorage.getItem("theme") !== theme) { @@ -37,7 +39,6 @@ function Dashboard() { if (response.data.length > 0) setDataKey(response.data[0]); }); - const apiStringBestCustomer = '/Sale/BestCustomer/' + Session.get("idUser"); api.get(apiStringBestCustomer).then((response) => { if (response.data.length > 0) @@ -45,8 +46,29 @@ function Dashboard() { else setinfoBestCustomer({name :"Aucun client",total: "0"}); }); - }, []); + + const date2 = new Date(); + const nbMonths = 12; + date2.setMonth(date2.getMonth() - nbMonths); + const month12 = (date2.getMonth() + 1); + const apiStringLine = '/Sale/Line/' + Session.get("idUser") + '/' + month12 + '/' + year; + console.log(apiStringLine); + api.get(apiStringLine).then((response) => { + setData12(response.data); + console.log(response.data); + }); + + const apiStringGetUser = '/User/Id/' + Session.get("idUser"); + api.get(apiStringGetUser).then((response) => { + setContact(response.data[0]); + console.log(response.data); + }); + // setTimeout(() => {}, 500) + }, []); + if(data12.length > 0){ + console.log((data12[8].total+data12[9].total+data12[10].total)/3 ) + console.log(data12[11].total)} return (
@@ -66,34 +88,43 @@ function Dashboard() {Mes infos
+Nom : {contact.lastname}
+Prénom : {contact.firstname}
+Email : {contact.mail}
+Téléphone : {contact.phone}
+Alertes
+Mes prochaines activités
Chiffre clés
Chiffre clés
Chiffre clés
Chiffre clés
Clients importants
Contacts ajoutés récemment
{infoContactRecent.map(info => (