local-weather/components/DailyCard/CardContainer.tsx

24 lines
744 B
TypeScript
Raw Permalink Normal View History

2024-05-12 19:14:36 +00:00
import { Forecast } from "@/types/types";
import DailyCard from "./DailyCard";
2024-05-13 07:22:58 +00:00
export default function CardContainer(props: { weather: Forecast }) {
const weather = props.weather;
return (
2024-05-13 07:30:43 +00:00
<div className="p-2 flex overflow-x-scroll md:overflow-hidden md:justify-center w-full">
2024-05-13 07:22:58 +00:00
{weather.daily &&
weather.daily.apparent_temperature_max.map(
(temp, index) =>
index > 0 &&
index < 7 && ( // Ensure we only render the next 6 days
<DailyCard
key={index}
temperature={temp}
weatherCode={weather.daily.weather_code[index]}
time={weather.daily.time[index]}
/>
)
)}
</div>
);
}