diff --git a/src/src/components/stationCard/StationCard.js b/src/src/components/stationCard/StationCard.js index 88ae285..2719723 100644 --- a/src/src/components/stationCard/StationCard.js +++ b/src/src/components/stationCard/StationCard.js @@ -4,6 +4,7 @@ import { Card, Col, Spinner } from "react-bootstrap"; import { IconDroplet, IconMapPin, IconSun } from "@tabler/icons-react"; import Services from "../../services/Services"; import { getDayOfWeek } from "../../utils/Utilities"; +import { Link } from "react-router-dom"; function StationCard({ loading, msgError, station }) { const [lastDataStation, setLastDataStation] = useState(); @@ -38,98 +39,111 @@ function StationCard({ loading, msgError, station }) { ); - return ( - - -
- - - - - + const cardContent = ( + +
+ + + + + +
+ {loading ? ( +
+ +

Cargando datos...

- {loading ? ( -
- -

Cargando datos...

-
- ) : msgError ? ( -
-

{msgError}

-
- ) : station ? ( - -
-
-
-

{station.name}

- - - {station.municipality}, {station.state} - -
-
- - {lastDataStation?.climaticData - ? lastDataStation.climaticData - .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"}{" "} - °C - - {renderClimaticData( - "prec", - , - "mm" - )} - {renderClimaticData( - "sol_rad", - , - "M/J" - )} -
+ ) : msgError ? ( +
+

{msgError}

+
+ ) : station ? ( + +
+
+
+

{station.name}

+ + + {station.municipality}, {station.state} + +
+
+ + {lastDataStation?.climaticData + ? lastDataStation.climaticData + .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"}{" "} + °C + + {renderClimaticData( + "prec", + , + "mm" + )} + {renderClimaticData( + "sol_rad", + , + "M/J" + )}
-
-
- - {lastDataStation?.date - ? getDayOfWeek(lastDataStation.date) - : "N/A"} - - {lastDataStation?.date ?? "N/A"} -
-
-
+
+
+
+ + {lastDataStation?.date + ? getDayOfWeek(lastDataStation.date) + : "N/A"} + + {lastDataStation?.date ?? "N/A"}
+
- - ) : ( -
-

No se ha seleccionado ninguna estación

- )} - + + ) : ( +
+

No se ha seleccionado ninguna estación

+
+ )} + + ); + + return ( + + {station ? ( + + {cardContent} + + ) : ( + cardContent + )} ); }