30 lines
596 B
TypeScript
30 lines
596 B
TypeScript
|
|
import { db } from "@/app/_lib/database";
|
||
|
|
import { serviceConfig } from "@/app/_lib/config";
|
||
|
|
import { Edit } from "./_components/Edit";
|
||
|
|
|
||
|
|
type PageProps = {
|
||
|
|
params: { service: string; segment: string[] };
|
||
|
|
};
|
||
|
|
|
||
|
|
export default async function Page({
|
||
|
|
params: { service, segment },
|
||
|
|
}: PageProps) {
|
||
|
|
const id = segment?.[0];
|
||
|
|
|
||
|
|
if (!id) return null;
|
||
|
|
|
||
|
|
const {
|
||
|
|
[service]: { table },
|
||
|
|
} = serviceConfig;
|
||
|
|
|
||
|
|
const row = await db
|
||
|
|
.selectFrom(table)
|
||
|
|
.selectAll()
|
||
|
|
.where("id", "=", id)
|
||
|
|
.executeTakeFirst();
|
||
|
|
|
||
|
|
if (!row) return null;
|
||
|
|
|
||
|
|
return <Edit service={service} row={row} />;
|
||
|
|
}
|