---
import type { ExtendedEvent } from "@components/types/event";
import PageLayout from "@layouts/PageLayout.astro";
import { getCollection } from "astro:content";
import EventPage from "@components/event/EventPage.svelte";

const events = await Promise.all(
    (await getCollection("events")).map(async (event) => ({
        ...event,
        data: {
            ...event.data,
            event: (await fetch(
                import.meta.env.PUBLIC_API_SERVER +
                    "/events/" +
                    event.data.eventId,
            ).then((value) => value.json())) as ExtendedEvent,
        },
    })),
);
---

<PageLayout title="Events">
    <EventPage client:load {events} />
</PageLayout>
