diff --git a/app/page.tsx b/app/page.tsx index 7787c08..1195d70 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -17,7 +17,7 @@ export default function Home() { return (
-
+
diff --git a/components/DailyCard/CardContainer.tsx b/components/DailyCard/CardContainer.tsx new file mode 100644 index 0000000..4573f6f --- /dev/null +++ b/components/DailyCard/CardContainer.tsx @@ -0,0 +1,20 @@ +import { Forecast } from "@/types/types"; +import DailyCard from "./DailyCard"; + +export default function CardContainer(props: {weather: Forecast}) { + const weather = props.weather; + return ( +
+ {weather.daily && weather.daily.apparent_temperature_max.map((temp, index) => ( + index > 0 && + index < 7 && // Ensure we only render the next 6 days + + ))} +
+ ) +}; \ No newline at end of file diff --git a/components/DailyCard/DailyCard.tsx b/components/DailyCard/DailyCard.tsx index f978c87..d6ffb68 100644 --- a/components/DailyCard/DailyCard.tsx +++ b/components/DailyCard/DailyCard.tsx @@ -8,7 +8,7 @@ export default function DailyCard(props: DailyCardPropType) { const weatherCode = props.weatherCode const temperature = props.temperature return ( -
+
diff --git a/components/DailyCard/DailyTemp.tsx b/components/DailyCard/DailyTemp.tsx index 89788fc..0086cc8 100644 --- a/components/DailyCard/DailyTemp.tsx +++ b/components/DailyCard/DailyTemp.tsx @@ -2,6 +2,6 @@ export default function DailyTemp(props: {temperature: number;}) { const feels = props.temperature; return ( -

{feels}°C

+

{feels}°C

) } \ No newline at end of file diff --git a/components/DailyCard/DailyTime.tsx b/components/DailyCard/DailyTime.tsx index 47e9e0d..57b12f9 100644 --- a/components/DailyCard/DailyTime.tsx +++ b/components/DailyCard/DailyTime.tsx @@ -1,7 +1,9 @@ -import { headers } from "next/headers"; +import weekday from "@/utils/functions/weekday" + export default function DailyTime(props: {time: string}) { + const day = weekday(props.time); return( -

{props.time}

+

{day}

) } \ No newline at end of file diff --git a/components/Temperature.tsx b/components/Temperature.tsx index ff12b70..656a0c4 100644 --- a/components/Temperature.tsx +++ b/components/Temperature.tsx @@ -7,6 +7,6 @@ export default function Temperature() { const { weather } = useContext(WeatherContext) const feels = weather.current.apparent_temperature; return ( -

{feels}°C

+

{feels}°C

) } \ No newline at end of file diff --git a/components/WeatherHero.tsx b/components/WeatherHero.tsx index f577a24..a2e19b9 100644 --- a/components/WeatherHero.tsx +++ b/components/WeatherHero.tsx @@ -85,7 +85,7 @@ export default function WeatherHero() { const weatherCode = weather.current.weather_code; return( <> - Weather icon + Weather icon ) }; \ No newline at end of file diff --git a/components/WeatherIcon.tsx b/components/WeatherIcon.tsx index 88e8073..af83eb1 100644 --- a/components/WeatherIcon.tsx +++ b/components/WeatherIcon.tsx @@ -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 16c748c..aa0e766 100644 --- a/components/WeatherNow.tsx +++ b/components/WeatherNow.tsx @@ -8,6 +8,7 @@ import { defaultHourlyForecast } from "@/app/defaultState"; import { LocationContext } from "@/context/LocationContext"; import WeatherHero from "./WeatherHero"; import DailyCard from "./DailyCard/DailyCard"; +import CardContainer from "./DailyCard/CardContainer"; export const WeatherContext = createContext({ weather: defaultHourlyForecast, @@ -42,19 +43,8 @@ export default function WeatherNow() { -

And the forecast for the coming week

-
- {weather.daily && weather.daily.apparent_temperature_max.map((temp, index) => ( - index > 0 && - index < 7 && // Ensure we only render the next 6 days - - ))} -
+

And the forecast for the coming week

+
); diff --git a/utils/functions/weekday.ts b/utils/functions/weekday.ts new file mode 100644 index 0000000..7d1a594 --- /dev/null +++ b/utils/functions/weekday.ts @@ -0,0 +1,6 @@ +export default function weekday(date: string): string { + const newDate = new Date(date); + const dayNumber = newDate.getDay(); + const weekdays = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']; + return weekdays[dayNumber]; // Directly return the weekday string +} \ No newline at end of file