// page.tsx
import { API_URL } from "@/config/constants";
import FacilityDetailView from "./FacilityDetailView";

export default async function GolfCoursePage({ params }: { params: Promise<{ slug: string }> }) {
  const { slug } = await params;
  
  const res = await fetch(`${API_URL}/facilities/${slug}`, { cache: 'no-store' });
  const facility = await res.json();

  if (!facility || facility.error) {
    return <div className="p-20 text-center font-bold text-2xl">Fant ikke golfbanen...</div>;
  }

  // Vi sender dataene til den navngitte komponenten
  return <FacilityDetailView facility={facility} />;
}
