mirror of
https://github.com/cfngc4594/monaco-editor-lsp-next.git
synced 2025-05-19 07:56:34 +00:00
feat(editor): fetch problem templates from database
This commit is contained in:
parent
6297419aad
commit
63bde8cafb
@ -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} />;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user