import { redirect } from "next/navigation";
import { auth } from "@/lib/auth";
import { getBackgroundImage } from "@/lib/preferences";
import NavigationWrapper from "@/components/navigation/NavigationWrapper";
import ChallengesSection from "@/components/challenges/ChallengesSection";

export const dynamic = "force-dynamic";

export default async function ChallengesPage() {
  const session = await auth();

  if (!session?.user) {
    redirect("/login");
  }

  const backgroundImage = await getBackgroundImage(
    "home",
    "/got-background.jpg"
  );

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

