diff --git a/src/src/components/stationCard/StationCard.js b/src/src/components/stationCard/StationCard.js
index af62606..57c3c88 100644
--- a/src/src/components/stationCard/StationCard.js
+++ b/src/src/components/stationCard/StationCard.js
@@ -14,7 +14,8 @@ function StationCard({ loading, msgError, station }) {
const fetchLastDailyWeather = async () => {
try {
const response = await Services.getLastDailyWeather(station.id);
- setLastDataStation(response);
+ console.log("response", response[0]);
+ setLastDataStation(response[0]);
} catch (error) {
console.error(
"Error al cargar la última información de las estaciones:",
@@ -83,12 +84,13 @@ function StationCard({ loading, msgError, station }) {
.find((item) => item.measure === "t_min")
?.value.toFixed(1) ?? "N/A"
: "N/A"}{" "}
- -{" "}
+ °C -{" "}
{lastDataStation?.climaticData
? lastDataStation.climaticData
.find((item) => item.measure === "t_max")
?.value.toFixed(1) ?? "N/A"
- : "N/A"}
+ : "N/A"}{" "}
+ °C
@@ -106,7 +108,7 @@ function StationCard({ loading, msgError, station }) {
-
+
{lastDataStation?.date
? getDayOfWeek(lastDataStation.date)
: "N/A"}
@@ -114,7 +116,7 @@ function StationCard({ loading, msgError, station }) {
{lastDataStation?.date ?? "N/A"}
-
+
{station.municipality}, {station.state}
diff --git a/src/src/pages/home/Home.js b/src/src/pages/home/Home.js
index b7c4f33..740d413 100644
--- a/src/src/pages/home/Home.js
+++ b/src/src/pages/home/Home.js
@@ -18,6 +18,7 @@ const Home = () => {
const [stations, setStations] = useState([]);
const [nearestStation, setNearestStation] = useState(null);
+ const [favoriteStation, setFavoriteStation] = useState(null);
const [error, setError] = useState(null);
const [loading, setLoading] = useState(true);
@@ -66,9 +67,23 @@ const Home = () => {
}
};
+ const favorites = JSON.parse(localStorage.getItem("favorites")) || [];
+ if (favorites.length > 0) {
+ setFavoriteStation(
+ stations.find((station) => station.id === favorites[0])
+ );
+ return;
+ }
getUserLocation();
}, [stations]);
+ // useEffect(() => {
+ // const favorites = JSON.parse(localStorage.getItem("favorites")) || [];
+ // if (favorites.length > 0) {
+ // setFavoriteStation(favorites[0]);
+ // }
+ // }, []);
+
return (
{/* Sección de bienvenida */}
@@ -96,7 +111,7 @@ const Home = () => {