Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 20 additions & 3 deletions frontend/src/app/meetings/page.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import CalendarWidget from "@/components/calendar/CalendarWidget";
import EmptyState from "@/components/ui/EmptyState";
import ErrorMessage from "@/components/ui/ErrorMessage";
import { getEvents } from "@/lib/api";
import { getEvents, getFinanceHearings } from "@/lib/api";
import { financeHearingsToCalendarEvents } from "@/lib/calendar";

export const dynamic = "force-dynamic";

export default async function MeetingsPage() {
let events: Awaited<ReturnType<typeof getEvents>> = [];
let financeHearings: Awaited<ReturnType<typeof getFinanceHearings>> | null =
null;
let hasError = false;

try {
Expand All @@ -15,6 +18,13 @@ export default async function MeetingsPage() {
hasError = true;
}

try {
financeHearings = await getFinanceHearings();
} catch {
// Finance hearings are optional — tolerate failure and fall back to
// showing only regular events.
}

if (hasError) {
return (
<section className="min-h-screen bg-gray-50">
Expand All @@ -25,16 +35,23 @@ export default async function MeetingsPage() {
);
}

const calendarEvents = [
...events,
...(financeHearings
? financeHearingsToCalendarEvents(financeHearings.dates)
: []),
];

return (
<section className="min-h-screen bg-gray-50">
<div className="container mx-auto px-4 py-12">
{events.length === 0 ? (
{calendarEvents.length === 0 ? (
<EmptyState
message="No meetings available right now."
description="Check back soon for upcoming meeting dates and details."
/>
) : (
<CalendarWidget events={events} compact={false} />
<CalendarWidget events={calendarEvents} compact={false} />
)}
</div>
</section>
Expand Down
10 changes: 9 additions & 1 deletion frontend/src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import RecentNews from "@/components/home/RecentNews";
import EmptyState from "@/components/ui/EmptyState";
import ErrorMessage from "@/components/ui/ErrorMessage";
import { ApiError, getCarousel, getEvents, getFinanceHearings } from "@/lib/api";
import { financeHearingsToCalendarEvents } from "@/lib/calendar";

export const dynamic = "force-dynamic";

Expand Down Expand Up @@ -40,6 +41,13 @@ export default async function Home() {
}
}

const calendarEvents = [
...events,
...(financeHearings
? financeHearingsToCalendarEvents(financeHearings.dates)
: []),
];

return (
<div className="min-h-screen bg-gray-50">
{carouselError ? (
Expand Down Expand Up @@ -71,7 +79,7 @@ export default async function Home() {
description="Check back soon for the latest calendar updates."
/>
) : (
<CalendarWidget events={events} compact={true} />
<CalendarWidget events={calendarEvents} compact={true} />
)}
</div>
</div>
Expand Down
32 changes: 32 additions & 0 deletions frontend/src/lib/calendar.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import type { CalendarEvent, FinanceHearingDate } from "@/types";

const FINANCE_HEARING_ID_OFFSET = 1000000;
const DEFAULT_DURATION_MINUTES = 30;

/**
* Converts a finance hearing date into a synthetic CalendarEvent so it can
* be rendered alongside regular events in CalendarWidget.
*/
export function financeHearingToCalendarEvent(
hearing: FinanceHearingDate,
): CalendarEvent {
const start = new Date(`${hearing.hearing_date}T${hearing.hearing_time}`);
const end = new Date(start.getTime() + DEFAULT_DURATION_MINUTES * 60 * 1000);

return {
id: FINANCE_HEARING_ID_OFFSET + hearing.id,
title: `Finance Hearing${hearing.is_full ? " (Full)" : ""}`,
description: hearing.description,
start_datetime: start.toISOString(),
end_datetime: end.toISOString(),
location: hearing.location,
event_type: "Finance Hearing",
is_published: true,
};
}

export function financeHearingsToCalendarEvents(
hearings: FinanceHearingDate[],
): CalendarEvent[] {
return hearings.map(financeHearingToCalendarEvent);
}
Loading