import { getEvents } from "@/app/actions/events";
import EventsClient from "@/components/admin/EventsClient";

export const dynamic = "force-dynamic";

export default async function EventsPage() {
  const result = await getEvents();
  const events = result.success && result.data ? result.data : [];

  // Data parsing for Client Component
  const parsedEvents = events.map(e => ({
    ...e,
    createdAt: e.createdAt.toISOString(),
    updatedAt: e.updatedAt.toISOString(),
  }));

  return <EventsClient initialEvents={parsedEvents as any} />;
}
