diff --git a/client/src/components/masterplanPage/map/Map.tsx b/client/src/components/masterplanPage/map/Map.tsx index 785f1b6..3636a47 100644 --- a/client/src/components/masterplanPage/map/Map.tsx +++ b/client/src/components/masterplanPage/map/Map.tsx @@ -8,6 +8,7 @@ import ZoomControlls from "./ZoomControlls"; import { Clouds } from "./Clouds"; import { getWeather } from "../../../api/weather"; import { useEffect } from "react"; +import WeatherWidget from "./WeatherWidget"; const Map = () => { const { hoveredMarker } = useMarker(); @@ -40,6 +41,7 @@ const Map = () => { animationTime: 500, }} > + { + const [temperature, setTemperature] = useState(0); + + const date = new Date(); + + const day = date.toLocaleDateString("en-US", { + weekday: "short", + }); + const month = date.toLocaleDateString("en-US", { + month: "short", + }); + + const hours = date.getHours() > 12 ? date.getHours() - 12 : date.getHours(); + const minutes = String(date.getMinutes()).padStart(2, "0"); + const dayPart = `${date.getHours() >= 12 ? "PM" : "AM"}`; + const formattedTime = `${hours}:${minutes}`; + + useEffect(() => { + getWeather().then((data) => { + const temp = Math.round(data[0].main.temp); + setTemperature(temp); + }); + + return () => {}; + }, []); + + return ( + + + {day} + {formattedTime} + + + + {date.getDate()} {month} + + {dayPart} + + + {temperature}°C + + + ); +}; + +export default WeatherWidget;
{day}
{formattedTime}
+ {date.getDate()} {month} +
{dayPart}
{temperature}°C