judge4c-demo/src/app/snippets/[id]/page.tsx

26 lines
520 B
TypeScript

import { db } from "@/db";
import { notFound } from "next/navigation";
interface SnippetShowPageProps {
params: Promise<{
id: string;
}>;
}
export default async function SnippetShowPage(props: SnippetShowPageProps) {
await new Promise((r) => setTimeout(r, 2000));
const params = await props.params;
const snippet = await db.snippet.findFirst({
where: {
id: parseInt(params.id),
},
});
if (!snippet) {
return notFound();
}
return <div>Show a snippet: {snippet.title}</div>;
}