import NavigationWrapper from "@/components/navigation/NavigationWrapper";
import HeroSection from "@/components/layout/HeroSection";
import EventsSection from "@/components/events/EventsSection";
import { eventService } from "@/services/events/event.service";
import { getBackgroundImage } from "@/lib/preferences";

export const dynamic = "force-dynamic";

export default async function Home() {
  const events = await eventService.getUpcomingEvents(3);

  // Convert Date objects to strings for serialization
  const serializedEvents = events.map((event) => ({
    ...event,
    date: event.date.toISOString(),
  }));

  // Récupérer l'image de fond côté serveur
  const backgroundImage = await getBackgroundImage("home", "/got-2.jpg");

  return (
    <main className="min-h-screen bg-black relative">
      <NavigationWrapper />
      <HeroSection backgroundImage={backgroundImage} />
      <EventsSection events={serializedEvents} />
    </main>
  );
}
