import { headers } from "next/headers";
import { auth } from "@/lib/auth/server";
import { SearchPageContent } from "@/components/search/search-page-content";

type Params = { searchParams: Promise<{ q?: string; difficulty?: string; dietary?: string }> };

export default async function SearchPage({ searchParams }: Params) {
  const session = await auth.api.getSession({ headers: await headers() });
  if (!session) return null;

  const { q } = await searchParams;
  return <SearchPageContent initialQuery={q ?? ""} />;
}
