import HeadlessTableViewer from "@/components/online-table/HeadlessTableViewer";

interface TableViewerPageProps {
  params: Promise<{ tableId: string }>;
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
  searchParams: Promise<Record<string, any>>;
}

export const dynamic = "force-dynamic";

export default async function TableViewerPage({ params, searchParams }: TableViewerPageProps) {
  const resolvedParams = await params;
  const resolvedSearch = await searchParams;
  const tableId = resolvedParams.tableId;
  const embedMode = resolvedSearch?.embed === "1";
  const allowEditing = resolvedSearch?.readonly !== "1";

  return (
    <div className={embedMode ? "h-full w-full bg-transparent" : "min-h-screen bg-white"}>
      <HeadlessTableViewer tableId={tableId} embed={embedMode} editable={allowEditing} />
    </div>
  );
}
