link-stack/apps/bridge-frontend/app/(main)/[...segment]/@detail/page.tsx

29 lines
595 B
TypeScript
Raw Normal View History

2024-04-26 14:31:33 +02:00
import { db } from "@/app/_lib/database";
import { serviceConfig } from "@/app/_lib/config";
import { Detail } from "./_components/Detail";
type Props = {
2024-04-26 15:49:58 +02:00
params: { segment: string[] };
2024-04-26 14:31:33 +02:00
};
2024-04-26 15:49:58 +02:00
export default async function Page({ params: { segment } }: Props) {
const service = segment[0];
const id = segment?.[1];
2024-04-26 14:31:33 +02:00
if (!id) return null;
const {
[service]: { table },
} = serviceConfig;
const row = await db
.selectFrom(table)
.selectAll()
.where("id", "=", id)
.executeTakeFirst();
if (!row) return null;
return <Detail service={service} row={row} />;
}