diff --git a/Front-end/src/components/MeteoInfos.jsx b/Front-end/src/components/MeteoInfos.jsx index 13a0046..f47ac65 100644 --- a/Front-end/src/components/MeteoInfos.jsx +++ b/Front-end/src/components/MeteoInfos.jsx @@ -1,26 +1,21 @@ import { Thermometer, Sun, CircleGauge, Droplet } from "lucide-react"; import React, { useEffect, useState } from "react"; - import axios from "axios"; import { API_BASE_URL } from "../config"; import BoutonGraphique from "./BoutonGraphique"; import AlertInactive from "./AlertInactive"; +import ParticularMeteo from "./ParticularMeteo"; -function MeteoInfos({ - object, - graphStates, - setGraphStates, - graphRefs -}) { +function MeteoInfos({ object, graphStates, setGraphStates, graphRefs }) { const [rawData, setRawData] = useState([]); - const [AffAlert,setAffAlert] = useState(false); + const [AffAlert, setAffAlert] = useState(false); const [AffRegles, setAffRegles] = useState(false); const identifiant = object.id; useEffect(() => { axios.get(`${API_BASE_URL}/meteo?id=${identifiant}`).then((response) => { setRawData(response.data); - if(rawData.length <5){ + if (rawData.length < 5) { setAffAlert(true); } }); @@ -29,7 +24,7 @@ function MeteoInfos({ const lastData = rawData.length > 0 ? rawData[rawData.length - 1] : null; return (
- {(AffAlert&&(object.status==="active")) && ( + {AffAlert && object.status === "active" && ( )}
@@ -40,83 +35,40 @@ function MeteoInfos({
{lastData ? (
- {lastData.temperature && ( -
-
-
-
- -
-
-

- Température -

-

- {lastData.temperature} °C -

-
-
+ + + {/* Pression */} + - -
-
- )} - {lastData.pressure && ( -
-
-
-
- -
-
-

- Pression -

-

- {lastData.pressure} hPa -

-
-
- -
-
- )} - {lastData.humidity && ( -
-
-
-
- -
-
-

- Humidité -

-

- {lastData.humidity} % -

-
-
- -
-
- )} + {/* Humidité */} +

Dernier enregistrement : {lastData.timestamp}

diff --git a/Front-end/src/components/ParticularMeteo.jsx b/Front-end/src/components/ParticularMeteo.jsx new file mode 100644 index 0000000..32d08f6 --- /dev/null +++ b/Front-end/src/components/ParticularMeteo.jsx @@ -0,0 +1,42 @@ +import React from "react"; +import BoutonGraphique from "./BoutonGraphique"; +function ParticularMeteo({ + type, + data, + Icon, + texte1, + texte2, + graphStates, + setGraphStates, + graphRefs, +}) { + if (data[type]) { + return ( +
+
+
+
+ +
+
+

+ {texte1} +

+

+ {data[type]} {texte2} +

+
+
+ +
+
+ ); + } +} + +export default ParticularMeteo; diff --git a/Front-end/src/components/WindGraph.jsx b/Front-end/src/components/WindGraph.jsx index 941cdcd..1509c96 100644 --- a/Front-end/src/components/WindGraph.jsx +++ b/Front-end/src/components/WindGraph.jsx @@ -25,7 +25,7 @@ function WindGraph({ object,reference }) { ); } - return null; // Si aucun point n'est survolé + return null; }; useEffect(() => { if (reference?.current) {