feat(editor): fetch problem templates from database

This commit is contained in:
cfngc4594 2025-03-09 10:49:34 +08:00
parent 6297419aad
commit 63bde8cafb

View File

@ -1,5 +1,28 @@
import prisma from "@/lib/prisma";
import CodeEditor from "@/components/code-editor"; import CodeEditor from "@/components/code-editor";
export default function WorkspaceEditorPage() { interface WorkspaceEditorProps {
return <CodeEditor />; params: Promise<{ id: string }>
}
export default async function WorkspaceEditorPage({
params,
}: WorkspaceEditorProps) {
const { id } = await params;
const problem = await prisma.problem.findUnique({
where: { id: parseInt(id) },
select: {
templates: {
select: {
language: true,
template: true,
}
}
}
});
const templates = problem?.templates ?? [];
return <CodeEditor problemId={id} templates={templates} />;
} }