import { cookies } from "next/headers";
import { API_URL } from "@/config/constants";
import EditFacilityClient from "../rediger/[slug]/EditFacilityClient";

const EMPTY_FACILITY = {
  name: "",
  slug: "",
  is_published: false,
  courses: [],
  gallery: [],
  greenfee: [],
  golfpakker: [],
  social_links: [],
  vtg_datoer: [],
  cooperating_clubs: [],
  amenities: {},
  nsg_data: {},
  golfamore_data: {},
};

export default async function NewFacilityPage() {
  const cookieHeader = (await cookies()).toString();
  const allRes = await fetch(`${API_URL}/admin/facilities`, {
    cache: "no-store",
    headers: cookieHeader ? { cookie: cookieHeader } : undefined,
  });

  const allFacilities = allRes.ok ? await allRes.json() : [];

  return <EditFacilityClient initialData={EMPTY_FACILITY} allFacilities={allFacilities} />;
}
