mirror of
https://litchi.icu/ngc2207/judge4c-demo.git
synced 2025-05-18 13:07:49 +00:00
feat: 实现代码片段编辑功能,添加代码片段编辑表单客户端组建
This commit is contained in:
parent
2478f1a91e
commit
6d093c327f
@ -1,3 +1,7 @@
|
|||||||
|
import { db } from "@/db";
|
||||||
|
import { notFound } from "next/navigation";
|
||||||
|
import SnippetEditForm from "@/components/snippet-edit-form";
|
||||||
|
|
||||||
interface SnippetEditPageProps {
|
interface SnippetEditPageProps {
|
||||||
params: Promise<{
|
params: Promise<{
|
||||||
id: string;
|
id: string;
|
||||||
@ -7,5 +11,16 @@ interface SnippetEditPageProps {
|
|||||||
export default async function SnippetEditPage(props: SnippetEditPageProps) {
|
export default async function SnippetEditPage(props: SnippetEditPageProps) {
|
||||||
const params = await props.params;
|
const params = await props.params;
|
||||||
const id = parseInt(params.id);
|
const id = parseInt(params.id);
|
||||||
return <div>Editing snippet with id {id}</div>;
|
const snippet = await db.snippet.findFirst({
|
||||||
|
where: { id },
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!snippet) {
|
||||||
|
return notFound();
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<SnippetEditForm snippet={snippet} />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
11
src/components/snippet-edit-form.tsx
Normal file
11
src/components/snippet-edit-form.tsx
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import { Snippet } from "@prisma/client";
|
||||||
|
|
||||||
|
interface SnippetEditFormProps {
|
||||||
|
snippet: Snippet;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function SnippetEditForm({ snippet }: SnippetEditFormProps) {
|
||||||
|
return <div>Client component has snippet with title {snippet.title}</div>;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user