import { API_URL } from "@/config/constants";
import EditFacilityClient from "./EditFacilityClient";

export default async function EditFacilityPage({ 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 anlegget...</div>;
  }

  return <EditFacilityClient initialData={facility} />;
}