diff --git a/app/page.tsx b/app/page.tsx index a25ab6d..4dacdaa 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -21,8 +21,8 @@ export default function Home() { }; return ( -
-
+
+
diff --git a/components/HourlyCard/HourlyCard.tsx b/components/HourlyCard/HourlyCard.tsx index 3f86d2e..855bed6 100644 --- a/components/HourlyCard/HourlyCard.tsx +++ b/components/HourlyCard/HourlyCard.tsx @@ -3,12 +3,12 @@ import WeatherIcon from "./WeatherIcon" import HourlyTemp from "./HourlyTemp" export default function HourlyCard(props: HourlyCardPropType) { - const weatherCode = props.weather.weather_code[props.timeIndex] - const temperature = props.weather.apparent_temperature[props.timeIndex] + const weatherCode = props.weatherCode + const temperature = props.temperature return ( - <> +
- +
) }; \ No newline at end of file diff --git a/components/HourlyCard/HourlyTemp.tsx b/components/HourlyCard/HourlyTemp.tsx index 54d74d7..ff6f486 100644 --- a/components/HourlyCard/HourlyTemp.tsx +++ b/components/HourlyCard/HourlyTemp.tsx @@ -2,6 +2,6 @@ export default function HourlyTemp(props: {temperature: number;}) { const feels = props.temperature; return ( -

{feels}°C

+

{feels}°C

) } \ No newline at end of file diff --git a/components/HourlyCard/WeatherIcon.tsx b/components/HourlyCard/WeatherIcon.tsx index f65f904..d20b3df 100644 --- a/components/HourlyCard/WeatherIcon.tsx +++ b/components/HourlyCard/WeatherIcon.tsx @@ -1,15 +1,15 @@ import Image from "next/image"; -import cloudAndLightening from '../public/cloud-and-lightening.svg' -import cloudAndMoon from '../public/cloud-and-moon.svg' -import cloudAndRain from '../public/cloud-and-rain.svg' -import cloudAndSnow from '../public/cloud-and-snow.svg' -import cloudAndWind from '../public/cloud-and-wind.svg' -import cloudSnowRain from '../public/cloud-snow-rain.svg' -import cloudAndSun from '../public/cloud-and-sun.svg' -import cloudWindRain from '../public/cloud-wind-rain.svg' -import cloud from '../public/cloud.svg' -import moon from '../public/moon.svg' -import sun from '../public/sun.svg' +import cloudAndLightening from '../../public/cloud-and-lightening.svg' +import cloudAndMoon from '../../public/cloud-and-moon.svg' +import cloudAndRain from '../../public/cloud-and-rain.svg' +import cloudAndSnow from '../../public/cloud-and-snow.svg' +import cloudAndWind from '../../public/cloud-and-wind.svg' +import cloudSnowRain from '../../public/cloud-snow-rain.svg' +import cloudAndSun from '../../public/cloud-and-sun.svg' +import cloudWindRain from '../../public/cloud-wind-rain.svg' +import cloud from '../../public/cloud.svg' +import moon from '../../public/moon.svg' +import sun from '../../public/sun.svg' @@ -81,8 +81,8 @@ function getCurrentWeatherIcon(weatherCode: number) { export default function WeatherIcon(props: {weatherCode: number}) { const weatherCode = props.weatherCode return ( - <> - Weather icon - +
+ Weather icon +
) }; \ No newline at end of file diff --git a/components/WeatherNow.tsx b/components/WeatherNow.tsx index 1cf907f..c6f9632 100644 --- a/components/WeatherNow.tsx +++ b/components/WeatherNow.tsx @@ -2,17 +2,19 @@ import { getHourlyForecast } from "@/app/actions"; import Temperature from "./Temperature"; -import { HourlyForecast, WeatherContextType } from "@/types/types"; +import { HourlyCardPropType, HourlyForecast, WeatherContextType } from "@/types/types"; import { createContext, useContext, useEffect, useState } from "react"; import { defaultHourlyForecast } from "@/app/defaultState"; import { LocationContext } from "@/app/page"; import WeatherHero from "./WeatherHero"; +import HourlyCard from "./HourlyCard/HourlyCard"; export const WeatherContext = createContext({ weather: defaultHourlyForecast, setWeather: () => {}, // Default function, does nothing }); + export default function WeatherNow() { const { geoLocation } = useContext(LocationContext); const [weather, setWeather] = useState(defaultHourlyForecast); @@ -20,6 +22,7 @@ export default function WeatherNow() { weather, setWeather, }; + useEffect(() => { let mounted = true; getHourlyForecast(geoLocation).then((data) => { @@ -39,6 +42,16 @@ export default function WeatherNow() { +
+ {weather.hourly && weather.hourly.apparent_temperature.map((temp, index) => ( + index < 12 && // Ensure we only render the first 12 hours + + ))} +
); diff --git a/types/types.ts b/types/types.ts index 9ec074c..6db1d1c 100644 --- a/types/types.ts +++ b/types/types.ts @@ -215,6 +215,6 @@ export interface WeatherContextType { } export interface HourlyCardPropType { - weather: HourlyWeather; - timeIndex: number; + temperature: number; + weatherCode: number; } \ No newline at end of file