import FacilitySearch from "./FacilitySearch";
import HeroSlider from "./HeroSlider";
import type { FacilityRecord } from "@/app/facilityData";
import { fetchPublicFacilities } from "@/app/publicFacilities";
import { createPageMetadata } from "@/app/seo";

export const revalidate = 900;
export const dynamic = "force-dynamic";
export const metadata = createPageMetadata({
  title: "Komplett oversikt over ALLE norske golfbaner",
  description:
    "Utforsk norske golfbaner med oppdatert banestatus, kart, priser, medlemskap og Veien til Golf samlet på TeeOff.",
  path: "/",
});

const getHeroRotationSeed = () => new Date().toISOString().slice(0, 13);

export default async function Home() {
  const safeData = await fetchPublicFacilities<FacilityRecord>("search", revalidate);

  return (
    <main className="site-shell min-h-screen">
      <HeroSlider facilities={safeData} rotationSeed={getHeroRotationSeed()} />
      <FacilitySearch initialFacilities={safeData} variant="home" />
    </main>
  );
}
