import UpcomingEventSinglePage from "@/components/events/UpcomingEventSinglePage";
import { events } from "@/utility/constant.utils";

const getEvent = (slug) => events.find((event) => event.slug === slug);

export function generateStaticParams() {
    return events
        .filter((event) => event.slug)
        .map((event) => ({
            slug: event.slug,
        }));
}

export async function generateMetadata({ params }) {
    const event = getEvent(params.slug);

    if (!event) {
        return {
            title: "Upcoming Event | Tamil Culture Waterloo",
        };
    }

    return {
        title: `${event.title} | Tamil Culture Waterloo`,
        description: event.desc || `Details for ${event.title}.`,
    };
}

export default function Page({ params }) {
    return <UpcomingEventSinglePage slug={params.slug} />;
}
