import { db } from "@link-stack/bridge-common";
import { serviceConfig, List } from "@link-stack/bridge-ui";

type PageProps = {
  params: {
    segment: string[];
  };
};

export default async function Page({ params: { segment } }: PageProps) {
  const service = segment[0];

  if (!service) return null;

  const config = serviceConfig[service];

  if (!config) return null;

  const rows = await db.selectFrom(config.table).selectAll().execute();

  return <List service={service} rows={rows} />;
}
