import { readSchema } from "@/lib/schema.server";
import EditorClient from "@/components/EditorClient";

export const dynamic = "force-dynamic";

export default async function EditPage({
  params,
}: {
  params: Promise<{ path?: string[] }>;
}) {
  const { path } = await params;
  const segments = (path ?? []).filter(Boolean);
  const route = segments.length === 0 ? "/" : "/" + segments.join("/");
  const schema = await readSchema();

  return (
    <div style={{ height: "100vh", width: "100vw" }}>
      <EditorClient initialSchema={schema} initialPath={route} />
    </div>
  );
}
