feat: fetch and pass previous weather entries through component tree

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-24 17:00:12 +01:00
parent 9b8c9efbd6
commit 3b212d6dda
3 changed files with 35 additions and 6 deletions

View File

@@ -2,7 +2,7 @@ import { notFound } from 'next/navigation';
import Link from 'next/link';
import { auth } from '@/lib/auth';
import { getWorkshop, getSessionsTabUrl } from '@/lib/workshops';
import { getWeatherSessionById } from '@/services/weather';
import { getWeatherSessionById, getPreviousWeatherEntriesForUsers } from '@/services/weather';
import { getUserTeams } from '@/services/teams';
import { WeatherBoard, WeatherLiveWrapper, WeatherInfoPanel, WeatherAverageBar } from '@/components/weather';
import { Badge } from '@/components/ui';
@@ -20,15 +20,22 @@ export default async function WeatherSessionPage({ params }: WeatherSessionPageP
return null;
}
const [session, userTeams] = await Promise.all([
getWeatherSessionById(id, authSession.user.id),
getUserTeams(authSession.user.id),
]);
const session = await getWeatherSessionById(id, authSession.user.id);
if (!session) {
notFound();
}
const allUserIds = [
session.user.id,
...session.shares.map((s: { userId: string }) => s.userId),
];
const [previousEntries, userTeams] = await Promise.all([
getPreviousWeatherEntriesForUsers(session.id, session.date, allUserIds),
getUserTeams(authSession.user.id),
]);
return (
<main className="mx-auto max-w-7xl px-4 py-8">
{/* Header */}
@@ -99,6 +106,7 @@ export default async function WeatherSessionPage({ params }: WeatherSessionPageP
email: session.user.email ?? '',
}}
canEdit={session.canEdit}
previousEntries={previousEntries}
/>
</WeatherLiveWrapper>
</main>